MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaL_newmetatable

Function luaL_newmetatable

third-party/lua-5.2.4/src/lauxlib.c:272–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270*/
271
272LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
273 luaL_getmetatable(L, tname); /* try to get metatable */
274 if (!lua_isnil(L, -1)) /* name already in use? */
275 return 0; /* leave previous value on top, but return 0 */
276 lua_pop(L, 1);
277 lua_newtable(L); /* create metatable */
278 lua_pushvalue(L, -1);
279 lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */
280 return 1;
281}
282
283
284LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname) {

Callers 1

createmetaFunction · 0.70

Calls 2

lua_pushvalueFunction · 0.70
lua_setfieldFunction · 0.70

Tested by

no test coverage detected