Conversation
8052173 to
05c8211
Compare
|
I've been working with JNI a lot lately using strategies similar to those in this library. My biggest source of confusion with high-level wrappers was that the design misses the fact that in this declaration TheTag is an abstraction for a Java class. TagTraits is just ancillary information that belongs to the these classes. Therefore StringTag, ClassTag, ArrayTag are classes, not "tags". If the design recognized this, the natural followup is that these classes contain state (the jclass reference) as well as cached jMethodId and jFieldIds. This is how method wrapping could be nicely done IMO. There are many good takeaways for sure, such as how the constexpr class-names are handled, the wrapping of Arrays with the automatic generation of signatures based on StringLiteral, that part IMO is state of the art and worth using. |
Prototyping the introduction of a templated base class for binding to Java objects. This is still missing support for native peers.
The idea is to introduce parallel classes in C++ as well that wrap the
jni::Object<...>and expose the Java methods as member functions, implementing the calling syntax proposed in #11. The parallel class is freely convertible to/fromjni::Object<...>.It also simplifies creating bindings for those class member functions, removing the need to use macros and verbose syntax. It supports overloaded functions as illustrated in
examples/binding.cpp./cc @jfirebaugh for feedback on this approach