Skip to content

Commit

Permalink
Add TextComment API (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
TravisCardwell committed Oct 11, 2024
1 parent 80eac75 commit f9ad716
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
8 changes: 8 additions & 0 deletions hs-bindgen-libclang/cbits/doxygen_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ static inline enum CXCommentKind wrap_Comment_getKind(const CXComment* Comment)
return clang_Comment_getKind(*Comment);
}

/**
* Comment type 'CXComment_Text'
*/

static inline void wrap_TextComment_getText(const CXComment* Comment, CXString* result) {
*result = clang_TextComment_getText(*Comment);
}

/**
* Comment type 'CXComment_InlineCommand'
*/
Expand Down
17 changes: 17 additions & 0 deletions hs-bindgen-libclang/src/HsBindgen/Clang/LowLevel/Doxygen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ module HsBindgen.Clang.LowLevel.Doxygen (
, CXCommentKind(..)
, clang_Cursor_getParsedComment
, clang_Comment_getKind
-- * Comment type 'CXComment_Text'
, clang_TextComment_getText
-- * Comment type 'CXComment_InlineCommand'
, clang_InlineCommandComment_getCommandName
, clang_InlineCommandComment_getRenderKind
Expand Down Expand Up @@ -66,6 +68,21 @@ clang_Comment_getKind comment =
onHaskellHeap comment $ \comment' ->
wrap_Comment_getKind comment'

{-------------------------------------------------------------------------------
Comment type 'CXComment_Text'
-------------------------------------------------------------------------------}

foreign import capi unsafe "doxygen_wrappers.h wrap_TextComment_getText"
wrap_TextComment_getText :: R CXComment_ -> W CXString_ -> IO ()

-- | Get the text contained in the AST node.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gae9a27e851356181beac36bbff6e638e2>
clang_TextComment_getText :: CXComment -> IO Text
clang_TextComment_getText comment =
onHaskellHeap comment $ \comment' ->
preallocate_ $ wrap_TextComment_getText comment'

{-------------------------------------------------------------------------------
Comment type 'CXComment_InlineCommand'
-------------------------------------------------------------------------------}
Expand Down

0 comments on commit f9ad716

Please sign in to comment.