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

Represents a revision walker.
-}

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

module GI.Ggit.Objects.RevisionWalker
    (

-- * Exported types
    RevisionWalker(..)                      ,
    IsRevisionWalker                        ,
    toRevisionWalker                        ,
    noRevisionWalker                        ,


 -- * Methods
-- ** getRepository #method:getRepository#

#if ENABLE_OVERLOADING
    RevisionWalkerGetRepositoryMethodInfo   ,
#endif
    revisionWalkerGetRepository             ,


-- ** hide #method:hide#

#if ENABLE_OVERLOADING
    RevisionWalkerHideMethodInfo            ,
#endif
    revisionWalkerHide                      ,


-- ** hideGlob #method:hideGlob#

#if ENABLE_OVERLOADING
    RevisionWalkerHideGlobMethodInfo        ,
#endif
    revisionWalkerHideGlob                  ,


-- ** hideHead #method:hideHead#

#if ENABLE_OVERLOADING
    RevisionWalkerHideHeadMethodInfo        ,
#endif
    revisionWalkerHideHead                  ,


-- ** hideRef #method:hideRef#

#if ENABLE_OVERLOADING
    RevisionWalkerHideRefMethodInfo         ,
#endif
    revisionWalkerHideRef                   ,


-- ** new #method:new#

    revisionWalkerNew                       ,


-- ** next #method:next#

#if ENABLE_OVERLOADING
    RevisionWalkerNextMethodInfo            ,
#endif
    revisionWalkerNext                      ,


-- ** push #method:push#

#if ENABLE_OVERLOADING
    RevisionWalkerPushMethodInfo            ,
#endif
    revisionWalkerPush                      ,


-- ** pushGlob #method:pushGlob#

#if ENABLE_OVERLOADING
    RevisionWalkerPushGlobMethodInfo        ,
#endif
    revisionWalkerPushGlob                  ,


-- ** pushHead #method:pushHead#

#if ENABLE_OVERLOADING
    RevisionWalkerPushHeadMethodInfo        ,
#endif
    revisionWalkerPushHead                  ,


-- ** pushRange #method:pushRange#

#if ENABLE_OVERLOADING
    RevisionWalkerPushRangeMethodInfo       ,
#endif
    revisionWalkerPushRange                 ,


-- ** pushRef #method:pushRef#

#if ENABLE_OVERLOADING
    RevisionWalkerPushRefMethodInfo         ,
#endif
    revisionWalkerPushRef                   ,


-- ** reset #method:reset#

#if ENABLE_OVERLOADING
    RevisionWalkerResetMethodInfo           ,
#endif
    revisionWalkerReset                     ,


-- ** setSortMode #method:setSortMode#

#if ENABLE_OVERLOADING
    RevisionWalkerSetSortModeMethodInfo     ,
#endif
    revisionWalkerSetSortMode               ,




 -- * Properties
-- ** repository #attr:repository#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    RevisionWalkerRepositoryPropertyInfo    ,
#endif
    clearRevisionWalkerRepository           ,
    constructRevisionWalkerRepository       ,
    getRevisionWalkerRepository             ,
#if ENABLE_OVERLOADING
    revisionWalkerRepository                ,
#endif
    setRevisionWalkerRepository             ,




    ) 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.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Ggit.Flags as Ggit.Flags
import {-# SOURCE #-} qualified GI.Ggit.Objects.Native as Ggit.Native
import {-# SOURCE #-} qualified GI.Ggit.Objects.ObjectFactoryBase as Ggit.ObjectFactoryBase
import {-# SOURCE #-} qualified GI.Ggit.Objects.Repository as Ggit.Repository
import {-# SOURCE #-} qualified GI.Ggit.Structs.OId as Ggit.OId
import qualified GI.Gio.Interfaces.Initable as Gio.Initable

-- | Memory-managed wrapper type.
newtype RevisionWalker = RevisionWalker (ManagedPtr RevisionWalker)
foreign import ccall "ggit_revision_walker_get_type"
    c_ggit_revision_walker_get_type :: IO GType

instance GObject RevisionWalker where
    gobjectType = c_ggit_revision_walker_get_type


-- | Type class for types which can be safely cast to `RevisionWalker`, for instance with `toRevisionWalker`.
class (GObject o, O.IsDescendantOf RevisionWalker o) => IsRevisionWalker o
instance (GObject o, O.IsDescendantOf RevisionWalker o) => IsRevisionWalker o

instance O.HasParentTypes RevisionWalker
type instance O.ParentTypes RevisionWalker = '[Ggit.Native.Native, Ggit.ObjectFactoryBase.ObjectFactoryBase, GObject.Object.Object, Gio.Initable.Initable]

-- | Cast to `RevisionWalker`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toRevisionWalker :: (MonadIO m, IsRevisionWalker o) => o -> m RevisionWalker
toRevisionWalker = liftIO . unsafeCastTo RevisionWalker

-- | A convenience alias for `Nothing` :: `Maybe` `RevisionWalker`.
noRevisionWalker :: Maybe RevisionWalker
noRevisionWalker = Nothing

#if ENABLE_OVERLOADING
type family ResolveRevisionWalkerMethod (t :: Symbol) (o :: *) :: * where
    ResolveRevisionWalkerMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveRevisionWalkerMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveRevisionWalkerMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveRevisionWalkerMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveRevisionWalkerMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveRevisionWalkerMethod "hide" o = RevisionWalkerHideMethodInfo
    ResolveRevisionWalkerMethod "hideGlob" o = RevisionWalkerHideGlobMethodInfo
    ResolveRevisionWalkerMethod "hideHead" o = RevisionWalkerHideHeadMethodInfo
    ResolveRevisionWalkerMethod "hideRef" o = RevisionWalkerHideRefMethodInfo
    ResolveRevisionWalkerMethod "init" o = Gio.Initable.InitableInitMethodInfo
    ResolveRevisionWalkerMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveRevisionWalkerMethod "next" o = RevisionWalkerNextMethodInfo
    ResolveRevisionWalkerMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveRevisionWalkerMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveRevisionWalkerMethod "push" o = RevisionWalkerPushMethodInfo
    ResolveRevisionWalkerMethod "pushGlob" o = RevisionWalkerPushGlobMethodInfo
    ResolveRevisionWalkerMethod "pushHead" o = RevisionWalkerPushHeadMethodInfo
    ResolveRevisionWalkerMethod "pushRange" o = RevisionWalkerPushRangeMethodInfo
    ResolveRevisionWalkerMethod "pushRef" o = RevisionWalkerPushRefMethodInfo
    ResolveRevisionWalkerMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveRevisionWalkerMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveRevisionWalkerMethod "reset" o = RevisionWalkerResetMethodInfo
    ResolveRevisionWalkerMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveRevisionWalkerMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveRevisionWalkerMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveRevisionWalkerMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveRevisionWalkerMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveRevisionWalkerMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveRevisionWalkerMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveRevisionWalkerMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveRevisionWalkerMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveRevisionWalkerMethod "getRepository" o = RevisionWalkerGetRepositoryMethodInfo
    ResolveRevisionWalkerMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveRevisionWalkerMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveRevisionWalkerMethod "setSortMode" o = RevisionWalkerSetSortModeMethodInfo
    ResolveRevisionWalkerMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveRevisionWalkerMethod t RevisionWalker, O.MethodInfo info RevisionWalker p) => OL.IsLabel t (RevisionWalker -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif

-- VVV Prop "repository"
   -- Type: TInterface (Name {namespace = "Ggit", name = "Repository"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Just True,Nothing)

{- |
Get the value of the “@repository@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' revisionWalker #repository
@
-}
getRevisionWalkerRepository :: (MonadIO m, IsRevisionWalker o) => o -> m (Maybe Ggit.Repository.Repository)
getRevisionWalkerRepository obj = liftIO $ B.Properties.getObjectPropertyObject obj "repository" Ggit.Repository.Repository

{- |
Set the value of the “@repository@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' revisionWalker [ #repository 'Data.GI.Base.Attributes.:=' value ]
@
-}
setRevisionWalkerRepository :: (MonadIO m, IsRevisionWalker o, Ggit.Repository.IsRepository a) => o -> a -> m ()
setRevisionWalkerRepository obj val = liftIO $ B.Properties.setObjectPropertyObject obj "repository" (Just val)

{- |
Construct a `GValueConstruct` with valid value for the “@repository@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructRevisionWalkerRepository :: (IsRevisionWalker o, Ggit.Repository.IsRepository a) => a -> IO (GValueConstruct o)
constructRevisionWalkerRepository val = B.Properties.constructObjectPropertyObject "repository" (Just val)

{- |
Set the value of the “@repository@” property to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #repository
@
-}
clearRevisionWalkerRepository :: (MonadIO m, IsRevisionWalker o) => o -> m ()
clearRevisionWalkerRepository obj = liftIO $ B.Properties.setObjectPropertyObject obj "repository" (Nothing :: Maybe Ggit.Repository.Repository)

#if ENABLE_OVERLOADING
data RevisionWalkerRepositoryPropertyInfo
instance AttrInfo RevisionWalkerRepositoryPropertyInfo where
    type AttrAllowedOps RevisionWalkerRepositoryPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint RevisionWalkerRepositoryPropertyInfo = Ggit.Repository.IsRepository
    type AttrBaseTypeConstraint RevisionWalkerRepositoryPropertyInfo = IsRevisionWalker
    type AttrGetType RevisionWalkerRepositoryPropertyInfo = (Maybe Ggit.Repository.Repository)
    type AttrLabel RevisionWalkerRepositoryPropertyInfo = "repository"
    type AttrOrigin RevisionWalkerRepositoryPropertyInfo = RevisionWalker
    attrGet _ = getRevisionWalkerRepository
    attrSet _ = setRevisionWalkerRepository
    attrConstruct _ = constructRevisionWalkerRepository
    attrClear _ = clearRevisionWalkerRepository
#endif

#if ENABLE_OVERLOADING
instance O.HasAttributeList RevisionWalker
type instance O.AttributeList RevisionWalker = RevisionWalkerAttributeList
type RevisionWalkerAttributeList = ('[ '("native", Ggit.Native.NativeNativePropertyInfo), '("repository", RevisionWalkerRepositoryPropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
revisionWalkerRepository :: AttrLabelProxy "repository"
revisionWalkerRepository = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
type instance O.SignalList RevisionWalker = RevisionWalkerSignalList
type RevisionWalkerSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

-- method RevisionWalker::new
-- method type : Constructor
-- Args : [Arg {argCName = "repository", argType = TInterface (Name {namespace = "Ggit", name = "Repository"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRepository.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}))
-- throws : True
-- Skip return : False

foreign import ccall "ggit_revision_walker_new" ggit_revision_walker_new ::
    Ptr Ggit.Repository.Repository ->       -- repository : TInterface (Name {namespace = "Ggit", name = "Repository"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr RevisionWalker)

{- |
Creates a new revision walker to iterate through /@repository@/.

This revision walker uses a custom memory pool and an internal
commit cache, so it is relatively expensive to allocate.

For maximum performance, this revision walker should be
reused for different walks.

This revision walker is *not* thread safe: it may only be
used to walk a repository on a single thread; however,
it is possible to have several revision walkers in
several different threads walking the same repository.
-}
revisionWalkerNew ::
    (B.CallStack.HasCallStack, MonadIO m, Ggit.Repository.IsRepository a) =>
    a
    {- ^ /@repository@/: a 'GI.Ggit.Objects.Repository.Repository'. -}
    -> m (Maybe RevisionWalker)
    {- ^ __Returns:__ a new 'GI.Ggit.Objects.RevisionWalker.RevisionWalker' or 'Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
revisionWalkerNew repository = liftIO $ do
    repository' <- unsafeManagedPtrCastPtr repository
    onException (do
        result <- propagateGError $ ggit_revision_walker_new repository'
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- (wrapObject RevisionWalker) result'
            return result''
        touchManagedPtr repository
        return maybeResult
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
#endif

-- method RevisionWalker::get_repository
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "walker", argType = TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRepository.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "Repository"}))
-- throws : False
-- Skip return : False

foreign import ccall "ggit_revision_walker_get_repository" ggit_revision_walker_get_repository ::
    Ptr RevisionWalker ->                   -- walker : TInterface (Name {namespace = "Ggit", name = "RevisionWalker"})
    IO (Ptr Ggit.Repository.Repository)

{- |
Gets the repository on which this walker is operating.
-}
revisionWalkerGetRepository ::
    (B.CallStack.HasCallStack, MonadIO m, IsRevisionWalker a) =>
    a
    {- ^ /@walker@/: a 'GI.Ggit.Objects.Repository.Repository'. -}
    -> m (Maybe Ggit.Repository.Repository)
    {- ^ __Returns:__ the repository on which this walker is operating or 'Nothing'. -}
revisionWalkerGetRepository walker = liftIO $ do
    walker' <- unsafeManagedPtrCastPtr walker
    result <- ggit_revision_walker_get_repository walker'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newObject Ggit.Repository.Repository) result'
        return result''
    touchManagedPtr walker
    return maybeResult

#if ENABLE_OVERLOADING
data RevisionWalkerGetRepositoryMethodInfo
instance (signature ~ (m (Maybe Ggit.Repository.Repository)), MonadIO m, IsRevisionWalker a) => O.MethodInfo RevisionWalkerGetRepositoryMethodInfo a signature where
    overloadedMethod _ = revisionWalkerGetRepository

#endif

-- method RevisionWalker::hide
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "walker", argType = TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRevisionWalker.", 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 "a #GgitOId.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_revision_walker_hide" ggit_revision_walker_hide ::
    Ptr RevisionWalker ->                   -- walker : TInterface (Name {namespace = "Ggit", name = "RevisionWalker"})
    Ptr Ggit.OId.OId ->                     -- oid : TInterface (Name {namespace = "Ggit", name = "OId"})
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
Marks a commit (and its ancestors) uninteresting for the output.

The given OID must belong to a commit on the walked
repository.

The resolved commit and all its parents will be hidden from the
output on the revision walk.
-}
revisionWalkerHide ::
    (B.CallStack.HasCallStack, MonadIO m, IsRevisionWalker a) =>
    a
    {- ^ /@walker@/: a 'GI.Ggit.Objects.RevisionWalker.RevisionWalker'. -}
    -> Ggit.OId.OId
    {- ^ /@oid@/: a 'GI.Ggit.Structs.OId.OId'. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
revisionWalkerHide walker oid = liftIO $ do
    walker' <- unsafeManagedPtrCastPtr walker
    oid' <- unsafeManagedPtrGetPtr oid
    onException (do
        propagateGError $ ggit_revision_walker_hide walker' oid'
        touchManagedPtr walker
        touchManagedPtr oid
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data RevisionWalkerHideMethodInfo
instance (signature ~ (Ggit.OId.OId -> m ()), MonadIO m, IsRevisionWalker a) => O.MethodInfo RevisionWalkerHideMethodInfo a signature where
    overloadedMethod _ = revisionWalkerHide

#endif

-- method RevisionWalker::hide_glob
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "walker", argType = TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRevisionWalker.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the glob to hide.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_revision_walker_hide_glob" ggit_revision_walker_hide_glob ::
    Ptr RevisionWalker ->                   -- walker : TInterface (Name {namespace = "Ggit", name = "RevisionWalker"})
    CString ->                              -- item : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
Hide all OIDs pointed to by references that match the given glob pattern
to the revsision walker. A leading \'refs\/\' is implied if not present, as well
as a trailing \'\/ \\ *\' if the glob lacks \'?\', \'\\ *\' or \'[\'.
-}
revisionWalkerHideGlob ::
    (B.CallStack.HasCallStack, MonadIO m, IsRevisionWalker a) =>
    a
    {- ^ /@walker@/: a 'GI.Ggit.Objects.RevisionWalker.RevisionWalker'. -}
    -> T.Text
    {- ^ /@item@/: the glob to hide. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
revisionWalkerHideGlob walker item = liftIO $ do
    walker' <- unsafeManagedPtrCastPtr walker
    item' <- textToCString item
    onException (do
        propagateGError $ ggit_revision_walker_hide_glob walker' item'
        touchManagedPtr walker
        freeMem item'
        return ()
     ) (do
        freeMem item'
     )

#if ENABLE_OVERLOADING
data RevisionWalkerHideGlobMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsRevisionWalker a) => O.MethodInfo RevisionWalkerHideGlobMethodInfo a signature where
    overloadedMethod _ = revisionWalkerHideGlob

#endif

-- method RevisionWalker::hide_head
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "walker", argType = TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRevisionWalker.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_revision_walker_hide_head" ggit_revision_walker_hide_head ::
    Ptr RevisionWalker ->                   -- walker : TInterface (Name {namespace = "Ggit", name = "RevisionWalker"})
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
Hide the OID of the current HEAD to the revision walker.
-}
revisionWalkerHideHead ::
    (B.CallStack.HasCallStack, MonadIO m, IsRevisionWalker a) =>
    a
    {- ^ /@walker@/: a 'GI.Ggit.Objects.RevisionWalker.RevisionWalker'. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
revisionWalkerHideHead walker = liftIO $ do
    walker' <- unsafeManagedPtrCastPtr walker
    onException (do
        propagateGError $ ggit_revision_walker_hide_head walker'
        touchManagedPtr walker
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data RevisionWalkerHideHeadMethodInfo
instance (signature ~ (m ()), MonadIO m, IsRevisionWalker a) => O.MethodInfo RevisionWalkerHideHeadMethodInfo a signature where
    overloadedMethod _ = revisionWalkerHideHead

#endif

-- method RevisionWalker::hide_ref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "walker", argType = TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRevisionWalker.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the reference to hide.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_revision_walker_hide_ref" ggit_revision_walker_hide_ref ::
    Ptr RevisionWalker ->                   -- walker : TInterface (Name {namespace = "Ggit", name = "RevisionWalker"})
    CString ->                              -- item : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
Hide the OID pointed to by the named reference to the revision walker.
-}
revisionWalkerHideRef ::
    (B.CallStack.HasCallStack, MonadIO m, IsRevisionWalker a) =>
    a
    {- ^ /@walker@/: a 'GI.Ggit.Objects.RevisionWalker.RevisionWalker'. -}
    -> T.Text
    {- ^ /@item@/: the reference to hide. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
revisionWalkerHideRef walker item = liftIO $ do
    walker' <- unsafeManagedPtrCastPtr walker
    item' <- textToCString item
    onException (do
        propagateGError $ ggit_revision_walker_hide_ref walker' item'
        touchManagedPtr walker
        freeMem item'
        return ()
     ) (do
        freeMem item'
     )

#if ENABLE_OVERLOADING
data RevisionWalkerHideRefMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsRevisionWalker a) => O.MethodInfo RevisionWalkerHideRefMethodInfo a signature where
    overloadedMethod _ = revisionWalkerHideRef

#endif

-- method RevisionWalker::next
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "walker", argType = TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRevisionWalker.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "OId"}))
-- throws : True
-- Skip return : False

foreign import ccall "ggit_revision_walker_next" ggit_revision_walker_next ::
    Ptr RevisionWalker ->                   -- walker : TInterface (Name {namespace = "Ggit", name = "RevisionWalker"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Ggit.OId.OId)

{- |
Gets the next commit from the revision walk.

The initial call to this method is *not* blocking when
iterating through a repository with a time-sorting mode.

Iterating with Topological or inverted modes makes the initial
call blocking to preprocess the commit list, but this block should be
mostly unnoticeable on most repositories (topological preprocessing
times at 0.3s on the git.git repo).

The revision walker is reset when the walk is over.
-}
revisionWalkerNext ::
    (B.CallStack.HasCallStack, MonadIO m, IsRevisionWalker a) =>
    a
    {- ^ /@walker@/: a 'GI.Ggit.Objects.RevisionWalker.RevisionWalker'. -}
    -> m (Maybe Ggit.OId.OId)
    {- ^ __Returns:__ the next commit from the revision walk or 'Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/ -}
revisionWalkerNext walker = liftIO $ do
    walker' <- unsafeManagedPtrCastPtr walker
    onException (do
        result <- propagateGError $ ggit_revision_walker_next walker'
        maybeResult <- convertIfNonNull result $ \result' -> do
            result'' <- (wrapBoxed Ggit.OId.OId) result'
            return result''
        touchManagedPtr walker
        return maybeResult
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data RevisionWalkerNextMethodInfo
instance (signature ~ (m (Maybe Ggit.OId.OId)), MonadIO m, IsRevisionWalker a) => O.MethodInfo RevisionWalkerNextMethodInfo a signature where
    overloadedMethod _ = revisionWalkerNext

#endif

-- method RevisionWalker::push
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "walker", argType = TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRevisionWalker.", 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 "a #GgitOId.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_revision_walker_push" ggit_revision_walker_push ::
    Ptr RevisionWalker ->                   -- walker : TInterface (Name {namespace = "Ggit", name = "RevisionWalker"})
    Ptr Ggit.OId.OId ->                     -- oid : TInterface (Name {namespace = "Ggit", name = "OId"})
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
Marks a commit to start traversal from.

The given OID must belong to a commit on the walked
repository.

The given commit will be used as one of the roots
when starting the revision walk. At least one commit
must be pushed the repository before a walk can
be started.
-}
revisionWalkerPush ::
    (B.CallStack.HasCallStack, MonadIO m, IsRevisionWalker a) =>
    a
    {- ^ /@walker@/: a 'GI.Ggit.Objects.RevisionWalker.RevisionWalker'. -}
    -> Ggit.OId.OId
    {- ^ /@oid@/: a 'GI.Ggit.Structs.OId.OId'. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
revisionWalkerPush walker oid = liftIO $ do
    walker' <- unsafeManagedPtrCastPtr walker
    oid' <- unsafeManagedPtrGetPtr oid
    onException (do
        propagateGError $ ggit_revision_walker_push walker' oid'
        touchManagedPtr walker
        touchManagedPtr oid
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data RevisionWalkerPushMethodInfo
instance (signature ~ (Ggit.OId.OId -> m ()), MonadIO m, IsRevisionWalker a) => O.MethodInfo RevisionWalkerPushMethodInfo a signature where
    overloadedMethod _ = revisionWalkerPush

#endif

-- method RevisionWalker::push_glob
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "walker", argType = TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRevisionWalker.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the glob to push.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_revision_walker_push_glob" ggit_revision_walker_push_glob ::
    Ptr RevisionWalker ->                   -- walker : TInterface (Name {namespace = "Ggit", name = "RevisionWalker"})
    CString ->                              -- item : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
Push all OIDs pointed to by references that match the given glob pattern
to the revsision walker. A leading \'refs\/\' is implied if not present, as well
as a trailing \'\/ \\ *\' if the glob lacks \'?\', \'\\ *\' or \'[\'.
-}
revisionWalkerPushGlob ::
    (B.CallStack.HasCallStack, MonadIO m, IsRevisionWalker a) =>
    a
    {- ^ /@walker@/: a 'GI.Ggit.Objects.RevisionWalker.RevisionWalker'. -}
    -> T.Text
    {- ^ /@item@/: the glob to push. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
revisionWalkerPushGlob walker item = liftIO $ do
    walker' <- unsafeManagedPtrCastPtr walker
    item' <- textToCString item
    onException (do
        propagateGError $ ggit_revision_walker_push_glob walker' item'
        touchManagedPtr walker
        freeMem item'
        return ()
     ) (do
        freeMem item'
     )

#if ENABLE_OVERLOADING
data RevisionWalkerPushGlobMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsRevisionWalker a) => O.MethodInfo RevisionWalkerPushGlobMethodInfo a signature where
    overloadedMethod _ = revisionWalkerPushGlob

#endif

-- method RevisionWalker::push_head
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "walker", argType = TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRevisionWalker.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_revision_walker_push_head" ggit_revision_walker_push_head ::
    Ptr RevisionWalker ->                   -- walker : TInterface (Name {namespace = "Ggit", name = "RevisionWalker"})
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
Push the OID of the current HEAD to the revision walker.
-}
revisionWalkerPushHead ::
    (B.CallStack.HasCallStack, MonadIO m, IsRevisionWalker a) =>
    a
    {- ^ /@walker@/: a 'GI.Ggit.Objects.RevisionWalker.RevisionWalker'. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
revisionWalkerPushHead walker = liftIO $ do
    walker' <- unsafeManagedPtrCastPtr walker
    onException (do
        propagateGError $ ggit_revision_walker_push_head walker'
        touchManagedPtr walker
        return ()
     ) (do
        return ()
     )

#if ENABLE_OVERLOADING
data RevisionWalkerPushHeadMethodInfo
instance (signature ~ (m ()), MonadIO m, IsRevisionWalker a) => O.MethodInfo RevisionWalkerPushHeadMethodInfo a signature where
    overloadedMethod _ = revisionWalkerPushHead

#endif

-- method RevisionWalker::push_range
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "walker", argType = TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRevisionWalker.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "range", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the range to push.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_revision_walker_push_range" ggit_revision_walker_push_range ::
    Ptr RevisionWalker ->                   -- walker : TInterface (Name {namespace = "Ggit", name = "RevisionWalker"})
    CString ->                              -- range : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
Push and hide the respective endpoints of the given range. The range
should be of the form: &ltcommit&gt..&lt;commit&gt;, where each &lt;commit&gt; is in the
form accepted by revparse. The left-hand commit will be hidden and the
right-hand commit pushed.
-}
revisionWalkerPushRange ::
    (B.CallStack.HasCallStack, MonadIO m, IsRevisionWalker a) =>
    a
    {- ^ /@walker@/: a 'GI.Ggit.Objects.RevisionWalker.RevisionWalker'. -}
    -> T.Text
    {- ^ /@range@/: the range to push. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
revisionWalkerPushRange walker range = liftIO $ do
    walker' <- unsafeManagedPtrCastPtr walker
    range' <- textToCString range
    onException (do
        propagateGError $ ggit_revision_walker_push_range walker' range'
        touchManagedPtr walker
        freeMem range'
        return ()
     ) (do
        freeMem range'
     )

#if ENABLE_OVERLOADING
data RevisionWalkerPushRangeMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsRevisionWalker a) => O.MethodInfo RevisionWalkerPushRangeMethodInfo a signature where
    overloadedMethod _ = revisionWalkerPushRange

#endif

-- method RevisionWalker::push_ref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "walker", argType = TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRevisionWalker.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "item", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the reference to push.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : True
-- Skip return : False

foreign import ccall "ggit_revision_walker_push_ref" ggit_revision_walker_push_ref ::
    Ptr RevisionWalker ->                   -- walker : TInterface (Name {namespace = "Ggit", name = "RevisionWalker"})
    CString ->                              -- item : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO ()

{- |
Push the OID pointed to by the named reference to the revision walker.
-}
revisionWalkerPushRef ::
    (B.CallStack.HasCallStack, MonadIO m, IsRevisionWalker a) =>
    a
    {- ^ /@walker@/: a 'GI.Ggit.Objects.RevisionWalker.RevisionWalker'. -}
    -> T.Text
    {- ^ /@item@/: the reference to push. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
revisionWalkerPushRef walker item = liftIO $ do
    walker' <- unsafeManagedPtrCastPtr walker
    item' <- textToCString item
    onException (do
        propagateGError $ ggit_revision_walker_push_ref walker' item'
        touchManagedPtr walker
        freeMem item'
        return ()
     ) (do
        freeMem item'
     )

#if ENABLE_OVERLOADING
data RevisionWalkerPushRefMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsRevisionWalker a) => O.MethodInfo RevisionWalkerPushRefMethodInfo a signature where
    overloadedMethod _ = revisionWalkerPushRef

#endif

-- method RevisionWalker::reset
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "walker", argType = TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRevisionWalker.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ggit_revision_walker_reset" ggit_revision_walker_reset ::
    Ptr RevisionWalker ->                   -- walker : TInterface (Name {namespace = "Ggit", name = "RevisionWalker"})
    IO ()

{- |
Resets the revision walker for reuse.

This will clear all the pushed and hidden commits, and
leave the walker in a blank state (just like at
creation) ready to receive new commit pushes and
start a new walk.

The revision walk is automatically reset when a walk
is over.
-}
revisionWalkerReset ::
    (B.CallStack.HasCallStack, MonadIO m, IsRevisionWalker a) =>
    a
    {- ^ /@walker@/: a 'GI.Ggit.Objects.RevisionWalker.RevisionWalker'. -}
    -> m ()
revisionWalkerReset walker = liftIO $ do
    walker' <- unsafeManagedPtrCastPtr walker
    ggit_revision_walker_reset walker'
    touchManagedPtr walker
    return ()

#if ENABLE_OVERLOADING
data RevisionWalkerResetMethodInfo
instance (signature ~ (m ()), MonadIO m, IsRevisionWalker a) => O.MethodInfo RevisionWalkerResetMethodInfo a signature where
    overloadedMethod _ = revisionWalkerReset

#endif

-- method RevisionWalker::set_sort_mode
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "walker", argType = TInterface (Name {namespace = "Ggit", name = "RevisionWalker"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitRevisionWalker.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "sort_mode", argType = TInterface (Name {namespace = "Ggit", name = "SortMode"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitSortMode value.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "ggit_revision_walker_set_sort_mode" ggit_revision_walker_set_sort_mode ::
    Ptr RevisionWalker ->                   -- walker : TInterface (Name {namespace = "Ggit", name = "RevisionWalker"})
    CUInt ->                                -- sort_mode : TInterface (Name {namespace = "Ggit", name = "SortMode"})
    IO ()

{- |
Change the sorting mode when iterating through the
repository\'s contents.

Changing the sorting mode resets the walker.
-}
revisionWalkerSetSortMode ::
    (B.CallStack.HasCallStack, MonadIO m, IsRevisionWalker a) =>
    a
    {- ^ /@walker@/: a 'GI.Ggit.Objects.RevisionWalker.RevisionWalker'. -}
    -> [Ggit.Flags.SortMode]
    {- ^ /@sortMode@/: a 'GI.Ggit.Flags.SortMode' value. -}
    -> m ()
revisionWalkerSetSortMode walker sortMode = liftIO $ do
    walker' <- unsafeManagedPtrCastPtr walker
    let sortMode' = gflagsToWord sortMode
    ggit_revision_walker_set_sort_mode walker' sortMode'
    touchManagedPtr walker
    return ()

#if ENABLE_OVERLOADING
data RevisionWalkerSetSortModeMethodInfo
instance (signature ~ ([Ggit.Flags.SortMode] -> m ()), MonadIO m, IsRevisionWalker a) => O.MethodInfo RevisionWalkerSetSortModeMethodInfo a signature where
    overloadedMethod _ = revisionWalkerSetSortMode

#endif