Ejemplo n.º 1
0
        public void PushSceneInfoKey(RealStatePtr L, SceneInfoKey val)
        {
            if (SceneInfoKey_TypeID == -1)
            {
                bool is_first;
                SceneInfoKey_TypeID = getTypeId(L, typeof(SceneInfoKey), out is_first);

                if (SceneInfoKey_EnumRef == -1)
                {
                    Utils.LoadCSTable(L, typeof(SceneInfoKey));
                    SceneInfoKey_EnumRef = LuaAPI.luaL_ref(L, LuaIndexes.LUA_REGISTRYINDEX);
                }
            }

            if (LuaAPI.xlua_tryget_cachedud(L, (int)val, SceneInfoKey_EnumRef) == 1)
            {
                return;
            }

            IntPtr buff = LuaAPI.xlua_pushstruct(L, 4, SceneInfoKey_TypeID);

            if (!CopyByValue.Pack(buff, 0, (int)val))
            {
                throw new Exception("pack fail fail for SceneInfoKey ,value=" + val);
            }

            LuaAPI.lua_getref(L, SceneInfoKey_EnumRef);
            LuaAPI.lua_pushvalue(L, -2);
            LuaAPI.xlua_rawseti(L, -2, (int)val);
            LuaAPI.lua_pop(L, 1);
        }
Ejemplo n.º 2
0
        public void UpdateSceneInfoKey(RealStatePtr L, int index, SceneInfoKey val)
        {
            if (LuaAPI.lua_type(L, index) == LuaTypes.LUA_TUSERDATA)
            {
                if (LuaAPI.xlua_gettypeid(L, index) != SceneInfoKey_TypeID)
                {
                    throw new Exception("invalid userdata for SceneInfoKey");
                }

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                if (!CopyByValue.Pack(buff, 0, (int)val))
                {
                    throw new Exception("pack fail for SceneInfoKey ,value=" + val);
                }
            }

            else
            {
                throw new Exception("try to update a data with lua type:" + LuaAPI.lua_type(L, index));
            }
        }
Ejemplo n.º 3
0
        public void Get(RealStatePtr L, int index, out SceneInfoKey val)
        {
            LuaTypes type = LuaAPI.lua_type(L, index);

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

                IntPtr buff = LuaAPI.lua_touserdata(L, index);
                int    e;
                if (!CopyByValue.UnPack(buff, 0, out e))
                {
                    throw new Exception("unpack fail for SceneInfoKey");
                }
                val = (SceneInfoKey)e;
            }
            else
            {
                val = (SceneInfoKey)objectCasters.GetCaster(typeof(SceneInfoKey))(L, index, null);
            }
        }