diff options
author | Mathieu Féry <[email protected]> | 2023-08-01 18:35:54 +0200 |
---|---|---|
committer | Mathieu Féry <[email protected]> | 2023-08-01 18:37:12 +0200 |
commit | 165e3b87b2d3abbb83e9fe5421ac63931b41c793 (patch) | |
tree | 453d51f798f7bc2a8fc9d554b99c0947971f1165 /doc | |
parent | ad69716fda64b517c33ed847c4b215ea398aac99 (diff) |
doc/GlueGen_Mapping.md: Add some documentation with JavaCallback without userData
Diffstat (limited to 'doc')
-rw-r--r-- | doc/GlueGen_Mapping.md | 70 |
1 files changed, 68 insertions, 2 deletions
diff --git a/doc/GlueGen_Mapping.md b/doc/GlueGen_Mapping.md index c1e71d5..2dd425f 100644 --- a/doc/GlueGen_Mapping.md +++ b/doc/GlueGen_Mapping.md @@ -826,9 +826,9 @@ as it is core to the semantic mapping of all resources. They also have to use th `JavaCallbackDef` attributes: - `SetCallbackFunction`: `SetCallbackFunction` name of the native toolkit API responsible to set the callback -- `SetCallback-UserParamIndex`: `UserParam` parameter-index of the `SetCallbackFunction` +- `SetCallback-UserParamIndex`: `UserParam` parameter-index of the `SetCallbackFunction` or negative index to disable UserParam management - `CallbackFunctionType`: The native toolkit API typedef-name of the function-pointer-type, aka the callback type name -- `CallbackFunction-UserParamIndex`: The `userParam` parameter-index of the `CallbackFunctionType`, which allows to [indicate a heterogeneous `UserParam`](#struct-type-user-param-heterogeneous) +- `CallbackFunction-UserParamIndex`: The `userParam` parameter-index of the `CallbackFunctionType`, which allows to [indicate a heterogeneous `UserParam`](#struct-type-user-param-heterogeneous) or negative index to disable UserParam management - `Callback-UserParamClass`: Optional [custom *UserParamClass*](#custom-callback-userparamclass) overriding the default `Object` for non-compound `UserParam` types. - `Callback-KeyClass`: Optional [custom *KeyClass*](#custom-callback-keyclass), providing the hash-map-key. @@ -1330,6 +1330,72 @@ leading to the following interface public void MessageCallback11bInject(long id, long val); ``` +### JavaCallback Example 12 (Without UserParam) + +This example demonstrates a JavaCallBack without user param and only a global key. + +The callback `T2_CallbackFunc12` is managed by the toolkit and passed to the callback function, while user passes JavaCallback to the registration method `SetLogCallBack(..)`. + + +C-API Header snipped +``` + typedef enum { + LOG_Off = 0, + LOG_Fatal = 100, + LOG_Error = 200, + LOG_Warning = 300, + LOG_Info = 400, + LOG_Verbose = 500, + LOG_VeryVerbose = 600 + } LogLevel; + + typedef struct { + const char* Category; + const char* Message; + LogLevel Level; + } LogMessage; + + typedef void ( * T2_CallbackFunc12)(const LogMessage* usrParam); + + void SetLogCallBack(T2_CallbackFunc12 cbFunc); + void LogCallBackInject(const LogMessage* message); +``` + +and the following GlueGen configuration +``` + ReturnsStringOnly LogMessage.Category + ReturnsStringOnly LogMessage.Message + + JavaCallbackDef SetLogCallBack -1 T2_CallbackFunc12 -1 +``` + +leading to the following interface +``` + + /** JavaCallback interface: T2_CallbackFunc12 -> void (*T2_CallbackFunc12)(const LogMessage * usrParam) */ + public static interface T2_CallbackFunc12 { + /** Interface to C language function: <br> <code>void callback(const LogMessage * usrParam)</code><br>Alias for: <code>T2_CallbackFunc12</code> */ + public void callback(LogMessage usrParam); + } + + ... + + /** Returns if callback is mapped for <br> <code> void SetLogCallBack(T2_CallbackFunc12 cbFunc)</code> */ + public boolean isSetLogCallBackMapped(); + + /** Returns T2_CallbackFunc12 callback for <br> <code> void SetLogCallBack(T2_CallbackFunc12 cbFunc)</code> */ + public T2_CallbackFunc12 getSetLogCallBack(); + + /** Releases callback data skipping toolkit API. Favor passing `null` callback ref to <br> <code> void SetLogCallBack(T2_CallbackFunc12 cbFunc)</code> */ + public void releaseSetLogCallBack(); + + /** Entry point (through function pointer) to C language function: <br> <code>void SetLogCallBack(T2_CallbackFunc12 cbFunc)</code><br> */ + public void SetLogCallBack(T2_CallbackFunc12 cbFunc); + + /** Entry point (through function pointer) to C language function: <br> <code>void LogCallBackInject(const LogMessage * message)</code><br> */ + public void LogCallBackInject(LogMessage message); +``` + *TODO: Enhance documentation* ## Misc Configurations |