Exemplo n.º 1
0
        public override int GetHashCode()
        {
            LuaAPI.lua_getref(luaEnv.L, luaReference);
            var pointer = LuaAPI.lua_topointer(luaEnv.L, -1);

            LuaAPI.lua_pop(luaEnv.L, 1);
            return(pointer.ToInt32());
        }
Exemplo n.º 2
0
        public void InvokeSessionStart()
        {
            System.Threading.Monitor.Enter(luaEnv.luaEnvLock);
            var L = luaEnv.L;

            _stack.Push(_oldTop);
            _oldTop = LuaAPI.lua_gettop(L);
            LuaAPI.load_error_func(L, luaEnv.errorFuncRef);
            LuaAPI.lua_getref(L, luaReference);
        }
Exemplo n.º 3
0
        public bool TryGet <TKey, TValue>(TKey key, out TValue value)
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            bool isAssignable = false;
            var L             = luaEnv.L;
            var translator    = luaEnv.translator;
            int oldTop        = LuaAPI.lua_gettop(L);
            LuaAPI.lua_getref(L, luaReference);
            translator.PushByType(L, key);

            if (0 != LuaAPI.xlua_pgettable(L, -2))
            {
                string err = LuaAPI.lua_tostring(L, -1);
                LuaAPI.lua_settop(L, oldTop);
                throw new Exception("get field [" + key + "] error:" + err);
            }

            LuaTypes lua_type  = LuaAPI.lua_type(L, -1);
            Type type_of_value = typeof(TValue);
            if (lua_type == LuaTypes.LUA_TNIL && type_of_value.IsValueType())
            {
                // throw new InvalidCastException("can not assign nil to " + type_of_value);
                value = default(TValue);
                return(isAssignable);
            }

            try
            {
                isAssignable = translator.Assignable <TValue>(L, -1);
                if (isAssignable)
                {
                    translator.Get(L, -1, out value);
                }
                else
                {
                    value = default(TValue);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                LuaAPI.lua_settop(L, oldTop);
            }
            return(isAssignable);

#if THREAD_SAFE || HOTFIX_ENABLE
        }
#endif
        }
Exemplo n.º 4
0
        public IEnumerable GetKeys()
        {
            var L          = luaEnv.L;
            var translator = luaEnv.translator;
            int oldTop     = LuaAPI.lua_gettop(L);

            LuaAPI.lua_getref(L, luaReference);
            LuaAPI.lua_pushnil(L);
            while (LuaAPI.lua_next(L, -2) != 0)
            {
                yield return(translator.GetObject(L, -2));

                LuaAPI.lua_pop(L, 1);
            }
            LuaAPI.lua_settop(L, oldTop);
        }
Exemplo n.º 5
0
        // no boxing version get
        public void Get <TKey, TValue>(TKey key, out TValue value)
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            var L          = luaEnv.L;
            var translator = luaEnv.translator;
            int oldTop     = LuaAPI.lua_gettop(L);
            LuaAPI.lua_getref(L, luaReference);
            translator.PushByType(L, key);

            if (0 != LuaAPI.xlua_pgettable(L, -2))
            {
                string err = LuaAPI.lua_tostring(L, -1);
                LuaAPI.lua_settop(L, oldTop);
                throw new Exception("get field [" + key + "] error:" + err);
            }

            LuaTypes lua_type  = LuaAPI.lua_type(L, -1);
            Type type_of_value = typeof(TValue);
            if (lua_type == LuaTypes.LUA_TNIL && type_of_value.IsValueType())
            {
                throw new InvalidCastException("can not assign nil to " + type_of_value);
            }

            try
            {
#if UNITY_EDITOR
                translator._current_get_object_name = key as string;
#endif
                translator.Get(L, -1, out value);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                LuaAPI.lua_settop(L, oldTop);
            }
#if THREAD_SAFE || HOTFIX_ENABLE
        }
#endif
        }
Exemplo n.º 6
0
        public void TryForEach <TKey>(Type type_of_value, Action <TKey, object, bool> action)
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            var L          = luaEnv.L;
            var translator = luaEnv.translator;
            int oldTop     = LuaAPI.lua_gettop(L);
            try
            {
                LuaAPI.lua_getref(L, luaReference);
                LuaAPI.lua_pushnil(L);
                while (LuaAPI.lua_next(L, -2) != 0)
                {
                    if (translator.Assignable <TKey>(L, -2))
                    {
                        bool isAssignable = translator.Assignable(L, -1, type_of_value);
                        if (isAssignable)
                        {
                            TKey key;
                            object val;
                            translator.Get(L, -2, out key);
                            translator.Get(L, -1, out val);
                            action(key, val, isAssignable);
                        }
                        else
                        {
                            action(default(TKey), null, isAssignable);
                        }
                    }
                    LuaAPI.lua_pop(L, 1);
                }
            }
            finally
            {
                LuaAPI.lua_settop(L, oldTop);
            }
#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
        }
        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
        }
Exemplo n.º 9
0
        public IEnumerable <T> GetKeys <T>()
        {
            var L          = luaEnv.L;
            var translator = luaEnv.translator;
            int oldTop     = LuaAPI.lua_gettop(L);

            LuaAPI.lua_getref(L, luaReference);
            LuaAPI.lua_pushnil(L);
            while (LuaAPI.lua_next(L, -2) != 0)
            {
                if (translator.Assignable <T>(L, -2))
                {
                    T v;
                    translator.Get(L, -2, out v);
                    yield return(v);
                }
                LuaAPI.lua_pop(L, 1);
            }
            LuaAPI.lua_settop(L, oldTop);
        }
Exemplo n.º 10
0
        public void SetInPath <T>(string path, T val)
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            var L      = luaEnv.L;
            int oldTop = LuaAPI.lua_gettop(L);
            LuaAPI.lua_getref(L, luaReference);
            luaEnv.translator.PushByType(L, val);
            if (0 != LuaAPI.xlua_psettable_bypath(L, -2, path))
            {
                luaEnv.ThrowExceptionFromError(oldTop);
            }

            LuaAPI.lua_settop(L, oldTop);
#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
        }
        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.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
        }
Exemplo n.º 14
0
        public void Action()
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            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);
            int error = LuaAPI.lua_pcall(L, 0, 0, errFunc);
            if (error != 0)
            {
                luaEnv.ThrowExceptionFromError(oldTop);
            }
            LuaAPI.lua_settop(L, oldTop);
#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
        }
Exemplo n.º 16
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
        }
Exemplo n.º 20
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
        }
Exemplo n.º 21
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
        }
        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
        }
Exemplo n.º 23
0
        public T GetInPath <T>(string path)
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            var L          = luaEnv.L;
            var translator = luaEnv.translator;
            int oldTop     = LuaAPI.lua_gettop(L);
            LuaAPI.lua_getref(L, luaReference);
            if (0 != LuaAPI.xlua_pgettable_bypath(L, -1, path))
            {
                luaEnv.ThrowExceptionFromError(oldTop);
            }
            LuaTypes lua_type = LuaAPI.lua_type(L, -1);
            if (lua_type == LuaTypes.LUA_TNIL && typeof(T).IsValueType())
            {
                throw new InvalidCastException("can not assign nil to " + typeof(T).GetFriendlyName());
            }

            T value;
            try
            {
                translator.Get(L, -1, out value);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                LuaAPI.lua_settop(L, oldTop);
            }
            return(value);

#if THREAD_SAFE || HOTFIX_ENABLE
        }
#endif
        }
Exemplo n.º 24
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
        }
Exemplo n.º 25
0
        public TResult Func <T1, T2, T3, T4, TResult>(T1 a1, T2 a2, T3 a3, T4 a4)
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            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);
            translator.PushByType(L, a1);
            translator.PushByType(L, a2);
            translator.PushByType(L, a3);
            translator.PushByType(L, a4);
            int error = LuaAPI.lua_pcall(L, 4, 1, errFunc);
            if (error != 0)
            {
                luaEnv.ThrowExceptionFromError(oldTop);
            }
            TResult ret;
            try
            {
                translator.Get(L, -1, out ret);
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            {
                LuaAPI.lua_settop(L, oldTop);
            }
            return(ret);

#if THREAD_SAFE || HOTFIX_ENABLE
        }
#endif
        }
Exemplo n.º 26
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
        }
        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
        }
Exemplo n.º 28
0
        public void Action <T1, T2>(T1 a1, T2 a2)
        {
#if THREAD_SAFT || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            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);
            translator.PushByType(L, a1);
            translator.PushByType(L, a2);
            int error = LuaAPI.lua_pcall(L, 2, 0, errFunc);
            if (error != 0)
            {
                luaEnv.ThrowExceptionFromError(oldTop);
            }
            LuaAPI.lua_settop(L, oldTop);
#if THREAD_SAFT || HOTFIX_ENABLE
        }
#endif
        }
Exemplo n.º 29
0
        //no boxing version set
        public void Set <TKey, TValue>(TKey key, TValue value)
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            var L          = luaEnv.L;
            int oldTop     = LuaAPI.lua_gettop(L);
            var translator = luaEnv.translator;

            LuaAPI.lua_getref(L, luaReference);
            translator.PushByType(L, key);
            translator.PushByType(L, value);

            if (0 != LuaAPI.xlua_psettable(L, -3))
            {
                luaEnv.ThrowExceptionFromError(oldTop);
            }
            LuaAPI.lua_settop(L, oldTop);
#if THREAD_SAFE || HOTFIX_ENABLE
        }
#endif
        }
Exemplo n.º 30
0
        public InvokeLua.ICalc __Gen_Delegate_Imp5(int p0, string[] p1)
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            RealStatePtr L = luaEnv.rawL;
            int err_func   = LuaAPI.load_error_func(L, errorFuncRef);
            ObjectTranslator translator = luaEnv.translator;

            LuaAPI.lua_getref(L, luaReference);

            LuaAPI.xlua_pushinteger(L, p0);
            if (p1 != null)
            {
                for (int __gen_i = 0; __gen_i < p1.Length; ++__gen_i)
                {
                    LuaAPI.lua_pushstring(L, p1[__gen_i]);
                }
            }
            ;

            int __gen_error = LuaAPI.lua_pcall(L, 1 + (p1 == null ? 0 : p1.Length), 1, err_func);
            if (__gen_error != 0)
            {
                luaEnv.ThrowExceptionFromError(err_func - 1);
            }


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

#if THREAD_SAFE || HOTFIX_ENABLE
        }
#endif
        }