Greets,

A problem that both Ferret and KinoSearch have faced in the past is how to support user-defined subclasses. Say you wrap a C-level object in a subclassed native wrapper object. Then the object disappears into the library internals, and the wrapper evaporates. What happens when the object re-emerges into the host environment later? The subclass will have been lost, and the new wrapper object will have devolved to the parent class.

The solution is to create a new VTable on the fly for each subclass. It should be an exact duplicate of the original save for the information necessary to hook into the user-defined class. (For Perl, changing the class name is enough.) Then, the C-level object never forgets its true class association, allowing us to always create appropriate new wrapper objects.

Gory details of the implementation include discovery and garbage collection of these VTable objects... but that's the gist.

Marvin Humphrey
Rectangular Research
http://www.rectangular.com/

Reply via email to