예제 #1
0
        public D2DTypes(XmlBindings.D2DTypes xmlData, Overrides.XmlBindings.Settings overrides, Dictionary<string, QualifiableType> typeDictionary, OutputDataTypes outputDataTypes)
        {
            const Namespace globalNamespace = null; // Using null as the namespace parameter indicates the global namespace.

            m_primitiveList = new List<Primitive>();
            foreach(XmlBindings.Primitive p in xmlData.Primitives)
            {
                Overrides.XmlBindings.Primitive overridePrimitive = null;
                if (overrides != null) overridePrimitive = overrides.Primitives.Find(x => x.Name == p.Name);

                m_primitiveList.Add(new Primitive(p, overridePrimitive, typeDictionary));
            }

            m_structList = new List<Struct>();
            foreach (XmlBindings.Struct s in xmlData.Structs)
            {
                Overrides.XmlBindings.Struct overrideStruct = null;
                if (overrides != null) overrideStruct = overrides.Structs.Find(x => x.Name == s.Name);

                m_structList.Add(new Struct(globalNamespace, s, overrideStruct, typeDictionary, outputDataTypes));
            }

            m_namespaceList = new List<Namespace>();
            foreach (XmlBindings.Namespace n in xmlData.Namespaces)
            {
                Overrides.XmlBindings.Namespace overrideNamespace = null;
                if (overrides != null) overrideNamespace = overrides.Namespaces.Find(x => x.Name == n.Name);

                m_namespaceList.Add(new Namespace(n, overrideNamespace, overrides.RootNamespace.Value, typeDictionary, outputDataTypes));
            }
        }
예제 #2
0
        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;

        }
예제 #3
0
파일: Enum.cs 프로젝트: gfcprogramer/Win2D
        static string GetValueExpression(XmlBindings.EnumValue xmlData)
        {
            //
            // Value and NumericalValue seem like they should be the same, but they're not. 
            //
            // Value may be an int literal, or some other symbol.
            // NumericalValue is always an int literal (may be hex or dec)
            //
            // NumericalValue is used for Direct2D's internal codegen, in cases where the 
            // symbol used for Value can't be referenced in the event manifest. 
            //
            // And so, the int literal is decided according to the following priority
            // 1. NumericalValue if avail
            // 2. Value, must always be parseable as int literal
            //

            if (xmlData.NumericalValue != null)
            {
                return xmlData.NumericalValue;
            }
            else
            {
                Debug.Assert(xmlData.Value != null);
                return xmlData.Value;
            }
        }
예제 #4
0
        public Namespace(XmlBindings.Namespace xmlData, Overrides.XmlBindings.Namespace overrides, string rootProjectedNamespace, Dictionary<string, QualifiableType> typeDictionary, OutputDataTypes outputDataTypes)
        {
            m_rawName = xmlData.Name;

            if (overrides != null && overrides.NameOverride != null)
            {
                m_apiName = overrides.NameOverride;
            }
            else
            {
                m_apiName = xmlData.Name;
            }

            m_enums = new List<Enum>();
            foreach (XmlBindings.Enum enumXml in xmlData.Enums)
            {
                Overrides.XmlBindings.Enum overridesEnum = null;
                if (overrides != null) overridesEnum = overrides.Enums.Find(x => x.Name == enumXml.Name);

                m_enums.Add(new Enum(this, rootProjectedNamespace, enumXml, overridesEnum, typeDictionary, outputDataTypes));
            }

            m_structs = new List<Struct>();
            foreach (XmlBindings.Struct structXml in xmlData.Structs)
            {
                Overrides.XmlBindings.Struct overridesStruct = null;
                if (overrides != null) overridesStruct = overrides.Structs.Find(x => x.Name == structXml.Name);

                m_structs.Add(new Struct(this, structXml, overridesStruct, typeDictionary, outputDataTypes));
            }

            m_interfaces = new List<Interface>();
            foreach (XmlBindings.Interface interfaceXml in xmlData.Interfaces)
            {
                Overrides.XmlBindings.Interface overridesInterface = null;
                if (overrides != null) overridesInterface = overrides.Interfaces.Find(x => x.Name == interfaceXml.Name);

                m_interfaces.Add(new Interface(this, interfaceXml, overridesInterface, typeDictionary));
            }

            foreach (XmlBindings.Typedef t in xmlData.Typedefs)
            {
                // In the types XML, often times types are declared as one type,
                // then typedefs to something else, and referenced thereafter
                // as that second type. And so, typedefs must be handled here.
                //
                // In the XML, the 'Name' field in each typedef is unqualified,
                // but the 'From' field is qualified.
                // For example, <Typedef Name="COLOR_F" From="D2D::COLOR_F"/>
                //
                // So, the entries are added to the type dictionary here
                // under the qualified name.
                //
                string qualified = xmlData.Name + "::" + t.Name;
                typeDictionary[qualified] = typeDictionary[t.From];
            }
        }
예제 #5
0
        public Primitive(XmlBindings.Primitive xmlData, Overrides.XmlBindings.Primitive overrides, Dictionary<string, QualifiableType> typeDictionary)
        {
            m_name = xmlData.Name;
            typeDictionary[m_name] = this;

            m_projectedName = m_name;
            if(overrides != null && overrides.ProjectedNameOverride != null)
            {
                m_projectedName = overrides.ProjectedNameOverride;
            }
        }
예제 #6
0
파일: Struct.cs 프로젝트: fengweijp/Win2D
        public StructField(XmlBindings.StructField xmlData)
        {
            // The projected classes use a private member variable for each
            // attribute. These are given a prefix, as per convention.
            if (xmlData.Name.StartsWith("_"))
            {
                m_privateMemberName = "m" + xmlData.Name;
            }
            else
            {
                m_privateMemberName = "m_" + xmlData.Name;
            }
            m_propertyName = Formatter.StylizeWithCapitalLeadingLetter(xmlData.Name);

            m_typeName = xmlData.Type;
        }
예제 #7
0
        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;

        }
예제 #8
0
파일: Enum.cs 프로젝트: gfcprogramer/Win2D
        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);

        }
예제 #9
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);
            }
        }
예제 #10
0
                public Parameter(XmlBindings.Parameter xmlData)
                {
                    m_name = xmlData.Name;

                    m_nativeTypeName = xmlData.Type;

                    m_form = xmlData.Form;

                    m_isArray = xmlData.IsArray;
                }
예제 #11
0
            public Method(XmlBindings.Method xmlData)
            {
                m_name = xmlData.Name;
                m_nativeReturnType = xmlData.Return;

                m_parameters = new List<Parameter>();
                foreach (XmlBindings.Parameter parameterXml in xmlData.Parameters)
                {
                    Parameter p = new Parameter(parameterXml);
                    m_parameters.Add(p);
                }

                m_isOverload = xmlData.OverloadId != null;

                m_isConst = xmlData.IsConst;
            }
예제 #12
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);
            }

        }