[cfe-dev] Java bindings for clang/libclang?
Alek Paunov
alex at declera.com
Tue Nov 29 17:01:31 PST 2011
Hi Nathan,
On 29.11.2011 23:51, Nathan Ridge wrote:
> I am wondering whether there exist Java bindings for libclang, or some other
> way to access the clang API from Java code (other than using JNI directly - I'm
> thinking of something like a Java wrapper library, possibly implemented using
> JNI)?
Another JNA variant (besides Kevin suggestion for semi-automatic
generation of complete binding) might be straight-forward translation of
current FFI based bindings ($CLANG/bindings/python).
Or, you might test if it will be zippy enough with in-process JIT-ed
FFI/IPC instead of classical bindings:
libclang - LiaJIT FFI - msgpack - zeromq-INPROC:// - msgpack - java
http://luajit.org/ext_ffi_tutorial.html#zlib
http://www.zeromq.org/bindings:lua
At least, the FFI part will be faster than JNA or current Python FFI
bindings (because Python FFI is not JIT-ed to machine code). The size of
LuaJIT.so on x86_64 is about 400K.
This way advantages - a) Like JNA, easier (compared to JNI) following of
libclang evolution, but with possible better performance b) potential
direct reuse of your libclang as zeromq/msgpack service by other
projects and c) practical experience in the build server direction of
research.
Kind regards,
Alek
P.S. Also, you can use Python bindings via JPype for the initial
sketching (or generating other bindings).
http://jpype.sourceforge.net/
More information about the cfe-dev
mailing list