-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Define size_t.ByReference and fix macOS sysctl size_t* parameters #1351
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a sane approach. I like the introduction of the size_t.ByReference
. Naming it like that makes it less ugly than I feared. I left a few inline comments.
contrib/platform/test/com/sun/jna/platform/mac/SystemBTest.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sane. One final idea - I would consider:
- rename
longValue
togetLongValue
andsetValue(long value)
tosetLongValue
(though I'm not sure whether the similarity toInteger#longValue
might be more important - directly implement
setValue(long)
instead of delegating tosetValue(size_t)
- the same is true for the constructor. The garbadge created by wrapping the long into asize_t
is not needed.
Looks like two ideas. 😁
I'll think about this but am still leaning toward This getter directly replaces
Which is a good point. |
I've taken some time to think about this:
So ultimately I think I just want to change the getter (whatever name is decided on) to bypass object creation and otherwise leave this PR as is. |
Thank you for the consideration. With that arguments, I would keep the changeset asis. |
I think there is one small optimization that could be done: since the size check is only needed in the <8 case, we could have a conditional where a size of 8 directly sets the value, and a smaller one does the existing check via object creation. That will minimize the overhead to a small number of platforms. |
I have no strong feelings here. So would take it any way. |
Unfortunately that pesky little rule that you can't call another constructor other than as the first call makes the gymnastics to avoid the initialization too unreadable for me to even understand a minute after I wrote it. So I'm just going to merge this as-is. |
This fixes the types in
SystemB
.I added a
ByReference
nested class to the existingsize_t
type already mapped in a superclass, to handle the conditional buffer allocation similarly toNativeLongByReference
.