Subject:
[ruby-ffi] Re: c++ examples
From:
rogerdpack
Date:
12/7/09 11:55 AM
To:
ruby-ffi

> > In the end I think I'm going to end up having to write ruby containers
> > for c++ objects, so I'll probably end up having to write a "real"
> > extension after all.  Anybody know of a cross-VM compatible way to
> > wrap C objects and call their destructors, etc.?
> > Thanks.
>
> You mean C++ objects and make them work with Ruby C API?

Good point. C++.

It appears on closer inspection that you can call something like
MyClass.free_object
(http://wiki.github.com/ffi/ffi/examples)
on objects, so perhaps I could register my C++ wrapped object using
ObjectSpace#define_finalizer and call a wrapper to the C++
destructor.  That might work.

-r