Closed utgarda closed 13 years ago
You don't hate me for always pointing all these troubles with jruby, right? :)
what version of jruby are you using here? I love bugs! It means you're using the library... keep em coming
I used the latest 1.5.0-dev to get that, namely jruby@035927d9b98e80a5530ff418e23a67d4659f8220 Didn't try it properly with stable 1.4.0, the current version of FFI doesn't build on 1.4.0 anymore.
Hrm. This looks like feature disparity between YARV FFI and JRuby FFI. I don't know much about writing Java code, but from looking at the JRuby source, it looks like it shouldn't be that hard to add the struct_class method. I'm going to file an issue with the JRuby people about it.
/cheers for community support!
Ok, FFI::StructByValue.struct_class is back in JRuby 1.6.0.dev,
but, with this one fixed and with ObjectSpace enabled, spec still fails:
:~/devenv/ruby/chipmunk-ffi> jruby --version
jruby 1.6.0.dev (ruby 1.8.7 patchlevel 249) (2010-04-17 6586) (OpenJDK 64-Bit Server VM 1.6.0_0) [amd64-java]
:~/devenv/ruby/chipmunk-ffi> jrake --version
rake, version 0.8.7
:~/devenv/ruby/chipmunk-ffi> jrake
(in /home/etsvigun/devenv/ruby/chipmunk-ffi)
.............FFFFFFFFF.................F..................................................................................................F........
1)
ArgumentError in 'Shape in chipmunk can do a segment query'
Invalid callback parameter type: #<FFI::StructByValue:CP::Vect>
./spec/space_spec.rb:192:
2)
TypeError in 'Shape in chipmunk can do a segment query that returns info'
wrong argument type FFI::Buffer (expected instance of FFI::Struct)
./spec/space_spec.rb:210:
3)
TypeError in 'Shape in chipmunk can do a segment query that returns a shape'
wrong argument type FFI::Buffer (expected instance of FFI::Struct)
./spec/space_spec.rb:228:
4)
TypeError in 'Shape in chipmunk can do a segment query that finds no shape'
wrong argument type FFI::Buffer (expected instance of FFI::Struct)
./spec/space_spec.rb:234:
5)
TypeError in 'Shape in chipmunk can do a segment query that finds no info'
wrong argument type FFI::Buffer (expected instance of FFI::Struct)
./spec/space_spec.rb:241:
...
For the first failure: Apparently in JRuby's FFI, FFI::StructByValue types are not valid parameters for callbacks, see http://github.com/jruby/jruby/blob/master/src/org/jruby/ext/ffi/jffi/CallbackManager.java . Not entirely sure how we could work around this, maybe use a buffer instead and then cast it as a struct? Otherwise, another bug needs to be filed with JRuby.
For the other failures: change lib/space.rb:368 to say: shape_ptr = CP.cpSpaceSegmentQueryFirst(@struct.pointer, a.struct, b.struct,layers,group,out_ptr)
and it all works.
philomory, for the space fix, can you fork/fix/pull request? Also, can you write up a bug for the StructByValue issue? I was told that the jruby and MRI FFI implementations need to stay in sync. Even if it means they remove StructByValue from MRI's version ;)
submitted a bug for the StuctByValue piece of this: http://jira.codehaus.org/browse/JRUBY-4748
Made that pull request; for the JRuby issue, it looks like we both filed issues with them. In any case, it's been fixed: http://jira.codehaus.org/browse/JRUBY-4745
done.
Don't know, if that can be helped, but here it is : etsvigun@linux-pzv7:~/devenv/ruby/chipmunk-ffi> jruby -S rake spec (in /home/etsvigun/devenv/ruby/chipmunk-ffi) /home/etsvigun/devenv/ruby/chipmunk-ffi/lib/chipmunk-ffi/struct_accessor.rb:41:in
resolve_type': undefined method
struct_class' for #FFI::StructByValue:CP::Vect (NoMethodError) from .../chipmunk-ffi/lib/chipmunk-ffi/struct_accessor.rb:21:inadd_struct_reader' from ..../chipmunk-ffi/lib/chipmunk-ffi/struct_accessor.rb:7:in
struct_reader' from .../chipmunk-ffi/lib/chipmunk-ffi/struct_accessor.rb:7:ineach' from .../chipmunk-ffi/lib/chipmunk-ffi/struct_accessor.rb:7:in
struct_reader' from .../chipmunk-ffi/lib/chipmunk-ffi/struct_accessor.rb:16:instruct_accessor' from .../chipmunk-ffi/lib/chipmunk-ffi/constraints/pin_joint.rb:20 from .../chipmunk-ffi/lib/chipmunk-ffi/constraints/pin_joint.rb:31:in
require' from .../jruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire' ... 14 levels... from /home/etsvigun/devenv/ruby/jruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/options.rb:133:in
run_examples' from /home/etsvigun/devenv/ruby/jruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/lib/spec/runner/command_line.rb:9:in `run' from /home/etsvigun/devenv/ruby/jruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/bin/spec:5 rake aborted! Command /home/etsvigun/devenv/ruby/jruby/bin/jruby -I"lib" "/home/etsvigun/devenv/ruby/jruby/lib/ruby/gems/1.8/gems/rspec-1.3.0/bin/spec" "spec/space_spec.rb" "spec/space_hash_spec.rb" "spec/core_spec.rb" "spec/shape_spec.rb" "spec/constraint_spec.rb" "spec/vec2_spec.rb" "spec/body_spec.rb" "spec/unsafe_spec.rb" "spec/bb_spec.rb" failed