public ComponentRecord(List <DatabaseRecordFragment> fragments) : base(fragments)
        {
            // Data begins at 0x10 (VBLK header is at 0x00)
            int offset = 0x00; // relative to Data

            ReadCommonFields(this.Data, ref offset);
            if (RecordRevision != 3)
            {
                throw new NotImplementedException("Unsupported record revision");
            }
            StateString         = ReadVarString(this.Data, ref offset);
            ExtentLayout        = (ExtentLayoutName)ByteReader.ReadByte(this.Data, ref offset);
            ComponentFlags      = (ComponentFlags)BigEndianReader.ReadUInt32(this.Data, ref offset);
            NumberOfExtents     = ReadVarUInt(this.Data, ref offset);
            CommitTransactionID = BigEndianReader.ReadUInt64(this.Data, ref offset);
            offset  += 8;
            VolumeId = ReadVarULong(this.Data, ref offset);
            LogSD    = ReadVarULong(this.Data, ref offset);

            if (HasStripedExtentsFlag)
            {
                StripeSizeLBA   = ReadVarULong(this.Data, ref offset);
                NumberOfColumns = ReadVarUInt(this.Data, ref offset);
            }
        }
Exemple #2
0
        public string GetDestinationWriteMaskName(int destinationLength, bool hlsl)
        {
            ComponentFlags writeMask       = GetDestinationWriteMask();
            int            writeMaskLength = GetDestinationMaskLength();

            if (!hlsl)
            {
                destinationLength = 4;                 // explicit mask in assembly
            }
            if (Opcode.Rep == Opcode)
            {
                return("");
            }
            // Check if mask is the same length and of the form .xyzw
            if (writeMaskLength == destinationLength && writeMask == (ComponentFlags)((1 << writeMaskLength) - 1))
            {
                return("");
            }

            string writeMaskName =
                string.Format(".{0}{1}{2}{3}",
                              ((writeMask & ComponentFlags.X) != 0) ? "x" : "",
                              ((writeMask & ComponentFlags.Y) != 0) ? "y" : "",
                              ((writeMask & ComponentFlags.Z) != 0) ? "z" : "",
                              ((writeMask & ComponentFlags.W) != 0) ? "w" : "");

            return(writeMaskName);
        }
Exemple #3
0
 internal Enumerator(EntityContext <TEntity> entitySystem, ComponentFlags hasAll, ComponentFlags hasNone)
 {
     _entitySystem          = entitySystem;
     _entityIndexEnumerator = entitySystem.GetEntityIndexEnumerator();
     _current = Entity <TEntity> .None;
     _hasAll  = hasAll;
     _hasNone = hasNone;
 }
Exemple #4
0
 public DestinationOperand(uint value)
 {
     RegisterNumber       = value & 0x7FF;
     RegisterType         = (RegisterType)(((value >> 28) & 0x7) | ((value >> 8) & 0x18));
     MinPrecision         = (value >> 12) & 0XC;
     DestinationWriteMask = (ComponentFlags)((value >> 16) & 0xF);
     ResultModifier       = (ResultModifier)((value >> 20) & 0xF);
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.NodeIndex = binaryReader.ReadInt16();
     this.ObjectSpaceNodeDataComponentFlags = ((ComponentFlags)(binaryReader.ReadInt16()));
     pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.Orientation.ReadFields(binaryReader)));
     return(pointerQueue);
 }
Exemple #6
0
 public GameObject(string name)
 {
     m_Name           = name;
     m_ComponentFlags = 0;
     m_Position       = new PositionComponent();
     m_Sprite         = new SpriteComponent();
     m_WorldBounds    = new WorldBoundsComponent();
     m_Move           = new MoveComponent();
 }
Exemple #7
0
        // Length of ".xy" = 2
        // Length of ".yw" = 4 (xyzw)
        public int GetDestinationMaskedLength()
        {
            ComponentFlags writeMask = GetDestinationWriteMask();

            for (int i = 3; i != 0; i--)
            {
                var mask = (ComponentFlags)(1 << i);
                if ((writeMask & mask) != ComponentFlags.None)
                {
                    return(i + 1);
                }
            }
            return(0);
        }
Exemple #8
0
        // Length of ".yw" = 2
        public int GetDestinationMaskLength()
        {
            ComponentFlags writeMask = GetDestinationWriteMask();
            int            length    = 0;

            for (int i = 0; i < 4; i++)
            {
                var mask = (ComponentFlags)(1 << i);
                if ((writeMask & mask) != ComponentFlags.None)
                {
                    length++;
                }
            }
            return(length);
        }
        private static IEnumerable <RegisterComponentKey> GetDestinationKeys(InstructionToken instruction)
        {
            int         index       = instruction.GetDestinationParamIndex();
            RegisterKey registerKey = instruction.GetParamRegisterKey(index);

            if (registerKey.Type == RegisterType.Sampler)
            {
                yield break;
            }

            ComponentFlags mask = instruction.GetDestinationWriteMask();

            for (int component = 0; component < 4; component++)
            {
                if ((mask & (ComponentFlags)(1 << component)) == 0)
                {
                    continue;
                }

                yield return(new RegisterComponentKey(registerKey, component));
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentAttribute"/> class.
 /// </summary>
 /// <param name="flags">Specifies how the implementation should be created/maintained.</param>
 /// <example>
 /// <code>
 /// [Component(ComponentFlags.Singleton)]
 /// public class CachedUserService : IUserService
 /// {
 /// }
 /// </code>
 /// </example>
 public ComponentAttribute(ComponentFlags flags)
 {
     Flags = flags;
 }
Exemple #11
0
 internal EntityQuery(EntityContext <TEntity> entitySystem)
 {
     _entitySystem = entitySystem;
     _hasAll       = default(ComponentFlags);
     _hasNone      = default(ComponentFlags);
 }
Exemple #12
0
        // TODO(jweyrich): Does NOT support paths that start with @"\\".
        public ComponentFlags Parse(string path, bool resolve = false)
        {
            Reset();

            ComponentFlags comps = ComponentFlags.NONE;

            // Full path
            string fullpath = resolve
                                ? ZetaLongPaths.ZlpPathHelper.GetFullPath(path) // Will throw an exception for an invalid path string.
                                : path;

            // Drive
            string drive = ZetaLongPaths.ZlpPathHelper.GetPathRoot(fullpath);

            if (drive != null)
            {
                if (Native.IsRunningOnWindows)
                {
                    // Get root from Windows path.
                    if (drive.EndsWith(":") || drive.EndsWith(@":\"))                     // ?? Path.VolumeSeparatorChar.ToString() + Path.DirectorySeparatorChar
                    {
                        drive = drive[0].ToString();
                    }
                }
                else
                {
                    // Get root from Linux/Unix/Mac path.
                    if (drive.EndsWith("/", StringComparison.Ordinal))
                    {
                        drive = drive.Substring(0, drive.Length - 1);
                    }
                }
            }

            if (!string.IsNullOrEmpty(drive))
            {
                comps |= ComponentFlags.DRIVE;
                Mode   = ModeEnum.BLOCK_DEVICE;
            }

            // Directories
            string[] directories   = null;
            string   parsing       = fullpath;
            int      whereItBegins = drive != null ? drive.Length : 0;

            if (comps.HasFlag(ComponentFlags.DRIVE))
            {
                if (Native.IsRunningOnWindows)
                {
                    whereItBegins++;                     // Skip the ":" in "C:\Foo\Bar\..." => Path.VolumeSeparatorChar
                    whereItBegins++;                     // Skip the 1st "\" in "C:\Foo\Bar\..." => Path.DirectorySeparatorChar
                }
                else
                {
                    whereItBegins += drive.Length;
                    whereItBegins++;                     // Skip the 2nd @"/" in "/home/jweyrich/foo/bar/..."
                }
            }

            if (whereItBegins < parsing.Length)
            {
                if (whereItBegins != -1)
                {
                    parsing = parsing.Substring(whereItBegins);
                }
                int whereItEnds = parsing.LastIndexOf(Path.DirectorySeparatorChar);
                if (whereItEnds != -1)
                {
                    parsing = parsing.Remove(whereItEnds);
                    if (parsing.Length > 0)
                    {
                        directories = parsing.Split(Path.DirectorySeparatorChar);
                        if (directories.Length > 0)
                        {
                            comps |= ComponentFlags.DIRECTORY;
                            Mode   = ModeEnum.DIRECTORY;
                        }
                    }
                }
            }
            //Console.WriteLine("whereItBegins = {0}", whereItBegins);
            //Console.WriteLine("whereItEnds = {0}", whereItEnds);
            //Console.WriteLine("parsing = {0}", parsing);
            //Console.WriteLine("directories = {0}", directories);

            // File name, with and without extension
            string filename = ZetaLongPaths.ZlpPathHelper.GetFileNameFromFilePath(fullpath);
            string filenameWithoutExtension = string.Empty;

            if (!string.IsNullOrEmpty(filename))
            {
                filenameWithoutExtension = Path.GetFileNameWithoutExtension(fullpath);
                comps |= ComponentFlags.FILENAME;
                Mode   = ModeEnum.REGULAR_FILE;
            }

            // File extension
            string extension = ZetaLongPaths.ZlpPathHelper.GetExtension(fullpath);

            if (!string.IsNullOrEmpty(extension))
            {
                extension = extension.Substring(1);                 // Remove the leading period '.'
                comps    |= ComponentFlags.EXTENSION;
            }

            // Ta-da!
            AvailableComponents = comps;
            FullPath            = fullpath;
            Drive       = drive;
            Directories = directories;
            FileName    = filename;
            FileNameWithoutExtension = filenameWithoutExtension;
            Extension = extension;

            return(AvailableComponents);
        }
 /// <summary>
 /// Inno Setup <a href="https://jrsoftware.org/ishelp/topic_componentssection.htm">Documentation</a>
 /// </summary>
 public Builder Flags(ComponentFlags componentFlags)
 {
     _component.Flags = componentFlags;
     return(this);
 }
Exemple #14
0
        void ReadCompound(Stream stream, BinaryReader reader)
        {
            Components = new List <GlyphComponent>();
            bool moreComponents = true;

            while (moreComponents)
            {
                ComponentFlags flags = (ComponentFlags)reader.ReadInt16();
                int            index = reader.ReadUInt16();

                int arg1, arg2;
                if (flags.HasFlag(ComponentFlags.ArgsAreWords))
                {
                    arg1 = reader.ReadUInt16();
                    arg2 = reader.ReadUInt16();
                }
                else
                {
                    arg1 = reader.ReadByte();
                    arg2 = reader.ReadByte();
                }

                decimal a, b, c, d;
                if (flags.HasFlag(ComponentFlags.IsScaled))
                {
                    a = reader.ReadFixed16();
                    d = a;
                    b = c = 0;
                }
                else if (flags.HasFlag(ComponentFlags.DifferentXYScale))
                {
                    a = reader.ReadFixed16();
                    d = reader.ReadFixed16();
                    b = c = 0;
                }
                else if (flags.HasFlag(ComponentFlags.TwoByTwoScale))
                {
                    a = reader.ReadFixed16();
                    b = reader.ReadFixed16();
                    c = reader.ReadFixed16();
                    d = reader.ReadFixed16();
                }
                else
                {
                    a = d = 1;
                    b = c = 0;
                }

                decimal m = Math.Max(Math.Abs(a), Math.Abs(b));
                if (Math.Abs(Math.Abs(a) - Math.Abs(c)) <= 33m / 65536m)
                {
                    m *= 2;                                                      //b?
                }
                decimal n = Math.Max(Math.Abs(c), Math.Abs(d));
                if (Math.Abs(Math.Abs(c) - Math.Abs(d)) <= 33m / 65536m)
                {
                    n *= 2;
                }

                Components.Add(new GlyphComponent()
                {
                    GlyphIndex      = index,
                    UseMetrics      = flags.HasFlag(ComponentFlags.UseMetrics),
                    Arg1            = arg1,
                    Arg2            = arg2,
                    ArgsAreXYValues = flags.HasFlag(ComponentFlags.ArgsAreXYValues),
                    Transform       = new[] { a, b, c, d, m, n }
                });

                moreComponents = flags.HasFlag(ComponentFlags.MoreComponents);
            }
        }