public static void __Gen_Delegate_Imp2(this DelegateBridgeBase d) { #if THREAD_SAFE || HOTFIX_ENABLE lock (d.luaEnv.luaEnvLock) { #endif RealStatePtr L = d.rawL; int err_func = LuaAPI.load_error_func(L, d.errorFuncRef); LuaAPI.lua_getref(L, d.pLuaReference); int __gen_error = LuaAPI.lua_pcall(L, 0, 0, err_func); if (__gen_error != 0) { d.pLuaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_settop(L, err_func - 1); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
public static void __Gen_Delegate_Imp1(this DelegateBridgeBase d, int p0, float p1, object p2) { #if THREAD_SAFE || HOTFIX_ENABLE lock (d.luaEnv.luaEnvLock) { #endif RealStatePtr L = d.rawL; int err_func = LuaAPI.load_error_func(L, d.errorFuncRef); ObjectTranslator translator = d.translator; LuaAPI.lua_getref(L, d.pLuaReference); LuaAPI.xlua_pushinteger(L, p0); LuaAPI.lua_pushnumber(L, p1); translator.PushAny(L, p2); int __gen_error = LuaAPI.lua_pcall(L, 3, 0, err_func); if (__gen_error != 0) { d.pLuaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_settop(L, err_func - 1); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
static int _m_TryGetDelegate(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); XLua.DelegateBridgeBase gen_to_be_invoked = (XLua.DelegateBridgeBase)translator.FastGetCSObj(L, 1); { System.Type _key = (System.Type)translator.GetObject(L, 2, typeof(System.Type)); System.Delegate _value; bool gen_ret = gen_to_be_invoked.TryGetDelegate(_key, out _value); LuaAPI.lua_pushboolean(L, gen_ret); translator.Push(L, _value); return(2); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
static int _m_AddDelegate(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); XLua.DelegateBridgeBase gen_to_be_invoked = (XLua.DelegateBridgeBase)translator.FastGetCSObj(L, 1); { System.Type _key = (System.Type)translator.GetObject(L, 2, typeof(System.Type)); System.Delegate _value = translator.GetDelegate <System.Delegate>(L, 3); gen_to_be_invoked.AddDelegate(_key, _value); return(0); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
static int _m_GetDelegateByType(RealStatePtr L) { try { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); XLua.DelegateBridgeBase gen_to_be_invoked = (XLua.DelegateBridgeBase)translator.FastGetCSObj(L, 1); { System.Type _type = (System.Type)translator.GetObject(L, 2, typeof(System.Type)); System.Delegate gen_ret = gen_to_be_invoked.GetDelegateByType(_type); translator.Push(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
public Delegate CreateDelegateBridge(RealStatePtr L, Type delegateType, int idx) { LuaAPI.lua_pushvalue(L, idx); LuaAPI.lua_rawget(L, LuaIndexes.LUA_REGISTRYINDEX); if (!LuaAPI.lua_isnil(L, -1)) { int referenced = LuaAPI.xlua_tointeger(L, -1); LuaAPI.lua_pop(L, 1); if (delegate_bridges[referenced].IsAlive) { DelegateBridgeBase exist_bridge = delegate_bridges[referenced].Target as DelegateBridgeBase; Delegate exist_delegate; if (exist_bridge.TryGetDelegate(delegateType, out exist_delegate)) { return(exist_delegate); } else { exist_delegate = exist_bridge.GetDelegateByType(delegateType); exist_bridge.AddDelegate(delegateType, exist_delegate); return(exist_delegate); } } } else { LuaAPI.lua_pop(L, 1); } LuaAPI.lua_pushvalue(L, idx); int reference = LuaAPI.luaL_ref(L); LuaAPI.lua_pushvalue(L, idx); LuaAPI.lua_pushnumber(L, reference); LuaAPI.lua_rawset(L, LuaIndexes.LUA_REGISTRYINDEX); DelegateBridgeBase bridge; try { #if UNITY_EDITOR if (!DelegateBridge.Gen_Flag) { bridge = Activator.CreateInstance(delegate_birdge_type, new object[] { reference, luaEnv }) as DelegateBridgeBase; } else #endif { bridge = new DelegateBridge(reference, luaEnv); } } catch (Exception e) { LuaAPI.lua_pushvalue(L, idx); LuaAPI.lua_pushnil(L); LuaAPI.lua_rawset(L, LuaIndexes.LUA_REGISTRYINDEX); LuaAPI.lua_pushnil(L); LuaAPI.xlua_rawseti(L, LuaIndexes.LUA_REGISTRYINDEX, reference); throw e; } try { var ret = bridge.GetDelegateByType(delegateType); bridge.AddDelegate(delegateType, ret); delegate_bridges[reference] = new WeakReference(bridge); return(ret); } catch (Exception e) { bridge.Dispose(); throw e; } }