| 58 | }; |
| 59 | |
| 60 | void get_weak_table(lua_State* L) |
| 61 | { |
| 62 | lua_pushliteral(L, "__luabind_weak_refs"); |
| 63 | lua_gettable(L, LUA_REGISTRYINDEX); |
| 64 | |
| 65 | if (lua_isnil(L, -1)) |
| 66 | { |
| 67 | lua_pop(L, 1); |
| 68 | lua_newtable(L); |
| 69 | // metatable |
| 70 | lua_newtable(L); |
| 71 | lua_pushliteral(L, "__mode"); |
| 72 | lua_pushliteral(L, "v"); |
| 73 | lua_rawset(L, -3); |
| 74 | // set metatable |
| 75 | lua_setmetatable(L, -2); |
| 76 | lua_pushnumber(L, 0); |
| 77 | lua_rawseti(L, -2, freelist_ref); |
| 78 | lua_pushnumber(L, 2); |
| 79 | lua_rawseti(L, -2, count_ref); |
| 80 | |
| 81 | lua_pushliteral(L, "__luabind_weak_refs"); |
| 82 | lua_pushvalue(L, -2); |
| 83 | lua_settable(L, LUA_REGISTRYINDEX); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | } // namespace unnamed |
| 88 |
no test coverage detected