Exemplo n.º 1
0
 public int BeginPCall()
 {
     LuaScriptMgr.PushTraceBack(L);
     beginPos = LuaDLL.lua_gettop(L);
     push(L);
     return(beginPos);
 }
Exemplo n.º 2
0
 public int BeginPCall()
 {
     LuaScriptMgr.PushTraceBack(this.L);
     this.beginPos = LuaDLL.lua_gettop(this.L);
     this.push(this.L);
     return(this.beginPos);
 }
Exemplo n.º 3
0
        public int BeginPCall()
        {
            LuaScriptMgr.PushTraceBack(L);
            int oldTop = LuaDLL.lua_gettop(L);

            push(L);
            return(oldTop);
        }
Exemplo n.º 4
0
        /*
         * Calls the function casting return values to the types
         * in returnTypes
         */
        internal object[] call(object[] args, Type[] returnTypes)
        {
            int nArgs = 0;

            LuaScriptMgr.PushTraceBack(L);
            int oldTop = LuaDLL.lua_gettop(L);

            if (!LuaDLL.lua_checkstack(L, args.Length + 6))
            {
                LuaDLL.lua_pop(L, 1);
                throw new LuaException("Lua stack overflow");
            }

            push(L);

            if (args != null)
            {
                nArgs = args.Length;

                for (int i = 0; i < args.Length; i++)
                {
                    PushArgs(L, args[i]);
                }
            }
            int error = 0;

            try
            {
                error = LuaDLL.lua_pcall(L, nArgs, -1, -nArgs - 2);
            }
            catch (Exception e)
            {
                //Debug.LogError(e.Message + "\n" + e.StackTrace);
                object[] trackBack = LuaScriptMgr.Instance.CallLuaFunction("debug.traceback");
                if (trackBack != null && trackBack.Length >= 1)
                {
                    //Debug.LogError(trackBack[0].ToString());
                }
            }
            if (error != 0)
            {
                string err = LuaDLL.lua_tostring(L, -1);
                LuaDLL.lua_settop(L, oldTop - 1);
                if (err == null)
                {
                    err = "Unknown Lua Error";
                }
                throw new LuaScriptException(err, "");
            }

            object[] ret = returnTypes != null?translator.popValues(L, oldTop, returnTypes) : translator.popValues(L, oldTop);

            LuaDLL.lua_settop(L, oldTop - 1);
            return(ret);
        }
Exemplo n.º 5
0
        /*
         * Calls the function casting return values to the types
         * in returnTypes
         */
        internal object[] call(object[] args, Type[] returnTypes)
        {
            int nArgs = 0;

            LuaScriptMgr.PushTraceBack(L);
            int oldTop = LuaDLL.lua_gettop(L);

            if (!LuaDLL.lua_checkstack(L, args.Length + 6))
            {
                LuaDLL.lua_pop(L, 1);
                throw new LuaException("Lua stack overflow");
            }

            push(L);

            if (args != null)
            {
                nArgs = args.Length;

                for (int i = 0; i < args.Length; i++)
                {
                    PushArgs(L, args[i]);
                }
            }

            int error = LuaDLL.lua_pcall(L, nArgs, -1, -nArgs - 2);

            if (error != 0)
            {
                string err = LuaDLL.lua_tostring(L, -1);
                LuaDLL.lua_settop(L, oldTop - 1);
                if (err == null)
                {
                    err = "Unknown Lua Error";
                }
                Debugger.LogError(err);
                LuaDLL.lua_settop(L, oldTop - 1);
                return(null);
            }

            object[] ret = returnTypes != null?translator.popValues(L, oldTop, returnTypes) : translator.popValues(L, oldTop);

            LuaDLL.lua_settop(L, oldTop - 1);
            return(ret);
        }
Exemplo n.º 6
0
        internal object[] call(object[] args, Type[] returnTypes)
        {
            int num = 0;

            LuaScriptMgr.PushTraceBack(this.L);
            int num2 = LuaDLL.lua_gettop(this.L);

            if (!LuaDLL.lua_checkstack(this.L, args.Length + 6))
            {
                LuaDLL.lua_pop(this.L, 1);
                throw new LuaException("Lua stack overflow");
            }
            this.push(this.L);
            if (args != null)
            {
                num = args.Length;
                for (int i = 0; i < args.Length; i++)
                {
                    base.PushArgs(this.L, args[i]);
                }
            }
            int num3 = LuaDLL.lua_pcall(this.L, num, -1, -num - 2);

            if (num3 != 0)
            {
                string text = LuaDLL.lua_tostring(this.L, -1);
                LuaDLL.lua_settop(this.L, num2 - 1);
                if (text == null)
                {
                    text = "Unknown Lua Error";
                }
                throw new LuaScriptException(text, string.Empty);
            }
            object[] result = (returnTypes == null) ? this.translator.popValues(this.L, num2) : this.translator.popValues(this.L, num2, returnTypes);
            LuaDLL.lua_settop(this.L, num2 - 1);
            return(result);
        }