Dynamic typing question
John Smith <[email protected]>
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
Is it possible to use the RTTI info to have lua figure out the original type
of a sliced object? IE:
class BaseObject : public luabind::wrap_base
{
};
class DerivedObject : public BaseObject
{
public:
int i;
}
lua_State* L;
bool LuaStateMgrImpl::Init()
{
L = lua_open();
// load the libs
luaL_openlibs(L);
// Add our libs
luabind::open(L);
luabind::module(L)
[
luabind::class_<BaseObject >("BaseObject "),
luabind::class_<DerivedObject , BaseObject >("DerivedObject ")
.def(luabind::constructor<>())
.def_readwrite("i", &DerivedObject ::i)
];
}
void GenericCall( const char* pszFunctionCall, BaseObject &o1, BaseObject
&o2 )
{
luabind::call_function<void>(L, pszFunctionCall, &o1, &o2);
}
void callsomething()
{
DerivedObject do1;
do1.i = 5;
DerivedObject do2;
GenericCall("SomeFunc", do1, do2);
cout << do2.i;
}
lua:
function SomeFunc( do1, do2)
print (do1.i)
do2.i = 3
end
Obviously the goal is to have standard out show:
5
3
Is there a way to handle this via RTTI or another mechanism, otherwise,
what's the best practice for some kind of generic call function?
------------------------------------------------------------------------------
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