public static IEnumerable <APIConstant> Read(APIPage Parent, DoxygenEntity Entity) { XmlNode EnumNode = Entity.Node; using (XmlNodeList ValueNodeList = EnumNode.SelectNodes("enumvalue")) { foreach (XmlNode ValueNode in ValueNodeList) { string Name = ValueNode.SelectSingleNode("name").InnerText; APIConstant Constant = new APIConstantEnum(Parent, Entity, ValueNode, Name); yield return(Constant); } } }
public static List <APIMember> CreateChildren(APIPage Parent, IEnumerable <DoxygenEntity> Entities) { List <APIMember> Children = new List <APIMember>(); Dictionary <APIFunctionKey, List <DoxygenEntity> > PendingFunctionGroups = new Dictionary <APIFunctionKey, List <DoxygenEntity> >(); // List of autogenerated structs List <DoxygenEntity> GeneratedEntities = new List <DoxygenEntity>(); // Parse the entities foreach (DoxygenEntity Entity in Entities) { if (Entity.Kind == "class" || Entity.Kind == "struct" || Entity.Kind == "union") { if (Entity.Kind == "struct" && Entity.Name.Contains("_event") && Entity.Name.EndsWith("_Parms")) { GeneratedEntities.Add(Entity); } else { APIRecord Record = new APIRecord(Parent, Entity); Record.Children.AddRange(CreateChildren(Record, Entity.Members)); Children.Add(Record); } } else if (Entity.Kind == "function") { APIFunctionKey FunctionKey = APIFunctionKey.FromEntity(Parent, Entity); if (!Program.IgnoredFunctionMacros.Contains(FunctionKey.Name)) { List <DoxygenEntity> EntityList; if (!PendingFunctionGroups.TryGetValue(FunctionKey, out EntityList)) { EntityList = new List <DoxygenEntity>(); PendingFunctionGroups.Add(FunctionKey, EntityList); } EntityList.Add(Entity); } } else if (Entity.Kind == "variable") { if (IsConstantVariable(Entity)) { Children.Add(new APIConstantVariable(Parent, Entity)); } else { Children.Add(new APIVariable(Parent, Entity.Node)); } } else if (Entity.Kind == "typedef") { Children.Add(new APITypeDef(Parent, Entity)); } else if (Entity.Kind == "enum") { if (Entity.Name != null && Entity.Name.StartsWith("@")) { // It's an enum constant Children.AddRange(APIConstantEnum.Read(Parent, Entity)); } else { // It's an enum Children.Add(new APIEnum(Parent, Entity, Entity.Name)); } } } // Fixup the functions foreach (KeyValuePair <APIFunctionKey, List <DoxygenEntity> > PendingFunctionGroup in PendingFunctionGroups) { if (PendingFunctionGroup.Value.Count == 1) { APIFunction Function = new APIFunction(Parent, PendingFunctionGroup.Value[0], PendingFunctionGroup.Key); Children.Add(Function); } else { APIFunctionGroup FunctionGroup = new APIFunctionGroup(Parent, PendingFunctionGroup.Key, PendingFunctionGroup.Value); Children.Add(FunctionGroup); } } // Attach all the autogenerated structures to their parent functions foreach (DoxygenEntity Entity in GeneratedEntities) { if (!CreateParametersStruct(Parent, Children, Entity)) { APIRecord Record = new APIRecord(Parent, Entity); Record.Children.AddRange(CreateChildren(Record, Entity.Members)); Children.Add(Record); } } // Sort the children by name Children.Sort((x, y) => String.Compare(x.Name, y.Name)); return(Children); }
public static IEnumerable<APIConstant> Read(APIPage Parent, DoxygenEntity Entity) { XmlNode EnumNode = Entity.Node; using (XmlNodeList ValueNodeList = EnumNode.SelectNodes("enumvalue")) { foreach (XmlNode ValueNode in ValueNodeList) { string Name = ValueNode.SelectSingleNode("name").InnerText; APIConstant Constant = new APIConstantEnum(Parent, EnumNode, ValueNode, Name); yield return Constant; } } }