Hello,
I'm associating a metatable to user data using following code
-----
static const struct luaL_Reg SelTimedColLib [] = {
{"Create", stwcol_create},
{NULL, NULL}
};
static const struct luaL_Reg SelTimedColM [] = {
{"Push", stwcol_push},
{"MinMax", stwcol_minmax},
{NULL, NULL}
};
libSel_objFuncs( L, "SelTimedWindowCollection", SelTimedColM);
libSel_libFuncs( L, "SelTimedWindowCollection", SelTimedColLib );
-----
with libSel_libFuncs() like that
-----
int libSel_objFuncs( lua_State *L, const char *name, const struct luaL_Reg *funcs){
luaL_newmetatable(L, name);
lua_pushstring(L, "__index");
lua_pushvalue(L, -2);
lua_settable(L, -3); /* metatable.__index = metatable */
if(funcs){ /* May be NULL if we're creating an empty metatable */
#if LUA_VERSION_NUM > 501
luaL_setfuncs( L, funcs, 0);
#else
luaL_register(L, NULL, funcs);
#endif
}
return 1;
}
----
and then
----
struct SelTimedWindowCollection *col = (struct SelTimedWindowCollection *)lua_newuserdata(L, sizeof(struct SelTimedWindowCollection));
luaL_getmetatable(L, "SelTimedWindowCollection");
lua_setmetatable(L, -2);
----
So, now, from Lua's side, how to retrieve metatable's name ???? (in my case, "SelTimedWindowCollection")
I tried to test against the metatable itself but it doesn't work :
print( getmetatable(col.getCollection()), SelTimedWindowCollection )
-> table: 0xb79650d8 table: 0xb7965100
Thanks for your help
Laurent