(RealStatePtr L, int reference, bool is_delegate)
| 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 | { |
no test coverage detected