Skip to content

Commit

Permalink
Add BlockCommandComment API (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
TravisCardwell committed Oct 9, 2024
1 parent 890f0ff commit c55886e
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 0 deletions.
20 changes: 20 additions & 0 deletions hs-bindgen-libclang/cbits/doxygen_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,26 @@ static inline void wrap_InlineCommandComment_getArgText(const CXComment* Comment
*result = clang_InlineCommandComment_getArgText(*Comment, argIdx);
}

/**
* Comment type 'CXComment_BlockCommand'
*/

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

static inline unsigned wrap_BlockCommandComment_getNumArgs(const CXComment* Comment) {
return clang_BlockCommandComment_getNumArgs(*Comment);
}

static inline void wrap_BlockCommandComment_getArgText(const CXComment* Comment, unsigned argIdx, CXString* result) {
*result = clang_BlockCommandComment_getArgText(*Comment, argIdx);
}

static inline void wrap_BlockCommandComment_getParagraph(const CXComment* Comment, CXComment* result) {
*result = clang_BlockCommandComment_getParagraph(*Comment);
}

/**
* Comment type 'CXComment_FullComment'
*/
Expand Down
66 changes: 66 additions & 0 deletions hs-bindgen-libclang/src/HsBindgen/Clang/Doxygen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ module HsBindgen.Clang.Doxygen (
, clang_InlineCommandComment_getRenderKind
, clang_InlineCommandComment_getNumArgs
, clang_InlineCommandComment_getArgText
-- * Comment type 'CXComment_BlockCommand'
, clang_BlockCommandComment_getCommandName
, clang_BlockCommandComment_getNumArgs
, clang_BlockCommandComment_getArgText
, clang_BlockCommandComment_getParagraph
-- * Comment type 'CXComment_FullComment'
, clang_FullComment_getAsHTML
, clang_FullComment_getAsXML
Expand Down Expand Up @@ -211,6 +216,67 @@ clang_InlineCommandComment_getArgText comment argIdx =
onHaskellHeap comment $ \comment' ->
preallocate_ $ wrap_InlineCommandComment_getArgText comment' argIdx

{-------------------------------------------------------------------------------
Comment type 'CXComment_BlockCommand'
-------------------------------------------------------------------------------}

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

foreign import capi unsafe "doxygen_wrappers.h wrap_BlockCommandComment_getNumArgs"
wrap_BlockCommandComment_getNumArgs :: R CXComment_ -> IO CUInt

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

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

-- | Get the name of the block command.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga8fdde998537370477362a4f84bc03420>
clang_BlockCommandComment_getCommandName :: CXComment -> IO Text
clang_BlockCommandComment_getCommandName comment =
onHaskellHeap comment $ \comment' ->
preallocate_ $ wrap_BlockCommandComment_getCommandName comment'

-- | Get the number of word-like arguments.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gacb447968ce9efdfdabbfca8918540cdf>
clang_BlockCommandComment_getNumArgs :: CXComment -> IO CUInt
clang_BlockCommandComment_getNumArgs comment =
onHaskellHeap comment $ \comment' ->
wrap_BlockCommandComment_getNumArgs comment'

-- | Get the text of the specified word-like argument.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga9faf08601d88c809a9a97a9826051990>
clang_BlockCommandComment_getArgText ::
CXComment
-> CUInt -- ^ argument index (zero-based)
-> IO Text
clang_BlockCommandComment_getArgText comment argIdx =
onHaskellHeap comment $ \comment' ->
preallocate_ $ wrap_BlockCommandComment_getArgText comment' argIdx

-- | Get the paragraph argument of the block command.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gac6f2ffc8fdbe9394bd4bb7d54327c968>
clang_BlockCommandComment_getParagraph ::
CXComment
-- ^ a @CXComment_BlockCommand@ or @CXComment_VerbatimBlockCommand@ AST node
-> IO CXComment
clang_BlockCommandComment_getParagraph comment =
onHaskellHeap comment $ \comment' ->
preallocate_ $ wrap_BlockCommandComment_getParagraph comment'

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

0 comments on commit c55886e

Please sign in to comment.