MCPcopy Create free account
hub / github.com/Overload-Technologies/Overload / luaL_newmetatable

Function luaL_newmetatable

Dependencies/lua/src/lauxlib.c:314–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

312*/
313
314LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
315 if (luaL_getmetatable(L, tname) != LUA_TNIL) /* name already in use? */
316 return 0; /* leave previous value on top, but return 0 */
317 lua_pop(L, 1);
318 lua_createtable(L, 0, 2); /* create metatable */
319 lua_pushstring(L, tname);
320 lua_setfield(L, -2, "__name"); /* metatable.__name = tname */
321 lua_pushvalue(L, -1);
322 lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */
323 return 1;
324}
325
326
327LUALIB_API void luaL_setmetatable (lua_State *L, const char *tname) {

Callers 8

operator()Method · 0.85
push_deepMethod · 0.85
push_withMethod · 0.85
operator()Method · 0.85
register_usertypeFunction · 0.85
runCFunction · 0.85
newboxFunction · 0.85
createmetaFunction · 0.85

Calls 4

lua_createtableFunction · 0.85
lua_pushstringFunction · 0.85
lua_setfieldFunction · 0.85
lua_pushvalueFunction · 0.85

Tested by 1

runCFunction · 0.68