MCPcopy Create free account
hub / github.com/RomanKubiak/ctrlr / luaL_newmetatable

Function luaL_newmetatable

Source/Misc/lua/src/lua.c:10324–10333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10322
10323
10324LUALIB_API int luaL_newmetatable (lua_State *L, const char *tname) {
10325lua_getfield(L, LUA_REGISTRYINDEX, tname); /* get registry.name */
10326if (!lua_isnil(L, -1)) /* name already in use? */
10327return 0; /* leave previous value on top, but return 0 */
10328lua_pop(L, 1);
10329lua_newtable(L); /* create metatable */
10330lua_pushvalue(L, -1);
10331lua_setfield(L, LUA_REGISTRYINDEX, tname); /* registry.name = metatable */
10332return 1;
10333}
10334
10335
10336LUALIB_API void *luaL_checkudata (lua_State *L, int ud, const char *tname) {

Callers 4

luausb_init_structsFunction · 0.85
luaopen_usbFunction · 0.85
createmetaFunction · 0.85
luaopen_packageFunction · 0.85

Calls 3

lua_getfieldFunction · 0.85
lua_pushvalueFunction · 0.85
lua_setfieldFunction · 0.85

Tested by

no test coverage detected