-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Direct Mapping for boolean arrays #816
Direct Mapping for boolean arrays #816
Conversation
In principal I agree with the direction that was started here, but it collides with the current size definition of boolean in JNA (it is defined to 4 bytes). See: https://github.com/java-native-access/jna/blob/master/src/com/sun/jna/Native.java#L1296 This would not be in line with a 1 byte wide mapping. There is a request for supporting C99 I started some work on this, but it is still unready and I think in the wrong direction: https://github.com/matthiasblaesing/jna/tree/boolean I think a way could be:
This should go into the 5.0.0 branch, as it invalidates assumptions about sizes and mappings. |
Yes, I understand it does, and I'm not necessarily very happy with the change. Still two changesets so... 8f2e773 IMHO is a simple fix. ba7881f simply makes direct mapping consistent with interface mapping. Also, note that the same reasoning applies to both
There's quite a lot of effort to handle the difference for So the only change here is making Now, this is just my opinion, and I'm very, very new to JNA. But in a sense, I feel JNA already tries to do a bit too much, and would avoid having it do even more. When things are passed by reference, I can do the marshaling by myself (e.g. convert between encodings). It's only when passing arguments and return values by value that JNA must help (with JNI and the ABI), so it doesn't at all bother me that arrays are not marshaled where simple values are. I'll have a look at your boolean branch. But feel free to ignore this if I'm slowing you down. |
Please: No need to apologize, in fact I'm glad your are looking into this! Your points are well taken and your reasoning is sound. Two things I'd like to ask you: Please add an entry to CHANGES.md. For the first PR I did that: https://github.com/java-native-access/jna/blob/master/CHANGES.md The second: Please rebase your changes on top of JNA master (I just merged your first PR) |
Regarding your branch, using Any inconsistencies between The real issue, I think, is breaking compatibility with previous JNA versions, and the mountain of APIs returning an |
@ncruces I merged this PR. Thanks for looking into this. I'll look into rebuilding the pre-build native parts in the next few days. With regard to StdBool I think the only realistic option is the introduction of a NativeBoolean. At some point I'll look into this again, but not in the near future :-) |
This is consistent with how these are handled in interface mapping.
Also boolean is
ffi_type_uint32
everywhere in the source code, except here.