================
@@ -4204,6 +4268,187 @@ def set_property(self, property, value):
cursor_visit_callback = CFUNCTYPE(c_int, Cursor, Cursor, py_object)
fields_visit_callback = CFUNCTYPE(c_int, Cursor, py_object)
+
+class CXTranslationUnitImpl(Structure):
+ pass # opaque structure
+
+
+CXTranslationUnit = POINTER(CXTranslationUnitImpl)
+
+
+class Comment(Structure):
+ _fields_ = [("ASTNode", c_void_p), ("TranslationUnit", CXTranslationUnit)]
+
+ def get_text(self):
+ return conf.lib.clang_TextComment_getText(self)
+
+ @property
+ def kind(self):
+ """Return the kind of this comment."""
+ kind_id = conf.lib.clang_Comment_getKind(self)
+ return CommentKind.from_id(kind_id)
+
+ def num_children(self):
+ """Get number of child nodes."""
+ return conf.lib.clang_Comment_getNumChildren(self)
+
+ def get_children(self):
+ """Return an iterator for accessing the children of this comment."""
+
+ def cast_child(child):
+ if child.kind == CommentKind.INLINECOMMAND:
+ child.__class__ = InlineCommand
+ if child.kind == CommentKind.HTMLSTARTTAG:
+ child.__class__ = HTMLComment
+ if child.kind == CommentKind.HTMLENDTAG:
+ child.__class__ = HTMLComment
+ if child.kind == CommentKind.BLOCKCOMMAND:
+ child.__class__ = BlockCommandComment
+ if child.kind == CommentKind.PARAMCOMMAND:
+ child.__class__ = ParamCommandComment
+ if child.kind == CommentKind.TPARAMCOMMAND:
+ child.__class__ = TParamCommandComment
+ if child.kind == CommentKind.VERBATIMBLOCKLINE:
+ child.__class__ = VerbatimBlockLineComment
+ if child.kind == CommentKind.VERBATIMLINE:
+ child.__class__ = VerbatimLineComment
+ if child.kind == CommentKind.FULLCOMMENT:
+ child.__class__ = FullComment
+ # if child.kind == CommentKind.PARAGRAPH:
+ # if child.kind == CommentKind.VERBATIMBLOCKCOMMAND:
+ return child
+
+ return (
+ cast_child(conf.lib.clang_Comment_getChild(self, i))
+ for i in range(self.num_children())
+ )
+
+ def is_whitespace(self):
+ """Check if all paragraph nodes are space or empty."""
+ return conf.lib.clang_Comment_isWhitespace(self)
+
+
+class InlineCommand(Comment):
+ def __init__(self):
+ super().__init__()
+
+ def has_trailing_newline(self):
+ return conf.lib.clang_InlineContentComment_hasTrailingNewline(self)
+
+ def get_command_name(self):
+ return conf.lib.clang_InlineCommandComment_getCommandName(self)
+
+ def render_kind(self):
+ kind = conf.lib.clang_InlineCommandComment_getRenderKind(self)
+ return CommentInlineCommandRenderKind.from_id(kind)
+
+ def get_num_args(self):
+ conf.lib.clang_InlineCommandComment_getNumArgs(self)
+
+ def get_args(self):
+ return (
+ conf.lib.clang_InlineCommandComment_getArgText(self, i)
+ for i in range(self.get_num_args())
+ )
+
+
+class HTMLComment(Comment):
+ def get_tag_name(self):
+ return conf.lib.clang_HTMLTagComment_getTagName(self)
+
+ def is_self_closing(self):
+ return conf.lib.clang_HTMLStartTagComment_isSelfClosing(self)
+
+ def get_num_attrs(self):
+ return conf.lib.clang_HTMLStartTag_getNumAttrs(self)
+
+ def get_attrs(self):
+ return (
+ conf.lib.clang_HTMLStartTag_getAttrName(self, i)
+ for i in range(self.get_num_attrs())
+ )
+
+ def get_attr_values(self):
+ return (
+ conf.lib.clang_HTMLStartTag_getAttrValue(self, i)
+ for i in range(self.get_num_attrs())
+ )
+
+
+class BlockCommandComment(Comment):
+ def get_command_name(self):
+ return conf.lib.clang_BlockCommandComment_getCommandName(self)
+
+ def get_num_args(self):
+ return conf.lib.clang_BlockCommandComment_getNumArgs(self)
+
+ def get_args(self):
+ return (
+ conf.lib.clang_BlockCommandComment_getArgText(self, i)
+ for i in range(self.get_num_args())
+ )
+
+ def get_paragraph(self):
+ return conf.lib.clang_BlockCommandComment_getParagraph(self)
+
+
+class ParamCommandComment(Comment):
+ def get_param_name(self):
+ return conf.lib.clang_ParamCommandComment_getParamName(self)
+
+ def is_param_index_valid(self):
+ return conf.lib.clang_ParamCommandComment_isParamIndexValid(self)
+
+ def get_param_index(self):
+ return conf.lib.clang_ParamCommandComment_getParamIndex(self)
+
+ def is_direction_explicit(self):
+ return conf.lib.clang_ParamCommandComment_isDirectionExplicit(self)
+
+ def get_direction(self):
+ return conf.lib.clang_ParamCommandComment_getDirection(self)
+
+
+class TParamCommandComment(Comment):
+ def get_param_name(self):
+ return conf.lib.clang_TParamCommandComment_getParamName(self)
+
+ def is_param_position_valid(self):
+ return conf.lib.clang_TParamCommandComment_isParamPositionValid(self)
+
+ def get_depth(self):
+ return conf.lib.clang_TParamCommandComment_getDepth(self)
+
+ def get_index(self):
+ return (
+ conf.lib.clang_TParamCommandComment_getIndex(self, i)
+ for i in range(self.get_depth())
+ )
+
+
+def VerbatimBlockLineComment(Comment):
+ def get_text(self):
+ return conf.lib.clang_VerbatimBlockLineComment_getText(self)
+
----------------
DeinAlptraum wrote:
Was this supposed to be a class? If not, this function definition does not make
any sense
https://github.com/llvm/llvm-project/pull/81684
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits