Now the problem is that the first object gets GCed, although it should
still be accessible in ruby via $foo. Or am I totally wrong?
Any ideas why it is like that?
What can one to prevent GC killing my object?
i know that ruby_obj goes out of scope when the function exit. But that
should NOT affect the ruby object should it?
After the function exit anything can be put at this address. This mean
that the GC will not mark the ruby object (the address don't reference it
any more) and logically it remove it at the sweep phase.
rb_gv_set instead of rb_define_variable works perfectly well!
Lots of thanks to "ts"
ps: what i'm doing is to extend a existing c++ app with scripting
capabilities.
Now it is possible to access wrapped c++ objects with a ruby script.
This allows rapid prototyping and stuff like that