MCPcopy Create free account
hub / github.com/F-Stack/f-stack / luaB_newproxy

Function luaB_newproxy

app/redis-6.2.6/deps/lua/src/lbaselib.c:422–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

420
421
422static int luaB_newproxy (lua_State *L) {
423 lua_settop(L, 1);
424 lua_newuserdata(L, 0); /* create proxy */
425 if (lua_toboolean(L, 1) == 0)
426 return 1; /* no metatable */
427 else if (lua_isboolean(L, 1)) {
428 lua_newtable(L); /* create a new metatable `m' ... */
429 lua_pushvalue(L, -1); /* ... and mark `m' as a valid metatable */
430 lua_pushboolean(L, 1);
431 lua_rawset(L, lua_upvalueindex(1)); /* weaktable[m] = true */
432 }
433 else {
434 int validproxy = 0; /* to check if weaktable[metatable(u)] == true */
435 if (lua_getmetatable(L, 1)) {
436 lua_rawget(L, lua_upvalueindex(1));
437 validproxy = lua_toboolean(L, -1);
438 lua_pop(L, 1); /* remove value */
439 }
440 luaL_argcheck(L, validproxy, 1, "boolean or proxy expected");
441 lua_getmetatable(L, 1); /* metatable is valid; get it */
442 }
443 lua_setmetatable(L, 2);
444 return 1;
445}
446
447
448static const luaL_Reg base_funcs[] = {

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected