コード例 #1
0
ファイル: Interface.cs プロジェクト: ben-sheeran/Win2D
        public Interface(Namespace parentNamespace, XmlBindings.Interface xmlData, Overrides.XmlBindings.Interface overrides, Dictionary<string, QualifiableType> typeDictionary)
        {
            Debug.Assert(xmlData.Name.StartsWith("I"));
            string unprefixed = xmlData.Name.Substring(1);
            m_stylizedName = Formatter.Prefix + unprefixed;

            m_innerName = "I" + parentNamespace.ApiName + unprefixed;

            m_nativeNameOfInheritanceParent = xmlData.Extends;

            if (overrides != null && overrides.IsProjectedAsAbstract)
            {
                m_stylizedName = "I" + Formatter.Prefix + unprefixed;
            }

            m_methods = new List<Method>();
            foreach (XmlBindings.Method xmlMethod in xmlData.Methods)
            {
                Method m = new Method(xmlMethod);
                m_methods.Add(m);
            }

            typeDictionary[parentNamespace.RawName + "::" + xmlData.Name] = this;

        }
コード例 #2
0
ファイル: Interface.cs プロジェクト: gfcprogramer/Win2D
        public Interface(Namespace parentNamespace, XmlBindings.Interface xmlData, Overrides.XmlBindings.Interface overrides, Dictionary<string, QualifiableType> typeDictionary)
        {
            Debug.Assert(xmlData.Name.StartsWith("I"));
            string unprefixed = xmlData.Name.Substring(1);
            m_stylizedName = Formatter.Prefix + unprefixed;

            m_innerName = "I" + parentNamespace.ApiName + unprefixed;

            if(overrides != null && overrides.IsProjectedAsAbstract)
            {
                m_stylizedName = "I" + Formatter.Prefix + unprefixed;
            }

            typeDictionary[parentNamespace.RawName + "::" + xmlData.Name] = this;

        }
コード例 #3
0
ファイル: Struct.cs プロジェクト: fengweijp/Win2D
        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);
            }
        }
コード例 #4
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);
            }
        }
コード例 #5
0
        public Enum(Namespace parentNamespace, string rootProjectedNamespace, 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));
            }

            Namespace = rootProjectedNamespace;

            bool shouldProject = false;

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

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

                if (overrides.Namespace != null)
                {
                    Namespace = Namespace + "." + overrides.Namespace;
                }
            }

            // 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);
            }
        }
コード例 #6
0
ファイル: Enum.cs プロジェクト: gfcprogramer/Win2D
        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, overridesEnumValue));
            }
            
            bool shouldProject = false;
            if(overrides != null)
            {
                shouldProject = overrides.ShouldProject;

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

            }

            // 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);
            }

        }