示例#1
0
        public static void LoadCSTable(RealStatePtr L, Type type)
        {
            int oldTop = LuaAPI.lua_gettop(L);

            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; ++i)
            {
                LuaAPI.xlua_pushasciistring(L, path[i]);
                if (0 != LuaAPI.xlua_pgettable(L, -2))
                {
                    LuaAPI.lua_settop(L, oldTop);
                    LuaAPI.lua_pushnil(L);
                    return;
                }
                if (!LuaAPI.lua_istable(L, -1) && i < path.Count - 1)
                {
                    LuaAPI.lua_settop(L, oldTop);
                    LuaAPI.lua_pushnil(L);
                    return;
                }
                LuaAPI.lua_remove(L, -2);
            }
        }
        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
        }
        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.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
        }
示例#6
0
        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.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
        }
示例#9
0
        //deprecated
        public object[] Call(object[] args, Type[] returnTypes)
        {
#if THREAD_SAFT || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            int nArgs      = 0;
            var L          = luaEnv.L;
            var translator = luaEnv.translator;
            int oldTop     = LuaAPI.lua_gettop(L);

            int errFunc = LuaAPI.load_error_func(L, luaEnv.errorFuncRef);
            LuaAPI.lua_getref(L, luaReference);
            if (args != null)
            {
                nArgs = args.Length;
                for (int i = 0; i < args.Length; i++)
                {
                    translator.PushAny(L, args[i]);
                }
            }
            int error = LuaAPI.lua_pcall(L, nArgs, -1, errFunc);
            if (error != 0)
            {
                luaEnv.ThrowExceptionFromError(oldTop);
            }

            LuaAPI.lua_remove(L, errFunc);
            if (returnTypes != null)
            {
                return(translator.popValues(L, oldTop, returnTypes));
            }
            else
            {
                return(translator.popValues(L, oldTop));
            }
#if THREAD_SAFT || 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
        }
        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 IFramework.Lua.IExchanger.exchange(System.Array arr)
        {
#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, "exchange");
            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 exchange");
                luaEnv.ThrowExceptionFromError(err_func - 1);
            }
            LuaAPI.lua_pushvalue(L, -2);
            LuaAPI.lua_remove(L, -3);
            translator.Push(L, arr);

            int __gen_error = LuaAPI.lua_pcall(L, 2, 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
        }
示例#13
0
        public object[] DoString(string chunk, string chunkName = "chunk", LuaTable env = null)
        {
#if THREAD_SAFT || HOTFIX_ENABLE
            lock (luaEnvLock)
            {
#endif
            var _L      = L;
            int oldTop  = LuaAPI.lua_gettop(_L);
            int errFunc = LuaAPI.load_error_func(_L, errorFuncRef);
            if (LuaAPI.luaL_loadbuffer(_L, chunk, chunkName) == 0)
            {
                if (env != null)
                {
                    env.push(_L);
                    LuaAPI.lua_setfenv(_L, -2);
                }

                //if (LuaAPI.lua_pcall(_L, 0, -1, errFunc) == 0)
                if (LuaAPI.lua_pcall(_L, 0, -1, 0) == 0)
                {
                    LuaAPI.lua_remove(_L, errFunc);
                    return(translator.popValues(_L, oldTop));
                }
                else
                {
                    ThrowExceptionFromError(oldTop);
                }
            }
            else
            {
                ThrowExceptionFromError(oldTop);
            }

            return(null);

#if THREAD_SAFT || HOTFIX_ENABLE
        }
#endif
        }
        void CAE.Core.ILuaPanelMgr.OnClose(string prefabPath)
        {
#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, "OnClose");
            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 OnClose");
                luaEnv.ThrowExceptionFromError(err_func - 1);
            }
            LuaAPI.lua_pushvalue(L, -2);
            LuaAPI.lua_remove(L, -3);
            LuaAPI.lua_pushstring(L, prefabPath);

            int __gen_error = LuaAPI.lua_pcall(L, 2, 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
        }
示例#15
0
        public Maria.Controller Peek()
        {
#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, "Peek");
            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 Peek");
                luaEnv.ThrowExceptionFromError(err_func - 1);
            }
            LuaAPI.lua_pushvalue(L, -2);
            LuaAPI.lua_remove(L, -3);

            int __gen_error = LuaAPI.lua_pcall(L, 1, 1, err_func);
            if (__gen_error != 0)
            {
                luaEnv.ThrowExceptionFromError(err_func - 1);
            }


            Maria.Controller __gen_ret = (Maria.Controller)translator.GetObject(L, err_func + 1, typeof(Maria.Controller));
            LuaAPI.lua_settop(L, err_func - 1);
            return(__gen_ret);

#if THREAD_SAFE || HOTFIX_ENABLE
        }
#endif
        }
示例#16
0
        public void Update(float delta)
        {
#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, "Update");
            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 Update");
                luaEnv.ThrowExceptionFromError(err_func - 1);
            }
            LuaAPI.lua_pushvalue(L, -2);
            LuaAPI.lua_remove(L, -3);
            LuaAPI.lua_pushnumber(L, delta);

            int __gen_error = LuaAPI.lua_pcall(L, 2, 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
        }
示例#17
0
        public void Push(Maria.Controller controller)
        {
#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, "Push");
            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 Push");
                luaEnv.ThrowExceptionFromError(err_func - 1);
            }
            LuaAPI.lua_pushvalue(L, -2);
            LuaAPI.lua_remove(L, -3);
            translator.Push(L, controller);

            int __gen_error = LuaAPI.lua_pcall(L, 2, 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 CSharpCallTable_3.IGameUser.Speak()
        {
#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, "Speak");
            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 Speak");
                luaEnv.ThrowExceptionFromError(err_func - 1);
            }
            LuaAPI.lua_pushvalue(L, -2);
            LuaAPI.lua_remove(L, -3);

            int __gen_error = LuaAPI.lua_pcall(L, 1, 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
        }
示例#19
0
        void System.Collections.IEnumerator.Reset()
        {
#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, "Reset");
            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 Reset");
                luaEnv.ThrowExceptionFromError(err_func - 1);
            }
            LuaAPI.lua_pushvalue(L, -2);
            LuaAPI.lua_remove(L, -3);

            int __gen_error = LuaAPI.lua_pcall(L, 1, 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
        }
示例#20
0
        public static void loadUpvalue(RealStatePtr L, Type type, string metafunc, int num)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            LuaAPI.xlua_pushasciistring(L, metafunc);
            LuaAPI.lua_rawget(L, LuaIndexes.LUA_REGISTRYINDEX);
            translator.Push(L, type);
            LuaAPI.lua_rawget(L, -2);
            for (int i = 1; i <= num; i++)
            {
                LuaAPI.lua_getupvalue(L, -i, i);
                if (LuaAPI.lua_isnil(L, -1))
                {
                    LuaAPI.lua_pop(L, 1);
                    LuaAPI.lua_newtable(L);
                    LuaAPI.lua_pushvalue(L, -1);
                    LuaAPI.lua_setupvalue(L, -i - 2, i);
                }
            }
            for (int i = 0; i < num; i++)
            {
                LuaAPI.lua_remove(L, -num - 1);
            }
        }
        object IFramework.Lua.Luac.ICalc.this[int index]
        {
            get
            {
#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, "get_Item");
                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 get_Item");
                    luaEnv.ThrowExceptionFromError(err_func - 1);
                }
                LuaAPI.lua_pushvalue(L, -2);
                LuaAPI.lua_remove(L, -3);
                LuaAPI.xlua_pushinteger(L, index);

                int __gen_error = LuaAPI.lua_pcall(L, 2, 1, err_func);
                if (__gen_error != 0)
                {
                    luaEnv.ThrowExceptionFromError(err_func - 1);
                }


                object __gen_ret = translator.GetObject(L, err_func + 1, typeof(object));
                LuaAPI.lua_settop(L, err_func - 1);
                return(__gen_ret);

#if THREAD_SAFE || HOTFIX_ENABLE
            }
#endif
            }


            set
            {
#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, "set_Item");
                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 set_Item");
                    luaEnv.ThrowExceptionFromError(err_func - 1);
                }
                LuaAPI.lua_pushvalue(L, -2);
                LuaAPI.lua_remove(L, -3);
                LuaAPI.xlua_pushinteger(L, index);
                translator.PushAny(L, value);

                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
            }
        }