{- |
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 an annotated commit object.
-}

module GI.Ggit.Structs.AnnotatedCommit
    ( 

-- * Exported types
    AnnotatedCommit(..)                     ,
    noAnnotatedCommit                       ,


 -- * Methods
-- ** getId #method:getId#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    AnnotatedCommitGetIdMethodInfo          ,
#endif
    annotatedCommitGetId                    ,


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


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




    ) 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.Structs.OId as Ggit.OId

newtype AnnotatedCommit = AnnotatedCommit (ManagedPtr AnnotatedCommit)
foreign import ccall "ggit_annotated_commit_get_type" c_ggit_annotated_commit_get_type :: 
    IO GType

instance BoxedObject AnnotatedCommit where
    boxedType _ = c_ggit_annotated_commit_get_type

noAnnotatedCommit :: Maybe AnnotatedCommit
noAnnotatedCommit = Nothing


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

-- method AnnotatedCommit::get_id
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "annotated_commit", argType = TInterface (Name {namespace = "Ggit", name = "AnnotatedCommit"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitAnnotatedCommit.", 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_annotated_commit_get_id" ggit_annotated_commit_get_id :: 
    Ptr AnnotatedCommit ->                  -- annotated_commit : TInterface (Name {namespace = "Ggit", name = "AnnotatedCommit"})
    IO (Ptr Ggit.OId.OId)

{- |
Gets the commit ID that the given /@annotatedCommit@/ refs to.
-}
annotatedCommitGetId ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    AnnotatedCommit
    {- ^ /@annotatedCommit@/: a 'GI.Ggit.Structs.AnnotatedCommit.AnnotatedCommit'. -}
    -> m Ggit.OId.OId
    {- ^ __Returns:__ the commit ID that the given /@annotatedCommit@/ refs to. -}
annotatedCommitGetId annotatedCommit = liftIO $ do
    annotatedCommit' <- unsafeManagedPtrGetPtr annotatedCommit
    result <- ggit_annotated_commit_get_id annotatedCommit'
    checkUnexpectedReturnNULL "annotatedCommitGetId" result
    result' <- (wrapBoxed Ggit.OId.OId) result
    touchManagedPtr annotatedCommit
    return result'

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

#endif

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

foreign import ccall "ggit_annotated_commit_ref" ggit_annotated_commit_ref :: 
    Ptr AnnotatedCommit ->                  -- annotated_commit : TInterface (Name {namespace = "Ggit", name = "AnnotatedCommit"})
    IO (Ptr AnnotatedCommit)

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

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

#endif

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

foreign import ccall "ggit_annotated_commit_unref" ggit_annotated_commit_unref :: 
    Ptr AnnotatedCommit ->                  -- annotated_commit : TInterface (Name {namespace = "Ggit", name = "AnnotatedCommit"})
    IO ()

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

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

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveAnnotatedCommitMethod (t :: Symbol) (o :: *) :: * where
    ResolveAnnotatedCommitMethod "ref" o = AnnotatedCommitRefMethodInfo
    ResolveAnnotatedCommitMethod "unref" o = AnnotatedCommitUnrefMethodInfo
    ResolveAnnotatedCommitMethod "getId" o = AnnotatedCommitGetIdMethodInfo
    ResolveAnnotatedCommitMethod l o = O.MethodResolutionFailed l o

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

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