public void PushTutorialDrivenClassTestEnumInner(RealStatePtr L, Tutorial.DrivenClass.TestEnumInner val) { if (TutorialDrivenClassTestEnumInner_TypeID == -1) { bool is_first; TutorialDrivenClassTestEnumInner_TypeID = getTypeId(L, typeof(Tutorial.DrivenClass.TestEnumInner), out is_first); if (TutorialDrivenClassTestEnumInner_EnumRef == -1) { Utils.LoadCSTable(L, typeof(Tutorial.DrivenClass.TestEnumInner)); TutorialDrivenClassTestEnumInner_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); } } if (LuaAPI.xlua_tryget_cachedud(L, (int)val, TutorialDrivenClassTestEnumInner_EnumRef) == 1) { return; } IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, TutorialDrivenClassTestEnumInner_TypeID); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail fail for Tutorial.DrivenClass.TestEnumInner ,value=" + val); } LuaAPI.lua_getref(L, TutorialDrivenClassTestEnumInner_EnumRef); LuaAPI.lua_pushvalue(L, -2); LuaAPI.xlua_rawseti(L, -2, (int)val); LuaAPI.lua_pop(L, 1); }
public void PushUnityEngineSystemLanguage(RealStatePtr L, UnityEngine.SystemLanguage val) { if (UnityEngineSystemLanguage_TypeID == -1) { bool is_first; UnityEngineSystemLanguage_TypeID = getTypeId(L, typeof(UnityEngine.SystemLanguage), out is_first); if (UnityEngineSystemLanguage_EnumRef == -1) { Utils.LoadCSTable(L, typeof(UnityEngine.SystemLanguage)); UnityEngineSystemLanguage_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); } } if (LuaAPI.xlua_tryget_cachedud(L, (int)val, UnityEngineSystemLanguage_EnumRef) == 1) { return; } IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, UnityEngineSystemLanguage_TypeID); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail fail for UnityEngine.SystemLanguage ,value=" + val); } LuaAPI.lua_getref(L, UnityEngineSystemLanguage_EnumRef); LuaAPI.lua_pushvalue(L, -2); LuaAPI.xlua_rawseti(L, -2, (int)val); LuaAPI.lua_pop(L, 1); }
public void PushResourcePrioritizedCacheLoadPriority(RealStatePtr L, ResourcePrioritizedCache.LoadPriority val) { if (ResourcePrioritizedCacheLoadPriority_TypeID == -1) { bool is_first; ResourcePrioritizedCacheLoadPriority_TypeID = getTypeId(L, typeof(ResourcePrioritizedCache.LoadPriority), out is_first); if (ResourcePrioritizedCacheLoadPriority_EnumRef == -1) { Utils.LoadCSTable(L, typeof(ResourcePrioritizedCache.LoadPriority)); ResourcePrioritizedCacheLoadPriority_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); } } if (LuaAPI.xlua_tryget_cachedud(L, (int)val, ResourcePrioritizedCacheLoadPriority_EnumRef) == 1) { return; } IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, ResourcePrioritizedCacheLoadPriority_TypeID); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail fail for ResourcePrioritizedCache.LoadPriority ,value=" + val); } LuaAPI.lua_getref(L, ResourcePrioritizedCacheLoadPriority_EnumRef); LuaAPI.lua_pushvalue(L, -2); LuaAPI.xlua_rawseti(L, -2, (int)val); LuaAPI.lua_pop(L, 1); }
public void WriteCookieAll(string ext_path) { List <string> table_list = new List <string>(); LuaAPI.xlua_getglobal(m_lua_state, DefineConstantsCookieHandler.COOKIE_VAR); int nIndex = LuaAPI.lua_gettop(m_lua_state); LuaAPI.lua_pushnil(m_lua_state); // nil入栈作为初始key while (0 != LuaAPI.lua_next(m_lua_state, nIndex)) { LuaAPI.lua_pushvalue(m_lua_state, -2); if (LuaAPI.lua_isstring(m_lua_state, -1)) { table_list.Add(LuaAPI.lua_tostring(m_lua_state, -1)); } LuaAPI.lua_pop(m_lua_state, 2); } LuaAPI.lua_pop(m_lua_state, 1); List <string> .Enumerator itr = table_list.GetEnumerator(); while (itr.MoveNext()) { Debug.LogWarning("WriteCookieAll :" + itr.ToString()); WriteCookie(itr.ToString(), itr.ToString(), ext_path); } }
public void ReleaseLuaBase(RealStatePtr L, int reference, bool is_delegate) { if (is_delegate) { LuaAPI.xlua_rawgeti(L, LuaIndexes.LUA_REGISTRYINDEX, reference); if (LuaAPI.lua_isnil(L, -1)) { LuaAPI.lua_pop(L, 1); } else { LuaAPI.lua_pushvalue(L, -1); LuaAPI.lua_rawget(L, LuaIndexes.LUA_REGISTRYINDEX); if (LuaAPI.lua_type(L, -1) == LuaTypes.LUA_TNUMBER && LuaAPI.xlua_tointeger(L, -1) == reference) // { //UnityEngine.Debug.LogWarning("release delegate ref = " + luaReference); LuaAPI.lua_pop(L, 1); // pop LUA_REGISTRYINDEX[func] LuaAPI.lua_pushnil(L); LuaAPI.lua_rawset(L, LuaIndexes.LUA_REGISTRYINDEX); // LUA_REGISTRYINDEX[func] = nil } else //another Delegate ref the function before the GC tick { LuaAPI.lua_pop(L, 2); // pop LUA_REGISTRYINDEX[func] & func } } LuaAPI.lua_unref(L, reference); delegate_bridges.Remove(reference); } else { LuaAPI.lua_unref(L, reference); } }
public void PushVVMUIScriptXLuaXLuaCommandType(RealStatePtr L, VVMUI.Script.XLua.XLuaCommandType val) { if (VVMUIScriptXLuaXLuaCommandType_TypeID == -1) { bool is_first; VVMUIScriptXLuaXLuaCommandType_TypeID = getTypeId(L, typeof(VVMUI.Script.XLua.XLuaCommandType), out is_first); if (VVMUIScriptXLuaXLuaCommandType_EnumRef == -1) { Utils.LoadCSTable(L, typeof(VVMUI.Script.XLua.XLuaCommandType)); VVMUIScriptXLuaXLuaCommandType_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); } } if (LuaAPI.xlua_tryget_cachedud(L, (int)val, VVMUIScriptXLuaXLuaCommandType_EnumRef) == 1) { return; } IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, VVMUIScriptXLuaXLuaCommandType_TypeID); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail fail for VVMUI.Script.XLua.XLuaCommandType ,value=" + val); } LuaAPI.lua_getref(L, VVMUIScriptXLuaXLuaCommandType_EnumRef); LuaAPI.lua_pushvalue(L, -2); LuaAPI.xlua_rawseti(L, -2, (int)val); LuaAPI.lua_pop(L, 1); }
public static void PushLogicModelEntityFlag(this ObjectTranslator t, RealStatePtr L, Logic.Model.EntityFlag val) { if (LogicModelEntityFlag_TypeID == -1) { bool is_first; LogicModelEntityFlag_TypeID = t.getTypeId(L, typeof(Logic.Model.EntityFlag), out is_first); if (LogicModelEntityFlag_EnumRef == -1) { Utils.LoadCSTable(L, typeof(Logic.Model.EntityFlag)); LogicModelEntityFlag_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); } } if (LuaAPI.xlua_tryget_cachedud(L, (int)val, LogicModelEntityFlag_EnumRef) == 1) { return; } IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, LogicModelEntityFlag_TypeID); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail fail for Logic.Model.EntityFlag ,value=" + val); } LuaAPI.lua_getref(L, LogicModelEntityFlag_EnumRef); LuaAPI.lua_pushvalue(L, -2); LuaAPI.xlua_rawseti(L, -2, (int)val); LuaAPI.lua_pop(L, 1); }
public void PushDotEngineUIUILayerLevel(RealStatePtr L, DotEngine.UI.UILayerLevel val) { if (DotEngineUIUILayerLevel_TypeID == -1) { bool is_first; DotEngineUIUILayerLevel_TypeID = getTypeId(L, typeof(DotEngine.UI.UILayerLevel), out is_first); if (DotEngineUIUILayerLevel_EnumRef == -1) { Utils.LoadCSTable(L, typeof(DotEngine.UI.UILayerLevel)); DotEngineUIUILayerLevel_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); } } if (LuaAPI.xlua_tryget_cachedud(L, (int)val, DotEngineUIUILayerLevel_EnumRef) == 1) { return; } IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, DotEngineUIUILayerLevel_TypeID); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail fail for DotEngine.UI.UILayerLevel ,value=" + val); } LuaAPI.lua_getref(L, DotEngineUIUILayerLevel_EnumRef); LuaAPI.lua_pushvalue(L, -2); LuaAPI.xlua_rawseti(L, -2, (int)val); LuaAPI.lua_pop(L, 1); }
internal static int Print(RealStatePtr L) { // For each argument we'll 'tostring' it int n = LuaAPI.lua_gettop(L); string s = String.Empty; LuaAPI.lua_getglobal(L, "tostring"); for (int i = 1; i <= n; i++) { LuaAPI.lua_pushvalue(L, -1); /* function to be called */ LuaAPI.lua_pushvalue(L, i); /* value to print */ if (0 != LuaAPI.lua_pcall(L, 1, 1, 0)) { return(LuaAPI.lua_error(L)); } s += LuaAPI.lua_tostring(L, -1); if (i != n) { s += "\t"; } LuaAPI.lua_pop(L, 1); /* pop result */ } UnityEngine.Debug.Log("LUA: " + s); return(0); }
public void PushXLuaTestMyEnum(RealStatePtr L, XLuaTest.MyEnum val) { if (XLuaTestMyEnum_TypeID == -1) { bool is_first; XLuaTestMyEnum_TypeID = getTypeId(L, typeof(XLuaTest.MyEnum), out is_first); if (XLuaTestMyEnum_EnumRef == -1) { Utils.LoadCSTable(L, typeof(XLuaTest.MyEnum)); XLuaTestMyEnum_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); } } if (LuaAPI.xlua_tryget_cachedud(L, (int)val, XLuaTestMyEnum_EnumRef) == 1) { return; } IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, XLuaTestMyEnum_TypeID); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail fail for XLuaTest.MyEnum ,value=" + val); } LuaAPI.lua_getref(L, XLuaTestMyEnum_EnumRef); LuaAPI.lua_pushvalue(L, -2); LuaAPI.xlua_rawseti(L, -2, (int)val); LuaAPI.lua_pop(L, 1); }
public void PushSystemNetSocketsProtocolType(RealStatePtr L, System.Net.Sockets.ProtocolType val) { if (SystemNetSocketsProtocolType_TypeID == -1) { bool is_first; SystemNetSocketsProtocolType_TypeID = getTypeId(L, typeof(System.Net.Sockets.ProtocolType), out is_first); if (SystemNetSocketsProtocolType_EnumRef == -1) { Utils.LoadCSTable(L, typeof(System.Net.Sockets.ProtocolType)); SystemNetSocketsProtocolType_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); } } if (LuaAPI.xlua_tryget_cachedud(L, (int)val, SystemNetSocketsProtocolType_EnumRef) == 1) { return; } IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, SystemNetSocketsProtocolType_TypeID); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail fail for System.Net.Sockets.ProtocolType ,value=" + val); } LuaAPI.lua_getref(L, SystemNetSocketsProtocolType_EnumRef); LuaAPI.lua_pushvalue(L, -2); LuaAPI.xlua_rawseti(L, -2, (int)val); LuaAPI.lua_pop(L, 1); }
internal static int Print(RealStatePtr L) { try { int n = LuaAPI.lua_gettop(L); string s = String.Empty; string color = ""; if (0 != LuaAPI.xlua_getglobal(L, "tostring")) { return(LuaAPI.luaL_error(L, "can not get tostring in print:")); } for (int i = 1; i <= n; i++) { LuaAPI.lua_pushvalue(L, -1); /* function to be called */ LuaAPI.lua_pushvalue(L, i); /* value to print */ if (0 != LuaAPI.lua_pcall(L, 1, 1, 0)) { return(LuaAPI.lua_error(L)); } if (i == 1) { color = LuaAPI.lua_tostring(L, -1); } else { s += LuaAPI.lua_tostring(L, -1); if (i != n) { s += "\t"; } } LuaAPI.lua_pop(L, 1); /* pop result */ } string stack = string.Empty; #if UNITY_EDITOR int old_top = LuaAPI.lua_gettop(L); LuaAPI.xlua_getglobal(L, "_G"); LuaAPI.lua_pushstring(L, "debug"); LuaAPI.lua_rawget(L, -2); LuaAPI.lua_pushstring(L, "traceback"); LuaAPI.lua_rawget(L, -2); int error = LuaAPI.lua_pcall(L, 0, 1, 0); if (error == 0) { stack = LuaAPI.lua_tostring(L, -1); } LuaAPI.lua_settop(L, old_top); #endif FairyStudy.LogUtil.InfoColor(color, "LUA: " + s + "\n"); return(0); } catch (System.Exception e) { return(LuaAPI.luaL_error(L, "c# exception in print:" + e)); } }
internal static int Print(RealStatePtr L) { try { int n = LuaAPI.lua_gettop(L); string s = String.Empty; if (0 != LuaAPI.xlua_getglobal(L, "tostring")) { return LuaAPI.luaL_error(L, "can not get tostring in print:"); } for (int i = 1; i <= n; i++) { LuaAPI.lua_pushvalue(L, -1); /* function to be called */ LuaAPI.lua_pushvalue(L, i); /* value to print */ if (0 != LuaAPI.lua_pcall(L, 1, 1, 0)) { return LuaAPI.lua_error(L); } s += LuaAPI.lua_tostring(L, -1); if (i != n) s += "\t"; LuaAPI.lua_pop(L, 1); /* pop result */ } UnityEngine.Debug.Log("LUA: " + s); return 0; } catch (System.Exception e) { return LuaAPI.luaL_error(L, "c# exception in print:" + e); } }
public void PushMinecraftBlocksDataBlockVertexType(RealStatePtr L, Minecraft.BlocksData.BlockVertexType val) { if (MinecraftBlocksDataBlockVertexType_TypeID == -1) { bool is_first; MinecraftBlocksDataBlockVertexType_TypeID = getTypeId(L, typeof(Minecraft.BlocksData.BlockVertexType), out is_first); if (MinecraftBlocksDataBlockVertexType_EnumRef == -1) { Utils.LoadCSTable(L, typeof(Minecraft.BlocksData.BlockVertexType)); MinecraftBlocksDataBlockVertexType_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); } } if (LuaAPI.xlua_tryget_cachedud(L, (int)val, MinecraftBlocksDataBlockVertexType_EnumRef) == 1) { return; } IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, MinecraftBlocksDataBlockVertexType_TypeID); if (!CopyByValue.Pack(buff, 0, (int)val)) { throw new Exception("pack fail fail for Minecraft.BlocksData.BlockVertexType ,value=" + val); } LuaAPI.lua_getref(L, MinecraftBlocksDataBlockVertexType_EnumRef); LuaAPI.lua_pushvalue(L, -2); LuaAPI.xlua_rawseti(L, -2, (int)val); LuaAPI.lua_pop(L, 1); }
private static int PrintBase(RealStatePtr L, UnityEngine.LogType type) { try { int n = LuaAPI.lua_gettop(L); string s = String.Empty; if (0 != LuaAPI.xlua_getglobal(L, "tostring")) { return(LuaAPI.luaL_error(L, "can not get tostring in print:")); } for (int i = 1; i <= n; i++) { LuaAPI.lua_pushvalue(L, -1); /* function to be called */ LuaAPI.lua_pushvalue(L, i); /* value to print */ if (0 != LuaAPI.lua_pcall(L, 1, 1, 0)) { return(LuaAPI.lua_error(L)); } s += LuaAPI.lua_tostring(L, -1); if (i != n) { s += "\t"; } LuaAPI.lua_pop(L, 1); /* pop result */ } switch (type) { case UnityEngine.LogType.Error: if (GLog.IsLogErrorEnabled) { GLog.LogError("LUA: " + s); } break; case UnityEngine.LogType.Warning: if (GLog.IsLogWarningEnabled) { GLog.LogError("LUA: " + s); } break; default: if (GLog.IsLogInfoEnabled) { GLog.LogInfo("LUA: " + s); } break; } return(0); } catch (System.Exception e) { return(LuaAPI.luaL_error(L, "c# exception in print:" + e)); } }
int getTypeId(RealStatePtr L, Type type, out bool is_first, LOGLEVEL log_level = LOGLEVEL.WARN) { int type_id; is_first = false; if (!typeIdMap.TryGetValue(type, out type_id)) // no reference { if (type.IsArray) { if (common_array_meta == -1) throw new Exception("Fatal Exception! Array Metatable not inited!"); return common_array_meta; } if (typeof(MulticastDelegate).IsAssignableFrom(type)) { if (common_delegate_meta == -1) throw new Exception("Fatal Exception! Delegate Metatable not inited!"); return common_delegate_meta; } is_first = true; Type alias_type = null; aliasCfg.TryGetValue(type, out alias_type); LuaAPI.luaL_getmetatable(L, alias_type == null ? type.FullName : alias_type.FullName); if (LuaAPI.lua_isnil(L, -1)) //no meta yet, try to use reflection meta { LuaAPI.lua_pop(L, 1); if (TryDelayWrapLoader(L, alias_type == null ? type : alias_type)) { LuaAPI.luaL_getmetatable(L, alias_type == null ? type.FullName : alias_type.FullName); } else { throw new Exception("Fatal: can not load metatable of type:" + type); } } //循环依赖,自身依赖自己的class,比如有个自身类型的静态readonly对象。 if (typeIdMap.TryGetValue(type, out type_id)) { LuaAPI.lua_pop(L, 1); } else { LuaAPI.lua_pushvalue(L, -1); type_id = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); LuaAPI.lua_pushnumber(L, type_id); LuaAPI.xlua_rawseti(L, -2, 1); LuaAPI.lua_pop(L, 1); if (type.IsValueType) { typeMap.Add(type_id, type); } typeIdMap.Add(type, type_id); } } return type_id; }
private object getLuaFunction(RealStatePtr L, int idx, object target) { if (LuaAPI.lua_type(L, idx) == LuaTypes.LUA_TUSERDATA) { object obj = translator.SafeGetCSObj(L, idx); return((obj != null && obj is LuaFunction) ? obj : null); } if (!LuaAPI.lua_isfunction(L, idx)) { return(null); } LuaAPI.lua_pushvalue(L, idx); return(new LuaFunction(LuaAPI.luaL_ref(L), translator.luaEnv)); }
public static int MetaFuncIndex(RealStatePtr L) { ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L); Type type = (Type)translator.FastGetCSObj(L, 2); if (type == null) { return(LuaAPI.luaL_error(L, "#2 param need a System.Type!")); } //UnityEngine.Debug.Log("============================load type by __index:" + type); translator.TryDelayWrapLoader(L, type); LuaAPI.lua_pushvalue(L, 2); LuaAPI.lua_rawget(L, 1); return(1); }
public static void EndClassRegister(Type type, RealStatePtr L, ObjectTranslator translator) { int top = LuaAPI.lua_gettop(L); int cls_idx = abs_idx(top, CLS_IDX); int cls_getter_idx = abs_idx(top, CLS_GETTER_IDX); int cls_setter_idx = abs_idx(top, CLS_SETTER_IDX); int cls_meta_idx = abs_idx(top, CLS_META_IDX); //begin cls index LuaAPI.xlua_pushasciistring(L, "__index"); LuaAPI.lua_pushvalue(L, cls_getter_idx); LuaAPI.lua_pushvalue(L, cls_idx); translator.Push(L, type.BaseType); LuaAPI.xlua_pushasciistring(L, Utils.LuaClassIndexsFieldName); LuaAPI.lua_rawget(L, LuaIndexes.LUA_REGISTRYINDEX); LuaAPI.gen_cls_indexer(L); LuaAPI.xlua_pushasciistring(L, Utils.LuaClassIndexsFieldName); LuaAPI.lua_rawget(L, LuaIndexes.LUA_REGISTRYINDEX);//store in lua indexs function tables translator.Push(L, type); LuaAPI.lua_pushvalue(L, -3); LuaAPI.lua_rawset(L, -3); LuaAPI.lua_pop(L, 1); LuaAPI.lua_rawset(L, cls_meta_idx); //end cls index //begin cls newindex LuaAPI.xlua_pushasciistring(L, "__newindex"); LuaAPI.lua_pushvalue(L, cls_setter_idx); translator.Push(L, type.BaseType); LuaAPI.xlua_pushasciistring(L, Utils.LuaClassNewIndexsFieldName); LuaAPI.lua_rawget(L, LuaIndexes.LUA_REGISTRYINDEX); LuaAPI.gen_cls_newindexer(L); LuaAPI.xlua_pushasciistring(L, Utils.LuaClassNewIndexsFieldName); LuaAPI.lua_rawget(L, LuaIndexes.LUA_REGISTRYINDEX);//store in lua newindexs function tables translator.Push(L, type); LuaAPI.lua_pushvalue(L, -3); LuaAPI.lua_rawset(L, -3); LuaAPI.lua_pop(L, 1); LuaAPI.lua_rawset(L, cls_meta_idx); //end cls newindex LuaAPI.lua_pop(L, 4); }
internal void createFunctionMetatable(RealStatePtr L) { LuaAPI.lua_newtable(L); LuaAPI.xlua_pushasciistring(L,"__gc"); LuaAPI.lua_pushstdcallcfunction(L,metaFunctions.GcMeta); LuaAPI.lua_rawset(L,-3); LuaAPI.lua_pushlightuserdata(L, LuaAPI.xlua_tag()); LuaAPI.lua_pushnumber(L, 1); LuaAPI.lua_rawset(L, -3); LuaAPI.lua_pushvalue(L, -1); int type_id = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX); LuaAPI.lua_pushnumber(L, type_id); LuaAPI.xlua_rawseti(L, -2, 1); LuaAPI.lua_pop(L, 1); typeIdMap.Add(typeof(LuaCSFunction), type_id); }
CAE.Core.ILuaPanelItem CAE.Core.ILuaPanelMgr.NewPanelItem(string itemName, UnityEngine.Transform tr, UnityEngine.GameObject go) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.L; int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef); ObjectTranslator translator = luaEnv.translator; LuaAPI.lua_getref(L, luaReference); LuaAPI.xlua_pushasciistring(L, "NewPanelItem"); if (0 != LuaAPI.xlua_pgettable(L, -2)) { luaEnv.ThrowExceptionFromError(err_func - 1); } if (!LuaAPI.lua_isfunction(L, -1)) { LuaAPI.xlua_pushasciistring(L, "no such function NewPanelItem"); luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_pushvalue(L, -2); LuaAPI.lua_remove(L, -3); LuaAPI.lua_pushstring(L, itemName); translator.Push(L, tr); translator.Push(L, go); int __gen_error = LuaAPI.lua_pcall(L, 4, 1, err_func); if (__gen_error != 0) { luaEnv.ThrowExceptionFromError(err_func - 1); } CAE.Core.ILuaPanelItem __gen_ret = (CAE.Core.ILuaPanelItem)translator.GetObject(L, err_func + 1, typeof(CAE.Core.ILuaPanelItem)); LuaAPI.lua_settop(L, err_func - 1); return(__gen_ret); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
void CAE.Core.ILuaPanelMgr.OnLoopGridValueChanged(string prefabPath, CAE.Core.UILoopGrid loopGrid, CAE.Core.ILuaPanelItem item, int index) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.L; int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef); ObjectTranslator translator = luaEnv.translator; LuaAPI.lua_getref(L, luaReference); LuaAPI.xlua_pushasciistring(L, "OnLoopGridValueChanged"); if (0 != LuaAPI.xlua_pgettable(L, -2)) { luaEnv.ThrowExceptionFromError(err_func - 1); } if (!LuaAPI.lua_isfunction(L, -1)) { LuaAPI.xlua_pushasciistring(L, "no such function OnLoopGridValueChanged"); luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_pushvalue(L, -2); LuaAPI.lua_remove(L, -3); LuaAPI.lua_pushstring(L, prefabPath); translator.Push(L, loopGrid); translator.PushAny(L, item); LuaAPI.xlua_pushinteger(L, index); int __gen_error = LuaAPI.lua_pcall(L, 5, 0, err_func); if (__gen_error != 0) { luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_settop(L, err_func - 1); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
public object CreateInterfaceBridge(RealStatePtr L, Type interfaceType, int idx) { Func <int, LuaEnv, LuaBase> creator; if (!interfaceBridgeCreators.TryGetValue(interfaceType, out creator)) { #if UNITY_EDITOR var bridgeType = ce.EmitInterfaceImpl(interfaceType); creator = (int reference, LuaEnv luaenv) => { return(Activator.CreateInstance(bridgeType, new object[] { reference, luaEnv }) as LuaBase); }; interfaceBridgeCreators.Add(interfaceType, creator); #else throw new InvalidCastException("This interface must add to CSharpCallLua: " + interfaceType); #endif } LuaAPI.lua_pushvalue(L, idx); return(creator(LuaAPI.luaL_ref(L), luaEnv)); }
void CAE.Core.ILuaPanelMgr.OnSliderValueChanged(string prefabPath, UnityEngine.Component slider, float val) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.L; int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef); ObjectTranslator translator = luaEnv.translator; LuaAPI.lua_getref(L, luaReference); LuaAPI.xlua_pushasciistring(L, "OnSliderValueChanged"); if (0 != LuaAPI.xlua_pgettable(L, -2)) { luaEnv.ThrowExceptionFromError(err_func - 1); } if (!LuaAPI.lua_isfunction(L, -1)) { LuaAPI.xlua_pushasciistring(L, "no such function OnSliderValueChanged"); luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_pushvalue(L, -2); LuaAPI.lua_remove(L, -3); LuaAPI.lua_pushstring(L, prefabPath); translator.Push(L, slider); LuaAPI.lua_pushnumber(L, val); int __gen_error = LuaAPI.lua_pcall(L, 4, 0, err_func); if (__gen_error != 0) { luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_settop(L, err_func - 1); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
public static void SetCSTable(RealStatePtr L, Type type, int cls_table) { int oldTop = LuaAPI.lua_gettop(L); cls_table = abs_idx(oldTop, cls_table); if (0 != LuaAPI.xlua_getglobal(L, "CS")) { throw new Exception("call xlua_getglobal fail!"); } List <string> path = getPathOfType(type); for (int i = 0; i < path.Count - 1; ++i) { LuaAPI.xlua_pushasciistring(L, path[i]); if (0 != LuaAPI.xlua_pgettable(L, -2)) { LuaAPI.lua_settop(L, oldTop); throw new Exception("SetCSTable for [" + type + "] error: " + LuaAPI.lua_tostring(L, -1)); } if (LuaAPI.lua_isnil(L, -1)) { LuaAPI.lua_pop(L, 1); LuaAPI.lua_createtable(L, 0, 0); LuaAPI.xlua_pushasciistring(L, path[i]); LuaAPI.lua_pushvalue(L, -2); LuaAPI.lua_rawset(L, -4); } else if (!LuaAPI.lua_istable(L, -1)) { LuaAPI.lua_settop(L, oldTop); throw new Exception("SetCSTable for [" + type + "] error: ancestors is not a table!"); } LuaAPI.lua_remove(L, -2); } LuaAPI.xlua_pushasciistring(L, path[path.Count - 1]); LuaAPI.lua_pushvalue(L, cls_table); LuaAPI.lua_rawset(L, -3); LuaAPI.lua_pop(L, 1); }
public int add(int a, int b) { #if THREAD_SAFT || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.L; int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef); LuaAPI.lua_getref(L, luaReference); LuaAPI.xlua_pushasciistring(L, "add"); if (0 != LuaAPI.xlua_pgettable(L, -2)) { luaEnv.ThrowExceptionFromError(err_func - 1); } if (!LuaAPI.lua_isfunction(L, -1)) { LuaAPI.xlua_pushasciistring(L, "no such function add"); luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_pushvalue(L, -2); LuaAPI.lua_remove(L, -3); LuaAPI.xlua_pushinteger(L, a); LuaAPI.xlua_pushinteger(L, b); int __gen_error = LuaAPI.lua_pcall(L, 3, 1, err_func); if (__gen_error != 0) { luaEnv.ThrowExceptionFromError(err_func - 1); } int __gen_ret = LuaAPI.xlua_tointeger(L, err_func + 1); LuaAPI.lua_settop(L, err_func - 1); return(__gen_ret); #if THREAD_SAFT || HOTFIX_ENABLE } #endif }
void CAE.Core.ILuaPanelMgr.OnDragEnd(string prefabPath, UnityEngine.GameObject go, UnityEngine.EventSystems.PointerEventData eventData) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.L; int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef); ObjectTranslator translator = luaEnv.translator; LuaAPI.lua_getref(L, luaReference); LuaAPI.xlua_pushasciistring(L, "OnDragEnd"); if (0 != LuaAPI.xlua_pgettable(L, -2)) { luaEnv.ThrowExceptionFromError(err_func - 1); } if (!LuaAPI.lua_isfunction(L, -1)) { LuaAPI.xlua_pushasciistring(L, "no such function OnDragEnd"); luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_pushvalue(L, -2); LuaAPI.lua_remove(L, -3); LuaAPI.lua_pushstring(L, prefabPath); translator.Push(L, go); translator.Push(L, eventData); int __gen_error = LuaAPI.lua_pcall(L, 4, 0, err_func); if (__gen_error != 0) { luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_settop(L, err_func - 1); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
void CAE.Core.ILuaPanelMgr.OnClickItem(CAE.Core.ILuaPanelItem item, UnityEngine.Component btn) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.L; int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef); ObjectTranslator translator = luaEnv.translator; LuaAPI.lua_getref(L, luaReference); LuaAPI.xlua_pushasciistring(L, "OnClickItem"); if (0 != LuaAPI.xlua_pgettable(L, -2)) { luaEnv.ThrowExceptionFromError(err_func - 1); } if (!LuaAPI.lua_isfunction(L, -1)) { LuaAPI.xlua_pushasciistring(L, "no such function OnClickItem"); luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_pushvalue(L, -2); LuaAPI.lua_remove(L, -3); translator.PushAny(L, item); translator.Push(L, btn); int __gen_error = LuaAPI.lua_pcall(L, 3, 0, err_func); if (__gen_error != 0) { luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_settop(L, err_func - 1); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
void CAE.Core.ILuaPanelMgr.OnOpen(string prefabPath, System.Collections.Generic.Dictionary <string, UnityEngine.Component> controls) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.L; int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef); ObjectTranslator translator = luaEnv.translator; LuaAPI.lua_getref(L, luaReference); LuaAPI.xlua_pushasciistring(L, "OnOpen"); if (0 != LuaAPI.xlua_pgettable(L, -2)) { luaEnv.ThrowExceptionFromError(err_func - 1); } if (!LuaAPI.lua_isfunction(L, -1)) { LuaAPI.xlua_pushasciistring(L, "no such function OnOpen"); luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_pushvalue(L, -2); LuaAPI.lua_remove(L, -3); LuaAPI.lua_pushstring(L, prefabPath); translator.Push(L, controls); int __gen_error = LuaAPI.lua_pcall(L, 3, 0, err_func); if (__gen_error != 0) { luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_settop(L, err_func - 1); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }
public bool recv(string package) { #if THREAD_SAFE || HOTFIX_ENABLE lock (luaEnv.luaEnvLock) { #endif RealStatePtr L = luaEnv.L; int err_func = LuaAPI.load_error_func(L, luaEnv.errorFuncRef); LuaAPI.lua_getref(L, luaReference); LuaAPI.xlua_pushasciistring(L, "recv"); if (0 != LuaAPI.xlua_pgettable(L, -2)) { luaEnv.ThrowExceptionFromError(err_func - 1); } if (!LuaAPI.lua_isfunction(L, -1)) { LuaAPI.xlua_pushasciistring(L, "no such function recv"); luaEnv.ThrowExceptionFromError(err_func - 1); } LuaAPI.lua_pushvalue(L, -2); LuaAPI.lua_remove(L, -3); LuaAPI.lua_pushstring(L, package); int __gen_error = LuaAPI.lua_pcall(L, 2, 1, err_func); if (__gen_error != 0) { luaEnv.ThrowExceptionFromError(err_func - 1); } bool __gen_ret = LuaAPI.lua_toboolean(L, err_func + 1); LuaAPI.lua_settop(L, err_func - 1); return(__gen_ret); #if THREAD_SAFE || HOTFIX_ENABLE } #endif }