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

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

module GI.Ggit.Objects.CommitParents
    (

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


 -- * Methods
-- ** get #method:get#

#if ENABLE_OVERLOADING
    CommitParentsGetMethodInfo              ,
#endif
    commitParentsGet                        ,


-- ** getId #method:getId#

#if ENABLE_OVERLOADING
    CommitParentsGetIdMethodInfo            ,
#endif
    commitParentsGetId                      ,


-- ** getSize #method:getSize#

#if ENABLE_OVERLOADING
    CommitParentsGetSizeMethodInfo          ,
#endif
    commitParentsGetSize                    ,


-- ** new #method:new#

    commitParentsNew                        ,




 -- * Properties
-- ** commit #attr:commit#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    CommitParentsCommitPropertyInfo         ,
#endif
#if ENABLE_OVERLOADING
    commitParentsCommit                     ,
#endif
    constructCommitParentsCommit            ,
    getCommitParentsCommit                  ,


-- ** size #attr:size#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    CommitParentsSizePropertyInfo           ,
#endif
#if ENABLE_OVERLOADING
    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.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.Objects.Commit as Ggit.Commit
import {-# SOURCE #-} qualified GI.Ggit.Structs.OId as Ggit.OId

-- | Memory-managed wrapper type.
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


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

instance O.HasParentTypes CommitParents
type instance O.ParentTypes CommitParents = '[GObject.Object.Object]

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

-- | A convenience alias for `Nothing` :: `Maybe` `CommitParents`.
noCommitParents :: Maybe CommitParents
noCommitParents = Nothing

#if ENABLE_OVERLOADING
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 "getv" o = GObject.Object.ObjectGetvMethodInfo
    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 "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) => OL.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

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

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

@
'Data.GI.Base.Attributes.get' commitParents #commit
@
-}
getCommitParentsCommit :: (MonadIO m, IsCommitParents o) => o -> m (Maybe Ggit.Commit.Commit)
getCommitParentsCommit obj = liftIO $ B.Properties.getObjectPropertyObject obj "commit" Ggit.Commit.Commit

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

#if ENABLE_OVERLOADING
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)

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

@
'Data.GI.Base.Attributes.get' commitParents #size
@
-}
getCommitParentsSize :: (MonadIO m, IsCommitParents o) => o -> m Word32
getCommitParentsSize obj = liftIO $ B.Properties.getObjectPropertyUInt32 obj "size"

#if ENABLE_OVERLOADING
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 ENABLE_OVERLOADING
instance O.HasAttributeList CommitParents
type instance O.AttributeList CommitParents = CommitParentsAttributeList
type CommitParentsAttributeList = ('[ '("commit", CommitParentsCommitPropertyInfo), '("size", CommitParentsSizePropertyInfo)] :: [(Symbol, *)])
#endif

#if ENABLE_OVERLOADING
commitParentsCommit :: AttrLabelProxy "commit"
commitParentsCommit = AttrLabelProxy

commitParentsSize :: AttrLabelProxy "size"
commitParentsSize = AttrLabelProxy

#endif

#if ENABLE_OVERLOADING
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 ENABLE_OVERLOADING
#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 (Maybe 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
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Ggit.Commit.Commit) result'
        return result''
    touchManagedPtr parents
    return maybeResult

#if ENABLE_OVERLOADING
data CommitParentsGetMethodInfo
instance (signature ~ (Word32 -> m (Maybe 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 (Maybe 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
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Ggit.OId.OId) result'
        return result''
    touchManagedPtr parents
    return maybeResult

#if ENABLE_OVERLOADING
data CommitParentsGetIdMethodInfo
instance (signature ~ (Word32 -> m (Maybe 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 ENABLE_OVERLOADING
data CommitParentsGetSizeMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsCommitParents a) => O.MethodInfo CommitParentsGetSizeMethodInfo a signature where
    overloadedMethod _ = commitParentsGetSize

#endif