{- |
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 a diff binary.
-}

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

module GI.Ggit.Structs.DiffBinary
    (

-- * Exported types
    DiffBinary(..)                          ,
    noDiffBinary                            ,


 -- * Methods
-- ** getNewFile #method:getNewFile#

#if ENABLE_OVERLOADING
    DiffBinaryGetNewFileMethodInfo          ,
#endif
    diffBinaryGetNewFile                    ,


-- ** getOldFile #method:getOldFile#

#if ENABLE_OVERLOADING
    DiffBinaryGetOldFileMethodInfo          ,
#endif
    diffBinaryGetOldFile                    ,


-- ** ref #method:ref#

#if ENABLE_OVERLOADING
    DiffBinaryRefMethodInfo                 ,
#endif
    diffBinaryRef                           ,


-- ** unref #method:unref#

#if ENABLE_OVERLOADING
    DiffBinaryUnrefMethodInfo               ,
#endif
    diffBinaryUnref                         ,




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

-- | Memory-managed wrapper type.
newtype DiffBinary = DiffBinary (ManagedPtr DiffBinary)
foreign import ccall "ggit_diff_binary_get_type" c_ggit_diff_binary_get_type ::
    IO GType

instance BoxedObject DiffBinary where
    boxedType _ = c_ggit_diff_binary_get_type

-- | A convenience alias for `Nothing` :: `Maybe` `DiffBinary`.
noDiffBinary :: Maybe DiffBinary
noDiffBinary = Nothing


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

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

foreign import ccall "ggit_diff_binary_get_new_file" ggit_diff_binary_get_new_file ::
    Ptr DiffBinary ->                       -- binary : TInterface (Name {namespace = "Ggit", name = "DiffBinary"})
    IO (Ptr Ggit.DiffBinaryFile.DiffBinaryFile)

{- |
Gets the 'GI.Ggit.Structs.DiffBinaryFile.DiffBinaryFile' new file for /@binary@/.
-}
diffBinaryGetNewFile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffBinary
    {- ^ /@binary@/: a 'GI.Ggit.Structs.DiffBinary.DiffBinary'. -}
    -> m (Maybe Ggit.DiffBinaryFile.DiffBinaryFile)
    {- ^ __Returns:__ the contents of the new file or 'Nothing'. -}
diffBinaryGetNewFile binary = liftIO $ do
    binary' <- unsafeManagedPtrGetPtr binary
    result <- ggit_diff_binary_get_new_file binary'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newBoxed Ggit.DiffBinaryFile.DiffBinaryFile) result'
        return result''
    touchManagedPtr binary
    return maybeResult

#if ENABLE_OVERLOADING
data DiffBinaryGetNewFileMethodInfo
instance (signature ~ (m (Maybe Ggit.DiffBinaryFile.DiffBinaryFile)), MonadIO m) => O.MethodInfo DiffBinaryGetNewFileMethodInfo DiffBinary signature where
    overloadedMethod _ = diffBinaryGetNewFile

#endif

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

foreign import ccall "ggit_diff_binary_get_old_file" ggit_diff_binary_get_old_file ::
    Ptr DiffBinary ->                       -- binary : TInterface (Name {namespace = "Ggit", name = "DiffBinary"})
    IO (Ptr Ggit.DiffBinaryFile.DiffBinaryFile)

{- |
Gets the 'GI.Ggit.Structs.DiffBinaryFile.DiffBinaryFile' old file for /@binary@/.
-}
diffBinaryGetOldFile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffBinary
    {- ^ /@binary@/: a 'GI.Ggit.Structs.DiffBinary.DiffBinary'. -}
    -> m (Maybe Ggit.DiffBinaryFile.DiffBinaryFile)
    {- ^ __Returns:__ the contents of the old file or 'Nothing'. -}
diffBinaryGetOldFile binary = liftIO $ do
    binary' <- unsafeManagedPtrGetPtr binary
    result <- ggit_diff_binary_get_old_file binary'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newBoxed Ggit.DiffBinaryFile.DiffBinaryFile) result'
        return result''
    touchManagedPtr binary
    return maybeResult

#if ENABLE_OVERLOADING
data DiffBinaryGetOldFileMethodInfo
instance (signature ~ (m (Maybe Ggit.DiffBinaryFile.DiffBinaryFile)), MonadIO m) => O.MethodInfo DiffBinaryGetOldFileMethodInfo DiffBinary signature where
    overloadedMethod _ = diffBinaryGetOldFile

#endif

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

foreign import ccall "ggit_diff_binary_ref" ggit_diff_binary_ref ::
    Ptr DiffBinary ->                       -- binary : TInterface (Name {namespace = "Ggit", name = "DiffBinary"})
    IO (Ptr DiffBinary)

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

#if ENABLE_OVERLOADING
data DiffBinaryRefMethodInfo
instance (signature ~ (m (Maybe DiffBinary)), MonadIO m) => O.MethodInfo DiffBinaryRefMethodInfo DiffBinary signature where
    overloadedMethod _ = diffBinaryRef

#endif

-- method DiffBinary::unref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "binary", argType = TInterface (Name {namespace = "Ggit", name = "DiffBinary"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffBinary.", 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_binary_unref" ggit_diff_binary_unref ::
    Ptr DiffBinary ->                       -- binary : TInterface (Name {namespace = "Ggit", name = "DiffBinary"})
    IO ()

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

#if ENABLE_OVERLOADING
data DiffBinaryUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo DiffBinaryUnrefMethodInfo DiffBinary signature where
    overloadedMethod _ = diffBinaryUnref

#endif

#if ENABLE_OVERLOADING
type family ResolveDiffBinaryMethod (t :: Symbol) (o :: *) :: * where
    ResolveDiffBinaryMethod "ref" o = DiffBinaryRefMethodInfo
    ResolveDiffBinaryMethod "unref" o = DiffBinaryUnrefMethodInfo
    ResolveDiffBinaryMethod "getNewFile" o = DiffBinaryGetNewFileMethodInfo
    ResolveDiffBinaryMethod "getOldFile" o = DiffBinaryGetOldFileMethodInfo
    ResolveDiffBinaryMethod l o = O.MethodResolutionFailed l o

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

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