Getting a C++ object back from a luabind::object?
"Josh Klint" <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <000001cc152d$3c859200$b590b600$@com> |
Here's my function to push a C++ object onto the Lua stack. I use a base
class all classes are derived from, called "Object". Each Object gets a
luabind::object associated with it when it is pushed onto the stack. The
luabind::object is stored in an std::map so it can be retrieved quickly:
void Interpreter::PushObject(Object* o)
{
if (objectmap[o]==NULL) objectmap[o] = new luabind::object(L,o);
objectmap[o]->push(L);
}
I can retrieve a luabind::object off the stack. But how do I retrieve the
original Object* I used in the luabind::object constructor?:
Object* Interpreter::ToObject(const int& index)
{
luabind::object o = luabind::object(L,index);
return (Object*) o.what?
}
Incidentally, the reason the luabind::object is stored in an std::map
instead of as a member of the Object class is because I want to keep all the
Lua code contained within the interpreter, as we have some customers that
want to replace the interpreter with alternate script languages.
Thanks.
Best Regards,
Josh Klint
CEO
Leadwerks Software
www.leadwerks.com
------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its
next-generation tools to help Windows* and Linux* C/C++ and Fortran
developers boost performance applications - including clusters.
http://p.sf.net/sfu/intel-dev2devmay
_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user