MCPcopy Create free account
hub / github.com/Tencent/xLua / ReleaseLuaBase

Method ReleaseLuaBase

Assets/XLua/Src/ObjectTranslator.cs:545–578  ·  view source on GitHub ↗
(RealStatePtr L, int reference, bool is_delegate)

Source from the content-addressed store, hash-verified

543 }
544
545 public void ReleaseLuaBase(RealStatePtr L, int reference, bool is_delegate)
546 {
547 if(is_delegate)
548 {
549 LuaAPI.xlua_rawgeti(L, LuaIndexes.LUA_REGISTRYINDEX, reference);
550 if (LuaAPI.lua_isnil(L, -1))
551 {
552 LuaAPI.lua_pop(L, 1);
553 }
554 else
555 {
556 LuaAPI.lua_pushvalue(L, -1);
557 LuaAPI.lua_rawget(L, LuaIndexes.LUA_REGISTRYINDEX);
558 if (LuaAPI.lua_type(L, -1) == LuaTypes.LUA_TNUMBER && LuaAPI.xlua_tointeger(L, -1) == reference) //
559 {
560 //UnityEngine.Debug.LogWarning("release delegate ref = " + luaReference);
561 LuaAPI.lua_pop(L, 1);// pop LUA_REGISTRYINDEX[func]
562 LuaAPI.lua_pushnil(L);
563 LuaAPI.lua_rawset(L, LuaIndexes.LUA_REGISTRYINDEX); // LUA_REGISTRYINDEX[func] = nil
564 }
565 else //another Delegate ref the function before the GC tick
566 {
567 LuaAPI.lua_pop(L, 2); // pop LUA_REGISTRYINDEX[func] & func
568 }
569 }
570
571 LuaAPI.lua_unref(L, reference);
572 delegate_bridges.Remove(reference);
573 }
574 else
575 {
576 LuaAPI.lua_unref(L, reference);
577 }
578 }
579
580 public object CreateInterfaceBridge(RealStatePtr L, Type interfaceType, int idx)
581 {

Callers 2

LuaEnv.csFile · 0.80
DisposeMethod · 0.80

Calls 11

xlua_rawgetiMethod · 0.80
lua_isnilMethod · 0.80
lua_popMethod · 0.80
lua_pushvalueMethod · 0.80
lua_rawgetMethod · 0.80
lua_typeMethod · 0.80
xlua_tointegerMethod · 0.80
lua_pushnilMethod · 0.80
lua_rawsetMethod · 0.80
lua_unrefMethod · 0.80
RemoveMethod · 0.45

Tested by

no test coverage detected