开发者

Android, SWIG and bidirectional communication

开发者 https://www.devze.com 2023-02-25 21:28 出处:网络
I have a C++ api I can\'t change which: exposes object (easy) exposes interfaces that have to be derived by caller (classical trigger-listener design pattern).

I have a C++ api I can't change which:

  • exposes object (easy)
  • exposes interfaces that have to be derived by caller (classical trigger-listener design pattern).

I managed to wrap this API to pyt开发者_开发技巧hon using SWIG and the director feature, which allows cross-language derivation. However, when I tried to compile it using ndk, to expose it in Dalvik's VM in Android, I discovered that directors in SWIG are supported through RTTI, and that Android does not support RTTI.

Any idea on how I could workaround this limitation? Basically, I have an easy way of exposing my native objects in Java using JNI and SWIG, but I need to be able to trigger my Java code from native code.


Android does support RTTI and exceptions from NDK r5. Just add -fexceptions and -frtti compilation flags and also add line APP_STL := gnustl_static to the Application.mk file.


you'll need to write your own JNI that doesn't use RTTI, i'm afraid.

0

精彩评论

暂无评论...
验证码 换一张
取 消