incubator-lucy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marvin Humphrey <>
Subject Dynamic VTables
Date Tue, 22 Apr 2008 04:08:30 GMT

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

View raw message