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

Represents a rebase operation.
-}

module GI.Ggit.Structs.RebaseOperation
    ( 

-- * Exported types
    RebaseOperation(..)                     ,
    noRebaseOperation                       ,


 -- * Methods
-- ** getExec #method:getExec#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RebaseOperationGetExecMethodInfo        ,
#endif
    rebaseOperationGetExec                  ,


-- ** getId #method:getId#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RebaseOperationGetIdMethodInfo          ,
#endif
    rebaseOperationGetId                    ,


-- ** getOperationType #method:getOperationType#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RebaseOperationGetOperationTypeMethodInfo,
#endif
    rebaseOperationGetOperationType         ,


-- ** ref #method:ref#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RebaseOperationRefMethodInfo            ,
#endif
    rebaseOperationRef                      ,


-- ** unref #method:unref#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    RebaseOperationUnrefMethodInfo          ,
#endif
    rebaseOperationUnref                    ,




    ) 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.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
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 {-# SOURCE #-} qualified GI.Ggit.Enums as Ggit.Enums
import {-# SOURCE #-} qualified GI.Ggit.Structs.OId as Ggit.OId

newtype RebaseOperation = RebaseOperation (ManagedPtr RebaseOperation)
foreign import ccall "ggit_rebase_operation_get_type" c_ggit_rebase_operation_get_type :: 
    IO GType

instance BoxedObject RebaseOperation where
    boxedType _ = c_ggit_rebase_operation_get_type

noRebaseOperation :: Maybe RebaseOperation
noRebaseOperation = Nothing


#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList RebaseOperation
type instance O.AttributeList RebaseOperation = RebaseOperationAttributeList
type RebaseOperationAttributeList = ('[ ] :: [(Symbol, *)])
#endif

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

foreign import ccall "ggit_rebase_operation_get_exec" ggit_rebase_operation_get_exec :: 
    Ptr RebaseOperation ->                  -- rebase_operation : TInterface (Name {namespace = "Ggit", name = "RebaseOperation"})
    IO CString

{- |
Gets the executable the user has requested be run.  This will only
be populated for operations of type /@gGITREBASEOPERATIONEXEC@/.
-}
rebaseOperationGetExec ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RebaseOperation
    {- ^ /@rebaseOperation@/: a 'GI.Ggit.Structs.RebaseOperation.RebaseOperation'. -}
    -> m T.Text
    {- ^ __Returns:__ the executable the user has requested be run. -}
rebaseOperationGetExec rebaseOperation = liftIO $ do
    rebaseOperation' <- unsafeManagedPtrGetPtr rebaseOperation
    result <- ggit_rebase_operation_get_exec rebaseOperation'
    checkUnexpectedReturnNULL "rebaseOperationGetExec" result
    result' <- cstringToText result
    touchManagedPtr rebaseOperation
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RebaseOperationGetExecMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo RebaseOperationGetExecMethodInfo RebaseOperation signature where
    overloadedMethod _ = rebaseOperationGetExec

#endif

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

foreign import ccall "ggit_rebase_operation_get_id" ggit_rebase_operation_get_id :: 
    Ptr RebaseOperation ->                  -- rebase_operation : TInterface (Name {namespace = "Ggit", name = "RebaseOperation"})
    IO (Ptr Ggit.OId.OId)

{- |
Gets the commit ID being cherry-picked. This will be populated for
all operations except those of type /@gGITREBASEOPERATIONEXEC@/.
-}
rebaseOperationGetId ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RebaseOperation
    {- ^ /@rebaseOperation@/: a 'GI.Ggit.Structs.RebaseOperation.RebaseOperation'. -}
    -> m Ggit.OId.OId
    {- ^ __Returns:__ the commit ID being cherry-picked. -}
rebaseOperationGetId rebaseOperation = liftIO $ do
    rebaseOperation' <- unsafeManagedPtrGetPtr rebaseOperation
    result <- ggit_rebase_operation_get_id rebaseOperation'
    checkUnexpectedReturnNULL "rebaseOperationGetId" result
    result' <- (wrapBoxed Ggit.OId.OId) result
    touchManagedPtr rebaseOperation
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RebaseOperationGetIdMethodInfo
instance (signature ~ (m Ggit.OId.OId), MonadIO m) => O.MethodInfo RebaseOperationGetIdMethodInfo RebaseOperation signature where
    overloadedMethod _ = rebaseOperationGetId

#endif

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

foreign import ccall "ggit_rebase_operation_get_operation_type" ggit_rebase_operation_get_operation_type :: 
    Ptr RebaseOperation ->                  -- rebase_operation : TInterface (Name {namespace = "Ggit", name = "RebaseOperation"})
    IO CUInt

{- |
Gets the type of rebase operation.
-}
rebaseOperationGetOperationType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RebaseOperation
    {- ^ /@rebaseOperation@/: a 'GI.Ggit.Structs.RebaseOperation.RebaseOperation'. -}
    -> m Ggit.Enums.RebaseOperationType
    {- ^ __Returns:__ a 'GI.Ggit.Enums.RebaseOperationType'. -}
rebaseOperationGetOperationType rebaseOperation = liftIO $ do
    rebaseOperation' <- unsafeManagedPtrGetPtr rebaseOperation
    result <- ggit_rebase_operation_get_operation_type rebaseOperation'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr rebaseOperation
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RebaseOperationGetOperationTypeMethodInfo
instance (signature ~ (m Ggit.Enums.RebaseOperationType), MonadIO m) => O.MethodInfo RebaseOperationGetOperationTypeMethodInfo RebaseOperation signature where
    overloadedMethod _ = rebaseOperationGetOperationType

#endif

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

foreign import ccall "ggit_rebase_operation_ref" ggit_rebase_operation_ref :: 
    Ptr RebaseOperation ->                  -- rebase_operation : TInterface (Name {namespace = "Ggit", name = "RebaseOperation"})
    IO (Ptr RebaseOperation)

{- |
Atomically increments the reference count of /@rebaseOperation@/ by one.
This function is MT-safe and may be called from any thread.
-}
rebaseOperationRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RebaseOperation
    {- ^ /@rebaseOperation@/: a 'GI.Ggit.Structs.RebaseOperation.RebaseOperation'. -}
    -> m RebaseOperation
    {- ^ __Returns:__ a newly allocated 'GI.Ggit.Structs.RebaseOperation.RebaseOperation'. -}
rebaseOperationRef rebaseOperation = liftIO $ do
    rebaseOperation' <- unsafeManagedPtrGetPtr rebaseOperation
    result <- ggit_rebase_operation_ref rebaseOperation'
    checkUnexpectedReturnNULL "rebaseOperationRef" result
    result' <- (newBoxed RebaseOperation) result
    touchManagedPtr rebaseOperation
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RebaseOperationRefMethodInfo
instance (signature ~ (m RebaseOperation), MonadIO m) => O.MethodInfo RebaseOperationRefMethodInfo RebaseOperation signature where
    overloadedMethod _ = rebaseOperationRef

#endif

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

foreign import ccall "ggit_rebase_operation_unref" ggit_rebase_operation_unref :: 
    Ptr RebaseOperation ->                  -- rebase_operation : TInterface (Name {namespace = "Ggit", name = "RebaseOperation"})
    IO ()

{- |
Atomically decrements the reference count of /@rebaseOperation@/ by one.
If the reference count drops to 0, /@rebaseOperation@/ is freed.
-}
rebaseOperationUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    RebaseOperation
    {- ^ /@rebaseOperation@/: a 'GI.Ggit.Structs.RebaseOperation.RebaseOperation'. -}
    -> m ()
rebaseOperationUnref rebaseOperation = liftIO $ do
    rebaseOperation' <- unsafeManagedPtrGetPtr rebaseOperation
    ggit_rebase_operation_unref rebaseOperation'
    touchManagedPtr rebaseOperation
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data RebaseOperationUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo RebaseOperationUnrefMethodInfo RebaseOperation signature where
    overloadedMethod _ = rebaseOperationUnref

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveRebaseOperationMethod (t :: Symbol) (o :: *) :: * where
    ResolveRebaseOperationMethod "ref" o = RebaseOperationRefMethodInfo
    ResolveRebaseOperationMethod "unref" o = RebaseOperationUnrefMethodInfo
    ResolveRebaseOperationMethod "getExec" o = RebaseOperationGetExecMethodInfo
    ResolveRebaseOperationMethod "getId" o = RebaseOperationGetIdMethodInfo
    ResolveRebaseOperationMethod "getOperationType" o = RebaseOperationGetOperationTypeMethodInfo
    ResolveRebaseOperationMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveRebaseOperationMethod t RebaseOperation, O.MethodInfo info RebaseOperation p) => O.IsLabelProxy t (RebaseOperation -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveRebaseOperationMethod t RebaseOperation, O.MethodInfo info RebaseOperation p) => O.IsLabel t (RebaseOperation -> 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

#endif