示例#1
0
        public static void PushValue(IntPtr ptr, ulong o)
        {
#if LUA_5_3
            LuaDLL.lua_pushinteger(ptr, (long)o);
#else
            LuaNativeMethods.lua_pushnumber(ptr, o);
#endif
        }
示例#2
0
        public static void PushValue(IntPtr ptr, long i)
        {
#if LUA_5_3
            LuaDLL.lua_pushinteger(l, i);
#else
            LuaNativeMethods.lua_pushnumber(ptr, i);
#endif
        }
示例#3
0
        public static int ErrorReport(IntPtr ptr)
        {
            LuaNativeMethods.lua_getglobal(ptr, "debug");
            LuaNativeMethods.lua_getfield(ptr, -1, "traceback");
            LuaNativeMethods.lua_pushvalue(ptr, 1);
            LuaNativeMethods.lua_pushnumber(ptr, 2);
            LuaNativeMethods.lua_call(ptr, 2, 1);
            LuaNativeMethods.lua_remove(ptr, -2);
            string error = LuaNativeMethods.lua_tostring(ptr, -1);

            LuaNativeMethods.lua_pop(ptr, 1);

            Logger.LogError(error, true);
            if (ErrorEvent != null)
            {
                ErrorEvent(error);
            }

            LuaNativeMethods.lua_getglobal(ptr, "dumpstack");
            LuaNativeMethods.lua_call(ptr, 0, 0);

            return(0);
        }
示例#4
0
 public static void PushValue(IntPtr ptr, double d)
 {
     LuaNativeMethods.lua_pushnumber(ptr, d);
 }
示例#5
0
 public static void PushValue(IntPtr ptr, float o)
 {
     LuaNativeMethods.lua_pushnumber(ptr, o);
 }
示例#6
0
        public void SetupPushVar()
        {
            typePushMap[typeof(float)] = (IntPtr ptr, object o) =>
            {
                LuaNativeMethods.lua_pushnumber(ptr, (float)o);
            };

            typePushMap[typeof(double)] = (IntPtr ptr, object o) =>
            {
                LuaNativeMethods.lua_pushnumber(ptr, (double)o);
            };

            typePushMap[typeof(int)] =
                (IntPtr ptr, object o) =>
            {
                LuaNativeMethods.lua_pushinteger(ptr, (int)o);
            };

            typePushMap[typeof(uint)] =
                (IntPtr ptr, object o) =>
            {
                LuaNativeMethods.lua_pushnumber(ptr, Convert.ToUInt32(o));
            };

            typePushMap[typeof(short)] =
                (IntPtr ptr, object o) =>
            {
                LuaNativeMethods.lua_pushinteger(ptr, (short)o);
            };

            typePushMap[typeof(ushort)] =
                (IntPtr ptr, object o) =>
            {
                LuaNativeMethods.lua_pushinteger(ptr, (ushort)o);
            };

            typePushMap[typeof(sbyte)] =
                (IntPtr ptr, object o) =>
            {
                LuaNativeMethods.lua_pushinteger(ptr, (sbyte)o);
            };

            typePushMap[typeof(byte)] =
                (IntPtr ptr, object o) =>
            {
                LuaNativeMethods.lua_pushinteger(ptr, (byte)o);
            };

            typePushMap[typeof(long)]      =
                typePushMap[typeof(ulong)] =
                    (IntPtr ptr, object o) =>
            {
#if LUA_5_3
                LuaNativeMethods.lua_pushinteger(ptr, (long)o);
#else
                LuaNativeMethods.lua_pushnumber(ptr, System.Convert.ToDouble(o));
#endif
            };

            typePushMap[typeof(string)] = (IntPtr ptr, object o) =>
            {
                LuaNativeMethods.lua_pushstring(ptr, (string)o);
            };

            typePushMap[typeof(bool)] = (IntPtr ptr, object o) =>
            {
                LuaNativeMethods.lua_pushboolean(ptr, (bool)o);
            };

            typePushMap[typeof(LuaTable)]          =
                typePushMap[typeof(LuaFunction)]   =
                    typePushMap[typeof(LuaThread)] =
                        (IntPtr ptr, object o) =>
            {
                ((LuaVar)o).Push(ptr);
            };

            typePushMap[typeof(LuaCSFunction)] = (IntPtr ptr, object o) =>
            {
                LuaObject.PushValue(ptr, (LuaCSFunction)o);
            };
        }