public APIFunctionIndex(APIPage InParent, IEnumerable<APIFunction> Functions) : base(InParent, "Functions", "Alphabetical list of all functions")
		{
			// Create the operators category
			Category OperatorsCategory = new Category("Operators");
			Categories.Add(OperatorsCategory);

			// Separate out all the functions by their unique names
			Dictionary<APIFunctionKey, List<APIFunction>> KeyedFunctions = new Dictionary<APIFunctionKey, List<APIFunction>>();
			foreach(APIFunction Function in Functions)
			{
				APIFunctionKey Key = new APIFunctionKey(Function.FullName, Function.FunctionType);
				Utility.AddToDictionaryList(Key, Function, KeyedFunctions);
			}

			// Build a list of all the members, creating function groups where necessary
			List<KeyValuePair<APIFunctionKey, APIMember>> KeyedMembers = new List<KeyValuePair<APIFunctionKey, APIMember>>();
			foreach (KeyValuePair<APIFunctionKey, List<APIFunction>> KeyedFunction in KeyedFunctions)
			{
				if (KeyedFunction.Value.Count == 1)
				{
					KeyedMembers.Add(new KeyValuePair<APIFunctionKey,APIMember>(KeyedFunction.Key, KeyedFunction.Value[0]));
				}
				else
				{
					// Check if all the members have the same function group
					APIFunctionGroup FunctionGroup = KeyedFunction.Value[0].Parent as APIFunctionGroup;
					for(int Idx = 1; Idx < KeyedFunction.Value.Count; Idx++)
					{
						if(KeyedFunction.Value[Idx].Parent != FunctionGroup)
						{
							FunctionGroup = null;
							break;
						}
					}

					// If there was no common function group, create a new one
					if (FunctionGroup == null)
					{
						FunctionGroup = new APIFunctionGroup(this, KeyedFunction.Key, KeyedFunction.Value);
						FunctionGroups.Add(FunctionGroup);
					}

					// Add the function group to the member list
					KeyedMembers.Add(new KeyValuePair<APIFunctionKey, APIMember>(KeyedFunction.Key, FunctionGroup));
				}
			}

			// Separate all the functions into different categories
			foreach (KeyValuePair<APIFunctionKey, APIMember> KeyedMember in KeyedMembers)
			{
				if (KeyedMember.Key.Type == APIFunctionType.UnaryOperator || KeyedMember.Key.Type == APIFunctionType.BinaryOperator)
				{
					OperatorsCategory.Entries.Add(new Entry(KeyedMember.Value));
				}
				else
				{
					AddToDefaultCategory(new Entry(KeyedMember.Value));
				}
			}
		}
Example #2
0
        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.Node));
                }
                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;
        }
Example #3
0
        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);
        }
Example #4
0
        public APIFunctionIndex(APIPage InParent, IEnumerable <APIFunction> Functions) : base(InParent, "Functions", "Alphabetical list of all functions")
        {
            // Create the operators category
            Category OperatorsCategory = new Category("Operators");

            Categories.Add(OperatorsCategory);

            // Separate out all the functions by their unique names
            Dictionary <APIFunctionKey, List <APIFunction> > KeyedFunctions = new Dictionary <APIFunctionKey, List <APIFunction> >();

            foreach (APIFunction Function in Functions)
            {
                APIFunctionKey Key = new APIFunctionKey(Function.FullName, Function.FunctionType);
                Utility.AddToDictionaryList(Key, Function, KeyedFunctions);
            }

            // Build a list of all the members, creating function groups where necessary
            List <KeyValuePair <APIFunctionKey, APIMember> > KeyedMembers = new List <KeyValuePair <APIFunctionKey, APIMember> >();

            foreach (KeyValuePair <APIFunctionKey, List <APIFunction> > KeyedFunction in KeyedFunctions)
            {
                if (KeyedFunction.Value.Count == 1)
                {
                    KeyedMembers.Add(new KeyValuePair <APIFunctionKey, APIMember>(KeyedFunction.Key, KeyedFunction.Value[0]));
                }
                else
                {
                    // Check if all the members have the same function group
                    APIFunctionGroup FunctionGroup = KeyedFunction.Value[0].Parent as APIFunctionGroup;
                    for (int Idx = 1; Idx < KeyedFunction.Value.Count; Idx++)
                    {
                        if (KeyedFunction.Value[Idx].Parent != FunctionGroup)
                        {
                            FunctionGroup = null;
                            break;
                        }
                    }

                    // If there was no common function group, create a new one
                    if (FunctionGroup == null)
                    {
                        FunctionGroup = new APIFunctionGroup(this, KeyedFunction.Key, KeyedFunction.Value);
                        FunctionGroups.Add(FunctionGroup);
                    }

                    // Add the function group to the member list
                    KeyedMembers.Add(new KeyValuePair <APIFunctionKey, APIMember>(KeyedFunction.Key, FunctionGroup));
                }
            }

            // Separate all the functions into different categories
            foreach (KeyValuePair <APIFunctionKey, APIMember> KeyedMember in KeyedMembers)
            {
                if (KeyedMember.Key.Type == APIFunctionType.UnaryOperator || KeyedMember.Key.Type == APIFunctionType.BinaryOperator)
                {
                    OperatorsCategory.Entries.Add(new Entry(KeyedMember.Value));
                }
                else
                {
                    AddToDefaultCategory(new Entry(KeyedMember.Value));
                }
            }
        }