It is not uncommon for C APIs to be defined in term of a single "struct object" -- that is, a struct that contains a bunch of function pointers to the "methods" supported by that API.
An example of this is the JNI API itself, but there's also other examples such ONNX runtime:
https://github.com/microsoft/onnxruntime/blob/main/include/onnxruntime/core/session/onnxruntime_c_api.h
In such cases it's common to end up with thousands of lines of generated code, and there's no way for developers to filter the output of jextract because:
* the noise comes from all the functional interfaces that are added (one per each struct/union field)
* jextract can only filter toplevel functions, or whole structs/unions, but not individual struct/union fields
This lack of filtering granularity makes jextract less usable with such C APIs.
It would be nice if jextract would add a way to filter struct/union fields -- so that only selected fields in a struct/union would have the corresponding accessors.
Example:
struct A {
int x;
int y;
};
If we could run jextract with the following options:
--include-struct A
--include-struct-field A.x
Then jextract would generate a binding for A which doesn't contain accessors and code for the field `y`.
An example of this is the JNI API itself, but there's also other examples such ONNX runtime:
https://github.com/microsoft/onnxruntime/blob/main/include/onnxruntime/core/session/onnxruntime_c_api.h
In such cases it's common to end up with thousands of lines of generated code, and there's no way for developers to filter the output of jextract because:
* the noise comes from all the functional interfaces that are added (one per each struct/union field)
* jextract can only filter toplevel functions, or whole structs/unions, but not individual struct/union fields
This lack of filtering granularity makes jextract less usable with such C APIs.
It would be nice if jextract would add a way to filter struct/union fields -- so that only selected fields in a struct/union would have the corresponding accessors.
Example:
struct A {
int x;
int y;
};
If we could run jextract with the following options:
--include-struct A
--include-struct-field A.x
Then jextract would generate a binding for A which doesn't contain accessors and code for the field `y`.