in tools/codegen/exe/Struct.cs [71:134]
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);
}
}