Original Post
Hello all, I am trying to replace an already existing Lua scripting system with Squirrel Plus. However, I immediatly encountered some major difficulties. The game engine is set up with an abstract interface. Plugins then provide implementations for those interfaces like in the following:
// Interface (abstract)
class ILight
{
virtual void doSomething(void) = 0;
};
// In plugin
class OpenGLLight : public ILight
{
virtual void doSomething(void)
{
...
}
};
The engine using Luabind binds the abstract interface, not the implementation, and passes instances of the derived classes to the script. In other words:
// Global function that returns instance of a light depending on the plugin loaded
static ILight* CreateLight(void)
{
if (usingOpenGL)
return new OpenGLLight;
...
}
That function is then binded to Squirrel. And in Squirrel I can then do:
light = CreateLight();
light.doSomething();
I am lost on how to do this not only in Squirrel but Luabind as well. I would bypass the interfaces completely and bind the implementations but I can't do that with the current engine design. How would I go about doing this? I tried binding the interface but I recieved a "cannot instantiate abstract class" linker error which I expected. How this engine manages to do this with Luabind is a mystery to me. It apperantly uses something called "abstract binder mechanism". I Googled for it and found nothing. Thanks in advance.