MCPcopy Create free account
hub / github.com/OGSR/OGSR-Engine / impl

Method impl

ogsr_engine/Luabind/src/weak_ref.cpp:91–120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89 struct weak_ref::impl
90 {
91 impl(lua_State* s, int index)
92 : count(0)
93 , state(s)
94 , ref(0)
95 {
96 lua_pushvalue(s, index);
97 get_weak_table(s);
98
99 lua_rawgeti(s, -1, freelist_ref);
100 ref = (int)lua_tonumber(s, -1);
101 lua_pop(s, 1);
102
103 if (ref == 0)
104 {
105 lua_rawgeti(s, -1, count_ref);
106 ref = (int)lua_tonumber(s, -1) + 1;
107 lua_pop(s, 1);
108 lua_pushnumber(s, (lua_Number)ref);
109 lua_rawseti(s, -2, count_ref);
110 }
111 else
112 {
113 lua_rawgeti(s, -1, ref);
114 lua_rawseti(s, -2, freelist_ref);
115 }
116
117 lua_pushvalue(s, -2); // duplicate value
118 lua_rawseti(s, -2, ref);
119 lua_pop(s, 2); // pop weakref table and value
120 }
121
122 ~impl()
123 {

Callers

nothing calls this directly

Calls 6

get_weak_tableFunction · 0.85
lua_pushvalueFunction · 0.50
lua_rawgetiFunction · 0.50
lua_tonumberFunction · 0.50
lua_pushnumberFunction · 0.50
lua_rawsetiFunction · 0.50

Tested by

no test coverage detected