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