{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- Represents an resolve undo index entry object.

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

module GI.Ggit.Structs.IndexEntryResolveUndo
    (

-- * Exported types
    IndexEntryResolveUndo(..)               ,
    noIndexEntryResolveUndo                 ,


 -- * Methods
-- ** Overloaded methods #method:Overloaded methods#

#if defined(ENABLE_OVERLOADING)
    ResolveIndexEntryResolveUndoMethod      ,
#endif


-- ** getFile #method:getFile#

#if defined(ENABLE_OVERLOADING)
    IndexEntryResolveUndoGetFileMethodInfo  ,
#endif
    indexEntryResolveUndoGetFile            ,


-- ** getId #method:getId#

#if defined(ENABLE_OVERLOADING)
    IndexEntryResolveUndoGetIdMethodInfo    ,
#endif
    indexEntryResolveUndoGetId              ,


-- ** getMode #method:getMode#

#if defined(ENABLE_OVERLOADING)
    IndexEntryResolveUndoGetModeMethodInfo  ,
#endif
    indexEntryResolveUndoGetMode            ,


-- ** ref #method:ref#

#if defined(ENABLE_OVERLOADING)
    IndexEntryResolveUndoRefMethodInfo      ,
#endif
    indexEntryResolveUndoRef                ,


-- ** unref #method:unref#

#if defined(ENABLE_OVERLOADING)
    IndexEntryResolveUndoUnrefMethodInfo    ,
#endif
    indexEntryResolveUndoUnref              ,




    ) 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.GI.Base.Signals as B.Signals
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 {-# SOURCE #-} qualified GI.Ggit.Structs.OId as Ggit.OId
import qualified GI.Gio.Interfaces.File as Gio.File

-- | Memory-managed wrapper type.
newtype IndexEntryResolveUndo = IndexEntryResolveUndo (ManagedPtr IndexEntryResolveUndo)
    deriving (Eq)
foreign import ccall "ggit_index_entry_resolve_undo_get_type" c_ggit_index_entry_resolve_undo_get_type ::
    IO GType

instance BoxedObject IndexEntryResolveUndo where
    boxedType _ = c_ggit_index_entry_resolve_undo_get_type

-- | Convert 'IndexEntryResolveUndo' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue IndexEntryResolveUndo where
    toGValue o = do
        gtype <- c_ggit_index_entry_resolve_undo_get_type
        B.ManagedPtr.withManagedPtr o (B.GValue.buildGValue gtype B.GValue.set_boxed)

    fromGValue gv = do
        ptr <- B.GValue.get_boxed gv :: IO (Ptr IndexEntryResolveUndo)
        B.ManagedPtr.newBoxed IndexEntryResolveUndo ptr



-- | A convenience alias for `Nothing` :: `Maybe` `IndexEntryResolveUndo`.
noIndexEntryResolveUndo :: Maybe IndexEntryResolveUndo
noIndexEntryResolveUndo = Nothing


#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList IndexEntryResolveUndo
type instance O.AttributeList IndexEntryResolveUndo = IndexEntryResolveUndoAttributeList
type IndexEntryResolveUndoAttributeList = ('[ ] :: [(Symbol, *)])
#endif

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

foreign import ccall "ggit_index_entry_resolve_undo_get_file" ggit_index_entry_resolve_undo_get_file ::
    Ptr IndexEntryResolveUndo ->            -- entry : TInterface (Name {namespace = "Ggit", name = "IndexEntryResolveUndo"})
    IO (Ptr Gio.File.File)

-- | Get the file of the index entry.
indexEntryResolveUndoGetFile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    IndexEntryResolveUndo
    -- ^ /@entry@/: a t'GI.Ggit.Structs.IndexEntryResolveUndo.IndexEntryResolveUndo'.
    -> m (Maybe Gio.File.File)
    -- ^ __Returns:__ a t'GI.Gio.Interfaces.File.File' or 'P.Nothing'.
indexEntryResolveUndoGetFile entry = liftIO $ do
    entry' <- unsafeManagedPtrGetPtr entry
    result <- ggit_index_entry_resolve_undo_get_file entry'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapObject Gio.File.File) result'
        return result''
    touchManagedPtr entry
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data IndexEntryResolveUndoGetFileMethodInfo
instance (signature ~ (m (Maybe Gio.File.File)), MonadIO m) => O.MethodInfo IndexEntryResolveUndoGetFileMethodInfo IndexEntryResolveUndo signature where
    overloadedMethod = indexEntryResolveUndoGetFile

#endif

-- method IndexEntryResolveUndo::get_id
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "entry"
--           , argType =
--               TInterface
--                 Name { namespace = "Ggit" , name = "IndexEntryResolveUndo" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitIndexEntryResolveUndo."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "stage"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the stage (0, 1 or 2)."
--                 , 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_index_entry_resolve_undo_get_id" ggit_index_entry_resolve_undo_get_id ::
    Ptr IndexEntryResolveUndo ->            -- entry : TInterface (Name {namespace = "Ggit", name = "IndexEntryResolveUndo"})
    Int32 ->                                -- stage : TBasicType TInt
    IO (Ptr Ggit.OId.OId)

-- | Get the oid of the index entry.
indexEntryResolveUndoGetId ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    IndexEntryResolveUndo
    -- ^ /@entry@/: a t'GI.Ggit.Structs.IndexEntryResolveUndo.IndexEntryResolveUndo'.
    -> Int32
    -- ^ /@stage@/: the stage (0, 1 or 2).
    -> m (Maybe Ggit.OId.OId)
    -- ^ __Returns:__ the oid or 'P.Nothing'.
indexEntryResolveUndoGetId entry stage = liftIO $ do
    entry' <- unsafeManagedPtrGetPtr entry
    result <- ggit_index_entry_resolve_undo_get_id entry' stage
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (wrapBoxed Ggit.OId.OId) result'
        return result''
    touchManagedPtr entry
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data IndexEntryResolveUndoGetIdMethodInfo
instance (signature ~ (Int32 -> m (Maybe Ggit.OId.OId)), MonadIO m) => O.MethodInfo IndexEntryResolveUndoGetIdMethodInfo IndexEntryResolveUndo signature where
    overloadedMethod = indexEntryResolveUndoGetId

#endif

-- method IndexEntryResolveUndo::get_mode
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "entry"
--           , argType =
--               TInterface
--                 Name { namespace = "Ggit" , name = "IndexEntryResolveUndo" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitIndexEntryResolveUndo."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "stage"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the stage (0, 1 or 2)."
--                 , 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_index_entry_resolve_undo_get_mode" ggit_index_entry_resolve_undo_get_mode ::
    Ptr IndexEntryResolveUndo ->            -- entry : TInterface (Name {namespace = "Ggit", name = "IndexEntryResolveUndo"})
    Int32 ->                                -- stage : TBasicType TInt
    IO Word32

-- | Get the mode of the index entry. The returned mode contains the modes from
-- stage 1, 2 and 3.
indexEntryResolveUndoGetMode ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    IndexEntryResolveUndo
    -- ^ /@entry@/: a t'GI.Ggit.Structs.IndexEntryResolveUndo.IndexEntryResolveUndo'.
    -> Int32
    -- ^ /@stage@/: the stage (0, 1 or 2).
    -> m Word32
    -- ^ __Returns:__ the mode.
indexEntryResolveUndoGetMode entry stage = liftIO $ do
    entry' <- unsafeManagedPtrGetPtr entry
    result <- ggit_index_entry_resolve_undo_get_mode entry' stage
    touchManagedPtr entry
    return result

#if defined(ENABLE_OVERLOADING)
data IndexEntryResolveUndoGetModeMethodInfo
instance (signature ~ (Int32 -> m Word32), MonadIO m) => O.MethodInfo IndexEntryResolveUndoGetModeMethodInfo IndexEntryResolveUndo signature where
    overloadedMethod = indexEntryResolveUndoGetMode

#endif

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

foreign import ccall "ggit_index_entry_resolve_undo_ref" ggit_index_entry_resolve_undo_ref ::
    Ptr IndexEntryResolveUndo ->            -- entry : TInterface (Name {namespace = "Ggit", name = "IndexEntryResolveUndo"})
    IO (Ptr IndexEntryResolveUndo)

-- | Atomically increments the reference count of /@entry@/ by one.
-- This function is MT-safe and may be called from any thread.
indexEntryResolveUndoRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    IndexEntryResolveUndo
    -- ^ /@entry@/: a t'GI.Ggit.Structs.IndexEntryResolveUndo.IndexEntryResolveUndo'.
    -> m (Maybe IndexEntryResolveUndo)
    -- ^ __Returns:__ a t'GI.Ggit.Structs.IndexEntryResolveUndo.IndexEntryResolveUndo' or 'P.Nothing'.
indexEntryResolveUndoRef entry = liftIO $ do
    entry' <- unsafeManagedPtrGetPtr entry
    result <- ggit_index_entry_resolve_undo_ref entry'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newBoxed IndexEntryResolveUndo) result'
        return result''
    touchManagedPtr entry
    return maybeResult

#if defined(ENABLE_OVERLOADING)
data IndexEntryResolveUndoRefMethodInfo
instance (signature ~ (m (Maybe IndexEntryResolveUndo)), MonadIO m) => O.MethodInfo IndexEntryResolveUndoRefMethodInfo IndexEntryResolveUndo signature where
    overloadedMethod = indexEntryResolveUndoRef

#endif

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

foreign import ccall "ggit_index_entry_resolve_undo_unref" ggit_index_entry_resolve_undo_unref ::
    Ptr IndexEntryResolveUndo ->            -- entry : TInterface (Name {namespace = "Ggit", name = "IndexEntryResolveUndo"})
    IO ()

-- | Atomically decrements the reference count of /@entry@/ by one.
-- If the reference count drops to 0, /@entry@/ is freed.
indexEntryResolveUndoUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    IndexEntryResolveUndo
    -- ^ /@entry@/: a t'GI.Ggit.Structs.IndexEntryResolveUndo.IndexEntryResolveUndo'.
    -> m ()
indexEntryResolveUndoUnref entry = liftIO $ do
    entry' <- unsafeManagedPtrGetPtr entry
    ggit_index_entry_resolve_undo_unref entry'
    touchManagedPtr entry
    return ()

#if defined(ENABLE_OVERLOADING)
data IndexEntryResolveUndoUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo IndexEntryResolveUndoUnrefMethodInfo IndexEntryResolveUndo signature where
    overloadedMethod = indexEntryResolveUndoUnref

#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveIndexEntryResolveUndoMethod (t :: Symbol) (o :: *) :: * where
    ResolveIndexEntryResolveUndoMethod "ref" o = IndexEntryResolveUndoRefMethodInfo
    ResolveIndexEntryResolveUndoMethod "unref" o = IndexEntryResolveUndoUnrefMethodInfo
    ResolveIndexEntryResolveUndoMethod "getFile" o = IndexEntryResolveUndoGetFileMethodInfo
    ResolveIndexEntryResolveUndoMethod "getId" o = IndexEntryResolveUndoGetIdMethodInfo
    ResolveIndexEntryResolveUndoMethod "getMode" o = IndexEntryResolveUndoGetModeMethodInfo
    ResolveIndexEntryResolveUndoMethod l o = O.MethodResolutionFailed l o

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

#endif