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
Add aliases in AbstractMemory for size_t and ssize_t. #958
base: master
Are you sure you want to change the base?
Conversation
Just passing by, this would need to be tested. |
@eregon I though so as well, but I couldn't find where the other aliases are tested. Maybe they are and I just missed it. |
|
@eregon I ended up adding tests to |
I just realized, actually this is already possible with the read/write/get/put methods: irb(main):008:0> ptr = FFI::MemoryPointer.new(100)
=> #<FFI::MemoryPointer address=0x0000000001deb6c0 size=100>
irb(main):009:0> ptr.write(:size_t, 42)
=> nil
irb(main):010:0> ptr.read(:size_t)
=> 42 So I think we should not add new methods, because it's already easily possible via a general way. I'm sorry I didn't think of that earlier, would have spared you some effort. |
For the sake of the argument: So I agree with you in general but I think Edit: Maybe |
I think it'd be good to add something like |
Hello,
This is a feature I end up re-implementing in most of my gems, so I thought maybe it warranted to be here.
This implements
read_size_t
andread_ssize_t
and their counterparts in AbstractMemory.The proposal is rather straightforward, but some aspects may warrant discussion:
_t
suffix as I didn't want any confusion betweenget_size
andsize
methods,sizeof(size_t)
is a compile time constant it shouldn't matter,This would also close #537
Thanks