[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Checking type of userdata in C++
- From: Rici Lake <lua@...>
- Date: Fri, 2 Feb 2007 12:34:30 -0500
On 2-Feb-07, at 12:20 PM, Zé Pedro wrote:
Sorry I've sent the message unfinished...
Hi, I have a method in C++ accessible from Lua that receives an
userdata object as a parameter. But it can receive one of several
userdata types.If I could get the string that I used when the
metatable was created (luaL_newmetatable(pLuaState, " Zara.sound");) I
could compare it, but I can't find a way to do it.
At the risk of being obvious:
int my_newmetatable (lua_State *L, const char *tname) {
int rc = luaL_newmetatable(L, tname);
if (rc) {
lua_pushstring(L, tname);
lua_setfield(L, -2, "__typename");
}
return rc;
}