Subject:
[ruby-ffi] AutoPointer#autorelease? and Releaser
From:
"dark.panda" <dark.panda@gmail.com>
Date:
5/18/11 8:39 PM
To:
ruby-ffi

G'day list.

I noticed that in ffi 1.0.8, an autorelease? method was added to the
Pointer class to check on @autorelease. In the AutoPointer class, the
autorelease= method is overridden and the value is forwarded to
Releaser, but the autorelease? method isn't overridden in a similar
fashion and will always return false.

I'm currently cleaning up an ffi wrapper for the GEOS library, and the
rules for whether or not to objects need to be explicitly freed
depends on the situation such as whether or not a parent object owns a
geometry and so forth. I'd like to use autorelease? to check on the
status of autorelease as I'm relying upon it to detect whether or not
I have to do some object cloning or if the objects I'm using are safe
to use directly.

So, I guess what I'm wondering is is if the absence of autorelease?
delegating to Releaser in AutoPointer intentional and that what I'm
trying to do is insane, or if I'm on to something here. At the moment
I'm relying on instance_variable_get to get to @releaser.autorelease,
but that seems pretty flaky.

Cheers.