Luabind: derived classes!
neosettlers <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <002601c9979c$ee3a2490$caae6db0$@ca> |
Hello again,
Intro: The way I ve implemented Lua in my project is considering that the
API can be compiled with or witout Lua. To achieve this, I ve created a
dummy Script class, so I don't propagate lua in the entire project.
I did condensed my work a big deal, so here it is:
.cpp
Script *CreateScript(const Char *in_name, const Char *in_path)
{
Script *l_script;
#if SUPPORT_LUA
l_script = new LUA_Script();
#else
l_script = new Script();
#endif
return l_script;
}
class Object
{
Object() {}
void AddScript(Script *in_script);
/// SNIP...
};
class Script: public Object
{
/// SNIP...
};
class LUA_Script: public Script
{
/// SNIP...
};
Luabind
Int Expose_Objects(lua_State* in_lua)
{
module(in_lua)
[
def("CreateScript", &CreateScript)
,
class_<Object>("Object")
.def("AddScript", &Object::AddScript)
,
class_<LUA_Script, Object>("Script")
.def(constructor<>())
];
return 0;
}
.lua
myScript = CreateScript("Test", "test.ai");
myObject = Object();
myObject:AddScript(myScript);
The bottleneck is right here:
if I do use new Script(); it will work but it won't have any Lua
functionalities.
when new LUA_Script(); is called I get:
No matching overload found, candidates:
void AddScript(Object&,Script*)
CreateScript creates a LUA_Script* and return a Script* but when passed in
myObject:AddScript(myScript); it is considered to be a LUA_Script wich it is
indeed. but there is no C++ match.
In pure C++ this would be legal but Luabind doesn't seem to like that at
all, any elegant way to make this work?
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user