Open basshelal opened 2 years ago
int
, float
, enum
etc)int *
, float *
, void**
(pointer of pointers, since pointer is merely a number))struct
, union
)
int
, int *
, void *
etc)struct
, union
, struct *
, union *
etc)int (*function)(int)
, struct*(*function)(struct *)
etc)int[]
, struct[]
, struct*[]
, void*[]
etc)struct *
, union *
)int (*function)(int)
, struct*(*function)(struct *)
etc)int[]
, struct[]
, struct*[]
, void*[]
etc)int
, float
, enum
, int*
etc)struct
, union
, struct*
, union*
)int[]
, struct[]
, struct*[]
, void*[]
etc)int (*function)(int)
, struct*(*function)(struct *)
etc)const
correctness for these as well especially pointers which have 2 const
-nesses, const int*
vs int* const
and the combined const int* const
int *function(int *a, struct *b)
, struct *function(callback_t a, void *b)
etc)int function(int a, struct b)
, struct function(int[] a, struct[] b)
etc)Pointer
classStruct
<==> Pointer
conversionDirectMemoryIO
, BoundedMemoryIO
etc)LibraryOptions
@In
, @Pinned
etc)@size_t
, @u_int64_t
etc)@IgnoreError
, @StdCall
etc)Probably turn these into their own issues upon completion:
Great list and great initiative to start pushing this forward! We can swipe examples from the various places we have them and turn them into nice readable tests. This will improve documentation as well as coverage. Let me know where I can help!
Hello.
Is there any news related to a struct being passed by value? Returning a struct and passing a struct into a parameter to a native function?
I know it's related to:
Right now, I'm kinda stuck because I have to call some native functions and pass structs as value.
I have the source code of the native library (it's an open source project) but making changes to the code will be a nightmare.
I love JNR (congrats! :)) but I'm also thinking on mixing with JNA. JNA deals with struct by value: https://segmentfault.com/a/1190000041817628/en
What do you think about the idea of combining JNR and JNA? Using JNA just to make the calls of the methods having struct by value.
I think it's probably best for us to have the missing functionality in JNR. I am not opposed to working toward merging or sharing some backend logic for JNR and JNA, and of course we're all looking forward to Project Panama.
We have a project that we have to create a Java Binding of an IoT solution which is written in C. I'm gonna share a little bit of our experience so far: 1) Panama: promising technology but... very poor documentation. We didn't have success in some forms of accessing the native library and we didn't like the way of doing a "jextract" before. Yeah, the stub creation is great but.... Also, we couldn't go to the Panaman because we had to go to the JDK 17 version; 2) JNR: We are very happy with the JNR (configuration and usage) but.... does not manage the "struct by value" 3) JNA: After using JNR, we tried JNA but... we started to have errors that we didn't have with JNR.
So... no perfect solution. What we did is: go back to JNR and change some native functions (we have the source because it's a open source project). We still don't know if at the end of the day we will have success but it's the path that we have chosen. Also, I don't like to apply a patch to an open source project before using JNR.
If you decided to carry on with the implementation of the "struct by value" in JNR maybe we can help.
The current test suite is good but doesn't cover many cases well enough and sometimes not at all.
I feel the quality and coverage of the tests can and should be significantly improved to be able to:
This relates partially to #253, since both are proposed so that we can have an easier time improving the existing code, especially regarding simplifying the code and improving and understanding performance.
This is a large endeavor that is more akin to multiple issues and will be fixed with multiple PRs each improving a small section of the test suite.