using System.Collections.Generic; namespace CppSharp.AST { /// /// Raw comment kind. /// public enum RawCommentKind { // Invalid comment. Invalid, // Any normal BCPL comments. OrdinaryBCPL, // Any normal C comment. OrdinaryC, // "/// stuff" BCPLSlash, // "//! stuff" BCPLExcl, // "/** stuff */" JavaDoc, // "/*! stuff */", also used by HeaderDoc Qt, // Two or more documentation comments merged together. Merged } /// /// Represents a raw C++ comment. /// public class RawComment { /// /// Kind of the comment. /// public RawCommentKind Kind; /// /// Raw text of the comment. /// public string Text; /// /// Brief text if it is a documentation comment. /// public string BriefText; /// /// Returns if the comment is invalid. /// public bool IsInvalid { get { return Kind == RawCommentKind.Invalid; } } /// /// Returns if the comment is ordinary (non-documentation). /// public bool IsOrdinary { get { return Kind == RawCommentKind.OrdinaryBCPL || Kind == RawCommentKind.OrdinaryC; } } /// /// Returns if this is a documentation comment. /// public bool IsDocumentation { get { return !IsInvalid && !IsOrdinary; } } /// /// Provides the full comment information. /// public FullComment FullComment; } /// /// Visitor for comments. /// public interface ICommentVisitor { T VisitBlockCommand(BlockCommandComment comment); T VisitParamCommand(ParamCommandComment comment); T VisitTParamCommand(TParamCommandComment comment); T VisitVerbatimBlock(VerbatimBlockComment comment); T VisitVerbatimLine(VerbatimLineComment comment); T VisitParagraphCommand(ParagraphComment comment); T VisitFull(FullComment comment); T VisitHTMLStartTag(HTMLStartTagComment comment); T VisitHTMLEndTag(HTMLEndTagComment comment); T VisitText(TextComment comment); T VisitInlineCommand(InlineCommandComment comment); T VisitVerbatimBlockLine(VerbatimBlockLineComment comment); } /// /// Any part of the comment. /// public abstract class Comment { protected Comment() { } public abstract void Visit(ICommentVisitor visitor); } #region Comments /// /// A full comment attached to a declaration, contains block content. /// public class FullComment : Comment { public List Blocks; public FullComment() { Blocks = new List(); } public override void Visit(ICommentVisitor visitor) { visitor.VisitFull(this); } } /// /// Block content (contains inline content). /// public abstract class BlockContentComment : Comment { } /// /// A command that has zero or more word-like arguments (number of /// word-like arguments depends on command name) and a paragraph as /// an argument (e. g., \brief). /// public class BlockCommandComment : BlockContentComment { public struct Argument { public string Text; } public uint CommandId; public CommentCommandKind CommandKind { get { return (CommentCommandKind) CommandId; } } public List Arguments; public BlockCommandComment() { Arguments = new List(); } public override void Visit(ICommentVisitor visitor) { visitor.VisitBlockCommand(this); } } /// /// Doxygen \param command. /// public class ParamCommandComment : BlockCommandComment { public const uint InvalidParamIndex = ~0U; public const uint VarArgParamIndex = ~0U/*InvalidParamIndex*/ - 1U; public enum PassDirection { In, Out, InOut, } public bool IsParamIndexValid { get { return ParamIndex != InvalidParamIndex; } } public bool IsVarArgParam { get { return ParamIndex == VarArgParamIndex; } } public uint ParamIndex; public PassDirection Direction; public override void Visit(ICommentVisitor visitor) { visitor.VisitParamCommand(this); } } /// /// Doxygen \tparam command, describes a template parameter. /// public class TParamCommandComment : BlockCommandComment { /// If this template parameter name was resolved (found in template parameter /// list), then this stores a list of position indexes in all template /// parameter lists. /// /// For example: /// \verbatim /// template class TT> /// void test(TT aaa); /// \endverbatim /// For C: Position = { 0 } /// For TT: Position = { 1 } /// For T: Position = { 1, 0 } public List Position; public TParamCommandComment() { Position = new List(); } public override void Visit(ICommentVisitor visitor) { visitor.VisitTParamCommand(this); } } /// /// A verbatim block command (e. g., preformatted code). Verbatim block /// has an opening and a closing command and contains multiple lines of /// text (VerbatimBlockLineComment nodes). /// public class VerbatimBlockComment : BlockCommandComment { public List Lines; public VerbatimBlockComment() { Lines = new List(); } public override void Visit(ICommentVisitor visitor) { visitor.VisitVerbatimBlock(this); } } /// /// A verbatim line command. Verbatim line has an opening command, a /// single line of text (up to the newline after the opening command) /// and has no closing command. /// public class VerbatimLineComment : BlockCommandComment { public string Text; public override void Visit(ICommentVisitor visitor) { visitor.VisitVerbatimLine(this); } } /// /// A single paragraph that contains inline content. /// public class ParagraphComment : BlockContentComment { public List Content; public bool IsWhitespace; public ParagraphComment() { Content = new List(); } public override void Visit(ICommentVisitor visitor) { visitor.VisitParagraphCommand(this); } } /// /// Inline content (contained within a block). /// public abstract class InlineContentComment : Comment { } /// /// Abstract class for opening and closing HTML tags. HTML tags are /// always treated as inline content (regardless HTML semantics); /// opening and closing tags are not matched. /// public abstract class HTMLTagComment : InlineContentComment { public string TagName; } /// /// An opening HTML tag with attributes. /// public class HTMLStartTagComment : HTMLTagComment { public struct Attribute { public string Name; public string Value; } public List Attributes; public HTMLStartTagComment() { Attributes = new List(); } public override void Visit(ICommentVisitor visitor) { visitor.VisitHTMLStartTag(this); } } /// /// A closing HTML tag. /// public class HTMLEndTagComment : HTMLTagComment { public override void Visit(ICommentVisitor visitor) { visitor.VisitHTMLEndTag(this); } } /// /// Plain text. /// public class TextComment : InlineContentComment { public string Text; public override void Visit(ICommentVisitor visitor) { visitor.VisitText(this); } } /// /// A command with word-like arguments that is considered inline content. /// public class InlineCommandComment : Comment { public struct Argument { public string Text; } public enum RenderKind { RenderNormal, RenderBold, RenderMonospaced, RenderEmphasized } public RenderKind Kind; public List Arguments; public InlineCommandComment() { Arguments = new List(); } public override void Visit(ICommentVisitor visitor) { visitor.VisitInlineCommand(this); } } /// /// A line of text contained in a verbatim block. /// public class VerbatimBlockLineComment : BlockCommandComment { public string Text; public override void Visit(ICommentVisitor visitor) { visitor.VisitVerbatimBlockLine(this); } } #endregion #region Commands /// /// Kinds of comment commands. /// Synchronized from "clang/AST/CommentCommandList.inc". /// public enum CommentCommandKind { A, Abstract, Addtogroup, Arg, Attention, Author, Authors, B, Brief, Bug, C, Callback, Category, Class, Classdesign, Coclass, Code, Endcode, Const, Constant, Copyright, Date, Defgroup, Dependency, Deprecated, Details, Discussion, Dot, Enddot, E, Em, Enum, Flbrace, Frbrace, Flsquare, Frsquare, Fdollar, Fn, Function, Functiongroup, Headerfile, Helper, Helperclass, Helps, Htmlonly, Endhtmlonly, Ingroup, Instancesize, Interface, Invariant, Latexonly, Endlatexonly, Li, Link, Slashlink, Mainpage, Manonly, Endmanonly, Method, Methodgroup, Msc, Endmsc, Name, Namespace, Note, Overload, Ownership, P, Par, Paragraph, Param, Performance, Post, Pre, Property, Protocol, Ref, Related, Relatedalso, Relates, Relatesalso, Remark, Remarks, Result, Return, Returns, Rtfonly, Endrtfonly, Sa, Section, Security, See, Seealso, Short, Since, Struct, Subpage, Subsection, Subsubsection, Superclass, Template, Templatefield, Textblock, Slashtextblock, Todo, Tparam, Typedef, Union, Var, Verbatim, Endverbatim, Version, Warning, Weakgroup, Xmlonly, Endxmlonly } #endregion }