示例#1
0
        public void Enum_HandleBitEncoder32Test()
        {
            var ss = new Memory.Strings.StringStorage(
                Memory.Strings.StringStorageWidthType.UTF32,
                Memory.Strings.StringStorageType.CharArray,
                Shell.EndianFormat.Big, 16);
            var encoder = new Bitwise.HandleBitEncoder();

            encoder.Encode32(ss.WidthType, TypeExtensions.BitEncoders.StringStorageWidthType);
            encoder.Encode32(ss.Type, TypeExtensions.BitEncoders.StringStorageType);
            encoder.Encode32(ss.ByteOrder, TypeExtensions.BitEncoders.EndianFormat);
            encoder.Encode32((uint)ss.FixedLength, 0x7FFF);

            var decoder = new Bitwise.HandleBitEncoder(encoder.GetHandle32());

            decoder.Decode32(out Memory.Strings.StringStorageWidthType widthType, TypeExtensions.BitEncoders.StringStorageWidthType);
            decoder.Decode32(out Memory.Strings.StringStorageType type, TypeExtensions.BitEncoders.StringStorageType);
            decoder.Decode32(out Shell.EndianFormat byteOrder, TypeExtensions.BitEncoders.EndianFormat);
            decoder.Decode32(out uint fixedLength, 0x7FFF);

            Assert.AreEqual(ss.WidthType, widthType);
            Assert.AreEqual(ss.Type, type);
            Assert.AreEqual(ss.ByteOrder, byteOrder);
            Assert.AreEqual(ss.FixedLength, (short)fixedLength);
        }
示例#2
0
        //internal uint Handle { get { return mHandle; } }

        static void InitializeHandle(out uint handle, MegaloScriptModelObjectType type, int id)
        {
            var encoder = new Bitwise.HandleBitEncoder();

            encoder.EncodeNoneable32(id, Constants.kIdBitField);
            encoder.Encode32(type, BitEncoders.MegaloScriptModelObjectType);

            Contract.Assert(encoder.UsedBitCount == MegaloScriptModelObjectHandle.BitCount);

            handle = encoder.GetHandle32();
        }
示例#3
0
        static void InitializeHandle(out uint handle,
                                     int engineIndex, int branchIndex, int revisionIndex)
        {
            var encoder = new Bitwise.HandleBitEncoder();

            EngineBuildRevision.BitEncodeIndex(ref encoder, revisionIndex);
            EngineBuildBranch.BitEncodeIndex(ref encoder, branchIndex);
            BlamEngine.BitEncodeIndex(ref encoder, engineIndex);

            Contract.Assert(encoder.UsedBitCount == EngineBuildHandle.BitCount);

            handle = encoder.GetHandle32();
        }
示例#4
0
		//internal uint Handle { get { return mHandle; } }

		static void InitializeHandle(out uint handle,
			Engine.EngineBuildHandle buildHandle, int langIndex, int gameIndex)
		{
			uint is_supported = gameIndex.IsNotNone() ? 1U : 0U;

			var encoder = new Bitwise.HandleBitEncoder();
			encoder.EncodeNoneable32(gameIndex, Constants.kGameIndexBitField);
			encoder.Encode32(is_supported, Constants.kIsSupportedBitField);
			LanguageRegistry.BitEncodeLanguageIndex(ref encoder, langIndex);
			encoder.Encode32(buildHandle.Handle, Constants.kBuildBitField);

			Contract.Assert(encoder.UsedBitCount == GameLanguageHandle.BitCount);

			handle = encoder.GetHandle32();
		}
        //internal uint Handle { get { return mHandle; } }

        static void InitializeHandle(out uint handle, int nameIndex, MegaloScriptValueBaseType baseType, int bitLength,
                                     uint typeParam = 0, uint typeTraits = 0)
        {
            var encoder = new Bitwise.HandleBitEncoder();

            encoder.Encode32((uint)nameIndex, Constants.kNameIndexBitField);
            encoder.Encode32(baseType, BitEncoders.MegaloScriptValueBaseType);
            encoder.Encode32((uint)bitLength, Constants.kBitLengthBitField);
            encoder.Encode32(typeParam, Constants.kTypeParamBitField);
            encoder.Encode32(typeTraits, Constants.kTypeTraitsBitField);

            Contract.Assert(encoder.UsedBitCount == MegaloScriptValueType.BitCount);

            handle = encoder.GetHandle32();
        }
示例#6
0
        //internal uint Handle { get { return mHandle; } }

        static void InitializeHandle(out uint handle,
                                     EngineBuildHandle buildHandle, int platformIndex, int resourceModelIndex)
        {
            if (platformIndex.IsNone() && resourceModelIndex.IsNone())
            {
                resourceModelIndex = 0;
            }

            var encoder = new Bitwise.HandleBitEncoder();

            EngineRegistry.BitEncodeResourceModelIndex(ref encoder, resourceModelIndex);
            EngineTargetPlatform.BitEncodeIndex(ref encoder, platformIndex);
            encoder.Encode32(buildHandle.Handle, EngineBuildHandle.Bitmask);

            Contract.Assert(encoder.UsedBitCount == BlamEngineTargetHandle.BitCount);

            handle = encoder.GetHandle32();
        }
示例#7
0
        static int CalculateHashCode(StringStorageWidthType widthType, StringStorageType type, Shell.EndianFormat byteOrder,
                                     StringStorageLengthPrefix prefix,
                                     short fixedLength)
        {
            var encoder = new Bitwise.HandleBitEncoder();

            encoder.Encode32(widthType, TypeExtensions.BitEncoders.StringStorageWidthType);
            encoder.Encode32(type, TypeExtensions.BitEncoders.StringStorageType);
            encoder.Encode32(byteOrder, TypeExtensions.BitEncoders.EndianFormat);

            if (type.UsesLengthPrefix())
            {
                encoder.Encode32(prefix, TypeExtensions.BitEncoders.StringStorageLengthPrefix);
            }
            else if (fixedLength != 0)
            {
                encoder.Encode32((uint)fixedLength, 0x7FFF);
            }

            return((int)encoder.GetHandle32());
        }