-
Notifications
You must be signed in to change notification settings - Fork 40
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
Import JRuby implementation #147
Conversation
Fig GH-104 lib/fiddle/jruby.rb is based on https://github.com/jruby/jruby/blob/master/lib/ruby/stdlib/fiddle/jruby.rb . Here are changes for it: * Move `Fiddle::TYPE_*` to `Fiddle::Types::*` * Add `Fiddle::Types::VARIADIC` * Add `Fiddle::Types::CONST_STRING` * Add `Fiddle::Types::BOOL` * Add `Fiddle::Types::INT8_T` * Add `Fiddle::Types::UINT8_T` * Add `Fiddle::Types::INT16_T` * Add `Fiddle::Types::UINT16_T` * Add `Fiddle::Types::INT32_T` * Add `Fiddle::Types::UINT32_T` * Add `Fiddle::Types::INT64_T` * Add `Fiddle::Types::UINT64_T` * Add more `Fiddle::ALIGN_*` for the above new `Fiddle::Types::*` * Add more `Fiddle::SIZEOF_*` for the above new `Fiddle::Types::*` * Add support for specifying type as not only `Fiddle::Types::*` but also `Symbol` like `:int` * Add support for variable size arguments in `Fiddle::Function` * Add `Fiddle::Closure#free` * Add `Fiddle::Closure#freed?` * Add `Fiddle::Error` as base the error class * Add `Fiddle::Pointer#call_free` and stop using `FFI::AutoPointer` in `Fiddle::Pointer` * Add support for `Fiddle::Pointer.malloc {}` `Fiddle::Pointer` * Add support for `Fiddle::Pointer#free=` * Add `Fiddle::Pointer#freed?` * Use binary string not C string for `Fiddle::Pointer#[]` * Add `Fiddle::Handle.sym_defined?` * Add `Fiddle::Handle#sym_defined?` * Add `Fiddle::Handle::DEFAULT` * Add `Fiddle::ClearedReferenceError` * Add no-op `Fiddle::Pinned` Some features are still "not implemented". So there are some "omit"s for JRuby in tests.
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.
@headius How about this?
test/fiddle/test_c_struct_entry.rb
Outdated
@@ -49,6 +49,11 @@ def test_class_size_with_count | |||
end | |||
|
|||
def test_set_ctypes | |||
if RUBY_ENGINE == "jruby" and Fiddle::WINDOWS | |||
omit("JRuby's 'l!' pack string is buggy. " + | |||
"See https://github.com/jruby/jruby/issues/8357 for details") |
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.
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.
I will look into it but the workaround is probably going to need to be in place for a while.
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.
@kou yeah for a while likely means JRuby 10 will fix this but 9.4 will continue to use that behavior since it would break any saved pack data for a JRuby app on windows.
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.
OK. I've added a workaround for JRuby 9.4 on Windows: b809583
Taking a quick look at this, since it is implementing Fiddle using FFI that should work on TruffleRuby too, since both JRuby and TruffleRuby ship |
It would be helpful to all involved if we could share a single pure-Ruby implementation for this gem that works across all implementations.
Fiddle uses FFI internally. Any overhead introduced by using FFI from Ruby to implement Fiddle can be mitigated along the way, using more direct FFI APIs or by improvements to FFI itself. |
@headius @enebo Can we relicense |
I will look into this. |
Regarding code from https://github.com/jruby/jruby/blob/master/lib/ruby/stdlib/fiddle.rb and https://github.com/jruby/jruby/blob/master/lib/ruby/stdlib/fiddle being imported into this repository, I consent to relicense my contributions under the terms of the Ruby license and the BSD-2-Clause license. |
@enebo @ahorek @ikaronen-relex You have change lines in the imported versions of these files. Could you reply here giving your consent to relicense the code for Ruby and BSD-2-Clause as I did above? |
@headius As far as I can tell, all I've contributed to this PR is an empty line, which is not copyrightable. But just in case I've missed something else (and for the avoidance of doubt), I hereby consent to relicense all my past and future contributions to JRuby (and specifically those included in this PR) under the terms of the Ruby license and the BSD-2-Clause license. |
@ikaronen-relex Ok, I just looked at the history. If you had other lines they may have been overwritten over time. Thanks for the consent in any case! |
sure! I consent to relicense my contributions under the terms of the Ruby license and the BSD-2-Clause license. |
I also consent to relicense my contributions under the terms of the Ruby license and the BSD-2-Clause license. |
@kou Everyone with lines in these source files has consented to relicense. I think we are good to go there! |
Thanks! |
@kou Thank you for the extra work to import JRuby's FFI fiddle! 🙇♂️ |
Fix GH-104
lib/fiddle/jruby.rb is based on
https://github.com/jruby/jruby/blob/master/lib/ruby/stdlib/fiddle/jruby.rb .
Here are changes for it:
Fiddle::TYPE_*
toFiddle::Types::*
Fiddle::Types::VARIADIC
Fiddle::Types::CONST_STRING
Fiddle::Types::BOOL
Fiddle::Types::INT8_T
Fiddle::Types::UINT8_T
Fiddle::Types::INT16_T
Fiddle::Types::UINT16_T
Fiddle::Types::INT32_T
Fiddle::Types::UINT32_T
Fiddle::Types::INT64_T
Fiddle::Types::UINT64_T
Fiddle::ALIGN_*
for the above newFiddle::Types::*
Fiddle::SIZEOF_*
for the above newFiddle::Types::*
Fiddle::Types::*
but alsoSymbol
like:int
Fiddle::Function
Fiddle::Closure#free
Fiddle::Closure#freed?
Fiddle::Error
as base the error classFiddle::Pointer#call_free
and stop usingFFI::AutoPointer
inFiddle::Pointer
Fiddle::Pointer.malloc {}
Fiddle::Pointer
Fiddle::Pointer#free=
Fiddle::Pointer#freed?
Fiddle::Pointer#[]
Fiddle::Handle.sym_defined?
Fiddle::Handle#sym_defined?
Fiddle::Handle::DEFAULT
Fiddle::ClearedReferenceError
Fiddle::Pinned
Some features are still "not implemented". So there are some "omit"s for JRuby in tests.