Thursday, March 15, 2012

Virtual Functions in Extensions!

This morning I checked in a big change to allow us to do a better job at wrapping C++ classes with virtual functions.  In summary, you can now create an extension class whose virtual methods call the underlying C++ function by default, but can be overriden in Crack as if they were normal Crack virtual methods.  This magic also works from C++: calling the virtual function on a Crack object from C++ transparently dispatches the call to the Crack override, cleanly solving the problem of C++ callbacks.  To top it all off, the interface is portable - it makes no assumptions about the C++ ABI.

You can read the original design doc at  At the time of this writing, this is not completely up-to-date, but test/ includes a complete example.

Happy wrapping!

No comments:

Post a Comment