Skip to content

Commit

Permalink
Add InlineCommandComment API (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
TravisCardwell committed Oct 9, 2024
1 parent 317e78b commit 050fd4b
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 1 deletion.
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 @@ -19,6 +19,26 @@ static inline enum CXCommentKind wrap_Comment_getKind(const CXComment* Comment)
return clang_Comment_getKind(*Comment);
}

/**
* Comment type 'CXComment_InlineCommand'
*/

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

static inline enum CXCommentInlineCommandRenderKind wrap_InlineCommandComment_getRenderKind(const CXComment* Comment) {
return clang_InlineCommandComment_getRenderKind(*Comment);
}

static inline unsigned wrap_InlineCommandComment_getNumArgs(const CXComment* Comment) {
return clang_InlineCommandComment_getNumArgs(*Comment);
}

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

/**
* Comment type 'CXComment_FullComment'
*/
Expand Down
65 changes: 65 additions & 0 deletions hs-bindgen-libclang/src/HsBindgen/Clang/Doxygen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ module HsBindgen.Clang.Doxygen (
, CXCommentKind(..)
, clang_Cursor_getParsedComment
, clang_Comment_getKind
-- * Comment type 'CXComment_InlineCommand'
, clang_InlineCommandComment_getCommandName
, clang_InlineCommandComment_getRenderKind
, clang_InlineCommandComment_getNumArgs
, clang_InlineCommandComment_getArgText
-- * Comment type 'CXComment_FullComment'
, clang_FullComment_getAsHTML
, clang_FullComment_getAsXML
Expand Down Expand Up @@ -61,6 +66,66 @@ clang_Comment_getKind comment =
onHaskellHeap comment $ \comment' ->
wrap_Comment_getKind comment'

{-------------------------------------------------------------------------------
Comment type 'CXComment_InlineCommand'
-------------------------------------------------------------------------------}

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

foreign import capi unsafe "doxygen_wrappers.h wrap_InlineCommandComment_getRenderKind"
wrap_InlineCommandComment_getRenderKind ::
R CXComment_
-> IO (SimpleEnum CXCommentInlineCommandRenderKind)

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

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

-- | Get the name of the inline command.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga77f5b160e7d73190ac518298c1e79d05>
clang_InlineCommandComment_getCommandName :: CXComment -> IO Text
clang_InlineCommandComment_getCommandName comment =
onHaskellHeap comment $ \comment' ->
preallocate_ $ wrap_InlineCommandComment_getCommandName comment'

-- | Get the most appropriate rendering mode, chosen on command semantics in
-- Doxygen.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga3dd54ce1288d09c408cac8c887da2ebd>
clang_InlineCommandComment_getRenderKind ::
CXComment
-> IO (SimpleEnum CXCommentInlineCommandRenderKind)
clang_InlineCommandComment_getRenderKind comment =
onHaskellHeap comment $ \comment' ->
wrap_InlineCommandComment_getRenderKind comment'

-- | Get the number of command arguments.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga78db1049239be9649c2829cdeb83c544>
clang_InlineCommandComment_getNumArgs :: CXComment -> IO CUInt
clang_InlineCommandComment_getNumArgs comment =
onHaskellHeap comment $ \comment' ->
wrap_InlineCommandComment_getNumArgs comment'

-- | Get the text of the specified argument.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga6824f3cdcb42edbd143db77a657fe888>
clang_InlineCommandComment_getArgText :: CXComment -> CUInt -> IO Text
clang_InlineCommandComment_getArgText comment argIdx =
onHaskellHeap comment $ \comment' ->
preallocate_ $ wrap_InlineCommandComment_getArgText comment' argIdx

{-------------------------------------------------------------------------------
Comment type 'CXComment_FullComment'
-------------------------------------------------------------------------------}
Expand Down
25 changes: 24 additions & 1 deletion hs-bindgen-libclang/src/HsBindgen/Clang/Doxygen/Enums.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module HsBindgen.Clang.Doxygen.Enums (
CXCommentKind(..)
, CXCommentInlineCommandRenderKind(..)
) where

-- | Describes the type of the comment AST node ('CXComment').
Expand Down Expand Up @@ -99,4 +100,26 @@ data CXCommentKind =

-- | A full comment attached to a declaration, contains block content.
| CXComment_FullComment
deriving stock (Show, Eq, Ord, Enum, Bounded)
deriving stock (Show, Eq, Ord, Enum, Bounded)

-- | The most appropriate rendering mode for an inline command, chosen on
-- command semantics in Doxygen.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga23efacd9c1e4e286a9f9714e1720fdcf>
data CXCommentInlineCommandRenderKind =
-- | Command argument should be rendered in a normal font.
CXCommentInlineCommandRenderKind_Normal

-- | Command argument should be rendered in a bold font.
| CXCommentInlineCommandRenderKind_Bold

-- | Command argument should be rendered in a monospaced font.
| CXCommentInlineCommandRenderKind_Monospaced

-- | Command argument should be rendered emphasized (typically italic
-- font).
| CXCommentInlineCommandRenderKind_Emphasized

-- | Command argument should not be rendered (since it only defines an
-- anchor).
| CXCommentInlineCommandRenderKind_Anchor

0 comments on commit 050fd4b

Please sign in to comment.