/* Create metatable * Create and register new metatable */ static int tolua_newmetatable (lua_State* L, char* name) { int r = luaL_newmetatable(L,name); if (r) tolua_classevents(L); /* set meta events */ lua_pop(L,1); return r; }
/* Create metatable * Create and register new metatable */ static void tolua_newmetatable (lua_State* L, char* name) { luaL_newmetatable(L,name); /* set meta events */ tolua_classevents(L); lua_pop(L,1); }
/* Create metatable * Create and register new metatable */ void tolua_newmetatable (lua_State* L, const char* name) { if (luaL_newmetatable(L,TOLUANAME(name))) { lua_pushvalue(L,-1); lua_pushstring(L,name); lua_rawset(L,LUA_REGISTRYINDEX); } /* set meta events */ tolua_classevents(L); lua_pop(L,1); }
/* Create metatable * Create and register new metatable */ static int tolua_newmetatable (lua_State* L, const char* name) { int r = luaL_newmetatable(L,name); #ifdef LUA_VERSION_NUM /* only lua 5.1 */ if (r) { lua_pushvalue(L, -1); lua_pushstring(L, name); lua_settable(L, LUA_REGISTRYINDEX); /* reg[mt] = type_name */ }; #endif if (r) tolua_classevents(L); /* set meta events */ lua_pop(L,1); return r; }