We use tolua ++ to create Lua bindings for C ++ classes.
Suppose I have a C ++ class:
class Foo {
and tolua.pkg file with the following contents
class Foo { };
Consider the following function:
void call_some_lua_function(lua_State* luaState) { Foo* myFoo = new Foo(); tolua_pushusertype(luaState, (void*)myFoo, "Foo");
Now, the question is:
tolua_pushusertype calls segfault in Lua if the third parameter does not match the valid full C ++ class string that was registered when tolua_cclass was called. So, if parameter 3, where "Bar", we get segfault.
I would like to do the following:
void call_some_lua_function(lua_State* luaState) { //determine if tolua is aware of my type, how to do this? //Something like: //if(!tolua_iscpptype_registered("Foo")) //{ // abort gracefully //} Foo* myFoo = new Foo(); tolua_pushusertype(luaState, (void*)myFoo, "Foo"); //More code to actually call Lua, irrelevant to question. }
Is there any way to do this with tolua?
source share