@@ -32,36 +32,40 @@ Pkl already has a https://pkl-lang.org/main/current/bindings-specification/messa
3232.native_pkl_interface.c
3333[source,c]
3434----
35- /**
36- * @brief The Pkl Message Response Handler that a user should implement.
3735*
38- * The resulting messages from `pkl_send` will be sent to this
39- * handler using a callback style.
40- */
41- typedef void (*PklMessageResponseHandler)(int length, char* message);
36+ * The callback that gets called when a message is received from Pkl.
37+ *
38+ * @param length The length the message bytes
39+ * @param message The message itself
40+ * @param userData User-defined data passed in from pkl_init.
41+ */
42+ typedef void (*PklMessageResponseHandler)(int length, char *message, void *userData);
4243
4344/**
44- * @brief Initialises and allocates a Pkl executor.
45- *
46- * @return -1 on failure.
47- * @return 0 on success.
48- */
49- int pkl_init(PklMessageResponseHandler handler);
45+ * Initialises and allocates a Pkl executor.
46+ *
47+ * @param handler The callback that gets called when a message is received from Pkl.
48+ * @param userData User-defined data that gets passed to handler.
49+ *
50+ * @return -1 on failure, 0 on success.
51+ */
52+ int pkl_init(PklMessageResponseHandler handler, void *userData);
5053
5154/**
52- * @brief Send a message to Pkl, providing the length and a pointer to the first byte.
53- *
54- * @return -1 on failure.
55- * @return 0 on success.
56- */
57- int pkl_send_message(int length, char* message);
55+ * Send a message to Pkl, providing the length and a pointer to the first byte.
56+ *
57+ * @param length The length of the message, in bytes.
58+ * @param message The message to send to Pkl.
59+ *
60+ * @return -1 on failure, 0 on success.
61+ */
62+ int pkl_send_message(int length, char *message);
5863
5964/**
60- * @brief Cleans up any resources that were created as part of the `pkl_init` process.
61- *
62- * @return -1 on failure.
63- * @return 0 on success.
64- */
65+ * Cleans up any resources that were created as part of the `pkl_init` process.
66+ *
67+ * @return -1 on failure, 0 on success.
68+ */
6569int pkl_close();
6670----
6771
0 commit comments