Hi Martin!
This is a very good question! I also stumbled upon this issue in the past.
Unfortunately you can't pass a CRuby VALUE pointer to ruby space per FFI. This is because FFI is meant to be ruby VM agnostic. Even though it would be very simple, it's not built in, since it wouldn't work with JRuby.
You have two ways to get the key value pairs to ruby space:
1. You convert the ruby hash object per rb_funcall() to a String that can be sent to ruby. For instance call "to_s" on the hash, pass it as a C-string to ruby and use "eval" to get a copy of the Hash. Or you call "Marshal.dump" with the Hash and pass the resulting binary String as a Struct<Pointer,Length> to ruby and use "Marshal.load" to get a copy of the Hash.
2. You build a C representation of the Hash - not using any rb_* functions. Like an Array<Struct<Key,Value>> or so. Then you can pass the Array pointer to ruby and construct the Hash by reading out your corresponding FFI::Struct's or so in Ruby space.
Hope this helps.
--
Regards, Lars
--
You received this message because you are subscribed to the Google Groups "ruby-ffi" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-ffi+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ruby-ffi/4e2e52ef-792e-4848-b2be-9d93cfd20222n%40googlegroups.com.