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

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

                IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.UnPack(buff, 0, out val))
                {
                    throw new Exception("unpack fail for XLuaTest.PushAsTableStruct");
                }
            }
            else if (type == LuaTypes.LUA_TTABLE)
            {
                CopyByValue.UnPack(this, L, index, out val);
            }
            else
            {
                val = (XLuaTest.PushAsTableStruct)objectCasters.GetCaster(typeof(XLuaTest.PushAsTableStruct))(L, index, null);
            }
        }
コード例 #2
0
        public void UpdateXLuaTestPushAsTableStruct(RealStatePtr L, int index, XLuaTest.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 プロジェクト: liuzhili1994/DouDiZhu
        public static bool Pack(IntPtr buff, int offset, XLuaTest.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 プロジェクト: liuzhili1994/DouDiZhu
        public static bool UnPack(IntPtr buff, int offset, out XLuaTest.PushAsTableStruct field)
        {
            field = default(XLuaTest.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 プロジェクト: liuzhili1994/DouDiZhu
        public static void UnPack(ObjectTranslator translator, RealStatePtr L, int idx, out XLuaTest.PushAsTableStruct val)
        {
            val = new XLuaTest.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 PushXLuaTestPushAsTableStruct(RealStatePtr L, XLuaTest.PushAsTableStruct val)
        {
            if (XLuaTestPushAsTableStruct_TypeID == -1)
            {
                bool is_first;
                XLuaTestPushAsTableStruct_TypeID = getTypeId(L, typeof(XLuaTest.PushAsTableStruct), out is_first);
            }


            LuaAPI.xlua_pushcstable(L, 2, XLuaTestPushAsTableStruct_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);
        }