jextract generates downcallHandles where I need upcallStubs
Sebastian Stenzel
sebastian.stenzel at gmail.com
Tue Dec 15 08:50:58 UTC 2020
Hi all,
I'm pretty new to this topic and therefore I may misunderstand what is going on here, but I'm pretty certain that jextract swaps downcalls and upcalls in some scenarios:
I jextracted [0] libfuse, which mainly consists of the fuse_operations struct [1], which contains a set of file system operations that need to be implemented by library users. These methods are then called by fuse. I.e. this is a typical upcall scenario (native code calls java code). Or am I mistaken?
However, jextract thinks otherwise: While I get correct downcallHandles for methods declared on "top level" in the .h file, such as fuse_main() [2], everything inside of aforementioned struct is reversed. Take for example readdir() [3], which gets called by fuse, so the library user can list directory contents. For this purpuse, fuse passes a "filler" callback as a parameter to this function. But with jextract will generate a downcallHandle for readdir and an upcallStub for the filler.
Tested with build 16-panama+3-385.
Might it be possible that guessing the "direction" of a call is not yet supported for methods inside of structs? Is it even _possible_ to always predict this direction correctly? If not, is this too much of a restriction and shouldn't it rather be the developers choice what to do with a generated FunctionDescriptor?
Regards,
Sebastian
[0]: jextract --source -l fuse -d someDir -t com.example.pkg -C-D_FILE_OFFSET_BITS=64 -C-DFUSE_USE_VERSION=29 --filter fuse.h /usr/local/include/fuse/fuse.h
[1]: https://github.com/libfuse/libfuse/blob/fuse_2_9_5/include/fuse.h#L88 <https://github.com/libfuse/libfuse/blob/fuse_2_9_5/include/fuse.h#L88>
[2]: https://github.com/libfuse/libfuse/blob/fuse_2_9_5/include/fuse.h#L766 <https://github.com/libfuse/libfuse/blob/fuse_2_9_5/include/fuse.h#L766>
[3]: https://github.com/libfuse/libfuse/blob/fuse_2_9_5/include/fuse.h#L304 <https://github.com/libfuse/libfuse/blob/fuse_2_9_5/include/fuse.h#L304>
More information about the panama-dev
mailing list