It does talk about what swig does, but it also talks about the other direction:
"If the C structure references other ruby objects, then the mark function pointer must also be provided and must properly mark the other objects with rb_gc_mark()" --Rafael On Fri, Jan 23, 2015 at 1:24 PM, Darryl L. Pierce <dpie...@redhat.com> wrote: > On Fri, Jan 23, 2015 at 11:02:59AM -0500, Rafael Schloming wrote: > <snip> > > For more info on how to integrate with Ruby's GC you can read this > > article[1]. It's one of the few pieces of documentation I've found that > > actually explain how to keep a reference from C to a Ruby object. > > > > [1] > > > http://clalance.blogspot.com/2013/11/writing-ruby-extensions-in-c-part-13.html > > This blog post shows how to manually do what Swig is doing for us: > represent a C struct as something Ruby can touch, with hooks to release > memory when GC runs on the Ruby wrapper. But, sadly, it's not showing > what we need, which is how to assign a reference to a Ruby object to a C > struct and then have Ruby not GC that Ruby object. > > -- > Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc. > Delivering value year after year. > Red Hat ranks #1 in value among software vendors. > http://www.redhat.com/promo/vendor/ > >