MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / createmetatable

Function createmetatable

3rd/lua-5.4.3/src/lstrlib.c:1795–1806  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1793
1794
1795static void createmetatable (lua_State *L) {
1796 /* table to be metatable for strings */
1797 luaL_newlibtable(L, stringmetamethods);
1798 luaL_setfuncs(L, stringmetamethods, 0);
1799 lua_pushliteral(L, ""); /* dummy string */
1800 lua_pushvalue(L, -2); /* copy table */
1801 lua_setmetatable(L, -2); /* set table as metatable for strings */
1802 lua_pop(L, 1); /* pop dummy string */
1803 lua_pushvalue(L, -2); /* get string library */
1804 lua_setfield(L, -2, "__index"); /* metatable.__index = string */
1805 lua_pop(L, 1); /* pop metatable */
1806}
1807
1808
1809/*

Callers 1

luaopen_stringFunction · 0.85

Calls 4

luaL_setfuncsFunction · 0.85
lua_pushvalueFunction · 0.85
lua_setmetatableFunction · 0.85
lua_setfieldFunction · 0.85

Tested by

no test coverage detected