Skip to content

Commit

Permalink
Add ParamCommandComment API (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
TravisCardwell committed Oct 8, 2024
1 parent 39f8b69 commit 08562c4
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 1 deletion.
24 changes: 24 additions & 0 deletions hs-bindgen-libclang/cbits/doxygen_wrappers.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,30 @@ static inline void wrap_BlockCommandComment_getParagraph(const CXComment* Commen
*result = clang_BlockCommandComment_getParagraph(*Comment);
}

/**
* Comment type 'CXComment_ParamCommand'
*/

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

static inline unsigned wrap_ParamCommandComment_isParamIndexValid(const CXComment* Comment) {
return clang_ParamCommandComment_isParamIndexValid(*Comment);
}

static inline unsigned wrap_ParamCommandComment_getParamIndex(const CXComment* Comment) {
return clang_ParamCommandComment_getParamIndex(*Comment);
}

static inline unsigned wrap_ParamCommandComment_isDirectionExplicit(const CXComment* Comment) {
return clang_ParamCommandComment_isDirectionExplicit(*Comment);
}

static inline enum CXCommentParamPassDirection wrap_ParamCommandComment_getDirection(const CXComment* Comment) {
return clang_ParamCommandComment_getDirection(*Comment);
}

/**
* Comment type 'CXComment_FullComment'
*/
Expand Down
72 changes: 72 additions & 0 deletions hs-bindgen-libclang/src/HsBindgen/Clang/Doxygen.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ module HsBindgen.Clang.Doxygen (
, clang_BlockCommandComment_getNumArgs
, clang_BlockCommandComment_getArgText
, clang_BlockCommandComment_getParagraph
-- * Comment type 'CXComment_ParamCommand'
, clang_ParamCommandComment_getParamName
, clang_ParamCommandComment_isParamIndexValid
, clang_ParamCommandComment_getParamIndex
, clang_ParamCommandComment_isDirectionExplicit
, clang_ParamCommandComment_getDirection
-- * Comment type 'CXComment_FullComment'
, clang_FullComment_getAsHTML
, clang_FullComment_getAsXML
Expand Down Expand Up @@ -277,6 +283,72 @@ clang_BlockCommandComment_getParagraph comment =
onHaskellHeap comment $ \comment' ->
preallocate_ $ wrap_BlockCommandComment_getParagraph comment'

{-------------------------------------------------------------------------------
Comment type 'CXComment_ParamCommand'
-------------------------------------------------------------------------------}

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

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

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

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

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

-- | Get the parameter name.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gaffd7aaf697c5eb3a3d2b508b5d806763>
clang_ParamCommandComment_getParamName :: CXComment -> IO Text
clang_ParamCommandComment_getParamName comment =
onHaskellHeap comment $ \comment' ->
preallocate_ $ wrap_ParamCommandComment_getParamName comment'

-- | Determine whether the parameter that this AST node represents was found in
-- the function prototype and @clang_ParamCommandComment_getParamIndex@ function
-- will return a meaningful value.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#ga92e6422da2a3e428b4452a3e8955ff76>
clang_ParamCommandComment_isParamIndexValid :: CXComment -> IO Bool
clang_ParamCommandComment_isParamIndexValid comment =
onHaskellHeap comment $ \comment' ->
cToBool <$> wrap_ParamCommandComment_isParamIndexValid comment'

-- | Get the zero-based parameter index in function prototype.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gad9d1dc9ebb52dcc9cb7da8ca4c23332a>
clang_ParamCommandComment_getParamIndex :: CXComment -> IO CUInt
clang_ParamCommandComment_getParamIndex comment =
onHaskellHeap comment $ \comment' ->
wrap_ParamCommandComment_getParamIndex comment'

-- | Determine whether the parameter passing direction was specified explicitly
-- in the comment.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gaf68f19e83ca9b27aec7eb22b065620bd>
clang_ParamCommandComment_isDirectionExplicit :: CXComment -> IO Bool
clang_ParamCommandComment_isDirectionExplicit comment =
onHaskellHeap comment $ \comment' ->
cToBool <$> wrap_ParamCommandComment_isDirectionExplicit comment'

-- | Get the parameter passing direction.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gac78b84734e9e6040a001a0036e6aa15c>
clang_ParamCommandComment_getDirection ::
CXComment
-> IO (SimpleEnum CXCommentParamPassDirection)
clang_ParamCommandComment_getDirection comment =
onHaskellHeap comment $ \comment' ->
wrap_ParamCommandComment_getDirection comment'

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

-- | Describes the type of the comment AST node ('CXComment').
Expand Down Expand Up @@ -122,4 +123,17 @@ data CXCommentInlineCommandRenderKind =

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

-- | Describes parameter passing direction for @\\param@ or @\\arg@ command.
--
-- <https://clang.llvm.org/doxygen/group__CINDEX__COMMENT.html#gafadf6e52217ea74d1a014198df656ee1>
data CXCommentParamPassDirection =
-- | The parameter is an input parameter.
CXCommentParamPassDirection_In

-- | The parameter is an output parameter.
| CXCommentParamPassDirection_Out

-- | The parameter is an input and output parameter.
| CXCommentParamPassDirection_InOut

0 comments on commit 08562c4

Please sign in to comment.