예제 #1
0
        public void Get(RealStatePtr L, int index, out XLuaTest.MyStruct val)
        {
            LuaTypes type = LuaAPI.lua_type(L, index);

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

                IntPtr buff = LuaAPI.lua_touserdata(L, index); if (!CopyByValue.UnPack(buff, 0, out val))
                {
                    throw new Exception("unpack fail for XLuaTest.MyStruct");
                }
            }
            else if (type == LuaTypes.LUA_TTABLE)
            {
                CopyByValue.UnPack(this, L, index, out val);
            }
            else
            {
                val = (XLuaTest.MyStruct)objectCasters.GetCaster(typeof(XLuaTest.MyStruct))(L, index, null);
            }
        }
        public void PushXLuaTestMyStruct(RealStatePtr L, XLuaTest.MyStruct val)
        {
            if (XLuaTestMyStruct_TypeID == -1)
            {
                bool is_first;
                XLuaTestMyStruct_TypeID = getTypeId(L, typeof(XLuaTest.MyStruct), out is_first);
            }

            IntPtr buff = LuaAPI.xlua_pushstruct(L, 25, XLuaTestMyStruct_TypeID);

            if (!CopyByValue.Pack(buff, 0, val))
            {
                throw new Exception("pack fail fail for XLuaTest.MyStruct ,value=" + val);
            }
        }
        static int __CreateInstance(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);

            try {
                if (LuaAPI.lua_gettop(L) == 3 && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 2) && LuaTypes.LUA_TNUMBER == LuaAPI.lua_type(L, 3))
                {
                    int p1 = LuaAPI.xlua_tointeger(L, 2);
                    int p2 = LuaAPI.xlua_tointeger(L, 3);

                    XLuaTest.MyStruct __cl_gen_ret = new XLuaTest.MyStruct(p1, p2);
                    translator.PushXLuaTestMyStruct(L, __cl_gen_ret);
                    return(1);
                }
            }
            catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
            return(LuaAPI.luaL_error(L, "invalid arguments to XLuaTest.MyStruct constructor!"));
        }
        public void UpdateXLuaTestMyStruct(RealStatePtr L, int index, XLuaTest.MyStruct val)
        {
            if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != XLuaTestMyStruct_TypeID)
                {
                    throw new Exception("invalid userdata for XLuaTest.MyStruct");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                if (!CopyByValue.Pack(buff, 0, val))
                {
                    throw new Exception("pack fail for XLuaTest.MyStruct ,value=" + val);
                }
            }
            else
            {
                throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index));
            }
        }
예제 #5
0
        public XLuaTest.MyStruct __Gen_Delegate_Imp14(XLuaTest.MyStruct p0)
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            RealStatePtr L = luaEnv.rawL;
            int errFunc    = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
            ObjectTranslator translator = luaEnv.translator;
            translator.PushXLuaTestMyStruct(L, p0);

            PCall(L, 1, 1, errFunc);


            XLuaTest.MyStruct __gen_ret; translator.Get(L, errFunc + 1, out __gen_ret);
            LuaAPI.lua_settop(L, errFunc - 1);
            return(__gen_ret);

#if THREAD_SAFE || HOTFIX_ENABLE
        }
#endif
        }
예제 #6
0
        public void __Gen_Delegate_Imp18(XLuaTest.MyStruct p0, int p1, int p2)
        {
#if THREAD_SAFE || HOTFIX_ENABLE
            lock (luaEnv.luaEnvLock)
            {
#endif
            RealStatePtr L = luaEnv.rawL;
            int errFunc    = LuaAPI.pcall_prepare(L, errorFuncRef, luaReference);
            ObjectTranslator translator = luaEnv.translator;
            translator.PushXLuaTestMyStruct(L, p0);
            LuaAPI.xlua_pushinteger(L, p1);
            LuaAPI.xlua_pushinteger(L, p2);

            PCall(L, 3, 0, errFunc);



            LuaAPI.lua_settop(L, errFunc - 1);

#if THREAD_SAFE || HOTFIX_ENABLE
        }
#endif
        }
예제 #7
0
        static int _m_StructParamMethod(RealStatePtr L)
        {
            ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


            XLuaTest.NoGc __cl_gen_to_be_invoked = (XLuaTest.NoGc)translator.FastGetCSObj(L, 1);


            try {
                {
                    XLuaTest.MyStruct p; translator.Get(L, 2, out p);

                    XLuaTest.MyStruct __cl_gen_ret = __cl_gen_to_be_invoked.StructParamMethod(p);
                    translator.PushXLuaTestMyStruct(L, __cl_gen_ret);



                    return(1);
                }
            } catch (System.Exception __gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + __gen_e));
            }
        }
예제 #8
0
        public static bool Pack(IntPtr buff, int offset, XLuaTest.MyStruct field)
        {
            if (!Pack(buff, offset, field.a))
            {
                return(false);
            }

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

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

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

            return(true);
        }
예제 #9
0
        public static void UnPack(ObjectTranslator translator, RealStatePtr L, int idx, out XLuaTest.MyStruct val)
        {
            val = new XLuaTest.MyStruct();
            int top = LuaAPI.lua_gettop(L);

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

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

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

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