@@ -47,6 +47,45 @@ pub extern fn webui_bind(
4747 func : * const fn (e : * Event ) callconv (.C ) void ,
4848) callconv (.C ) usize ;
4949
50+ /// @brief Use this API after using `webui_bind()` to add any user data to it that can be
51+ /// read later using `webui_get_context()`.
52+ ///
53+ /// @param window The window number
54+ /// @param element The HTML element / JavaScript object
55+ /// @param context Any user data
56+ ///
57+ /// @example
58+ /// webui_bind(myWindow, "myFunction", myFunction);
59+ ///
60+ /// webui_set_context(myWindow, "myFunction", myData);
61+ ///
62+ /// void myFunction(webui_event_t* e) {
63+ /// void* myData = webui_get_context(e);
64+ /// }
65+ pub extern fn webui_set_context (
66+ window : usize ,
67+ element : [* :0 ]const u8 ,
68+ context : * anyopaque ,
69+ ) callconv (.C ) void ;
70+
71+ /// @brief Get user data that is set using `webui_set_context()`.
72+ ///
73+ /// @param e The event struct
74+ ///
75+ /// @return Returns user data pointer.
76+ ///
77+ /// @example
78+ /// webui_bind(myWindow, "myFunction", myFunction);
79+ ///
80+ /// webui_set_context(myWindow, "myFunction", myData);
81+ ///
82+ /// void myFunction(webui_event_t* e) {
83+ /// void* myData = webui_get_context(e);
84+ /// }
85+ pub extern fn webui_get_context (
86+ e : * Event ,
87+ ) callconv (.C ) * anyopaque ;
88+
5089/// @brief Get the recommended web browser ID to use. If you
5190/// are already using one, this function will return the same ID.
5291///
@@ -242,16 +281,16 @@ pub extern fn webui_set_file_handler_window(
242281 ) callconv (.C ) ? * const anyopaque ,
243282) callconv (.C ) void ;
244283
245- ///
246- /// @brief Use this API to set a file handler response if your backend need async
284+ ///
285+ /// @brief Use this API to set a file handler response if your backend need async
247286/// response for `webui_set_file_handler()`.
248- ///
287+ ///
249288/// @param window The window number
250289/// @param response The response buffer
251290/// @param length The response size
252- ///
291+ ///
253292/// @example webui_interface_set_response_file_handler(myWindow, buffer, 1024);
254- ///
293+ ///
255294pub extern fn webui_interface_set_response_file_handler (
256295 window : usize ,
257296 response : ? * const anyopaque ,
@@ -311,6 +350,19 @@ pub extern fn webui_decode(str: [*:0]const u8) callconv(.C) ?[*:0]u8;
311350/// @example webui_free(my_buffer);
312351pub extern fn webui_free (ptr : * anyopaque ) callconv (.C ) void ;
313352
353+ /// @brief Copy raw data.
354+ ///
355+ /// @param dest Destination memory pointer
356+ /// @param src Source memory pointer
357+ /// @param count Bytes to copy
358+ ///
359+ /// @example webui_memcpy(myBuffer, myData, 64);
360+ pub extern fn webui_memcpy (
361+ dest : * anyopaque ,
362+ src : * anyopaque ,
363+ count : usize ,
364+ ) callconv (.C ) void ;
365+
314366/// @brief Safely allocate memory using the WebUI memory management system. It
315367/// can be safely freed using `webui_free()` at any time.
316368///
0 commit comments