chipmunk-rb / chipmunk-ffi

chipmunk ruby bindings using ffi
26 stars 6 forks source link

This week's kill #18

Closed utgarda closed 13 years ago

utgarda commented 13 years ago

Hi m8, here's what I got this week. Seems like I successfully chewed through those problems using nested FFI structs. But there's a new one:

cp_static_inline doesn't take as function argument types any callbacks defined earlier in code. Never before was an issue, cause it's the first time static inline functions in chipmunk API have something except pointers and structs for args.

Thus, lines like this

   cp_static_inline :cpSpatialIndexEach, [:pointer, :cpSpatialIndexIteratorFunc, :pointer], :void

result in errors :

/chipmunk-ffi/lib/chipmunk-ffi.rb:35:in `initialize': Invalid parameter type (:cpSpatialIndexIteratorFunc) (TypeError)

Should we go to jacius with a feature request for NiceFFI, or to FFI maintainers, or maybe you can fix it?

There are many more of static inline functions with signatures like that, so this is pretty much a show-stopper. Please advise something here.

Good news:

shawn42 commented 13 years ago

I think you can get around this for the time being by passing in a :pointer there. the cp_static_inline is a crazy little work around for the static inline methods that chipmunk uses all over the place.

utgarda commented 13 years ago

Cool. If that works, it would mean this typing has about as much value as comments. So it can be easily covered in some documentation, if docs are ever to appear.

shawn42 commented 13 years ago

utgarda: did that work for you?

utgarda commented 13 years ago

Seems like a yes. Only checked for cpSpatialIndexQuery though ( last commit just now ) , but I have a good feeling about that :) More use cases to test can appear only from practice, cause even chipmunk's examples don't give much index query sample code. When I cover everything I need and finally start using it, maybe I'll invent better specs for this.

utgarda commented 13 years ago

Oh no, it did not work. Trying to pass a method, when there's a :pointer in a cp_static_inline signature instead of a properly defined callback results in error messages like ":pointer argument is not a valid pointer"

19