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