in tools/codegen/exe/Effect.cs [581:651]
private static List<Enum> ParseD2DEffectsEnums(List<string> pathsToHeaders, Dictionary<string, QualifiableType> typeDictionary)
{
List<Enum> d2dEnums = new List<Enum>();
foreach (var path in pathsToHeaders)
{
StreamReader reader = File.OpenText(path);
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.Contains("typedef enum") && line.Substring(line.Length - 4) != "PROP")
{
char[] separator = { ' ' };
string[] words = line.Split(separator, StringSplitOptions.RemoveEmptyEntries);
string enumName = words[words.Length - 1];
// Skip brace
reader.ReadLine();
List<EnumValue> enumValues = new List<EnumValue>();
while ((line = reader.ReadLine()) != "")
{
words = line.TrimEnd(',').Split(separator, StringSplitOptions.RemoveEmptyEntries);
// Looking for definitions of the form "EnumEntry = value"
if (words.Length == 3 &&
words[1] == "=" &&
!words[0].StartsWith("//") &&
!words[0].Contains("FORCE_DWORD"))
{
NumberStyles numberStyle = 0;
if (words[2].StartsWith("0x"))
{
words[2] = words[2].Substring(2);
numberStyle = NumberStyles.HexNumber;
}
int value;
if (!int.TryParse(words[2], numberStyle, null, out value))
{
value = enumValues.Count;
}
string nativeValueName = words[0];
Debug.Assert(nativeValueName.StartsWith("D2D1_"));
string rawValueNameComponent = nativeValueName.Substring(5);
enumValues.Add(new EnumValue(nativeValueName, rawValueNameComponent, value));
}
}
Debug.Assert(enumName.StartsWith("D2D1_"));
enumName = enumName.Substring(5);
Enum effectEnum;
string key = "D2D1::" + enumName;
if (typeDictionary.ContainsKey(key))
{
effectEnum = typeDictionary[key] as Enum;
}
else
{
effectEnum = new Enum(enumName, enumValues, typeDictionary);
}
d2dEnums.Add(effectEnum);
}
}
}
return d2dEnums;
}