{- |
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 the parents of a commit object.
-}

module GI.Ggit.Objects.CommitParents
    ( 

-- * Exported types
    CommitParents(..)                       ,
    IsCommitParents                         ,
    toCommitParents                         ,
    noCommitParents                         ,


 -- * Methods
-- ** get #method:get#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitParentsGetMethodInfo              ,
#endif
    commitParentsGet                        ,


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


-- ** getSize #method:getSize#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitParentsGetSizeMethodInfo          ,
#endif
    commitParentsGetSize                    ,


-- ** new #method:new#
    commitParentsNew                        ,




 -- * Properties
-- ** commit #attr:commit#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitParentsCommitPropertyInfo         ,
#endif
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    commitParentsCommit                     ,
#endif
    constructCommitParentsCommit            ,
    getCommitParentsCommit                  ,


-- ** size #attr:size#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    CommitParentsSizePropertyInfo           ,
#endif
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    commitParentsSize                       ,
#endif
    getCommitParentsSize                    ,




    ) 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 qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Ggit.Objects.Commit as Ggit.Commit
import {-# SOURCE #-} qualified GI.Ggit.Structs.OId as Ggit.OId

newtype CommitParents = CommitParents (ManagedPtr CommitParents)
foreign import ccall "ggit_commit_parents_get_type"
    c_ggit_commit_parents_get_type :: IO GType

instance GObject CommitParents where
    gobjectType _ = c_ggit_commit_parents_get_type
    

class GObject o => IsCommitParents o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError CommitParents a) =>
    IsCommitParents a
#endif
instance IsCommitParents CommitParents
instance GObject.Object.IsObject CommitParents

toCommitParents :: (MonadIO m, IsCommitParents o) => o -> m CommitParents
toCommitParents = liftIO . unsafeCastTo CommitParents

noCommitParents :: Maybe CommitParents
noCommitParents = Nothing

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveCommitParentsMethod (t :: Symbol) (o :: *) :: * where
    ResolveCommitParentsMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveCommitParentsMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveCommitParentsMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveCommitParentsMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveCommitParentsMethod "get" o = CommitParentsGetMethodInfo
    ResolveCommitParentsMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveCommitParentsMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveCommitParentsMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveCommitParentsMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveCommitParentsMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveCommitParentsMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveCommitParentsMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveCommitParentsMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveCommitParentsMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveCommitParentsMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveCommitParentsMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveCommitParentsMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveCommitParentsMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveCommitParentsMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveCommitParentsMethod "getId" o = CommitParentsGetIdMethodInfo
    ResolveCommitParentsMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveCommitParentsMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveCommitParentsMethod "getSize" o = CommitParentsGetSizeMethodInfo
    ResolveCommitParentsMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveCommitParentsMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveCommitParentsMethod l o = O.MethodResolutionFailed l o

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

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

-- VVV Prop "commit"
   -- Type: TInterface (Name {namespace = "Ggit", name = "Commit"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getCommitParentsCommit :: (MonadIO m, IsCommitParents o) => o -> m (Maybe Ggit.Commit.Commit)
getCommitParentsCommit obj = liftIO $ getObjectPropertyObject obj "commit" Ggit.Commit.Commit

constructCommitParentsCommit :: (IsCommitParents o, Ggit.Commit.IsCommit a) => a -> IO (GValueConstruct o)
constructCommitParentsCommit val = constructObjectPropertyObject "commit" (Just val)

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitParentsCommitPropertyInfo
instance AttrInfo CommitParentsCommitPropertyInfo where
    type AttrAllowedOps CommitParentsCommitPropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint CommitParentsCommitPropertyInfo = Ggit.Commit.IsCommit
    type AttrBaseTypeConstraint CommitParentsCommitPropertyInfo = IsCommitParents
    type AttrGetType CommitParentsCommitPropertyInfo = (Maybe Ggit.Commit.Commit)
    type AttrLabel CommitParentsCommitPropertyInfo = "commit"
    type AttrOrigin CommitParentsCommitPropertyInfo = CommitParents
    attrGet _ = getCommitParentsCommit
    attrSet _ = undefined
    attrConstruct _ = constructCommitParentsCommit
    attrClear _ = undefined
#endif

-- VVV Prop "size"
   -- Type: TBasicType TUInt
   -- Flags: [PropertyReadable]
   -- Nullable: (Just False,Nothing)

getCommitParentsSize :: (MonadIO m, IsCommitParents o) => o -> m Word32
getCommitParentsSize obj = liftIO $ getObjectPropertyUInt32 obj "size"

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitParentsSizePropertyInfo
instance AttrInfo CommitParentsSizePropertyInfo where
    type AttrAllowedOps CommitParentsSizePropertyInfo = '[ 'AttrGet]
    type AttrSetTypeConstraint CommitParentsSizePropertyInfo = (~) ()
    type AttrBaseTypeConstraint CommitParentsSizePropertyInfo = IsCommitParents
    type AttrGetType CommitParentsSizePropertyInfo = Word32
    type AttrLabel CommitParentsSizePropertyInfo = "size"
    type AttrOrigin CommitParentsSizePropertyInfo = CommitParents
    attrGet _ = getCommitParentsSize
    attrSet _ = undefined
    attrConstruct _ = undefined
    attrClear _ = undefined
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList CommitParents
type instance O.AttributeList CommitParents = CommitParentsAttributeList
type CommitParentsAttributeList = ('[ '("commit", CommitParentsCommitPropertyInfo), '("size", CommitParentsSizePropertyInfo)] :: [(Symbol, *)])
#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
commitParentsCommit :: AttrLabelProxy "commit"
commitParentsCommit = AttrLabelProxy

commitParentsSize :: AttrLabelProxy "size"
commitParentsSize = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type instance O.SignalList CommitParents = CommitParentsSignalList
type CommitParentsSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)])

#endif

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

foreign import ccall "ggit_commit_parents_new" ggit_commit_parents_new :: 
    Ptr Ggit.Commit.Commit ->               -- commit : TInterface (Name {namespace = "Ggit", name = "Commit"})
    IO (Ptr CommitParents)

{- |
/No description available in the introspection data./
-}
commitParentsNew ::
    (B.CallStack.HasCallStack, MonadIO m, Ggit.Commit.IsCommit a) =>
    a
    -> m CommitParents
commitParentsNew commit = liftIO $ do
    commit' <- unsafeManagedPtrCastPtr commit
    result <- ggit_commit_parents_new commit'
    checkUnexpectedReturnNULL "commitParentsNew" result
    result' <- (wrapObject CommitParents) result
    touchManagedPtr commit
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
#endif

-- method CommitParents::get
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "parents", argType = TInterface (Name {namespace = "Ggit", name = "CommitParents"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitCommitParents.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "idx", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the parent index.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "Commit"}))
-- throws : False
-- Skip return : False

foreign import ccall "ggit_commit_parents_get" ggit_commit_parents_get :: 
    Ptr CommitParents ->                    -- parents : TInterface (Name {namespace = "Ggit", name = "CommitParents"})
    Word32 ->                               -- idx : TBasicType TUInt
    IO (Ptr Ggit.Commit.Commit)

{- |
Get the 'GI.Ggit.Objects.Commit.Commit' of a parent.
-}
commitParentsGet ::
    (B.CallStack.HasCallStack, MonadIO m, IsCommitParents a) =>
    a
    {- ^ /@parents@/: a 'GI.Ggit.Objects.CommitParents.CommitParents'. -}
    -> Word32
    {- ^ /@idx@/: the parent index. -}
    -> m Ggit.Commit.Commit
    {- ^ __Returns:__ a 'GI.Ggit.Objects.Commit.Commit'. -}
commitParentsGet parents idx = liftIO $ do
    parents' <- unsafeManagedPtrCastPtr parents
    result <- ggit_commit_parents_get parents' idx
    checkUnexpectedReturnNULL "commitParentsGet" result
    result' <- (wrapObject Ggit.Commit.Commit) result
    touchManagedPtr parents
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitParentsGetMethodInfo
instance (signature ~ (Word32 -> m Ggit.Commit.Commit), MonadIO m, IsCommitParents a) => O.MethodInfo CommitParentsGetMethodInfo a signature where
    overloadedMethod _ = commitParentsGet

#endif

-- method CommitParents::get_id
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "parents", argType = TInterface (Name {namespace = "Ggit", name = "CommitParents"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitCommitParents.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "idx", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the parent index.", 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_commit_parents_get_id" ggit_commit_parents_get_id :: 
    Ptr CommitParents ->                    -- parents : TInterface (Name {namespace = "Ggit", name = "CommitParents"})
    Word32 ->                               -- idx : TBasicType TUInt
    IO (Ptr Ggit.OId.OId)

{- |
Get the 'GI.Ggit.Structs.OId.OId' of a parent.
-}
commitParentsGetId ::
    (B.CallStack.HasCallStack, MonadIO m, IsCommitParents a) =>
    a
    {- ^ /@parents@/: a 'GI.Ggit.Objects.CommitParents.CommitParents'. -}
    -> Word32
    {- ^ /@idx@/: the parent index. -}
    -> m Ggit.OId.OId
    {- ^ __Returns:__ a 'GI.Ggit.Structs.OId.OId'. -}
commitParentsGetId parents idx = liftIO $ do
    parents' <- unsafeManagedPtrCastPtr parents
    result <- ggit_commit_parents_get_id parents' idx
    checkUnexpectedReturnNULL "commitParentsGetId" result
    result' <- (wrapBoxed Ggit.OId.OId) result
    touchManagedPtr parents
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitParentsGetIdMethodInfo
instance (signature ~ (Word32 -> m Ggit.OId.OId), MonadIO m, IsCommitParents a) => O.MethodInfo CommitParentsGetIdMethodInfo a signature where
    overloadedMethod _ = commitParentsGetId

#endif

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

foreign import ccall "ggit_commit_parents_get_size" ggit_commit_parents_get_size :: 
    Ptr CommitParents ->                    -- parents : TInterface (Name {namespace = "Ggit", name = "CommitParents"})
    IO Word32

{- |
Get the number of parents in the parents collection.
-}
commitParentsGetSize ::
    (B.CallStack.HasCallStack, MonadIO m, IsCommitParents a) =>
    a
    {- ^ /@parents@/: a 'GI.Ggit.Objects.CommitParents.CommitParents'. -}
    -> m Word32
    {- ^ __Returns:__ the number of parents. -}
commitParentsGetSize parents = liftIO $ do
    parents' <- unsafeManagedPtrCastPtr parents
    result <- ggit_commit_parents_get_size parents'
    touchManagedPtr parents
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data CommitParentsGetSizeMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsCommitParents a) => O.MethodInfo CommitParentsGetSizeMethodInfo a signature where
    overloadedMethod _ = commitParentsGetSize

#endif