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

Function luaB_newproxy

Source/Misc/lua/src/lua.c:11285–11308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11283
11284
11285static int luaB_newproxy (lua_State *L) {
11286lua_settop(L, 1);
11287lua_newuserdata(L, 0); /* create proxy */
11288if (lua_toboolean(L, 1) == 0)
11289return 1; /* no metatable */
11290else if (lua_isboolean(L, 1)) {
11291lua_newtable(L); /* create a new metatable `m' ... */
11292lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */
11293lua_pushboolean(L, 1);
11294lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */
11295}
11296else {
11297int validproxy = 0; /* to check if weaktable[metatable(u)] == true */
11298if (lua_getmetatable(L, 1)) {
11299lua_rawget(L, lua_upvalueindex(1));
11300validproxy = lua_toboolean(L, -1);
11301lua_pop(L, 1); /* remove value */
11302}
11303luaL_argcheck(L, validproxy, 1, "boolean or proxy expected");
11304lua_getmetatable(L, 1); /* metatable is valid; get it */
11305}
11306lua_setmetatable(L, 2);
11307return 1;
11308}
11309
11310
11311static const luaL_Reg base_funcs[] = {

Callers

nothing calls this directly

Calls 9

lua_settopFunction · 0.85
lua_newuserdataFunction · 0.85
lua_tobooleanFunction · 0.85
lua_pushvalueFunction · 0.85
lua_pushbooleanFunction · 0.85
lua_rawsetFunction · 0.85
lua_getmetatableFunction · 0.85
lua_rawgetFunction · 0.85
lua_setmetatableFunction · 0.85

Tested by

no test coverage detected