コード例 #1
0
        public void Get(RealStatePtr L, int index, out PushAsTableStruct val)
        {
            LuaTypes type = LuaAPI.lua_type(L, index);

            if (type == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != PushAsTableStruct_TypeID)
                {
                    throw new Exception("invalid userdata for PushAsTableStruct");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.UnPack(buff, 0, out val))
                {
                    throw new Exception("unpack fail for PushAsTableStruct");
                }
            }
            else if (type == LuaTypes.LUA_TTABLE)
            {
                CopyByValue.UnPack(this, L, index, out val);
            }
            else
            {
                val = (PushAsTableStruct)objectCasters.GetCaster(typeof(PushAsTableStruct))(L, index, null);
            }
        }
コード例 #2
0
        public void UpdatePushAsTableStruct(RealStatePtr L, int index, PushAsTableStruct val)
        {
            if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TTABLE)
            {
                return;
            }

            else
            {
                throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index));
            }
        }
コード例 #3
0
ファイル: PackUnpack.cs プロジェクト: isoundy000/shmj3d
        public static bool Pack(IntPtr buff, int offset, PushAsTableStruct field)
        {
            if (!Pack(buff, offset, field.x))
            {
                return(false);
            }

            if (!Pack(buff, offset + 4, field.y))
            {
                return(false);
            }

            return(true);
        }
コード例 #4
0
ファイル: PackUnpack.cs プロジェクト: isoundy000/shmj3d
        public static bool UnPack(IntPtr buff, int offset, out PushAsTableStruct field)
        {
            field = default(PushAsTableStruct);

            if (!UnPack(buff, offset, out field.x))
            {
                return(false);
            }

            if (!UnPack(buff, offset + 4, out field.y))
            {
                return(false);
            }

            return(true);
        }
コード例 #5
0
ファイル: PackUnpack.cs プロジェクト: isoundy000/shmj3d
        public static void UnPack(ObjectTranslator translator, RealStatePtr L, int idx, out PushAsTableStruct val)
        {
            val = new PushAsTableStruct();
            int top = LuaAPI.lua_gettop(L);

            if (Utils.LoadField(L, idx, "x"))
            {
                translator.Get(L, top + 1, out val.x);
            }
            LuaAPI.lua_pop(L, 1);

            if (Utils.LoadField(L, idx, "y"))
            {
                translator.Get(L, top + 1, out val.y);
            }
            LuaAPI.lua_pop(L, 1);
        }
コード例 #6
0
        public void PushPushAsTableStruct(RealStatePtr L, PushAsTableStruct val)
        {
            if (PushAsTableStruct_TypeID == -1)
            {
                bool is_first;
                PushAsTableStruct_TypeID = getTypeId(L, typeof(PushAsTableStruct), out is_first);
            }

            LuaAPI.xlua_pushcstable(L, 2, PushAsTableStruct_TypeID);

            LuaAPI.xlua_pushasciistring(L, "x");
            LuaAPI.xlua_pushinteger(L, val.x);
            LuaAPI.lua_rawset(L, -3);

            LuaAPI.xlua_pushasciistring(L, "y");
            LuaAPI.xlua_pushinteger(L, val.y);
            LuaAPI.lua_rawset(L, -3);
        }