{- |
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 changes done to one file.
-}

module GI.Ggit.Structs.DiffDelta
    ( 

-- * Exported types
    DiffDelta(..)                           ,
    noDiffDelta                             ,


 -- * Methods
-- ** getFlags #method:getFlags#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffDeltaGetFlagsMethodInfo             ,
#endif
    diffDeltaGetFlags                       ,


-- ** getNewFile #method:getNewFile#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffDeltaGetNewFileMethodInfo           ,
#endif
    diffDeltaGetNewFile                     ,


-- ** getOldFile #method:getOldFile#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffDeltaGetOldFileMethodInfo           ,
#endif
    diffDeltaGetOldFile                     ,


-- ** getSimilarity #method:getSimilarity#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffDeltaGetSimilarityMethodInfo        ,
#endif
    diffDeltaGetSimilarity                  ,


-- ** getStatus #method:getStatus#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffDeltaGetStatusMethodInfo            ,
#endif
    diffDeltaGetStatus                      ,


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


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




    ) 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.Flags as Ggit.Flags
import {-# SOURCE #-} qualified GI.Ggit.Structs.DiffFile as Ggit.DiffFile

newtype DiffDelta = DiffDelta (ManagedPtr DiffDelta)
foreign import ccall "ggit_diff_delta_get_type" c_ggit_diff_delta_get_type :: 
    IO GType

instance BoxedObject DiffDelta where
    boxedType _ = c_ggit_diff_delta_get_type

noDiffDelta :: Maybe DiffDelta
noDiffDelta = Nothing


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

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

foreign import ccall "ggit_diff_delta_get_flags" ggit_diff_delta_get_flags :: 
    Ptr DiffDelta ->                        -- delta : TInterface (Name {namespace = "Ggit", name = "DiffDelta"})
    IO CUInt

{- |
Gets flags for /@delta@/.
-}
diffDeltaGetFlags ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> m [Ggit.Flags.DiffFlag]
    {- ^ __Returns:__ the delta flags -}
diffDeltaGetFlags delta = liftIO $ do
    delta' <- unsafeManagedPtrGetPtr delta
    result <- ggit_diff_delta_get_flags delta'
    let result' = wordToGFlags result
    touchManagedPtr delta
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffDeltaGetFlagsMethodInfo
instance (signature ~ (m [Ggit.Flags.DiffFlag]), MonadIO m) => O.MethodInfo DiffDeltaGetFlagsMethodInfo DiffDelta signature where
    overloadedMethod _ = diffDeltaGetFlags

#endif

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

foreign import ccall "ggit_diff_delta_get_new_file" ggit_diff_delta_get_new_file :: 
    Ptr DiffDelta ->                        -- delta : TInterface (Name {namespace = "Ggit", name = "DiffDelta"})
    IO (Ptr Ggit.DiffFile.DiffFile)

{- |
Gets the new file for /@delta@/.
-}
diffDeltaGetNewFile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> m Ggit.DiffFile.DiffFile
    {- ^ __Returns:__ the delta\'s new file. -}
diffDeltaGetNewFile delta = liftIO $ do
    delta' <- unsafeManagedPtrGetPtr delta
    result <- ggit_diff_delta_get_new_file delta'
    checkUnexpectedReturnNULL "diffDeltaGetNewFile" result
    result' <- (newBoxed Ggit.DiffFile.DiffFile) result
    touchManagedPtr delta
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffDeltaGetNewFileMethodInfo
instance (signature ~ (m Ggit.DiffFile.DiffFile), MonadIO m) => O.MethodInfo DiffDeltaGetNewFileMethodInfo DiffDelta signature where
    overloadedMethod _ = diffDeltaGetNewFile

#endif

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

foreign import ccall "ggit_diff_delta_get_old_file" ggit_diff_delta_get_old_file :: 
    Ptr DiffDelta ->                        -- delta : TInterface (Name {namespace = "Ggit", name = "DiffDelta"})
    IO (Ptr Ggit.DiffFile.DiffFile)

{- |
Gets the old file for /@delta@/.
-}
diffDeltaGetOldFile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> m Ggit.DiffFile.DiffFile
    {- ^ __Returns:__ the delta\'s old file. -}
diffDeltaGetOldFile delta = liftIO $ do
    delta' <- unsafeManagedPtrGetPtr delta
    result <- ggit_diff_delta_get_old_file delta'
    checkUnexpectedReturnNULL "diffDeltaGetOldFile" result
    result' <- (newBoxed Ggit.DiffFile.DiffFile) result
    touchManagedPtr delta
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffDeltaGetOldFileMethodInfo
instance (signature ~ (m Ggit.DiffFile.DiffFile), MonadIO m) => O.MethodInfo DiffDeltaGetOldFileMethodInfo DiffDelta signature where
    overloadedMethod _ = diffDeltaGetOldFile

#endif

-- method DiffDelta::get_similarity
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "delta", argType = TInterface (Name {namespace = "Ggit", name = "DiffDelta"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffDelta.", 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_diff_delta_get_similarity" ggit_diff_delta_get_similarity :: 
    Ptr DiffDelta ->                        -- delta : TInterface (Name {namespace = "Ggit", name = "DiffDelta"})
    IO Word32

{- |
Gets the similarity between /@delta@/ files.
-}
diffDeltaGetSimilarity ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> m Word32
    {- ^ __Returns:__ the delta\'s similarity. -}
diffDeltaGetSimilarity delta = liftIO $ do
    delta' <- unsafeManagedPtrGetPtr delta
    result <- ggit_diff_delta_get_similarity delta'
    touchManagedPtr delta
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffDeltaGetSimilarityMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo DiffDeltaGetSimilarityMethodInfo DiffDelta signature where
    overloadedMethod _ = diffDeltaGetSimilarity

#endif

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

foreign import ccall "ggit_diff_delta_get_status" ggit_diff_delta_get_status :: 
    Ptr DiffDelta ->                        -- delta : TInterface (Name {namespace = "Ggit", name = "DiffDelta"})
    IO CUInt

{- |
Gets the 'GI.Ggit.Enums.DeltaType' for /@delta@/.
-}
diffDeltaGetStatus ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffDelta
    {- ^ /@delta@/: a 'GI.Ggit.Structs.DiffDelta.DiffDelta'. -}
    -> m Ggit.Enums.DeltaType
    {- ^ __Returns:__ the delta\'s status. -}
diffDeltaGetStatus delta = liftIO $ do
    delta' <- unsafeManagedPtrGetPtr delta
    result <- ggit_diff_delta_get_status delta'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr delta
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffDeltaGetStatusMethodInfo
instance (signature ~ (m Ggit.Enums.DeltaType), MonadIO m) => O.MethodInfo DiffDeltaGetStatusMethodInfo DiffDelta signature where
    overloadedMethod _ = diffDeltaGetStatus

#endif

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

foreign import ccall "ggit_diff_delta_ref" ggit_diff_delta_ref :: 
    Ptr DiffDelta ->                        -- delta : TInterface (Name {namespace = "Ggit", name = "DiffDelta"})
    IO (Ptr DiffDelta)

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

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

#endif

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

foreign import ccall "ggit_diff_delta_unref" ggit_diff_delta_unref :: 
    Ptr DiffDelta ->                        -- delta : TInterface (Name {namespace = "Ggit", name = "DiffDelta"})
    IO ()

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

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

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveDiffDeltaMethod (t :: Symbol) (o :: *) :: * where
    ResolveDiffDeltaMethod "ref" o = DiffDeltaRefMethodInfo
    ResolveDiffDeltaMethod "unref" o = DiffDeltaUnrefMethodInfo
    ResolveDiffDeltaMethod "getFlags" o = DiffDeltaGetFlagsMethodInfo
    ResolveDiffDeltaMethod "getNewFile" o = DiffDeltaGetNewFileMethodInfo
    ResolveDiffDeltaMethod "getOldFile" o = DiffDeltaGetOldFileMethodInfo
    ResolveDiffDeltaMethod "getSimilarity" o = DiffDeltaGetSimilarityMethodInfo
    ResolveDiffDeltaMethod "getStatus" o = DiffDeltaGetStatusMethodInfo
    ResolveDiffDeltaMethod l o = O.MethodResolutionFailed l o

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

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