Awesome
jParser
jParser is a small Java library that helps bind C/C++ code to desktop, mobile, and the web, allowing it to be written inline with Java source code.
It was inspired by gdx-jnigen that you add a native code into a code block. This code block will be translated to the specific code target. You can add multiple code block targets in the same java source. For each code target, it will generate a new java source code.
For the web, it needs emscripten to generate a js/wasm file and teavm. The generated classes in teavm module use JSBody to communicate with javascript.
jParser only supports JNI
and TEAVM
code targets.
How it works
jParser has two part.
- Read the java source code containing the jParser solution and generate a new java source code for each target. We use base module for this. For desktop/mobile the generated JNI code will be at
core module
and the web code will be insideteavm module
. - Compile C/C++ for each platform (Windows/Linux/MacOS/Android/iOS/Web).
WebIDL
To improve even more the long hours of porting each method manually, jParser also has Emscripten WebIDL support. You create a webidl file, and it will generate binding code for JNI and teaVM. It's not 100%, but it will reduce the amount of work binding big libraries. You can check the example:lib module or gdx-imgui for a complete example.
It will create the exact same method as the webidl file. If C++ is case-sensitive as in ImGui, the Java methods will be also case-sensitive. <br> C/C++ attributes are converted to methods, it starts with 'set_' or 'get_'.
Libraries usisng jParser: <br>