12-05-2020, 04:07 AM
You picked two extreme cases ![Smile Smile](http://tilengine.org/forum/images/smilies/smile.png)
In order to communicate, sometimes the binding must do data conversion before passing the arguments. In other cases, it must create and destroy elements that are needed on the Java side.
The first example is the simplest one: no conversion of any data is needed, just call the function. Done!
The second one manages the callback, the Java function that needs to be called from the native library. Callbacks are always the trickiest part of a binding. In thsi case, it requires destroying a previously allocated Java object, and creating a new one. In addition, it gets a text string, that needs explicit conversion because C and Java don't represent strings internally in the same way. That's why this function is the most complex of all.
![Smile Smile](http://tilengine.org/forum/images/smilies/smile.png)
In order to communicate, sometimes the binding must do data conversion before passing the arguments. In other cases, it must create and destroy elements that are needed on the Java side.
The first example is the simplest one: no conversion of any data is needed, just call the function. Done!
The second one manages the callback, the Java function that needs to be called from the native library. Callbacks are always the trickiest part of a binding. In thsi case, it requires destroying a previously allocated Java object, and creating a new one. In addition, it gets a text string, that needs explicit conversion because C and Java don't represent strings internally in the same way. That's why this function is the most complex of all.