I have two sources:
- an xml-file containing definitions of several hundred data structures, basically structs with fields consisting of simple data types (e.g.
int,short,boolean,enum), and - a c header-file containing the same data structures represented a c structs. (I cannot modify this header-file or the c structs.)
I also have a library, written in c, that is able to use these c structs to perform a specific task.
Last I have a Java application which needs to use this library somehow.
Currently I generate Java classes from the xml-file representing the data structures, now I "just" need to provide them to the library somehow.
My current approach is to generate jni code, to call a c-function for each struct from Java, accepting the Java generated class as a parameter. Then generate c-code which takes the Java classes and fill in the appropriate fields in the c-structs.
Is this a good approach? Does anybody have suggestions for a simpler approach?
I am considering using sockets and e.g. protobuf, but I do not see this as any simpler.
Thanks in advance for any suggestions.