{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)
-}

#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
       && !defined(__HADDOCK_VERSION__))

module GI.Ggit.Callbacks
    (

 -- * Signals
-- ** ConfigCallback #signal:ConfigCallback#

    C_ConfigCallback                        ,
    ConfigCallback                          ,
    ConfigCallback_WithClosures             ,
    drop_closures_ConfigCallback            ,
    dynamic_ConfigCallback                  ,
    genClosure_ConfigCallback               ,
    mk_ConfigCallback                       ,
    noConfigCallback                        ,
    noConfigCallback_WithClosures           ,
    wrap_ConfigCallback                     ,


-- ** ConfigMatchCallback #signal:ConfigMatchCallback#

    C_ConfigMatchCallback                   ,
    ConfigMatchCallback                     ,
    ConfigMatchCallback_WithClosures        ,
    drop_closures_ConfigMatchCallback       ,
    dynamic_ConfigMatchCallback             ,
    genClosure_ConfigMatchCallback          ,
    mk_ConfigMatchCallback                  ,
    noConfigMatchCallback                   ,
    noConfigMatchCallback_WithClosures      ,
    wrap_ConfigMatchCallback                ,


-- ** CredAcquireCallback #signal:CredAcquireCallback#

    C_CredAcquireCallback                   ,
    CredAcquireCallback                     ,
    CredAcquireCallback_WithClosures        ,
    drop_closures_CredAcquireCallback       ,
    dynamic_CredAcquireCallback             ,
    genClosure_CredAcquireCallback          ,
    mk_CredAcquireCallback                  ,
    noCredAcquireCallback                   ,
    noCredAcquireCallback_WithClosures      ,
    wrap_CredAcquireCallback                ,


-- ** DiffBinaryCallback #signal:DiffBinaryCallback#

    C_DiffBinaryCallback                    ,
    DiffBinaryCallback                      ,
    DiffBinaryCallback_WithClosures         ,
    drop_closures_DiffBinaryCallback        ,
    dynamic_DiffBinaryCallback              ,
    genClosure_DiffBinaryCallback           ,
    mk_DiffBinaryCallback                   ,
    noDiffBinaryCallback                    ,
    noDiffBinaryCallback_WithClosures       ,
    wrap_DiffBinaryCallback                 ,


-- ** DiffFileCallback #signal:DiffFileCallback#

    C_DiffFileCallback                      ,
    DiffFileCallback                        ,
    DiffFileCallback_WithClosures           ,
    drop_closures_DiffFileCallback          ,
    dynamic_DiffFileCallback                ,
    genClosure_DiffFileCallback             ,
    mk_DiffFileCallback                     ,
    noDiffFileCallback                      ,
    noDiffFileCallback_WithClosures         ,
    wrap_DiffFileCallback                   ,


-- ** DiffHunkCallback #signal:DiffHunkCallback#

    C_DiffHunkCallback                      ,
    DiffHunkCallback                        ,
    DiffHunkCallback_WithClosures           ,
    drop_closures_DiffHunkCallback          ,
    dynamic_DiffHunkCallback                ,
    genClosure_DiffHunkCallback             ,
    mk_DiffHunkCallback                     ,
    noDiffHunkCallback                      ,
    noDiffHunkCallback_WithClosures         ,
    wrap_DiffHunkCallback                   ,


-- ** DiffLineCallback #signal:DiffLineCallback#

    C_DiffLineCallback                      ,
    DiffLineCallback                        ,
    DiffLineCallback_WithClosures           ,
    drop_closures_DiffLineCallback          ,
    dynamic_DiffLineCallback                ,
    genClosure_DiffLineCallback             ,
    mk_DiffLineCallback                     ,
    noDiffLineCallback                      ,
    noDiffLineCallback_WithClosures         ,
    wrap_DiffLineCallback                   ,


-- ** DiffSimilarityMetricBufferSignatureCallback #signal:DiffSimilarityMetricBufferSignatureCallback#

    C_DiffSimilarityMetricBufferSignatureCallback,
    DiffSimilarityMetricBufferSignatureCallback,
    DiffSimilarityMetricBufferSignatureCallback_WithClosures,
    drop_closures_DiffSimilarityMetricBufferSignatureCallback,
    dynamic_DiffSimilarityMetricBufferSignatureCallback,
    genClosure_DiffSimilarityMetricBufferSignatureCallback,
    mk_DiffSimilarityMetricBufferSignatureCallback,
    noDiffSimilarityMetricBufferSignatureCallback,
    noDiffSimilarityMetricBufferSignatureCallback_WithClosures,
    wrap_DiffSimilarityMetricBufferSignatureCallback,


-- ** DiffSimilarityMetricFileSignatureCallback #signal:DiffSimilarityMetricFileSignatureCallback#

    C_DiffSimilarityMetricFileSignatureCallback,
    DiffSimilarityMetricFileSignatureCallback,
    DiffSimilarityMetricFileSignatureCallback_WithClosures,
    drop_closures_DiffSimilarityMetricFileSignatureCallback,
    dynamic_DiffSimilarityMetricFileSignatureCallback,
    genClosure_DiffSimilarityMetricFileSignatureCallback,
    mk_DiffSimilarityMetricFileSignatureCallback,
    noDiffSimilarityMetricFileSignatureCallback,
    noDiffSimilarityMetricFileSignatureCallback_WithClosures,
    wrap_DiffSimilarityMetricFileSignatureCallback,


-- ** DiffSimilarityMetricFreeSignatureCallback #signal:DiffSimilarityMetricFreeSignatureCallback#

    C_DiffSimilarityMetricFreeSignatureCallback,
    DiffSimilarityMetricFreeSignatureCallback,
    DiffSimilarityMetricFreeSignatureCallback_WithClosures,
    drop_closures_DiffSimilarityMetricFreeSignatureCallback,
    dynamic_DiffSimilarityMetricFreeSignatureCallback,
    genClosure_DiffSimilarityMetricFreeSignatureCallback,
    mk_DiffSimilarityMetricFreeSignatureCallback,
    noDiffSimilarityMetricFreeSignatureCallback,
    noDiffSimilarityMetricFreeSignatureCallback_WithClosures,
    wrap_DiffSimilarityMetricFreeSignatureCallback,


-- ** DiffSimilarityMetricSimilarityCallback #signal:DiffSimilarityMetricSimilarityCallback#

    C_DiffSimilarityMetricSimilarityCallback,
    DiffSimilarityMetricSimilarityCallback  ,
    DiffSimilarityMetricSimilarityCallback_WithClosures,
    drop_closures_DiffSimilarityMetricSimilarityCallback,
    dynamic_DiffSimilarityMetricSimilarityCallback,
    genClosure_DiffSimilarityMetricSimilarityCallback,
    mk_DiffSimilarityMetricSimilarityCallback,
    noDiffSimilarityMetricSimilarityCallback,
    noDiffSimilarityMetricSimilarityCallback_WithClosures,
    wrap_DiffSimilarityMetricSimilarityCallback,


-- ** NoteCallback #signal:NoteCallback#

    C_NoteCallback                          ,
    NoteCallback                            ,
    NoteCallback_WithClosures               ,
    drop_closures_NoteCallback              ,
    dynamic_NoteCallback                    ,
    genClosure_NoteCallback                 ,
    mk_NoteCallback                         ,
    noNoteCallback                          ,
    noNoteCallback_WithClosures             ,
    wrap_NoteCallback                       ,


-- ** ReferencesCallback #signal:ReferencesCallback#

    C_ReferencesCallback                    ,
    ReferencesCallback                      ,
    ReferencesCallback_WithClosures         ,
    drop_closures_ReferencesCallback        ,
    dynamic_ReferencesCallback              ,
    genClosure_ReferencesCallback           ,
    mk_ReferencesCallback                   ,
    noReferencesCallback                    ,
    noReferencesCallback_WithClosures       ,
    wrap_ReferencesCallback                 ,


-- ** ReferencesNameCallback #signal:ReferencesNameCallback#

    C_ReferencesNameCallback                ,
    ReferencesNameCallback                  ,
    ReferencesNameCallback_WithClosures     ,
    drop_closures_ReferencesNameCallback    ,
    dynamic_ReferencesNameCallback          ,
    genClosure_ReferencesNameCallback       ,
    mk_ReferencesNameCallback               ,
    noReferencesNameCallback                ,
    noReferencesNameCallback_WithClosures   ,
    wrap_ReferencesNameCallback             ,


-- ** RemoteListCallback #signal:RemoteListCallback#

    C_RemoteListCallback                    ,
    RemoteListCallback                      ,
    RemoteListCallback_WithClosures         ,
    drop_closures_RemoteListCallback        ,
    dynamic_RemoteListCallback              ,
    genClosure_RemoteListCallback           ,
    mk_RemoteListCallback                   ,
    noRemoteListCallback                    ,
    noRemoteListCallback_WithClosures       ,
    wrap_RemoteListCallback                 ,


-- ** StashCallback #signal:StashCallback#

    C_StashCallback                         ,
    StashCallback                           ,
    StashCallback_WithClosures              ,
    drop_closures_StashCallback             ,
    dynamic_StashCallback                   ,
    genClosure_StashCallback                ,
    mk_StashCallback                        ,
    noStashCallback                         ,
    noStashCallback_WithClosures            ,
    wrap_StashCallback                      ,


-- ** StatusCallback #signal:StatusCallback#

    C_StatusCallback                        ,
    StatusCallback                          ,
    StatusCallback_WithClosures             ,
    drop_closures_StatusCallback            ,
    dynamic_StatusCallback                  ,
    genClosure_StatusCallback               ,
    mk_StatusCallback                       ,
    noStatusCallback                        ,
    noStatusCallback_WithClosures           ,
    wrap_StatusCallback                     ,


-- ** SubmoduleCallback #signal:SubmoduleCallback#

    C_SubmoduleCallback                     ,
    SubmoduleCallback                       ,
    SubmoduleCallback_WithClosures          ,
    drop_closures_SubmoduleCallback         ,
    dynamic_SubmoduleCallback               ,
    genClosure_SubmoduleCallback            ,
    mk_SubmoduleCallback                    ,
    noSubmoduleCallback                     ,
    noSubmoduleCallback_WithClosures        ,
    wrap_SubmoduleCallback                  ,


-- ** TagCallback #signal:TagCallback#

    C_TagCallback                           ,
    TagCallback                             ,
    TagCallback_WithClosures                ,
    drop_closures_TagCallback               ,
    dynamic_TagCallback                     ,
    genClosure_TagCallback                  ,
    mk_TagCallback                          ,
    noTagCallback                           ,
    noTagCallback_WithClosures              ,
    wrap_TagCallback                        ,


-- ** TransferProgressCallback #signal:TransferProgressCallback#

    C_TransferProgressCallback              ,
    TransferProgressCallback                ,
    TransferProgressCallback_WithClosures   ,
    drop_closures_TransferProgressCallback  ,
    dynamic_TransferProgressCallback        ,
    genClosure_TransferProgressCallback     ,
    mk_TransferProgressCallback             ,
    noTransferProgressCallback              ,
    noTransferProgressCallback_WithClosures ,
    wrap_TransferProgressCallback           ,


-- ** TreeWalkCallback #signal:TreeWalkCallback#

    C_TreeWalkCallback                      ,
    TreeWalkCallback                        ,
    TreeWalkCallback_WithClosures           ,
    drop_closures_TreeWalkCallback          ,
    dynamic_TreeWalkCallback                ,
    genClosure_TreeWalkCallback             ,
    mk_TreeWalkCallback                     ,
    noTreeWalkCallback                      ,
    noTreeWalkCallback_WithClosures         ,
    wrap_TreeWalkCallback                   ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import qualified GI.GLib.Structs.MatchInfo as GLib.MatchInfo
import {-# SOURCE #-} qualified GI.Ggit.Flags as Ggit.Flags
import {-# SOURCE #-} qualified GI.Ggit.Objects.Cred as Ggit.Cred
import {-# SOURCE #-} qualified GI.Ggit.Objects.Ref as Ggit.Ref
import {-# SOURCE #-} qualified GI.Ggit.Structs.ConfigEntry as Ggit.ConfigEntry
import {-# SOURCE #-} qualified GI.Ggit.Structs.DiffBinary as Ggit.DiffBinary
import {-# SOURCE #-} qualified GI.Ggit.Structs.DiffDelta as Ggit.DiffDelta
import {-# SOURCE #-} qualified GI.Ggit.Structs.DiffFile as Ggit.DiffFile
import {-# SOURCE #-} qualified GI.Ggit.Structs.DiffHunk as Ggit.DiffHunk
import {-# SOURCE #-} qualified GI.Ggit.Structs.DiffLine as Ggit.DiffLine
import {-# SOURCE #-} qualified GI.Ggit.Structs.OId as Ggit.OId
import {-# SOURCE #-} qualified GI.Ggit.Structs.Submodule as Ggit.Submodule
import {-# SOURCE #-} qualified GI.Ggit.Structs.TransferProgress as Ggit.TransferProgress
import {-# SOURCE #-} qualified GI.Ggit.Structs.TreeEntry as Ggit.TreeEntry

-- callback TreeWalkCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go for the next entry or a #GgitError in case there was an error.", sinceVersion = Nothing}, args = [Arg {argCName = "root", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the current (relative) root of the entry", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "entry", argType = TInterface (Name {namespace = "Ggit", name = "TreeEntry"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the tree entry", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The type of the callback functions for walking a tree.\nSee ggit_tree_walk().", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_TreeWalkCallback =
    CString ->
    Ptr Ggit.TreeEntry.TreeEntry ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "root", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the current (relative) root of the entry", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "entry", argType = TInterface (Name {namespace = "Ggit", name = "TreeEntry"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the tree entry", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_TreeWalkCallback :: FunPtr C_TreeWalkCallback -> C_TreeWalkCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_TreeWalkCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_TreeWalkCallback
    -> T.Text
    {- ^ /@root@/: the current (relative) root of the entry -}
    -> Ggit.TreeEntry.TreeEntry
    {- ^ /@entry@/: the tree entry -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go for the next entry or a 'GI.Ggit.Enums.Error' in case there was an error. -}
dynamic_TreeWalkCallback __funPtr root entry userData = liftIO $ do
    root' <- textToCString root
    entry' <- unsafeManagedPtrGetPtr entry
    result <- (__dynamic_C_TreeWalkCallback __funPtr) root' entry' userData
    touchManagedPtr entry
    freeMem root'
    return result

-- | Generate a function pointer callable from C code, from a `C_TreeWalkCallback`.
foreign import ccall "wrapper"
    mk_TreeWalkCallback :: C_TreeWalkCallback -> IO (FunPtr C_TreeWalkCallback)

{- |
The type of the callback functions for walking a tree.
See 'GI.Ggit.Objects.Tree.treeWalk'.
-}
type TreeWalkCallback =
    T.Text
    {- ^ /@root@/: the current (relative) root of the entry -}
    -> Ggit.TreeEntry.TreeEntry
    {- ^ /@entry@/: the tree entry -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next entry or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `TreeWalkCallback`@.
noTreeWalkCallback :: Maybe TreeWalkCallback
noTreeWalkCallback = Nothing

{- |
The type of the callback functions for walking a tree.
See 'GI.Ggit.Objects.Tree.treeWalk'.
-}
type TreeWalkCallback_WithClosures =
    T.Text
    {- ^ /@root@/: the current (relative) root of the entry -}
    -> Ggit.TreeEntry.TreeEntry
    {- ^ /@entry@/: the tree entry -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next entry or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `TreeWalkCallback_WithClosures`@.
noTreeWalkCallback_WithClosures :: Maybe TreeWalkCallback_WithClosures
noTreeWalkCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_TreeWalkCallback :: TreeWalkCallback -> TreeWalkCallback_WithClosures
drop_closures_TreeWalkCallback _f root entry _ = _f root entry

-- | Wrap the callback into a `GClosure`.
genClosure_TreeWalkCallback :: MonadIO m => TreeWalkCallback -> m (GClosure C_TreeWalkCallback)
genClosure_TreeWalkCallback cb = liftIO $ do
    let cb' = drop_closures_TreeWalkCallback cb
    let cb'' = wrap_TreeWalkCallback Nothing cb'
    mk_TreeWalkCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `TreeWalkCallback` into a `C_TreeWalkCallback`.
wrap_TreeWalkCallback ::
    Maybe (Ptr (FunPtr C_TreeWalkCallback)) ->
    TreeWalkCallback_WithClosures ->
    C_TreeWalkCallback
wrap_TreeWalkCallback funptrptr _cb root entry userData = do
    root' <- cstringToText root
    B.ManagedPtr.withTransient Ggit.TreeEntry.TreeEntry entry $ \entry' -> do
        result <- _cb  root' entry' userData
        maybeReleaseFunPtr funptrptr
        return result


-- callback TransferProgressCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "a value less than zero to cancel the transfer.", sinceVersion = Nothing}, args = [Arg {argCName = "stats", argType = TInterface (Name {namespace = "Ggit", name = "TransferProgress"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitTransferProgress.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Progress callbacks during indexing.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_TransferProgressCallback =
    Ptr Ggit.TransferProgress.TransferProgress ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "stats", argType = TInterface (Name {namespace = "Ggit", name = "TransferProgress"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitTransferProgress.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_TransferProgressCallback :: FunPtr C_TransferProgressCallback -> C_TransferProgressCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_TransferProgressCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_TransferProgressCallback
    -> Ggit.TransferProgress.TransferProgress
    {- ^ /@stats@/: a 'GI.Ggit.Structs.TransferProgress.TransferProgress'. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
    {- ^ __Returns:__ a value less than zero to cancel the transfer. -}
dynamic_TransferProgressCallback __funPtr stats userData = liftIO $ do
    stats' <- unsafeManagedPtrGetPtr stats
    result <- (__dynamic_C_TransferProgressCallback __funPtr) stats' userData
    touchManagedPtr stats
    return result

-- | Generate a function pointer callable from C code, from a `C_TransferProgressCallback`.
foreign import ccall "wrapper"
    mk_TransferProgressCallback :: C_TransferProgressCallback -> IO (FunPtr C_TransferProgressCallback)

{- |
Progress callbacks during indexing.
-}
type TransferProgressCallback =
    Ggit.TransferProgress.TransferProgress
    {- ^ /@stats@/: a 'GI.Ggit.Structs.TransferProgress.TransferProgress'. -}
    -> IO Int32
    {- ^ __Returns:__ a value less than zero to cancel the transfer. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `TransferProgressCallback`@.
noTransferProgressCallback :: Maybe TransferProgressCallback
noTransferProgressCallback = Nothing

{- |
Progress callbacks during indexing.
-}
type TransferProgressCallback_WithClosures =
    Ggit.TransferProgress.TransferProgress
    {- ^ /@stats@/: a 'GI.Ggit.Structs.TransferProgress.TransferProgress'. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32
    {- ^ __Returns:__ a value less than zero to cancel the transfer. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `TransferProgressCallback_WithClosures`@.
noTransferProgressCallback_WithClosures :: Maybe TransferProgressCallback_WithClosures
noTransferProgressCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_TransferProgressCallback :: TransferProgressCallback -> TransferProgressCallback_WithClosures
drop_closures_TransferProgressCallback _f stats _ = _f stats

-- | Wrap the callback into a `GClosure`.
genClosure_TransferProgressCallback :: MonadIO m => TransferProgressCallback -> m (GClosure C_TransferProgressCallback)
genClosure_TransferProgressCallback cb = liftIO $ do
    let cb' = drop_closures_TransferProgressCallback cb
    let cb'' = wrap_TransferProgressCallback Nothing cb'
    mk_TransferProgressCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `TransferProgressCallback` into a `C_TransferProgressCallback`.
wrap_TransferProgressCallback ::
    Maybe (Ptr (FunPtr C_TransferProgressCallback)) ->
    TransferProgressCallback_WithClosures ->
    C_TransferProgressCallback
wrap_TransferProgressCallback funptrptr _cb stats userData = do
    B.ManagedPtr.withTransient Ggit.TransferProgress.TransferProgress stats $ \stats' -> do
        result <- _cb  stats' userData
        maybeReleaseFunPtr funptrptr
        return result


-- callback TagCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go continue or a #GgitError in case there was an error.", sinceVersion = Nothing}, args = [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the tag name.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "tag_oid", argType = TInterface (Name {namespace = "Ggit", name = "OId"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the tag oid.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-suplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "When iterating over all the tags, callback that will be\nissued per entry. See ggit_repository_tag_foreach().", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_TagCallback =
    CString ->
    Ptr Ggit.OId.OId ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the tag name.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "tag_oid", argType = TInterface (Name {namespace = "Ggit", name = "OId"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the tag oid.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-suplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_TagCallback :: FunPtr C_TagCallback -> C_TagCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_TagCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_TagCallback
    -> T.Text
    {- ^ /@name@/: the tag name. -}
    -> Ggit.OId.OId
    {- ^ /@tagOid@/: the tag oid. -}
    -> Ptr ()
    {- ^ /@userData@/: user-suplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}
dynamic_TagCallback __funPtr name tagOid userData = liftIO $ do
    name' <- textToCString name
    tagOid' <- unsafeManagedPtrGetPtr tagOid
    result <- (__dynamic_C_TagCallback __funPtr) name' tagOid' userData
    touchManagedPtr tagOid
    freeMem name'
    return result

-- | Generate a function pointer callable from C code, from a `C_TagCallback`.
foreign import ccall "wrapper"
    mk_TagCallback :: C_TagCallback -> IO (FunPtr C_TagCallback)

{- |
When iterating over all the tags, callback that will be
issued per entry. See 'GI.Ggit.Objects.Repository.repositoryTagForeach'.
-}
type TagCallback =
    T.Text
    {- ^ /@name@/: the tag name. -}
    -> Ggit.OId.OId
    {- ^ /@tagOid@/: the tag oid. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `TagCallback`@.
noTagCallback :: Maybe TagCallback
noTagCallback = Nothing

{- |
When iterating over all the tags, callback that will be
issued per entry. See 'GI.Ggit.Objects.Repository.repositoryTagForeach'.
-}
type TagCallback_WithClosures =
    T.Text
    {- ^ /@name@/: the tag name. -}
    -> Ggit.OId.OId
    {- ^ /@tagOid@/: the tag oid. -}
    -> Ptr ()
    {- ^ /@userData@/: user-suplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `TagCallback_WithClosures`@.
noTagCallback_WithClosures :: Maybe TagCallback_WithClosures
noTagCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_TagCallback :: TagCallback -> TagCallback_WithClosures
drop_closures_TagCallback _f name tagOid _ = _f name tagOid

-- | Wrap the callback into a `GClosure`.
genClosure_TagCallback :: MonadIO m => TagCallback -> m (GClosure C_TagCallback)
genClosure_TagCallback cb = liftIO $ do
    let cb' = drop_closures_TagCallback cb
    let cb'' = wrap_TagCallback Nothing cb'
    mk_TagCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `TagCallback` into a `C_TagCallback`.
wrap_TagCallback ::
    Maybe (Ptr (FunPtr C_TagCallback)) ->
    TagCallback_WithClosures ->
    C_TagCallback
wrap_TagCallback funptrptr _cb name tagOid userData = do
    name' <- cstringToText name
    B.ManagedPtr.withTransient Ggit.OId.OId tagOid $ \tagOid' -> do
        result <- _cb  name' tagOid' userData
        maybeReleaseFunPtr funptrptr
        return result


-- callback SubmoduleCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go for the next submodule or a #GgitError in case there was an error.", sinceVersion = Nothing}, args = [Arg {argCName = "submodule", argType = TInterface (Name {namespace = "Ggit", name = "Submodule"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitSubmodule.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the submodule.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The type of the callback functions for retrieving the submodules\nin a #GgitRepository. See ggit_repository_submodule_foreach().", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_SubmoduleCallback =
    Ptr Ggit.Submodule.Submodule ->
    CString ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "submodule", argType = TInterface (Name {namespace = "Ggit", name = "Submodule"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitSubmodule.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the submodule.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_SubmoduleCallback :: FunPtr C_SubmoduleCallback -> C_SubmoduleCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_SubmoduleCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_SubmoduleCallback
    -> Ggit.Submodule.Submodule
    {- ^ /@submodule@/: a 'GI.Ggit.Structs.Submodule.Submodule'. -}
    -> T.Text
    {- ^ /@name@/: the name of the submodule. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go for the next submodule or a 'GI.Ggit.Enums.Error' in case there was an error. -}
dynamic_SubmoduleCallback __funPtr submodule name userData = liftIO $ do
    submodule' <- unsafeManagedPtrGetPtr submodule
    name' <- textToCString name
    result <- (__dynamic_C_SubmoduleCallback __funPtr) submodule' name' userData
    touchManagedPtr submodule
    freeMem name'
    return result

-- | Generate a function pointer callable from C code, from a `C_SubmoduleCallback`.
foreign import ccall "wrapper"
    mk_SubmoduleCallback :: C_SubmoduleCallback -> IO (FunPtr C_SubmoduleCallback)

{- |
The type of the callback functions for retrieving the submodules
in a 'GI.Ggit.Objects.Repository.Repository'. See 'GI.Ggit.Objects.Repository.repositorySubmoduleForeach'.
-}
type SubmoduleCallback =
    Ggit.Submodule.Submodule
    {- ^ /@submodule@/: a 'GI.Ggit.Structs.Submodule.Submodule'. -}
    -> T.Text
    {- ^ /@name@/: the name of the submodule. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next submodule or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `SubmoduleCallback`@.
noSubmoduleCallback :: Maybe SubmoduleCallback
noSubmoduleCallback = Nothing

{- |
The type of the callback functions for retrieving the submodules
in a 'GI.Ggit.Objects.Repository.Repository'. See 'GI.Ggit.Objects.Repository.repositorySubmoduleForeach'.
-}
type SubmoduleCallback_WithClosures =
    Ggit.Submodule.Submodule
    {- ^ /@submodule@/: a 'GI.Ggit.Structs.Submodule.Submodule'. -}
    -> T.Text
    {- ^ /@name@/: the name of the submodule. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next submodule or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `SubmoduleCallback_WithClosures`@.
noSubmoduleCallback_WithClosures :: Maybe SubmoduleCallback_WithClosures
noSubmoduleCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_SubmoduleCallback :: SubmoduleCallback -> SubmoduleCallback_WithClosures
drop_closures_SubmoduleCallback _f submodule name _ = _f submodule name

-- | Wrap the callback into a `GClosure`.
genClosure_SubmoduleCallback :: MonadIO m => SubmoduleCallback -> m (GClosure C_SubmoduleCallback)
genClosure_SubmoduleCallback cb = liftIO $ do
    let cb' = drop_closures_SubmoduleCallback cb
    let cb'' = wrap_SubmoduleCallback Nothing cb'
    mk_SubmoduleCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `SubmoduleCallback` into a `C_SubmoduleCallback`.
wrap_SubmoduleCallback ::
    Maybe (Ptr (FunPtr C_SubmoduleCallback)) ->
    SubmoduleCallback_WithClosures ->
    C_SubmoduleCallback
wrap_SubmoduleCallback funptrptr _cb submodule name userData = do
    B.ManagedPtr.withTransient Ggit.Submodule.Submodule submodule $ \submodule' -> do
        name' <- cstringToText name
        result <- _cb  submodule' name' userData
        maybeReleaseFunPtr funptrptr
        return result


-- callback StatusCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go for the next file or a #GgitError in case there was an error.", sinceVersion = Nothing}, args = [Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the file to retrieve status for, rooted at the repository working dir.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "status_flags", argType = TInterface (Name {namespace = "Ggit", name = "StatusFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the status value.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The type of the callback functions for retrieving the status of the files\nin a #GgitRepository. See ggit_repository_file_status_foreach().", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_StatusCallback =
    CString ->
    CUInt ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the file to retrieve status for, rooted at the repository working dir.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "status_flags", argType = TInterface (Name {namespace = "Ggit", name = "StatusFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the status value.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_StatusCallback :: FunPtr C_StatusCallback -> C_StatusCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_StatusCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_StatusCallback
    -> T.Text
    {- ^ /@path@/: the file to retrieve status for, rooted at the repository working dir. -}
    -> [Ggit.Flags.StatusFlags]
    {- ^ /@statusFlags@/: the status value. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go for the next file or a 'GI.Ggit.Enums.Error' in case there was an error. -}
dynamic_StatusCallback __funPtr path statusFlags userData = liftIO $ do
    path' <- textToCString path
    let statusFlags' = gflagsToWord statusFlags
    result <- (__dynamic_C_StatusCallback __funPtr) path' statusFlags' userData
    freeMem path'
    return result

-- | Generate a function pointer callable from C code, from a `C_StatusCallback`.
foreign import ccall "wrapper"
    mk_StatusCallback :: C_StatusCallback -> IO (FunPtr C_StatusCallback)

{- |
The type of the callback functions for retrieving the status of the files
in a 'GI.Ggit.Objects.Repository.Repository'. See 'GI.Ggit.Objects.Repository.repositoryFileStatusForeach'.
-}
type StatusCallback =
    T.Text
    {- ^ /@path@/: the file to retrieve status for, rooted at the repository working dir. -}
    -> [Ggit.Flags.StatusFlags]
    {- ^ /@statusFlags@/: the status value. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next file or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `StatusCallback`@.
noStatusCallback :: Maybe StatusCallback
noStatusCallback = Nothing

{- |
The type of the callback functions for retrieving the status of the files
in a 'GI.Ggit.Objects.Repository.Repository'. See 'GI.Ggit.Objects.Repository.repositoryFileStatusForeach'.
-}
type StatusCallback_WithClosures =
    T.Text
    {- ^ /@path@/: the file to retrieve status for, rooted at the repository working dir. -}
    -> [Ggit.Flags.StatusFlags]
    {- ^ /@statusFlags@/: the status value. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next file or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `StatusCallback_WithClosures`@.
noStatusCallback_WithClosures :: Maybe StatusCallback_WithClosures
noStatusCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_StatusCallback :: StatusCallback -> StatusCallback_WithClosures
drop_closures_StatusCallback _f path statusFlags _ = _f path statusFlags

-- | Wrap the callback into a `GClosure`.
genClosure_StatusCallback :: MonadIO m => StatusCallback -> m (GClosure C_StatusCallback)
genClosure_StatusCallback cb = liftIO $ do
    let cb' = drop_closures_StatusCallback cb
    let cb'' = wrap_StatusCallback Nothing cb'
    mk_StatusCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `StatusCallback` into a `C_StatusCallback`.
wrap_StatusCallback ::
    Maybe (Ptr (FunPtr C_StatusCallback)) ->
    StatusCallback_WithClosures ->
    C_StatusCallback
wrap_StatusCallback funptrptr _cb path statusFlags userData = do
    path' <- cstringToText path
    let statusFlags' = wordToGFlags statusFlags
    result <- _cb  path' statusFlags' userData
    maybeReleaseFunPtr funptrptr
    return result


-- callback StashCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go continue or a #GgitError in case there was an error.", sinceVersion = Nothing}, args = [Arg {argCName = "index", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the position within the stash list. 0 points to the\nmost recent stashed state.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "message", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the stash message.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stash_oid", argType = TInterface (Name {namespace = "Ggit", name = "OId"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the commit oid of the stashed state.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-suplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "When iterating over all the stashed states, callback that will be\nissued per entry. See ggit_repository_stash_foreach().", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_StashCallback =
    Word64 ->
    CString ->
    Ptr Ggit.OId.OId ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "index", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the position within the stash list. 0 points to the\nmost recent stashed state.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "message", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the stash message.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stash_oid", argType = TInterface (Name {namespace = "Ggit", name = "OId"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the commit oid of the stashed state.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-suplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_StashCallback :: FunPtr C_StashCallback -> C_StashCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_StashCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_StashCallback
    -> Word64
    {- ^ /@index@/: the position within the stash list. 0 points to the
most recent stashed state. -}
    -> T.Text
    {- ^ /@message@/: the stash message. -}
    -> Ggit.OId.OId
    {- ^ /@stashOid@/: the commit oid of the stashed state. -}
    -> Ptr ()
    {- ^ /@userData@/: user-suplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}
dynamic_StashCallback __funPtr index message stashOid userData = liftIO $ do
    message' <- textToCString message
    stashOid' <- unsafeManagedPtrGetPtr stashOid
    result <- (__dynamic_C_StashCallback __funPtr) index message' stashOid' userData
    touchManagedPtr stashOid
    freeMem message'
    return result

-- | Generate a function pointer callable from C code, from a `C_StashCallback`.
foreign import ccall "wrapper"
    mk_StashCallback :: C_StashCallback -> IO (FunPtr C_StashCallback)

{- |
When iterating over all the stashed states, callback that will be
issued per entry. See 'GI.Ggit.Objects.Repository.repositoryStashForeach'.
-}
type StashCallback =
    Word64
    {- ^ /@index@/: the position within the stash list. 0 points to the
most recent stashed state. -}
    -> T.Text
    {- ^ /@message@/: the stash message. -}
    -> Ggit.OId.OId
    {- ^ /@stashOid@/: the commit oid of the stashed state. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `StashCallback`@.
noStashCallback :: Maybe StashCallback
noStashCallback = Nothing

{- |
When iterating over all the stashed states, callback that will be
issued per entry. See 'GI.Ggit.Objects.Repository.repositoryStashForeach'.
-}
type StashCallback_WithClosures =
    Word64
    {- ^ /@index@/: the position within the stash list. 0 points to the
most recent stashed state. -}
    -> T.Text
    {- ^ /@message@/: the stash message. -}
    -> Ggit.OId.OId
    {- ^ /@stashOid@/: the commit oid of the stashed state. -}
    -> Ptr ()
    {- ^ /@userData@/: user-suplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `StashCallback_WithClosures`@.
noStashCallback_WithClosures :: Maybe StashCallback_WithClosures
noStashCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_StashCallback :: StashCallback -> StashCallback_WithClosures
drop_closures_StashCallback _f index message stashOid _ = _f index message stashOid

-- | Wrap the callback into a `GClosure`.
genClosure_StashCallback :: MonadIO m => StashCallback -> m (GClosure C_StashCallback)
genClosure_StashCallback cb = liftIO $ do
    let cb' = drop_closures_StashCallback cb
    let cb'' = wrap_StashCallback Nothing cb'
    mk_StashCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `StashCallback` into a `C_StashCallback`.
wrap_StashCallback ::
    Maybe (Ptr (FunPtr C_StashCallback)) ->
    StashCallback_WithClosures ->
    C_StashCallback
wrap_StashCallback funptrptr _cb index message stashOid userData = do
    message' <- cstringToText message
    B.ManagedPtr.withTransient Ggit.OId.OId stashOid $ \stashOid' -> do
        result <- _cb  index message' stashOid' userData
        maybeReleaseFunPtr funptrptr
        return result


-- callback RemoteListCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go continue or a #GgitError in case there was an error.", sinceVersion = Nothing}, args = [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the reference.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "oid", argType = TInterface (Name {namespace = "Ggit", name = "OId"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the reference's oid.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "loid", argType = TInterface (Name {namespace = "Ggit", name = "OId"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the reference's loid.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "local", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "if available locally.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The type of the callback functions for listing the references of a\n#GgitRemote. See ggit_remote_list().", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_RemoteListCallback =
    CString ->
    Ptr Ggit.OId.OId ->
    Ptr Ggit.OId.OId ->
    CInt ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the reference.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "oid", argType = TInterface (Name {namespace = "Ggit", name = "OId"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the reference's oid.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "loid", argType = TInterface (Name {namespace = "Ggit", name = "OId"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the reference's loid.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "local", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "if available locally.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_RemoteListCallback :: FunPtr C_RemoteListCallback -> C_RemoteListCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_RemoteListCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_RemoteListCallback
    -> T.Text
    {- ^ /@name@/: the name of the reference. -}
    -> Ggit.OId.OId
    {- ^ /@oid@/: the reference\'s oid. -}
    -> Ggit.OId.OId
    {- ^ /@loid@/: the reference\'s loid. -}
    -> Bool
    {- ^ /@local@/: if available locally. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}
dynamic_RemoteListCallback __funPtr name oid loid local userData = liftIO $ do
    name' <- textToCString name
    oid' <- unsafeManagedPtrGetPtr oid
    loid' <- unsafeManagedPtrGetPtr loid
    let local' = (fromIntegral . fromEnum) local
    result <- (__dynamic_C_RemoteListCallback __funPtr) name' oid' loid' local' userData
    touchManagedPtr oid
    touchManagedPtr loid
    freeMem name'
    return result

-- | Generate a function pointer callable from C code, from a `C_RemoteListCallback`.
foreign import ccall "wrapper"
    mk_RemoteListCallback :: C_RemoteListCallback -> IO (FunPtr C_RemoteListCallback)

{- |
The type of the callback functions for listing the references of a
'GI.Ggit.Objects.Remote.Remote'. See 'GI.Ggit.Objects.Remote.remoteList'.
-}
type RemoteListCallback =
    T.Text
    {- ^ /@name@/: the name of the reference. -}
    -> Ggit.OId.OId
    {- ^ /@oid@/: the reference\'s oid. -}
    -> Ggit.OId.OId
    {- ^ /@loid@/: the reference\'s loid. -}
    -> Bool
    {- ^ /@local@/: if available locally. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `RemoteListCallback`@.
noRemoteListCallback :: Maybe RemoteListCallback
noRemoteListCallback = Nothing

{- |
The type of the callback functions for listing the references of a
'GI.Ggit.Objects.Remote.Remote'. See 'GI.Ggit.Objects.Remote.remoteList'.
-}
type RemoteListCallback_WithClosures =
    T.Text
    {- ^ /@name@/: the name of the reference. -}
    -> Ggit.OId.OId
    {- ^ /@oid@/: the reference\'s oid. -}
    -> Ggit.OId.OId
    {- ^ /@loid@/: the reference\'s loid. -}
    -> Bool
    {- ^ /@local@/: if available locally. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `RemoteListCallback_WithClosures`@.
noRemoteListCallback_WithClosures :: Maybe RemoteListCallback_WithClosures
noRemoteListCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_RemoteListCallback :: RemoteListCallback -> RemoteListCallback_WithClosures
drop_closures_RemoteListCallback _f name oid loid local _ = _f name oid loid local

-- | Wrap the callback into a `GClosure`.
genClosure_RemoteListCallback :: MonadIO m => RemoteListCallback -> m (GClosure C_RemoteListCallback)
genClosure_RemoteListCallback cb = liftIO $ do
    let cb' = drop_closures_RemoteListCallback cb
    let cb'' = wrap_RemoteListCallback Nothing cb'
    mk_RemoteListCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `RemoteListCallback` into a `C_RemoteListCallback`.
wrap_RemoteListCallback ::
    Maybe (Ptr (FunPtr C_RemoteListCallback)) ->
    RemoteListCallback_WithClosures ->
    C_RemoteListCallback
wrap_RemoteListCallback funptrptr _cb name oid loid local userData = do
    name' <- cstringToText name
    B.ManagedPtr.withTransient Ggit.OId.OId oid $ \oid' -> do
        B.ManagedPtr.withTransient Ggit.OId.OId loid $ \loid' -> do
            let local' = (/= 0) local
            result <- _cb  name' oid' loid' local' userData
            maybeReleaseFunPtr funptrptr
            return result


-- callback ReferencesNameCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go for the next references or a #GgitError in case there was an error.", sinceVersion = Nothing}, args = [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the reference", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The type of the callback functions for retrieving the references\nin a #GgitRepository. See ggit_repository_references_foreach_name().", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_ReferencesNameCallback =
    CString ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the name of the reference", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_ReferencesNameCallback :: FunPtr C_ReferencesNameCallback -> C_ReferencesNameCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_ReferencesNameCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_ReferencesNameCallback
    -> T.Text
    {- ^ /@name@/: the name of the reference -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go for the next references or a 'GI.Ggit.Enums.Error' in case there was an error. -}
dynamic_ReferencesNameCallback __funPtr name userData = liftIO $ do
    name' <- textToCString name
    result <- (__dynamic_C_ReferencesNameCallback __funPtr) name' userData
    freeMem name'
    return result

-- | Generate a function pointer callable from C code, from a `C_ReferencesNameCallback`.
foreign import ccall "wrapper"
    mk_ReferencesNameCallback :: C_ReferencesNameCallback -> IO (FunPtr C_ReferencesNameCallback)

{- |
The type of the callback functions for retrieving the references
in a 'GI.Ggit.Objects.Repository.Repository'. See 'GI.Ggit.Objects.Repository.repositoryReferencesForeachName'.
-}
type ReferencesNameCallback =
    T.Text
    {- ^ /@name@/: the name of the reference -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next references or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `ReferencesNameCallback`@.
noReferencesNameCallback :: Maybe ReferencesNameCallback
noReferencesNameCallback = Nothing

{- |
The type of the callback functions for retrieving the references
in a 'GI.Ggit.Objects.Repository.Repository'. See 'GI.Ggit.Objects.Repository.repositoryReferencesForeachName'.
-}
type ReferencesNameCallback_WithClosures =
    T.Text
    {- ^ /@name@/: the name of the reference -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next references or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `ReferencesNameCallback_WithClosures`@.
noReferencesNameCallback_WithClosures :: Maybe ReferencesNameCallback_WithClosures
noReferencesNameCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_ReferencesNameCallback :: ReferencesNameCallback -> ReferencesNameCallback_WithClosures
drop_closures_ReferencesNameCallback _f name _ = _f name

-- | Wrap the callback into a `GClosure`.
genClosure_ReferencesNameCallback :: MonadIO m => ReferencesNameCallback -> m (GClosure C_ReferencesNameCallback)
genClosure_ReferencesNameCallback cb = liftIO $ do
    let cb' = drop_closures_ReferencesNameCallback cb
    let cb'' = wrap_ReferencesNameCallback Nothing cb'
    mk_ReferencesNameCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `ReferencesNameCallback` into a `C_ReferencesNameCallback`.
wrap_ReferencesNameCallback ::
    Maybe (Ptr (FunPtr C_ReferencesNameCallback)) ->
    ReferencesNameCallback_WithClosures ->
    C_ReferencesNameCallback
wrap_ReferencesNameCallback funptrptr _cb name userData = do
    name' <- cstringToText name
    result <- _cb  name' userData
    maybeReleaseFunPtr funptrptr
    return result


-- callback ReferencesCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go for the next references or a #GgitError in case there was an error.", sinceVersion = Nothing}, args = [Arg {argCName = "reference", argType = TInterface (Name {namespace = "Ggit", name = "Ref"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the reference.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The type of the callback functions for retrieving the references\nin a #GgitRepository. See ggit_repository_references_foreach().", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_ReferencesCallback =
    Ptr Ggit.Ref.Ref ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "reference", argType = TInterface (Name {namespace = "Ggit", name = "Ref"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the reference.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_ReferencesCallback :: FunPtr C_ReferencesCallback -> C_ReferencesCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_ReferencesCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Ggit.Ref.IsRef a) =>
    FunPtr C_ReferencesCallback
    -> a
    {- ^ /@reference@/: the reference. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go for the next references or a 'GI.Ggit.Enums.Error' in case there was an error. -}
dynamic_ReferencesCallback __funPtr reference userData = liftIO $ do
    reference' <- B.ManagedPtr.disownObject reference
    result <- (__dynamic_C_ReferencesCallback __funPtr) reference' userData
    touchManagedPtr reference
    return result

-- | Generate a function pointer callable from C code, from a `C_ReferencesCallback`.
foreign import ccall "wrapper"
    mk_ReferencesCallback :: C_ReferencesCallback -> IO (FunPtr C_ReferencesCallback)

{- |
The type of the callback functions for retrieving the references
in a 'GI.Ggit.Objects.Repository.Repository'. See 'GI.Ggit.Objects.Repository.repositoryReferencesForeach'.
-}
type ReferencesCallback =
    Ggit.Ref.Ref
    {- ^ /@reference@/: the reference. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next references or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `ReferencesCallback`@.
noReferencesCallback :: Maybe ReferencesCallback
noReferencesCallback = Nothing

{- |
The type of the callback functions for retrieving the references
in a 'GI.Ggit.Objects.Repository.Repository'. See 'GI.Ggit.Objects.Repository.repositoryReferencesForeach'.
-}
type ReferencesCallback_WithClosures =
    Ggit.Ref.Ref
    {- ^ /@reference@/: the reference. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next references or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `ReferencesCallback_WithClosures`@.
noReferencesCallback_WithClosures :: Maybe ReferencesCallback_WithClosures
noReferencesCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_ReferencesCallback :: ReferencesCallback -> ReferencesCallback_WithClosures
drop_closures_ReferencesCallback _f reference _ = _f reference

-- | Wrap the callback into a `GClosure`.
genClosure_ReferencesCallback :: MonadIO m => ReferencesCallback -> m (GClosure C_ReferencesCallback)
genClosure_ReferencesCallback cb = liftIO $ do
    let cb' = drop_closures_ReferencesCallback cb
    let cb'' = wrap_ReferencesCallback Nothing cb'
    mk_ReferencesCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `ReferencesCallback` into a `C_ReferencesCallback`.
wrap_ReferencesCallback ::
    Maybe (Ptr (FunPtr C_ReferencesCallback)) ->
    ReferencesCallback_WithClosures ->
    C_ReferencesCallback
wrap_ReferencesCallback funptrptr _cb reference userData = do
    reference' <- (wrapObject Ggit.Ref.Ref) reference
    result <- _cb  reference' userData
    maybeReleaseFunPtr funptrptr
    return result


-- callback NoteCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go continue or a #GgitError in case there was an error.", sinceVersion = Nothing}, args = [Arg {argCName = "blob_id", argType = TInterface (Name {namespace = "Ggit", name = "OId"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "id of the blob containing the message.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "annotated_object_id", argType = TInterface (Name {namespace = "Ggit", name = "OId"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "id of the git object being annotated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-suplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "When iterating over all the notes, callback that will be\nissued per note. See ggit_repository_note_foreach().", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_NoteCallback =
    Ptr Ggit.OId.OId ->
    Ptr Ggit.OId.OId ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "blob_id", argType = TInterface (Name {namespace = "Ggit", name = "OId"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "id of the blob containing the message.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "annotated_object_id", argType = TInterface (Name {namespace = "Ggit", name = "OId"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "id of the git object being annotated.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-suplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_NoteCallback :: FunPtr C_NoteCallback -> C_NoteCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_NoteCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_NoteCallback
    -> Ggit.OId.OId
    {- ^ /@blobId@/: id of the blob containing the message. -}
    -> Ggit.OId.OId
    {- ^ /@annotatedObjectId@/: id of the git object being annotated. -}
    -> Ptr ()
    {- ^ /@userData@/: user-suplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}
dynamic_NoteCallback __funPtr blobId annotatedObjectId userData = liftIO $ do
    blobId' <- unsafeManagedPtrGetPtr blobId
    annotatedObjectId' <- unsafeManagedPtrGetPtr annotatedObjectId
    result <- (__dynamic_C_NoteCallback __funPtr) blobId' annotatedObjectId' userData
    touchManagedPtr blobId
    touchManagedPtr annotatedObjectId
    return result

-- | Generate a function pointer callable from C code, from a `C_NoteCallback`.
foreign import ccall "wrapper"
    mk_NoteCallback :: C_NoteCallback -> IO (FunPtr C_NoteCallback)

{- |
When iterating over all the notes, callback that will be
issued per note. See 'GI.Ggit.Objects.Repository.repositoryNoteForeach'.
-}
type NoteCallback =
    Ggit.OId.OId
    {- ^ /@blobId@/: id of the blob containing the message. -}
    -> Ggit.OId.OId
    {- ^ /@annotatedObjectId@/: id of the git object being annotated. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `NoteCallback`@.
noNoteCallback :: Maybe NoteCallback
noNoteCallback = Nothing

{- |
When iterating over all the notes, callback that will be
issued per note. See 'GI.Ggit.Objects.Repository.repositoryNoteForeach'.
-}
type NoteCallback_WithClosures =
    Ggit.OId.OId
    {- ^ /@blobId@/: id of the blob containing the message. -}
    -> Ggit.OId.OId
    {- ^ /@annotatedObjectId@/: id of the git object being annotated. -}
    -> Ptr ()
    {- ^ /@userData@/: user-suplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `NoteCallback_WithClosures`@.
noNoteCallback_WithClosures :: Maybe NoteCallback_WithClosures
noNoteCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_NoteCallback :: NoteCallback -> NoteCallback_WithClosures
drop_closures_NoteCallback _f blobId annotatedObjectId _ = _f blobId annotatedObjectId

-- | Wrap the callback into a `GClosure`.
genClosure_NoteCallback :: MonadIO m => NoteCallback -> m (GClosure C_NoteCallback)
genClosure_NoteCallback cb = liftIO $ do
    let cb' = drop_closures_NoteCallback cb
    let cb'' = wrap_NoteCallback Nothing cb'
    mk_NoteCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `NoteCallback` into a `C_NoteCallback`.
wrap_NoteCallback ::
    Maybe (Ptr (FunPtr C_NoteCallback)) ->
    NoteCallback_WithClosures ->
    C_NoteCallback
wrap_NoteCallback funptrptr _cb blobId annotatedObjectId userData = do
    B.ManagedPtr.withTransient Ggit.OId.OId blobId $ \blobId' -> do
        B.ManagedPtr.withTransient Ggit.OId.OId annotatedObjectId $ \annotatedObjectId' -> do
            result <- _cb  blobId' annotatedObjectId' userData
            maybeReleaseFunPtr funptrptr
            return result


-- callback DiffSimilarityMetricSimilarityCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "score", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "signature_a", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "signature_b", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_DiffSimilarityMetricSimilarityCallback =
    Int32 ->
    Ptr () ->
    Ptr () ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "score", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "signature_a", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "signature_b", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_DiffSimilarityMetricSimilarityCallback :: FunPtr C_DiffSimilarityMetricSimilarityCallback -> C_DiffSimilarityMetricSimilarityCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_DiffSimilarityMetricSimilarityCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_DiffSimilarityMetricSimilarityCallback
    -> Int32
    -> Ptr ()
    -> Ptr ()
    -> Ptr ()
    -> m Int32
dynamic_DiffSimilarityMetricSimilarityCallback __funPtr score signatureA signatureB userData = liftIO $ do
    result <- (__dynamic_C_DiffSimilarityMetricSimilarityCallback __funPtr) score signatureA signatureB userData
    return result

-- | Generate a function pointer callable from C code, from a `C_DiffSimilarityMetricSimilarityCallback`.
foreign import ccall "wrapper"
    mk_DiffSimilarityMetricSimilarityCallback :: C_DiffSimilarityMetricSimilarityCallback -> IO (FunPtr C_DiffSimilarityMetricSimilarityCallback)

{- |
/No description available in the introspection data./
-}
type DiffSimilarityMetricSimilarityCallback =
    Int32
    -> Ptr ()
    -> Ptr ()
    -> IO Int32

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffSimilarityMetricSimilarityCallback`@.
noDiffSimilarityMetricSimilarityCallback :: Maybe DiffSimilarityMetricSimilarityCallback
noDiffSimilarityMetricSimilarityCallback = Nothing

{- |
/No description available in the introspection data./
-}
type DiffSimilarityMetricSimilarityCallback_WithClosures =
    Int32
    -> Ptr ()
    -> Ptr ()
    -> Ptr ()
    -> IO Int32

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffSimilarityMetricSimilarityCallback_WithClosures`@.
noDiffSimilarityMetricSimilarityCallback_WithClosures :: Maybe DiffSimilarityMetricSimilarityCallback_WithClosures
noDiffSimilarityMetricSimilarityCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_DiffSimilarityMetricSimilarityCallback :: DiffSimilarityMetricSimilarityCallback -> DiffSimilarityMetricSimilarityCallback_WithClosures
drop_closures_DiffSimilarityMetricSimilarityCallback _f score signatureA signatureB _ = _f score signatureA signatureB

-- | Wrap the callback into a `GClosure`.
genClosure_DiffSimilarityMetricSimilarityCallback :: MonadIO m => DiffSimilarityMetricSimilarityCallback -> m (GClosure C_DiffSimilarityMetricSimilarityCallback)
genClosure_DiffSimilarityMetricSimilarityCallback cb = liftIO $ do
    let cb' = drop_closures_DiffSimilarityMetricSimilarityCallback cb
    let cb'' = wrap_DiffSimilarityMetricSimilarityCallback Nothing cb'
    mk_DiffSimilarityMetricSimilarityCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `DiffSimilarityMetricSimilarityCallback` into a `C_DiffSimilarityMetricSimilarityCallback`.
wrap_DiffSimilarityMetricSimilarityCallback ::
    Maybe (Ptr (FunPtr C_DiffSimilarityMetricSimilarityCallback)) ->
    DiffSimilarityMetricSimilarityCallback_WithClosures ->
    C_DiffSimilarityMetricSimilarityCallback
wrap_DiffSimilarityMetricSimilarityCallback funptrptr _cb score signatureA signatureB userData = do
    result <- _cb  score signatureA signatureB userData
    maybeReleaseFunPtr funptrptr
    return result


-- callback DiffSimilarityMetricFreeSignatureCallback
--          -> Callable {returnType = Nothing, returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "signature", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_DiffSimilarityMetricFreeSignatureCallback =
    Ptr () ->
    Ptr () ->
    IO ()

-- Args : [Arg {argCName = "signature", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_DiffSimilarityMetricFreeSignatureCallback :: FunPtr C_DiffSimilarityMetricFreeSignatureCallback -> C_DiffSimilarityMetricFreeSignatureCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_DiffSimilarityMetricFreeSignatureCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_DiffSimilarityMetricFreeSignatureCallback
    -> Ptr ()
    -> Ptr ()
    -> m ()
dynamic_DiffSimilarityMetricFreeSignatureCallback __funPtr signature userData = liftIO $ do
    (__dynamic_C_DiffSimilarityMetricFreeSignatureCallback __funPtr) signature userData
    return ()

-- | Generate a function pointer callable from C code, from a `C_DiffSimilarityMetricFreeSignatureCallback`.
foreign import ccall "wrapper"
    mk_DiffSimilarityMetricFreeSignatureCallback :: C_DiffSimilarityMetricFreeSignatureCallback -> IO (FunPtr C_DiffSimilarityMetricFreeSignatureCallback)

{- |
/No description available in the introspection data./
-}
type DiffSimilarityMetricFreeSignatureCallback =
    Ptr ()
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffSimilarityMetricFreeSignatureCallback`@.
noDiffSimilarityMetricFreeSignatureCallback :: Maybe DiffSimilarityMetricFreeSignatureCallback
noDiffSimilarityMetricFreeSignatureCallback = Nothing

{- |
/No description available in the introspection data./
-}
type DiffSimilarityMetricFreeSignatureCallback_WithClosures =
    Ptr ()
    -> Ptr ()
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffSimilarityMetricFreeSignatureCallback_WithClosures`@.
noDiffSimilarityMetricFreeSignatureCallback_WithClosures :: Maybe DiffSimilarityMetricFreeSignatureCallback_WithClosures
noDiffSimilarityMetricFreeSignatureCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_DiffSimilarityMetricFreeSignatureCallback :: DiffSimilarityMetricFreeSignatureCallback -> DiffSimilarityMetricFreeSignatureCallback_WithClosures
drop_closures_DiffSimilarityMetricFreeSignatureCallback _f signature _ = _f signature

-- | Wrap the callback into a `GClosure`.
genClosure_DiffSimilarityMetricFreeSignatureCallback :: MonadIO m => DiffSimilarityMetricFreeSignatureCallback -> m (GClosure C_DiffSimilarityMetricFreeSignatureCallback)
genClosure_DiffSimilarityMetricFreeSignatureCallback cb = liftIO $ do
    let cb' = drop_closures_DiffSimilarityMetricFreeSignatureCallback cb
    let cb'' = wrap_DiffSimilarityMetricFreeSignatureCallback Nothing cb'
    mk_DiffSimilarityMetricFreeSignatureCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `DiffSimilarityMetricFreeSignatureCallback` into a `C_DiffSimilarityMetricFreeSignatureCallback`.
wrap_DiffSimilarityMetricFreeSignatureCallback ::
    Maybe (Ptr (FunPtr C_DiffSimilarityMetricFreeSignatureCallback)) ->
    DiffSimilarityMetricFreeSignatureCallback_WithClosures ->
    C_DiffSimilarityMetricFreeSignatureCallback
wrap_DiffSimilarityMetricFreeSignatureCallback funptrptr _cb signature userData = do
    _cb  signature userData
    maybeReleaseFunPtr funptrptr


-- callback DiffSimilarityMetricFileSignatureCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "file", argType = TInterface (Name {namespace = "Ggit", name = "DiffFile"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fullpath", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_DiffSimilarityMetricFileSignatureCallback =
    Ptr Ggit.DiffFile.DiffFile ->
    CString ->
    Ptr () ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Ggit", name = "DiffFile"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fullpath", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_DiffSimilarityMetricFileSignatureCallback :: FunPtr C_DiffSimilarityMetricFileSignatureCallback -> C_DiffSimilarityMetricFileSignatureCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_DiffSimilarityMetricFileSignatureCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_DiffSimilarityMetricFileSignatureCallback
    -> Ggit.DiffFile.DiffFile
    -> T.Text
    -> Ptr ()
    -> Ptr ()
    -> m Int32
dynamic_DiffSimilarityMetricFileSignatureCallback __funPtr file fullpath out userData = liftIO $ do
    file' <- unsafeManagedPtrGetPtr file
    fullpath' <- textToCString fullpath
    result <- (__dynamic_C_DiffSimilarityMetricFileSignatureCallback __funPtr) file' fullpath' out userData
    touchManagedPtr file
    freeMem fullpath'
    return result

-- | Generate a function pointer callable from C code, from a `C_DiffSimilarityMetricFileSignatureCallback`.
foreign import ccall "wrapper"
    mk_DiffSimilarityMetricFileSignatureCallback :: C_DiffSimilarityMetricFileSignatureCallback -> IO (FunPtr C_DiffSimilarityMetricFileSignatureCallback)

{- |
/No description available in the introspection data./
-}
type DiffSimilarityMetricFileSignatureCallback =
    Ggit.DiffFile.DiffFile
    -> T.Text
    -> Ptr ()
    -> IO Int32

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffSimilarityMetricFileSignatureCallback`@.
noDiffSimilarityMetricFileSignatureCallback :: Maybe DiffSimilarityMetricFileSignatureCallback
noDiffSimilarityMetricFileSignatureCallback = Nothing

{- |
/No description available in the introspection data./
-}
type DiffSimilarityMetricFileSignatureCallback_WithClosures =
    Ggit.DiffFile.DiffFile
    -> T.Text
    -> Ptr ()
    -> Ptr ()
    -> IO Int32

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffSimilarityMetricFileSignatureCallback_WithClosures`@.
noDiffSimilarityMetricFileSignatureCallback_WithClosures :: Maybe DiffSimilarityMetricFileSignatureCallback_WithClosures
noDiffSimilarityMetricFileSignatureCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_DiffSimilarityMetricFileSignatureCallback :: DiffSimilarityMetricFileSignatureCallback -> DiffSimilarityMetricFileSignatureCallback_WithClosures
drop_closures_DiffSimilarityMetricFileSignatureCallback _f file fullpath out _ = _f file fullpath out

-- | Wrap the callback into a `GClosure`.
genClosure_DiffSimilarityMetricFileSignatureCallback :: MonadIO m => DiffSimilarityMetricFileSignatureCallback -> m (GClosure C_DiffSimilarityMetricFileSignatureCallback)
genClosure_DiffSimilarityMetricFileSignatureCallback cb = liftIO $ do
    let cb' = drop_closures_DiffSimilarityMetricFileSignatureCallback cb
    let cb'' = wrap_DiffSimilarityMetricFileSignatureCallback Nothing cb'
    mk_DiffSimilarityMetricFileSignatureCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `DiffSimilarityMetricFileSignatureCallback` into a `C_DiffSimilarityMetricFileSignatureCallback`.
wrap_DiffSimilarityMetricFileSignatureCallback ::
    Maybe (Ptr (FunPtr C_DiffSimilarityMetricFileSignatureCallback)) ->
    DiffSimilarityMetricFileSignatureCallback_WithClosures ->
    C_DiffSimilarityMetricFileSignatureCallback
wrap_DiffSimilarityMetricFileSignatureCallback funptrptr _cb file fullpath out userData = do
    B.ManagedPtr.withTransient Ggit.DiffFile.DiffFile file $ \file' -> do
        fullpath' <- cstringToText fullpath
        result <- _cb  file' fullpath' out userData
        maybeReleaseFunPtr funptrptr
        return result


-- callback DiffSimilarityMetricBufferSignatureCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "file", argType = TInterface (Name {namespace = "Ggit", name = "DiffFile"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buf", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buflen", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_DiffSimilarityMetricBufferSignatureCallback =
    Ptr Ggit.DiffFile.DiffFile ->
    CString ->
    Word64 ->
    Ptr () ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "file", argType = TInterface (Name {namespace = "Ggit", name = "DiffFile"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buf", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buflen", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "out", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_DiffSimilarityMetricBufferSignatureCallback :: FunPtr C_DiffSimilarityMetricBufferSignatureCallback -> C_DiffSimilarityMetricBufferSignatureCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_DiffSimilarityMetricBufferSignatureCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_DiffSimilarityMetricBufferSignatureCallback
    -> Ggit.DiffFile.DiffFile
    -> T.Text
    -> Word64
    -> Ptr ()
    -> Ptr ()
    -> m Int32
dynamic_DiffSimilarityMetricBufferSignatureCallback __funPtr file buf buflen out userData = liftIO $ do
    file' <- unsafeManagedPtrGetPtr file
    buf' <- textToCString buf
    result <- (__dynamic_C_DiffSimilarityMetricBufferSignatureCallback __funPtr) file' buf' buflen out userData
    touchManagedPtr file
    freeMem buf'
    return result

-- | Generate a function pointer callable from C code, from a `C_DiffSimilarityMetricBufferSignatureCallback`.
foreign import ccall "wrapper"
    mk_DiffSimilarityMetricBufferSignatureCallback :: C_DiffSimilarityMetricBufferSignatureCallback -> IO (FunPtr C_DiffSimilarityMetricBufferSignatureCallback)

{- |
/No description available in the introspection data./
-}
type DiffSimilarityMetricBufferSignatureCallback =
    Ggit.DiffFile.DiffFile
    -> T.Text
    -> Word64
    -> Ptr ()
    -> IO Int32

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffSimilarityMetricBufferSignatureCallback`@.
noDiffSimilarityMetricBufferSignatureCallback :: Maybe DiffSimilarityMetricBufferSignatureCallback
noDiffSimilarityMetricBufferSignatureCallback = Nothing

{- |
/No description available in the introspection data./
-}
type DiffSimilarityMetricBufferSignatureCallback_WithClosures =
    Ggit.DiffFile.DiffFile
    -> T.Text
    -> Word64
    -> Ptr ()
    -> Ptr ()
    -> IO Int32

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffSimilarityMetricBufferSignatureCallback_WithClosures`@.
noDiffSimilarityMetricBufferSignatureCallback_WithClosures :: Maybe DiffSimilarityMetricBufferSignatureCallback_WithClosures
noDiffSimilarityMetricBufferSignatureCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_DiffSimilarityMetricBufferSignatureCallback :: DiffSimilarityMetricBufferSignatureCallback -> DiffSimilarityMetricBufferSignatureCallback_WithClosures
drop_closures_DiffSimilarityMetricBufferSignatureCallback _f file buf buflen out _ = _f file buf buflen out

-- | Wrap the callback into a `GClosure`.
genClosure_DiffSimilarityMetricBufferSignatureCallback :: MonadIO m => DiffSimilarityMetricBufferSignatureCallback -> m (GClosure C_DiffSimilarityMetricBufferSignatureCallback)
genClosure_DiffSimilarityMetricBufferSignatureCallback cb = liftIO $ do
    let cb' = drop_closures_DiffSimilarityMetricBufferSignatureCallback cb
    let cb'' = wrap_DiffSimilarityMetricBufferSignatureCallback Nothing cb'
    mk_DiffSimilarityMetricBufferSignatureCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `DiffSimilarityMetricBufferSignatureCallback` into a `C_DiffSimilarityMetricBufferSignatureCallback`.
wrap_DiffSimilarityMetricBufferSignatureCallback ::
    Maybe (Ptr (FunPtr C_DiffSimilarityMetricBufferSignatureCallback)) ->
    DiffSimilarityMetricBufferSignatureCallback_WithClosures ->
    C_DiffSimilarityMetricBufferSignatureCallback
wrap_DiffSimilarityMetricBufferSignatureCallback funptrptr _cb file buf buflen out userData = do
    B.ManagedPtr.withTransient Ggit.DiffFile.DiffFile file $ \file' -> do
        buf' <- cstringToText buf
        result <- _cb  file' buf' buflen out userData
        maybeReleaseFunPtr funptrptr
        return result


-- callback DiffLineCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go continue or a #GgitError in case there was an error.", sinceVersion = Nothing}, args = [Arg {argCName = "delta", argType = TInterface (Name {namespace = "Ggit", name = "DiffDelta"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffDelta.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hunk", argType = TInterface (Name {namespace = "Ggit", name = "DiffHunk"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GgitDiffHunk.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TInterface (Name {namespace = "Ggit", name = "DiffLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffLine.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Called for each line.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_DiffLineCallback =
    Ptr Ggit.DiffDelta.DiffDelta ->
    Ptr Ggit.DiffHunk.DiffHunk ->
    Ptr Ggit.DiffLine.DiffLine ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "delta", argType = TInterface (Name {namespace = "Ggit", name = "DiffDelta"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffDelta.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hunk", argType = TInterface (Name {namespace = "Ggit", name = "DiffHunk"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "a #GgitDiffHunk.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TInterface (Name {namespace = "Ggit", name = "DiffLine"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffLine.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 3, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_DiffLineCallback :: FunPtr C_DiffLineCallback -> C_DiffLineCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_DiffLineCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_DiffLineCallback
    -> Ggit.DiffDelta.DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> Maybe (Ggit.DiffHunk.DiffHunk)
    {- ^ /@hunk@/: a 'GI.Ggit.Structs.DiffHunk.DiffHunk'. -}
    -> Ggit.DiffLine.DiffLine
    {- ^ /@line@/: a 'GI.Ggit.Structs.DiffLine.DiffLine'. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}
dynamic_DiffLineCallback __funPtr delta hunk line userData = liftIO $ do
    delta' <- unsafeManagedPtrGetPtr delta
    maybeHunk <- case hunk of
        Nothing -> return nullPtr
        Just jHunk -> do
            jHunk' <- unsafeManagedPtrGetPtr jHunk
            return jHunk'
    line' <- unsafeManagedPtrGetPtr line
    result <- (__dynamic_C_DiffLineCallback __funPtr) delta' maybeHunk line' userData
    touchManagedPtr delta
    whenJust hunk touchManagedPtr
    touchManagedPtr line
    return result

-- | Generate a function pointer callable from C code, from a `C_DiffLineCallback`.
foreign import ccall "wrapper"
    mk_DiffLineCallback :: C_DiffLineCallback -> IO (FunPtr C_DiffLineCallback)

{- |
Called for each line.
-}
type DiffLineCallback =
    Ggit.DiffDelta.DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> Maybe Ggit.DiffHunk.DiffHunk
    {- ^ /@hunk@/: a 'GI.Ggit.Structs.DiffHunk.DiffHunk'. -}
    -> Ggit.DiffLine.DiffLine
    {- ^ /@line@/: a 'GI.Ggit.Structs.DiffLine.DiffLine'. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffLineCallback`@.
noDiffLineCallback :: Maybe DiffLineCallback
noDiffLineCallback = Nothing

{- |
Called for each line.
-}
type DiffLineCallback_WithClosures =
    Ggit.DiffDelta.DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> Maybe Ggit.DiffHunk.DiffHunk
    {- ^ /@hunk@/: a 'GI.Ggit.Structs.DiffHunk.DiffHunk'. -}
    -> Ggit.DiffLine.DiffLine
    {- ^ /@line@/: a 'GI.Ggit.Structs.DiffLine.DiffLine'. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffLineCallback_WithClosures`@.
noDiffLineCallback_WithClosures :: Maybe DiffLineCallback_WithClosures
noDiffLineCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_DiffLineCallback :: DiffLineCallback -> DiffLineCallback_WithClosures
drop_closures_DiffLineCallback _f delta hunk line _ = _f delta hunk line

-- | Wrap the callback into a `GClosure`.
genClosure_DiffLineCallback :: MonadIO m => DiffLineCallback -> m (GClosure C_DiffLineCallback)
genClosure_DiffLineCallback cb = liftIO $ do
    let cb' = drop_closures_DiffLineCallback cb
    let cb'' = wrap_DiffLineCallback Nothing cb'
    mk_DiffLineCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `DiffLineCallback` into a `C_DiffLineCallback`.
wrap_DiffLineCallback ::
    Maybe (Ptr (FunPtr C_DiffLineCallback)) ->
    DiffLineCallback_WithClosures ->
    C_DiffLineCallback
wrap_DiffLineCallback funptrptr _cb delta hunk line userData = do
    B.ManagedPtr.withTransient Ggit.DiffDelta.DiffDelta delta $ \delta' -> do
        maybeHunk <-
            if hunk == nullPtr
            then return Nothing
            else do
                B.ManagedPtr.withTransient Ggit.DiffHunk.DiffHunk hunk $ \hunk' -> do
                    return $ Just hunk'
        B.ManagedPtr.withTransient Ggit.DiffLine.DiffLine line $ \line' -> do
            result <- _cb  delta' maybeHunk line' userData
            maybeReleaseFunPtr funptrptr
            return result


-- callback DiffHunkCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go continue or a #GgitError in case there was an error.", sinceVersion = Nothing}, args = [Arg {argCName = "delta", argType = TInterface (Name {namespace = "Ggit", name = "DiffDelta"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffDelta.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hunk", argType = TInterface (Name {namespace = "Ggit", name = "DiffHunk"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffHunk.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Called for each hunk.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_DiffHunkCallback =
    Ptr Ggit.DiffDelta.DiffDelta ->
    Ptr Ggit.DiffHunk.DiffHunk ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "delta", argType = TInterface (Name {namespace = "Ggit", name = "DiffDelta"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffDelta.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hunk", argType = TInterface (Name {namespace = "Ggit", name = "DiffHunk"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffHunk.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_DiffHunkCallback :: FunPtr C_DiffHunkCallback -> C_DiffHunkCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_DiffHunkCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_DiffHunkCallback
    -> Ggit.DiffDelta.DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> Ggit.DiffHunk.DiffHunk
    {- ^ /@hunk@/: a 'GI.Ggit.Structs.DiffHunk.DiffHunk'. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}
dynamic_DiffHunkCallback __funPtr delta hunk userData = liftIO $ do
    delta' <- unsafeManagedPtrGetPtr delta
    hunk' <- unsafeManagedPtrGetPtr hunk
    result <- (__dynamic_C_DiffHunkCallback __funPtr) delta' hunk' userData
    touchManagedPtr delta
    touchManagedPtr hunk
    return result

-- | Generate a function pointer callable from C code, from a `C_DiffHunkCallback`.
foreign import ccall "wrapper"
    mk_DiffHunkCallback :: C_DiffHunkCallback -> IO (FunPtr C_DiffHunkCallback)

{- |
Called for each hunk.
-}
type DiffHunkCallback =
    Ggit.DiffDelta.DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> Ggit.DiffHunk.DiffHunk
    {- ^ /@hunk@/: a 'GI.Ggit.Structs.DiffHunk.DiffHunk'. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffHunkCallback`@.
noDiffHunkCallback :: Maybe DiffHunkCallback
noDiffHunkCallback = Nothing

{- |
Called for each hunk.
-}
type DiffHunkCallback_WithClosures =
    Ggit.DiffDelta.DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> Ggit.DiffHunk.DiffHunk
    {- ^ /@hunk@/: a 'GI.Ggit.Structs.DiffHunk.DiffHunk'. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffHunkCallback_WithClosures`@.
noDiffHunkCallback_WithClosures :: Maybe DiffHunkCallback_WithClosures
noDiffHunkCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_DiffHunkCallback :: DiffHunkCallback -> DiffHunkCallback_WithClosures
drop_closures_DiffHunkCallback _f delta hunk _ = _f delta hunk

-- | Wrap the callback into a `GClosure`.
genClosure_DiffHunkCallback :: MonadIO m => DiffHunkCallback -> m (GClosure C_DiffHunkCallback)
genClosure_DiffHunkCallback cb = liftIO $ do
    let cb' = drop_closures_DiffHunkCallback cb
    let cb'' = wrap_DiffHunkCallback Nothing cb'
    mk_DiffHunkCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `DiffHunkCallback` into a `C_DiffHunkCallback`.
wrap_DiffHunkCallback ::
    Maybe (Ptr (FunPtr C_DiffHunkCallback)) ->
    DiffHunkCallback_WithClosures ->
    C_DiffHunkCallback
wrap_DiffHunkCallback funptrptr _cb delta hunk userData = do
    B.ManagedPtr.withTransient Ggit.DiffDelta.DiffDelta delta $ \delta' -> do
        B.ManagedPtr.withTransient Ggit.DiffHunk.DiffHunk hunk $ \hunk' -> do
            result <- _cb  delta' hunk' userData
            maybeReleaseFunPtr funptrptr
            return result


-- callback DiffFileCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go continue or a #GgitError in case there was an error.", sinceVersion = Nothing}, args = [Arg {argCName = "delta", argType = TInterface (Name {namespace = "Ggit", name = "DiffDelta"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffDelta.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "progress", argType = TBasicType TFloat, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the progress.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Called for each file.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_DiffFileCallback =
    Ptr Ggit.DiffDelta.DiffDelta ->
    CFloat ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "delta", argType = TInterface (Name {namespace = "Ggit", name = "DiffDelta"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffDelta.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "progress", argType = TBasicType TFloat, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the progress.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_DiffFileCallback :: FunPtr C_DiffFileCallback -> C_DiffFileCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_DiffFileCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_DiffFileCallback
    -> Ggit.DiffDelta.DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> Float
    {- ^ /@progress@/: the progress. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}
dynamic_DiffFileCallback __funPtr delta progress userData = liftIO $ do
    delta' <- unsafeManagedPtrGetPtr delta
    let progress' = realToFrac progress
    result <- (__dynamic_C_DiffFileCallback __funPtr) delta' progress' userData
    touchManagedPtr delta
    return result

-- | Generate a function pointer callable from C code, from a `C_DiffFileCallback`.
foreign import ccall "wrapper"
    mk_DiffFileCallback :: C_DiffFileCallback -> IO (FunPtr C_DiffFileCallback)

{- |
Called for each file.
-}
type DiffFileCallback =
    Ggit.DiffDelta.DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> Float
    {- ^ /@progress@/: the progress. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffFileCallback`@.
noDiffFileCallback :: Maybe DiffFileCallback
noDiffFileCallback = Nothing

{- |
Called for each file.
-}
type DiffFileCallback_WithClosures =
    Ggit.DiffDelta.DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> Float
    {- ^ /@progress@/: the progress. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffFileCallback_WithClosures`@.
noDiffFileCallback_WithClosures :: Maybe DiffFileCallback_WithClosures
noDiffFileCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_DiffFileCallback :: DiffFileCallback -> DiffFileCallback_WithClosures
drop_closures_DiffFileCallback _f delta progress _ = _f delta progress

-- | Wrap the callback into a `GClosure`.
genClosure_DiffFileCallback :: MonadIO m => DiffFileCallback -> m (GClosure C_DiffFileCallback)
genClosure_DiffFileCallback cb = liftIO $ do
    let cb' = drop_closures_DiffFileCallback cb
    let cb'' = wrap_DiffFileCallback Nothing cb'
    mk_DiffFileCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `DiffFileCallback` into a `C_DiffFileCallback`.
wrap_DiffFileCallback ::
    Maybe (Ptr (FunPtr C_DiffFileCallback)) ->
    DiffFileCallback_WithClosures ->
    C_DiffFileCallback
wrap_DiffFileCallback funptrptr _cb delta progress userData = do
    B.ManagedPtr.withTransient Ggit.DiffDelta.DiffDelta delta $ \delta' -> do
        let progress' = realToFrac progress
        result <- _cb  delta' progress' userData
        maybeReleaseFunPtr funptrptr
        return result


-- callback DiffBinaryCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go continue or a #GgitError in case there was an error.", sinceVersion = Nothing}, args = [Arg {argCName = "delta", argType = TInterface (Name {namespace = "Ggit", name = "DiffDelta"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffDelta.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "binary", argType = TInterface (Name {namespace = "Ggit", name = "DiffBinary"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffBinary.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Called for each file.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_DiffBinaryCallback =
    Ptr Ggit.DiffDelta.DiffDelta ->
    Ptr Ggit.DiffBinary.DiffBinary ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "delta", argType = TInterface (Name {namespace = "Ggit", name = "DiffDelta"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffDelta.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "binary", argType = TInterface (Name {namespace = "Ggit", name = "DiffBinary"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffBinary.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_DiffBinaryCallback :: FunPtr C_DiffBinaryCallback -> C_DiffBinaryCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_DiffBinaryCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_DiffBinaryCallback
    -> Ggit.DiffDelta.DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> Ggit.DiffBinary.DiffBinary
    {- ^ /@binary@/: a 'GI.Ggit.Structs.DiffBinary.DiffBinary'. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}
dynamic_DiffBinaryCallback __funPtr delta binary userData = liftIO $ do
    delta' <- unsafeManagedPtrGetPtr delta
    binary' <- unsafeManagedPtrGetPtr binary
    result <- (__dynamic_C_DiffBinaryCallback __funPtr) delta' binary' userData
    touchManagedPtr delta
    touchManagedPtr binary
    return result

-- | Generate a function pointer callable from C code, from a `C_DiffBinaryCallback`.
foreign import ccall "wrapper"
    mk_DiffBinaryCallback :: C_DiffBinaryCallback -> IO (FunPtr C_DiffBinaryCallback)

{- |
Called for each file.
-}
type DiffBinaryCallback =
    Ggit.DiffDelta.DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> Ggit.DiffBinary.DiffBinary
    {- ^ /@binary@/: a 'GI.Ggit.Structs.DiffBinary.DiffBinary'. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffBinaryCallback`@.
noDiffBinaryCallback :: Maybe DiffBinaryCallback
noDiffBinaryCallback = Nothing

{- |
Called for each file.
-}
type DiffBinaryCallback_WithClosures =
    Ggit.DiffDelta.DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> Ggit.DiffBinary.DiffBinary
    {- ^ /@binary@/: a 'GI.Ggit.Structs.DiffBinary.DiffBinary'. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go continue or a 'GI.Ggit.Enums.Error' in case there was an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `DiffBinaryCallback_WithClosures`@.
noDiffBinaryCallback_WithClosures :: Maybe DiffBinaryCallback_WithClosures
noDiffBinaryCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_DiffBinaryCallback :: DiffBinaryCallback -> DiffBinaryCallback_WithClosures
drop_closures_DiffBinaryCallback _f delta binary _ = _f delta binary

-- | Wrap the callback into a `GClosure`.
genClosure_DiffBinaryCallback :: MonadIO m => DiffBinaryCallback -> m (GClosure C_DiffBinaryCallback)
genClosure_DiffBinaryCallback cb = liftIO $ do
    let cb' = drop_closures_DiffBinaryCallback cb
    let cb'' = wrap_DiffBinaryCallback Nothing cb'
    mk_DiffBinaryCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `DiffBinaryCallback` into a `C_DiffBinaryCallback`.
wrap_DiffBinaryCallback ::
    Maybe (Ptr (FunPtr C_DiffBinaryCallback)) ->
    DiffBinaryCallback_WithClosures ->
    C_DiffBinaryCallback
wrap_DiffBinaryCallback funptrptr _cb delta binary userData = do
    B.ManagedPtr.withTransient Ggit.DiffDelta.DiffDelta delta $ \delta' -> do
        B.ManagedPtr.withTransient Ggit.DiffBinary.DiffBinary binary $ \binary' -> do
            result <- _cb  delta' binary' userData
            maybeReleaseFunPtr funptrptr
            return result


-- callback CredAcquireCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, args = [Arg {argCName = "url", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the resource for which we are demanding a credential.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "username_from_url", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "The username that was embedded in a \"user@host\"\n                                  remote url, or NULL if not included.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "allowed_types", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a bitmask stating which cred types are OK to return.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cred", argType = TInterface (Name {namespace = "Ggit", name = "Cred"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "newly created credential object.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "Signature of a function which acquires a credential object.", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_CredAcquireCallback =
    CString ->
    CString ->
    Word32 ->
    Ptr Ggit.Cred.Cred ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "url", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the resource for which we are demanding a credential.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "username_from_url", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "The username that was embedded in a \"user@host\"\n                                  remote url, or NULL if not included.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "allowed_types", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a bitmask stating which cred types are OK to return.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "cred", argType = TInterface (Name {namespace = "Ggit", name = "Cred"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "newly created credential object.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferEverything},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 4, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_CredAcquireCallback :: FunPtr C_CredAcquireCallback -> C_CredAcquireCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_CredAcquireCallback ::
    (B.CallStack.HasCallStack, MonadIO m, Ggit.Cred.IsCred a) =>
    FunPtr C_CredAcquireCallback
    -> T.Text
    {- ^ /@url@/: the resource for which we are demanding a credential. -}
    -> Maybe (T.Text)
    {- ^ /@usernameFromUrl@/: The username that was embedded in a \"user/@host@/\"
                                  remote url, or NULL if not included. -}
    -> Word32
    {- ^ /@allowedTypes@/: a bitmask stating which cred types are OK to return. -}
    -> a
    {- ^ /@cred@/: newly created credential object. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
dynamic_CredAcquireCallback __funPtr url usernameFromUrl allowedTypes cred userData = liftIO $ do
    url' <- textToCString url
    maybeUsernameFromUrl <- case usernameFromUrl of
        Nothing -> return nullPtr
        Just jUsernameFromUrl -> do
            jUsernameFromUrl' <- textToCString jUsernameFromUrl
            return jUsernameFromUrl'
    cred' <- B.ManagedPtr.disownObject cred
    result <- (__dynamic_C_CredAcquireCallback __funPtr) url' maybeUsernameFromUrl allowedTypes cred' userData
    touchManagedPtr cred
    freeMem url'
    freeMem maybeUsernameFromUrl
    return result

-- | Generate a function pointer callable from C code, from a `C_CredAcquireCallback`.
foreign import ccall "wrapper"
    mk_CredAcquireCallback :: C_CredAcquireCallback -> IO (FunPtr C_CredAcquireCallback)

{- |
Signature of a function which acquires a credential object.
-}
type CredAcquireCallback =
    T.Text
    {- ^ /@url@/: the resource for which we are demanding a credential. -}
    -> Maybe T.Text
    {- ^ /@usernameFromUrl@/: The username that was embedded in a \"user/@host@/\"
                                  remote url, or NULL if not included. -}
    -> Word32
    {- ^ /@allowedTypes@/: a bitmask stating which cred types are OK to return. -}
    -> Ggit.Cred.Cred
    {- ^ /@cred@/: newly created credential object. -}
    -> IO Int32

-- | A convenience synonym for @`Nothing` :: `Maybe` `CredAcquireCallback`@.
noCredAcquireCallback :: Maybe CredAcquireCallback
noCredAcquireCallback = Nothing

{- |
Signature of a function which acquires a credential object.
-}
type CredAcquireCallback_WithClosures =
    T.Text
    {- ^ /@url@/: the resource for which we are demanding a credential. -}
    -> Maybe T.Text
    {- ^ /@usernameFromUrl@/: The username that was embedded in a \"user/@host@/\"
                                  remote url, or NULL if not included. -}
    -> Word32
    {- ^ /@allowedTypes@/: a bitmask stating which cred types are OK to return. -}
    -> Ggit.Cred.Cred
    {- ^ /@cred@/: newly created credential object. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32

-- | A convenience synonym for @`Nothing` :: `Maybe` `CredAcquireCallback_WithClosures`@.
noCredAcquireCallback_WithClosures :: Maybe CredAcquireCallback_WithClosures
noCredAcquireCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_CredAcquireCallback :: CredAcquireCallback -> CredAcquireCallback_WithClosures
drop_closures_CredAcquireCallback _f url usernameFromUrl allowedTypes cred _ = _f url usernameFromUrl allowedTypes cred

-- | Wrap the callback into a `GClosure`.
genClosure_CredAcquireCallback :: MonadIO m => CredAcquireCallback -> m (GClosure C_CredAcquireCallback)
genClosure_CredAcquireCallback cb = liftIO $ do
    let cb' = drop_closures_CredAcquireCallback cb
    let cb'' = wrap_CredAcquireCallback Nothing cb'
    mk_CredAcquireCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `CredAcquireCallback` into a `C_CredAcquireCallback`.
wrap_CredAcquireCallback ::
    Maybe (Ptr (FunPtr C_CredAcquireCallback)) ->
    CredAcquireCallback_WithClosures ->
    C_CredAcquireCallback
wrap_CredAcquireCallback funptrptr _cb url usernameFromUrl allowedTypes cred userData = do
    url' <- cstringToText url
    maybeUsernameFromUrl <-
        if usernameFromUrl == nullPtr
        then return Nothing
        else do
            usernameFromUrl' <- cstringToText usernameFromUrl
            return $ Just usernameFromUrl'
    cred' <- (wrapObject Ggit.Cred.Cred) cred
    result <- _cb  url' maybeUsernameFromUrl allowedTypes cred' userData
    maybeReleaseFunPtr funptrptr
    return result


-- callback ConfigMatchCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go for the next config value or a #GgitError in case there was\n         an error.", sinceVersion = Nothing}, args = [Arg {argCName = "match_info", argType = TInterface (Name {namespace = "GLib", name = "MatchInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the match", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The type of the callback functions for retrieving values from a #GgitConfig\nusing a regular expression. See ggit_config_match_foreach().", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_ConfigMatchCallback =
    Ptr GLib.MatchInfo.MatchInfo ->
    CString ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "match_info", argType = TInterface (Name {namespace = "GLib", name = "MatchInfo"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the match", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the value", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 2, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_ConfigMatchCallback :: FunPtr C_ConfigMatchCallback -> C_ConfigMatchCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_ConfigMatchCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_ConfigMatchCallback
    -> GLib.MatchInfo.MatchInfo
    {- ^ /@matchInfo@/: the match -}
    -> T.Text
    {- ^ /@value@/: the value -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go for the next config value or a 'GI.Ggit.Enums.Error' in case there was
         an error. -}
dynamic_ConfigMatchCallback __funPtr matchInfo value userData = liftIO $ do
    matchInfo' <- unsafeManagedPtrGetPtr matchInfo
    value' <- textToCString value
    result <- (__dynamic_C_ConfigMatchCallback __funPtr) matchInfo' value' userData
    touchManagedPtr matchInfo
    freeMem value'
    return result

-- | Generate a function pointer callable from C code, from a `C_ConfigMatchCallback`.
foreign import ccall "wrapper"
    mk_ConfigMatchCallback :: C_ConfigMatchCallback -> IO (FunPtr C_ConfigMatchCallback)

{- |
The type of the callback functions for retrieving values from a 'GI.Ggit.Objects.Config.Config'
using a regular expression. See 'GI.Ggit.Objects.Config.configMatchForeach'.
-}
type ConfigMatchCallback =
    GLib.MatchInfo.MatchInfo
    {- ^ /@matchInfo@/: the match -}
    -> T.Text
    {- ^ /@value@/: the value -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next config value or a 'GI.Ggit.Enums.Error' in case there was
         an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `ConfigMatchCallback`@.
noConfigMatchCallback :: Maybe ConfigMatchCallback
noConfigMatchCallback = Nothing

{- |
The type of the callback functions for retrieving values from a 'GI.Ggit.Objects.Config.Config'
using a regular expression. See 'GI.Ggit.Objects.Config.configMatchForeach'.
-}
type ConfigMatchCallback_WithClosures =
    GLib.MatchInfo.MatchInfo
    {- ^ /@matchInfo@/: the match -}
    -> T.Text
    {- ^ /@value@/: the value -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next config value or a 'GI.Ggit.Enums.Error' in case there was
         an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `ConfigMatchCallback_WithClosures`@.
noConfigMatchCallback_WithClosures :: Maybe ConfigMatchCallback_WithClosures
noConfigMatchCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_ConfigMatchCallback :: ConfigMatchCallback -> ConfigMatchCallback_WithClosures
drop_closures_ConfigMatchCallback _f matchInfo value _ = _f matchInfo value

-- | Wrap the callback into a `GClosure`.
genClosure_ConfigMatchCallback :: MonadIO m => ConfigMatchCallback -> m (GClosure C_ConfigMatchCallback)
genClosure_ConfigMatchCallback cb = liftIO $ do
    let cb' = drop_closures_ConfigMatchCallback cb
    let cb'' = wrap_ConfigMatchCallback Nothing cb'
    mk_ConfigMatchCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `ConfigMatchCallback` into a `C_ConfigMatchCallback`.
wrap_ConfigMatchCallback ::
    Maybe (Ptr (FunPtr C_ConfigMatchCallback)) ->
    ConfigMatchCallback_WithClosures ->
    C_ConfigMatchCallback
wrap_ConfigMatchCallback funptrptr _cb matchInfo value userData = do
    B.ManagedPtr.withTransient GLib.MatchInfo.MatchInfo matchInfo $ \matchInfo' -> do
        value' <- cstringToText value
        result <- _cb  matchInfo' value' userData
        maybeReleaseFunPtr funptrptr
        return result


-- callback ConfigCallback
--          -> Callable {returnType = Just (TBasicType TInt), returnMayBeNull = False, returnTransfer = TransferNothing, returnDocumentation = Documentation {rawDocText = Just "0 to go for the next config value or a #GgitError in case there was\n         an error.", sinceVersion = Nothing}, args = [Arg {argCName = "entry", argType = TInterface (Name {namespace = "Ggit", name = "ConfigEntry"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitConfigEntry.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}], skipReturn = False, callableThrows = False, callableDeprecated = Nothing, callableDocumentation = Documentation {rawDocText = Just "The type of the callback functions for retrieving values from a #GgitConfig.\nSee ggit_config_foreach().", sinceVersion = Nothing}}
-- | Type for the callback on the (unwrapped) C side.
type C_ConfigCallback =
    Ptr Ggit.ConfigEntry.ConfigEntry ->
    Ptr () ->
    IO Int32

-- Args : [Arg {argCName = "entry", argType = TInterface (Name {namespace = "Ggit", name = "ConfigEntry"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitConfigEntry.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "user-supplied data.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = 1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "dynamic" __dynamic_C_ConfigCallback :: FunPtr C_ConfigCallback -> C_ConfigCallback

-- | Given a pointer to a foreign C function, wrap it into a function callable from Haskell.
dynamic_ConfigCallback ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    FunPtr C_ConfigCallback
    -> Ggit.ConfigEntry.ConfigEntry
    {- ^ /@entry@/: a 'GI.Ggit.Structs.ConfigEntry.ConfigEntry'. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> m Int32
    {- ^ __Returns:__ 0 to go for the next config value or a 'GI.Ggit.Enums.Error' in case there was
         an error. -}
dynamic_ConfigCallback __funPtr entry userData = liftIO $ do
    entry' <- unsafeManagedPtrGetPtr entry
    result <- (__dynamic_C_ConfigCallback __funPtr) entry' userData
    touchManagedPtr entry
    return result

-- | Generate a function pointer callable from C code, from a `C_ConfigCallback`.
foreign import ccall "wrapper"
    mk_ConfigCallback :: C_ConfigCallback -> IO (FunPtr C_ConfigCallback)

{- |
The type of the callback functions for retrieving values from a 'GI.Ggit.Objects.Config.Config'.
See 'GI.Ggit.Objects.Config.configForeach'.
-}
type ConfigCallback =
    Ggit.ConfigEntry.ConfigEntry
    {- ^ /@entry@/: a 'GI.Ggit.Structs.ConfigEntry.ConfigEntry'. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next config value or a 'GI.Ggit.Enums.Error' in case there was
         an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `ConfigCallback`@.
noConfigCallback :: Maybe ConfigCallback
noConfigCallback = Nothing

{- |
The type of the callback functions for retrieving values from a 'GI.Ggit.Objects.Config.Config'.
See 'GI.Ggit.Objects.Config.configForeach'.
-}
type ConfigCallback_WithClosures =
    Ggit.ConfigEntry.ConfigEntry
    {- ^ /@entry@/: a 'GI.Ggit.Structs.ConfigEntry.ConfigEntry'. -}
    -> Ptr ()
    {- ^ /@userData@/: user-supplied data. -}
    -> IO Int32
    {- ^ __Returns:__ 0 to go for the next config value or a 'GI.Ggit.Enums.Error' in case there was
         an error. -}

-- | A convenience synonym for @`Nothing` :: `Maybe` `ConfigCallback_WithClosures`@.
noConfigCallback_WithClosures :: Maybe ConfigCallback_WithClosures
noConfigCallback_WithClosures = Nothing

-- | A simple wrapper that ignores the closure arguments.
drop_closures_ConfigCallback :: ConfigCallback -> ConfigCallback_WithClosures
drop_closures_ConfigCallback _f entry _ = _f entry

-- | Wrap the callback into a `GClosure`.
genClosure_ConfigCallback :: MonadIO m => ConfigCallback -> m (GClosure C_ConfigCallback)
genClosure_ConfigCallback cb = liftIO $ do
    let cb' = drop_closures_ConfigCallback cb
    let cb'' = wrap_ConfigCallback Nothing cb'
    mk_ConfigCallback cb'' >>= B.GClosure.newGClosure


-- | Wrap a `ConfigCallback` into a `C_ConfigCallback`.
wrap_ConfigCallback ::
    Maybe (Ptr (FunPtr C_ConfigCallback)) ->
    ConfigCallback_WithClosures ->
    C_ConfigCallback
wrap_ConfigCallback funptrptr _cb entry userData = do
    B.ManagedPtr.withTransient Ggit.ConfigEntry.ConfigEntry entry $ \entry' -> do
        result <- _cb  entry' userData
        maybeReleaseFunPtr funptrptr
        return result