Example #1
0
 public static APIFunctionKey FromEntity(APIPage Parent, DoxygenEntity Entity)
 {
     string Name = Entity.Name;
     if (Parent != null && Parent is APIRecord)
     {
         if (Name == Parent.Name && (Parent is APIRecord) && Entity.Node.Attributes["static"].Value != "yes")
         {
             return new APIFunctionKey(Name, APIFunctionType.Constructor);
         }
         else if (Name == "~" + Parent.Name)
         {
             return new APIFunctionKey(Name, APIFunctionType.Destructor);
         }
     }
     if (Name.StartsWith("operator") && Name.Length > 8 && !Char.IsLetterOrDigit(Name[8]) && Name[8] != '_')
     {
         int NumParams = 0;
         using (XmlNodeList ParamNodeList = Entity.Node.SelectNodes("param"))
         {
             foreach (XmlNode ParamNode in ParamNodeList)
             {
                 NumParams++;
             }
         }
         if ((Parent is APIRecord) && Entity.Node.Attributes["static"].Value != "yes")
         {
             NumParams++;
         }
         return new APIFunctionKey(Name, (NumParams == 1) ? APIFunctionType.UnaryOperator : APIFunctionType.BinaryOperator);
     }
     return new APIFunctionKey(Name, APIFunctionType.Normal);
 }
Example #2
0
		public static DoxygenEntity FromXml(DoxygenModule InModule, string Name, XmlNode Node, XmlNode NamespaceNode)
		{
			DoxygenEntity Entity = new DoxygenEntity(InModule);
			Entity.Id = Node.Attributes["id"].Value;
			Entity.Name = Name;
			Entity.Kind = Node.Attributes["kind"].Value;
			Entity.Node = Node;
			Entity.NamespaceNode = NamespaceNode;

			XmlNode LocationNode = Entity.Node.SelectSingleNode("location");
			if (LocationNode != null)
			{
				Entity.File = LocationNode.Attributes["file"].Value.Replace('/', '\\');

				XmlAttribute LineAttribute = LocationNode.Attributes["line"];
				if (LineAttribute != null)
				{
					Entity.Line = int.Parse(LineAttribute.Value);
					Entity.Column = int.Parse(LocationNode.Attributes["column"].Value);
				}

				XmlAttribute BodyFileAttribute = LocationNode.Attributes["bodyfile"];
				XmlAttribute BodyStartAttribute = LocationNode.Attributes["bodystart"];
				XmlAttribute BodyEndAttribute = LocationNode.Attributes["bodyend"];
				if (BodyFileAttribute != null && BodyStartAttribute != null && BodyEndAttribute != null)
				{
					Entity.BodyFile = BodyFileAttribute.Value.Replace('/', '\\');
					Entity.BodyStart = Int32.Parse(BodyStartAttribute.Value);
					Entity.BodyEnd = Int32.Parse(BodyEndAttribute.Value);
				}
			}
			return Entity;
		}
 public APIEventParameters(APIPage InParent, APIMember InAttachedTo, DoxygenEntity InEntity)
     : base(InParent, InEntity.Name)
 {
     AttachedTo = InAttachedTo;
     Entity = InEntity;
     AddRefLink(Entity.Id, this);
 }
		public APIRecord(APIPage InParent, DoxygenEntity InEntity)
			: base(InParent, GetNameFromNode(InEntity.Node))
		{
			// Set all the readonly vars
			Entity = InEntity;
			Node = InEntity.Node;
			RefId = Node.Attributes["id"].InnerText;
			Protection = ParseProtection(Node);

			// Set the record type
			switch (Node.Attributes["kind"].Value)
			{
				case "class":
					RecordType = Name.StartsWith("I")? APIRecordType.Interface : APIRecordType.Class;
					break;
				case "struct":
					RecordType = APIRecordType.Struct;
					break;
				case "union":
					RecordType = APIRecordType.Union;
					break;
			}

			// Register the record for incoming links
			AddRefLink(RefId, this);

			// Add it to the template list
			if(Node.SelectSingleNode("templateparamlist") != null)
			{
				bIsTemplate = true;
				bIsTemplateSpecialization = Name.Contains('<');
				if(!bIsTemplateSpecialization && !TemplateRecords.ContainsKey(FullName)) TemplateRecords.Add(FullName, this);
			}
        }
Example #5
0
		public APITypeDef(APIPage InParent, DoxygenEntity InEntity) 
			: base(InParent, InEntity.Node.SelectSingleNode("name").InnerText)
		{
			Entity = InEntity;
			Node = Entity.Node;
			Id = Node.Attributes["id"].Value;
			AddRefLink(Id, this);
		}
Example #6
0
		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 DoxygenEntity FromXml(DoxygenModule InModule, string Name, XmlNode Node, XmlNode NamespaceNode)
        {
            DoxygenEntity Entity = new DoxygenEntity(InModule);

            Entity.Id            = Node.Attributes["id"].Value;
            Entity.Name          = Name;
            Entity.Kind          = Node.Attributes["kind"].Value;
            Entity.Node          = Node;
            Entity.NamespaceNode = NamespaceNode;

            XmlNode LocationNode = Entity.Node.SelectSingleNode("location");

            if (LocationNode != null)
            {
                Entity.File = LocationNode.Attributes["file"].Value.Replace('/', '\\');

                // Fix Doxygen's inconsistent pathing.
                if (!Entity.File.StartsWith(InModule.BaseSrcDir))
                {
                    Entity.File = InModule.BaseSrcDir + "Source\\" + Entity.File;
                }

                XmlAttribute LineAttribute = LocationNode.Attributes["line"];
                if (LineAttribute != null)
                {
                    Entity.Line   = int.Parse(LineAttribute.Value);
                    Entity.Column = int.Parse(LocationNode.Attributes["column"].Value);
                }

                XmlAttribute BodyFileAttribute  = LocationNode.Attributes["bodyfile"];
                XmlAttribute BodyStartAttribute = LocationNode.Attributes["bodystart"];
                XmlAttribute BodyEndAttribute   = LocationNode.Attributes["bodyend"];
                if (BodyFileAttribute != null && BodyStartAttribute != null && BodyEndAttribute != null)
                {
                    Entity.BodyFile = BodyFileAttribute.Value.Replace('/', '\\');
                    // Fix Doxygen's inconsistent pathing.
                    if (!Entity.BodyFile.StartsWith(InModule.BaseSrcDir))
                    {
                        Entity.BodyFile = InModule.BaseSrcDir + "Source\\" + Entity.BodyFile;
                    }
                    Entity.BodyStart = Int32.Parse(BodyStartAttribute.Value);
                    Entity.BodyEnd   = Int32.Parse(BodyEndAttribute.Value);
                }
            }
            return(Entity);
        }
 protected static void ReadEnumMembers(DoxygenModule Module, DoxygenCompound Compound, string NamePrefix, DoxygenEntity Parent, XmlNode NamespaceNode, List <DoxygenEntity> Entities)
 {
     using (XmlNodeList NodeList = Compound.Node.SelectNodes("sectiondef/memberdef"))
     {
         foreach (XmlNode Node in NodeList)
         {
             XmlNode NameNode = Node.SelectSingleNode("name");
             if (NameNode.InnerText.Length > 0)
             {
                 string        Name   = NamePrefix + NameNode.InnerText;
                 DoxygenEntity Entity = DoxygenEntity.FromXml(Module, Name, Node, NamespaceNode);
                 Entity.Parent = Parent;
                 Entities.Add(Entity);
             }
         }
     }
 }
Example #9
0
		public APIEnum(APIPage InParent, DoxygenEntity InEntity, string InName)
			: base(InParent, GetCleanName(InName))
        {
			// Set the defaults
			Entity = InEntity;
			Node = InEntity.Node;
			Protection = ParseProtection(Node);

			// Read the values
			using(XmlNodeList ValueNodeList = Node.SelectNodes("enumvalue"))
			{
				foreach(XmlNode ValueNode in ValueNodeList)
				{
					APIEnumValue Value = new APIEnumValue(ValueNode);
					AddRefLink(Value.Id, this);
					Values.Add(Value);
				}
			}

			// Add it as a link target
			AddRefLink(Node.Attributes["id"].InnerText, this);
        }
Example #10
0
 public static bool IsConstantVariable(DoxygenEntity Entity)
 {
     return Entity.Node.Attributes["static"].Value == "yes";
 }
Example #11
0
        public static bool CreateParametersStruct(APIPage Parent, List<APIMember> Children, DoxygenEntity Entity)
        {
            string Name = Entity.Name;
            int ClassMaxIdx = Name.IndexOf("_event");
            if (ClassMaxIdx == -1) return false;

            string ClassName = Name.Substring(0, ClassMaxIdx);
            APIRecord ClassRecord = Children.OfType<APIRecord>().FirstOrDefault(x => x.Name.EndsWith(ClassName) && x.Name.Length == ClassName.Length + 1);
            if (ClassRecord == null) return false;

            if (!Name.EndsWith("_Parms")) return false;
            int MemberMinIdx = ClassMaxIdx + 6;
            int MemberMaxIdx = Name.Length - 6;
            string MemberName = Name.Substring(MemberMinIdx, MemberMaxIdx - MemberMinIdx);

            APIRecord Delegate = Children.OfType<APIRecord>().FirstOrDefault(x => x.Name == "F" + MemberName);
            if(Delegate != null)
            {
                Delegate.DelegateEventParameters = new APIEventParameters(Parent, Delegate, Entity);
                Children.Add(Delegate.DelegateEventParameters);
                return true;
            }

            APIFunction Function = ClassRecord.Children.OfType<APIFunction>().FirstOrDefault(x => x.Name == MemberName);
            if (Function != null)
            {
                Function.EventParameters = new APIEventParameters(Parent, Function, Entity);
                Children.Add(Function.EventParameters);
                return true;
            }

            return false;
        }
Example #12
0
        public static bool FilterEntity(DoxygenEntity Entity, string Filter)
        {
            // Check the module matches
            if(!Filter.StartsWith(Entity.Module.Name + "/", StringComparison.InvariantCultureIgnoreCase))
            {
                return false;
            }

            // Remove the module from the start of the filter
            string PathFilter = Filter.Substring(Entity.Module.Name.Length + 1);

            // Now check what sort of filter it is
            if (PathFilter == "...")
            {
                // Let anything through matching the module name, regardless of which subdirectory it's in (maybe it doesn't match a normal subdirectory at all)
                return true;
            }
            else if(PathFilter.EndsWith("/..."))
            {
                // Remove the ellipsis
                PathFilter = PathFilter.Substring(0, PathFilter.Length - 3);

                // Check the entity starts with the base directory
                if(!Entity.File.StartsWith(Entity.Module.BaseSrcDir, StringComparison.InvariantCultureIgnoreCase))
                {
                    return false;
                }

                // Get the entity path, ignoring the
                int EntityMinIdx = Entity.File.IndexOf('\\', Entity.Module.BaseSrcDir.Length);
                string EntityPath = Entity.File.Substring(EntityMinIdx + 1).Replace('\\', '/');

                // Get the entity path. Ignore the first directory under the module directory, as it'll be public/private/classes etc...
                return EntityPath.StartsWith(PathFilter, StringComparison.InvariantCultureIgnoreCase);
            }
            else
            {
                // Get the full entity name
                string EntityFullName = Entity.Name;
                for (DoxygenEntity ParentEntity = Entity.Parent; ParentEntity != null; ParentEntity = ParentEntity.Parent)
                {
                    EntityFullName = ParentEntity.Name + "::" + EntityFullName;
                }

                // Compare it to the filter
                return Filter == (Entity.Module.Name + "/" + EntityFullName);
            }
        }
Example #13
0
 public APIConstantVariable(APIPage InParent, DoxygenEntity InEntity)
     : base(InParent, InEntity.Name)
 {
     Entity = InEntity;
     Node = Entity.Node;
 }
Example #14
0
        public APIFunction(APIPage InParent, DoxygenEntity InEntity, APIFunctionKey InKey, string InLinkPath)
            : base(InParent, InEntity.Name, InLinkPath)
        {
            Entity = InEntity;
            Node = Entity.Node;

            Protection = ParseProtection(Node);
            FunctionType = InKey.Type;
            AddRefLink(Entity.Node.Attributes["id"].Value, this);

            bIsTemplateSpecialization = Name.Contains('<');
            if (Node.SelectSingleNode("templateparamlist") != null && !bIsTemplateSpecialization && !TemplateFunctions.ContainsKey(FullName))
            {
                TemplateFunctions.Add(FullName, this);
            }
        }
        public static DoxygenModule TryRead(string Name, string BaseSrcDir, string BaseXmlDir)
        {
            // Load the index
            XmlDocument Document;

            if (!TryReadXmlDocument(Path.Combine(BaseXmlDir, "index.xml"), out Document))
            {
                return(null);
            }

            // Create all the compound entities
            List <string> CompoundIdList = new List <string>();

            using (XmlNodeList NodeList = Document.SelectNodes("doxygenindex/compound"))
            {
                foreach (XmlNode Node in NodeList)
                {
                    CompoundIdList.Add(Node.Attributes["refid"].Value);
                }
            }

            // Read all the compound id nodes
            List <DoxygenCompound> Compounds = new List <DoxygenCompound>();

            foreach (string CompoundId in CompoundIdList)
            {
                string      EntityPath = Path.Combine(BaseXmlDir, CompoundId + ".xml");
                XmlDocument EntityDocument;
                if (TryReadXmlDocument(EntityPath, out EntityDocument))
                {
                    Compounds.Add(DoxygenCompound.FromXml(EntityDocument.SelectSingleNode("doxygen/compounddef")));
                }
                else
                {
                    Console.WriteLine("Couldn't read entity document: '{0}'", EntityPath);
                }
            }

            // Create the module
            DoxygenModule Module = new DoxygenModule(Name, BaseSrcDir);

            // Create all the other namespaces
            Dictionary <string, DoxygenEntity> Scopes = new Dictionary <string, DoxygenEntity>();

            foreach (DoxygenCompound Compound in Compounds)
            {
                if (Compound.Kind == "namespace")
                {
                    ReadMembers(Module, Compound, Compound.Name + "::", null, Compound.Node, Module.Entities);
                }
                else if (Compound.Kind == "class" || Compound.Kind == "struct" || Compound.Kind == "union")
                {
                    DoxygenEntity Entity = DoxygenEntity.FromXml(Module, Compound.Name, Compound.Node, null);
                    ReadMembers(Module, Compound, "", Entity, null, Entity.Members);
                    Scopes.Add(Entity.Name, Entity);
                }
            }

            // Go back over all the scopes and fixup their parents
            foreach (KeyValuePair <string, DoxygenEntity> Scope in Scopes)
            {
                int ScopeIdx = Scope.Key.LastIndexOf("::");
                if (ScopeIdx != -1 && Scopes.TryGetValue(Scope.Key.Substring(0, ScopeIdx), out Scope.Value.Parent))
                {
                    Scope.Value.Parent.Members.Add(Scope.Value);
                }
                else
                {
                    Module.Entities.Add(Scope.Value);
                }
            }

            // Create the module
            return(Module);
        }
Example #16
0
        public void WriteReferencesSection(UdnWriter Writer, DoxygenEntity Entity)
        {
            List<UdnListItem> Items = new List<UdnListItem>();

            // Get the module
            for (APIPage Page = this; Page != null; Page = Page.Parent)
            {
                APIModule Module = Page as APIModule;
                if(Module != null)
                {
                    Items.Add(new UdnListItem("Module", String.Format("[{0}]({1})", Module.Name, Module.LinkPath), null));
                    break;
                }
            }

            // Get the header file
            if (Entity.File != null)
            {
                string NormalizedFileName = GetNormalizedFileName(Entity.File);
                if (NormalizedFileName != null)
                {
                    Items.Add(new UdnListItem("Header", Utility.EscapeText(NormalizedFileName), null));
                }
            }

            // Get the source file
            if(Entity.BodyFile != null && Entity.BodyFile != Entity.File)
            {
                string NormalizedFileName = GetNormalizedFileName(Entity.BodyFile);
                if (NormalizedFileName != null)
                {
                    Items.Add(new UdnListItem("Source", Utility.EscapeText(NormalizedFileName), null));
                }
            }

            // Write the section
            if(Items.Count > 0)
            {
                Writer.EnterSection("references", "References");
                Writer.WriteList(Items);
                Writer.LeaveSection();
            }
        }
Example #17
0
 public APIEnum(APIPage InParent, DoxygenEntity InEntity, string InName)
     : this(InParent, InEntity.Node, InName)
 {
 }
Example #18
0
 public APIFunction(APIPage InParent, DoxygenEntity InEntity, APIFunctionKey InKey)
     : this(InParent, InEntity, InKey, Utility.MakeLinkPath(InParent.LinkPath, InKey.GetLinkName()))
 {
 }
		public string RelativeNameFrom(DoxygenEntity Scope)
		{
			string Result = Name;
			for (DoxygenEntity Next = Parent; Next != Scope; Next = Next.Parent)
			{
				Result = Next.Name + "::" + Result;
			}
			return Result;
		}
Example #20
0
 public APIConstant(APIPage InParent, DoxygenEntity InEntity, string InName)
     : base(InParent, InName)
 {
     Entity = InEntity;
 }
Example #21
0
 public APIFunction(APIPage InParent, DoxygenEntity InEntity, APIFunctionKey InKey)
     : this(InParent, InEntity.Node, InKey)
 {
 }
		protected static void ReadMembers(DoxygenModule Module, DoxygenCompound Compound, string NamePrefix, DoxygenEntity Parent, XmlNode NamespaceNode, List<DoxygenEntity> Entities)
		{
			using (XmlNodeList NodeList = Compound.Node.SelectNodes("sectiondef/memberdef"))
			{
				foreach (XmlNode Node in NodeList)
				{
					XmlNode NameNode = Node.SelectSingleNode("name");
					string Name = NamePrefix + NameNode.InnerText;
					DoxygenEntity Entity = DoxygenEntity.FromXml(Module, Name, Node, NamespaceNode);
					Entity.Parent = Parent;
					Entities.Add(Entity);
				}
			}
		}
Example #23
0
 public APIConstantEnum(APIPage InParent, DoxygenEntity InEnumEntity, XmlNode InValueNode, string InName)
     : base(InParent, InEnumEntity, InName)
 {
     EnumNode = InEnumEntity.Node;
     ValueNode = InValueNode;
 }