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 http://code.google.com/p/crack-language/wiki/ExtensionsVirtualFunctions. At the time of this writing, this is not completely up-to-date, but test/testext.cc includes a complete example.
Happy wrapping!
No comments:
Post a Comment