pushValue() public static method

public static pushValue ( IntPtr l, byte buffer ) : void
l System.IntPtr
buffer byte
return void
Exemplo n.º 1
0
        internal static int loader(IntPtr L)
        {
            string fileName = LuaDLL.lua_tostring(L, 1);

            byte[] bytes = loadFile(fileName);
            if (bytes != null)
            {
                if (LuaDLL.luaL_loadbuffer(L, bytes, bytes.Length, "@" + fileName) == 0)
                {
                    LuaObject.pushValue(L, true);
                    LuaDLL.lua_insert(L, -2);
                    return(2);
                }
                else
                {
                    string errstr = LuaDLL.lua_tostring(L, -1);
                    return(LuaObject.error(L, errstr));
                }
            }
            LuaObject.pushValue(L, true);
            LuaDLL.lua_pushnil(L);
            return(2);
        }
Exemplo n.º 2
0
        void setupPushVar()
        {
            typePushMap[typeof(float)] = (IntPtr L, object o) =>
            {
                LuaDLL.lua_pushnumber(L, (float)o);
            };
            typePushMap[typeof(double)] = (IntPtr L, object o) =>
            {
                LuaDLL.lua_pushnumber(L, (double)o);
            };

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

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

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

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

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

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


            typePushMap[typeof(Int64)]      =
                typePushMap[typeof(UInt64)] =
                    (IntPtr L, object o) =>
            {
#if LUA_5_3
                LuaDLL.lua_pushinteger(L, (long)o);
#else
                LuaDLL.lua_pushnumber(L, System.Convert.ToDouble(o));
#endif
            };

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

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

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

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