Exemple #1
0
 public EnumValue(string nativeName, string rawNameComponent, int valueExpression)
 {
     m_nativeName       = nativeName;
     m_rawNameComponent = rawNameComponent;
     m_stylizedName     = Formatter.StylizeNameFromUnderscoreSeparators(nativeName);
     m_shouldProject    = true;
     m_valueExpression  = valueExpression.ToString();
 }
Exemple #2
0
        public Enum(Namespace parentNamespace, XmlBindings.Enum xmlData, Overrides.XmlBindings.Enum overrides, Dictionary <string, QualifiableType> typeDictionary, OutputDataTypes outputDataTypes)
        {
            m_stylizedName = Formatter.Prefix + Formatter.StylizeNameFromUnderscoreSeparators(xmlData.Name);

            if (parentNamespace != null)
            {
                m_rawName = parentNamespace.ApiName + "_" + xmlData.Name;
                typeDictionary[parentNamespace.RawName + "::" + xmlData.Name] = this;
            }
            else
            {
                //
                // Namespace of NULL indicates the global namespace.
                // These types aren't D2D types, and their full native name is
                // exactly what's in the name field (no need to prepend anything).
                //
                m_rawName = xmlData.Name;
                typeDictionary[xmlData.Name] = this;
            }

            m_isFlags = xmlData.IsFlags;

            m_enumValues = new List <EnumValue>();
            foreach (XmlBindings.EnumValue valueXml in xmlData.EnumValues)
            {
                Overrides.XmlBindings.EnumValue overridesEnumValue = null;
                if (overrides != null)
                {
                    overridesEnumValue = overrides.Values.Find(x => x.Name == valueXml.Name);
                }

                m_enumValues.Add(new EnumValue(valueXml, m_rawName, overridesEnumValue));
            }

            bool shouldProject = false;

            if (overrides != null)
            {
                shouldProject = overrides.ShouldProject;

                if (overrides.ProjectedNameOverride != null)
                {
                    m_stylizedName = Formatter.Prefix + overrides.ProjectedNameOverride;
                }
            }

            // One of the XML files has a mistake where it doesn't properly order its enums.
            if (m_isFlags)
            {
                m_enumValues.Sort(new EnumValueComparer());
            }

            // Enums in the global namespace are defined as aliases only. By convention, only enums in a namespace are output.
            if (parentNamespace != null && shouldProject)
            {
                outputDataTypes.AddEnum(this);
            }
        }
Exemple #3
0
        public Enum(string rawName, List <EnumValue> values, Dictionary <string, QualifiableType> typeDictionary)
        {
            m_rawName = rawName;
            typeDictionary[rawName] = this;
            m_stylizedName          = Formatter.Prefix + Formatter.StylizeNameFromUnderscoreSeparators(rawName);

            m_isFlags = false;

            m_enumValues = values;
        }
Exemple #4
0
        public EnumValue(XmlBindings.EnumValue xmlData, Overrides.XmlBindings.EnumValue overrides)
        {
            m_nativeName    = xmlData.Name;
            m_stylizedName  = Formatter.StylizeNameFromUnderscoreSeparators(xmlData.Name);
            m_shouldProject = true;

            if (overrides != null)
            {
                if (overrides.ProjectedNameOverride != null)
                {
                    m_stylizedName = overrides.ProjectedNameOverride;
                }

                m_shouldProject = overrides.ShouldProject;
            }

            m_valueExpression = GetValueExpression(xmlData);
        }
Exemple #5
0
        public EnumValue(XmlBindings.EnumValue xmlData, string containingEnumName, Overrides.XmlBindings.EnumValue overrides)
        {
            m_rawNameComponent = xmlData.Name;
            m_nativeName       = containingEnumName + "_" + m_rawNameComponent;
            m_stylizedName     = Formatter.StylizeNameFromUnderscoreSeparators(xmlData.Name);
            m_shouldProject    = true;
            m_valueExpression  = GetValueExpression(xmlData);

            if (overrides != null)
            {
                if (overrides.ProjectedNameOverride != null)
                {
                    m_stylizedName = overrides.ProjectedNameOverride;
                }

                if (overrides.ProjectedValueOverride != null)
                {
                    m_valueExpression = overrides.ProjectedValueOverride;
                }

                m_shouldProject = overrides.ShouldProject;
            }
        }
Exemple #6
0
        public Struct(Namespace parentNamespace, XmlBindings.Struct xmlData, Overrides.XmlBindings.Struct overrideData, Dictionary <string, QualifiableType> typeDictionary, OutputDataTypes outputDataTypes)
        {
            if (parentNamespace != null)
            {
                m_rawName = parentNamespace.ApiName + "_" + xmlData.Name;
                typeDictionary[parentNamespace.RawName + "::" + xmlData.Name] = this;
            }
            else
            {
                m_rawName = xmlData.Name;
                typeDictionary[xmlData.Name] = this;
            }

            m_stylizedName = Formatter.Prefix + Formatter.StylizeNameFromUnderscoreSeparators(xmlData.Name);

            if (overrideData != null)
            {
                if (overrideData.Guid != null)
                {
                    m_guid = overrideData.Guid;
                }

                if (overrideData.ProjectedNameOverride != null)
                {
                    if (overrideData.ShouldProject)
                    {
                        m_stylizedName = Formatter.Prefix + overrideData.ProjectedNameOverride;
                    }
                    else
                    {
                        m_stylizedName = overrideData.ProjectedNameOverride;
                    }
                }

                if (overrideData.IdlNamespaceQualifier != null)
                {
                    m_idlTypeNameQualifier = overrideData.IdlNamespaceQualifier;
                }
            }

            m_idlInterfaceName = "I" + m_stylizedName;

            m_structFields = new List <StructField>();
            foreach (XmlBindings.StructField structXmlData in xmlData.Fields)
            {
                m_structFields.Add(new StructField(structXmlData));
            }
            if (xmlData.Extends != null)
            {
                m_extendsTypeName = xmlData.Extends;

                // Note: the Extends field is already qualified. See D2DTypes.xml. Example: Extends="D2D1::IImage"
                QualifiableType parentType = typeDictionary[m_extendsTypeName];

                Struct parentAsStruct = parentType as Struct;         // Structs should only be deriving from struct types
                m_structFields.InsertRange(0, parentAsStruct.Fields);
                Debug.Assert(parentAsStruct.ExtendsTypeName == null); // Multiple levels in the hierarchy are not supported at this time.
            }

            // For the time being, unions are not output (they are very uncommon).
            bool usesUnions = xmlData.Fields == null;

            // Structs in the global namespace are defined as aliases only. By convention, only structs in a namespace are output.
            if (parentNamespace != null && !usesUnions && (overrideData != null && overrideData.ShouldProject))
            {
                outputDataTypes.AddStruct(this);
            }
        }