MCPcopy Create free account
hub / github.com/Tencent/UnLua / Unbind

Method Unbind

Plugins/UnLua/Source/UnLua/Private/Registries/ObjectRegistry.cpp:172–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170 }
171
172 void FObjectRegistry::Unbind(UObject* Object)
173 {
174 int32 Ref;
175 if (!ObjectRefs.RemoveAndCopyValue(Object, Ref))
176 return;
177
178 const auto L = Env->GetMainState();
179 const auto Top = lua_gettop(L);
180 RemoveFromObjectMapAndPushToStack(Object);
181
182 if (Ref == LUA_NOREF)
183 {
184 if (lua_isnil(L, -1))
185 {
186 lua_pop(L, 1);
187 return;
188 }
189 check(lua_isuserdata(L, -1));
190 bool bTwoLvlPtr;
191 void* Userdata = GetUserdataFast(L, -1, &bTwoLvlPtr);
192 check(bTwoLvlPtr)
193 *((void**)Userdata) = (void*)LowLevel::ReleasedPtr;
194 lua_settop(L, Top);
195 return;
196 }
197
198 check(lua_istable(L, -1));
199 luaL_unref(L, LUA_REGISTRYINDEX, Ref);
200 FUnLuaDelegates::OnObjectUnbinded.Broadcast(Object); // object instance ('INSTANCE') is on the top of stack now
201
202 lua_pushstring(L, "Object");
203 lua_rawget(L, -2);
204 void* Userdata = lua_touserdata(L, -1);
205 *((void**)Userdata) = (void*)LowLevel::ReleasedPtr;
206
207 lua_settop(L, Top);
208 }
209
210 void FObjectRegistry::AddManualRef(lua_State* L, UObject* Object)
211 {

Callers 4

SetupCustomLoaderMethod · 0.45
OnLegacyCallbackMethod · 0.45
FScriptDelegate_UnbindFunction · 0.45
ShutdownModuleMethod · 0.45

Calls 10

lua_gettopFunction · 0.85
checkFunction · 0.85
lua_isuserdataFunction · 0.85
GetUserdataFastFunction · 0.85
lua_settopFunction · 0.85
luaL_unrefFunction · 0.85
lua_pushstringFunction · 0.85
lua_rawgetFunction · 0.85
lua_touserdataFunction · 0.85
BroadcastMethod · 0.45

Tested by

no test coverage detected