aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-06-25 08:03:53 +0200
committerSven Gothel <[email protected]>2023-06-25 08:03:53 +0200
commited49b01838f3c07fa7a997b1f758ce2c983f49f7 (patch)
treee6e399be4d6cabf56548d0adee49db305dfc936e /doc
parent5a130ab0c6db44225692e362e41e7b45481f9392 (diff)
GlueGen JavaCallback: Add more related documentation
Diffstat (limited to 'doc')
-rw-r--r--doc/GlueGen_Mapping.html30
-rw-r--r--doc/GlueGen_Mapping.md36
2 files changed, 62 insertions, 4 deletions
diff --git a/doc/GlueGen_Mapping.html b/doc/GlueGen_Mapping.html
index dd63718..96c56c5 100644
--- a/doc/GlueGen_Mapping.html
+++ b/doc/GlueGen_Mapping.html
@@ -1809,11 +1809,37 @@ StructPackage T2_InitializeOptions com.jogamp.gluegen.test.junit.generation</cod
Native C-API Support</h3>
<p>GlueGen supports registering Java callback methods to native C-API
functions in the form:</p>
-<pre><code>typedef int32_t ( * T_CallbackFunc)(size_t id, size_t msg_len, const char* msg, void* userParam);
+<pre><code>typedef int32_t ( * T_CallbackFunc)(size_t id, const char* msg, void* userParam);
void AddMessageCallback(T_CallbackFunc func, void* userParam);
void RemoveMessageCallback(T_CallbackFunc func, void* userParam);
-void InjectMessageCallback(size_t id, size_t msg_len, const char* msg);</code></pre>
+void InjectMessageCallback(size_t id, const char* msg);</code></pre>
+<p>and the following GlueGen configuration</p>
+<pre><code>ArgumentIsString T2_CallbackFunc 1
+ArgumentIsString InjectMessageCallback 1
+
+# Define a JavaCallback, enacted on a function-pointer argument `T2_CallbackFunc` and a user-param `void*` for Java Object mapping
+JavaCallbackDef T2_CallbackFunc 2</code></pre>
+<p>This will lead to the following result</p>
+<pre><code>public interface Bindingtest2 {
+
+ /** JavaCallback interface: T2_CallbackFunc -&gt; int32_t (*T2_CallbackFunc)(size_t id, const char * msg, void * userParam) */
+ public static interface T2_CallbackFunc {
+ /** Interface to C language function: &lt;br&gt; &lt;code&gt;int32_t callback(size_t id, const char * msg, void * userParam)&lt;/code&gt;&lt;br&gt;Alias for: &lt;code&gt;T2_CallbackFunc&lt;/code&gt; */
+ public int callback(long id, String msg, Object userParam);
+ }
+
+ ...
+
+ /** Entry point (through function pointer) to C language function: &lt;br&gt; &lt;code&gt;void AddMessageCallback(int32_t (*func)(size_t id, const char * msg, void * userParam), void * userParam)&lt;/code&gt;&lt;br&gt; */
+ public void AddMessageCallback(T2_CallbackFunc func, Object userParam);
+
+ /** Entry point (through function pointer) to C language function: &lt;br&gt; &lt;code&gt;void RemoveMessageCallback(int32_t (*func)(size_t id, const char * msg, void * userParam), void * userParam)&lt;/code&gt;&lt;br&gt; */
+ public void RemoveMessageCallback(T2_CallbackFunc func, Object userParam);
+
+ /** Entry point (through function pointer) to C language function: &lt;br&gt; &lt;code&gt;void InjectMessageCallback(size_t id, const char * msg)&lt;/code&gt;&lt;br&gt; */
+ public void InjectMessageCallback(long id, String msg);
+</code></pre>
<p><em>TODO: Work in progress</em></p>
<h4 id="example-1">Example</h4>
<h2 id="platform-header-files">Platform Header Files</h2>
diff --git a/doc/GlueGen_Mapping.md b/doc/GlueGen_Mapping.md
index 2a0de78..8965dd6 100644
--- a/doc/GlueGen_Mapping.md
+++ b/doc/GlueGen_Mapping.md
@@ -667,11 +667,43 @@ and similar to `T2_CustomFuncB customFuncB1`
### Java Callback from Native C-API Support
GlueGen supports registering Java callback methods to native C-API functions in the form:
```
-typedef int32_t ( * T_CallbackFunc)(size_t id, size_t msg_len, const char* msg, void* userParam);
+typedef int32_t ( * T_CallbackFunc)(size_t id, const char* msg, void* userParam);
void AddMessageCallback(T_CallbackFunc func, void* userParam);
void RemoveMessageCallback(T_CallbackFunc func, void* userParam);
-void InjectMessageCallback(size_t id, size_t msg_len, const char* msg);
+void InjectMessageCallback(size_t id, const char* msg);
+```
+
+and the following GlueGen configuration
+```
+ArgumentIsString T2_CallbackFunc 1
+ArgumentIsString InjectMessageCallback 1
+
+# Define a JavaCallback, enacted on a function-pointer argument `T2_CallbackFunc` and a user-param `void*` for Java Object mapping
+JavaCallbackDef T2_CallbackFunc 2
+```
+
+This will lead to the following result
+```
+public interface Bindingtest2 {
+
+ /** JavaCallback interface: T2_CallbackFunc -> int32_t (*T2_CallbackFunc)(size_t id, const char * msg, void * userParam) */
+ public static interface T2_CallbackFunc {
+ /** Interface to C language function: <br> <code>int32_t callback(size_t id, const char * msg, void * userParam)</code><br>Alias for: <code>T2_CallbackFunc</code> */
+ public int callback(long id, String msg, Object userParam);
+ }
+
+ ...
+
+ /** Entry point (through function pointer) to C language function: <br> <code>void AddMessageCallback(int32_t (*func)(size_t id, const char * msg, void * userParam), void * userParam)</code><br> */
+ public void AddMessageCallback(T2_CallbackFunc func, Object userParam);
+
+ /** Entry point (through function pointer) to C language function: <br> <code>void RemoveMessageCallback(int32_t (*func)(size_t id, const char * msg, void * userParam), void * userParam)</code><br> */
+ public void RemoveMessageCallback(T2_CallbackFunc func, Object userParam);
+
+ /** Entry point (through function pointer) to C language function: <br> <code>void InjectMessageCallback(size_t id, const char * msg)</code><br> */
+ public void InjectMessageCallback(long id, String msg);
+
```
*TODO: Work in progress*