Ejemplo n.º 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));
            }
        }
Ejemplo n.º 2
0
        public Namespace(XmlBindings.Namespace xmlData, Overrides.XmlBindings.Namespace overrides, 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, 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];
            }
        }