{- |
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.
-}

module GI.Ggit.Structs.DiffBinary
    ( 

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


 -- * Methods
-- ** getNewFile #method:getNewFile#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffBinaryGetNewFileMethodInfo          ,
#endif
    diffBinaryGetNewFile                    ,


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


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


-- ** unref #method:unref#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    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.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

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

noDiffBinary :: Maybe DiffBinary
noDiffBinary = Nothing


#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
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 Ggit.DiffBinaryFile.DiffBinaryFile
    {- ^ __Returns:__ the contents of the new file. -}
diffBinaryGetNewFile binary = liftIO $ do
    binary' <- unsafeManagedPtrGetPtr binary
    result <- ggit_diff_binary_get_new_file binary'
    checkUnexpectedReturnNULL "diffBinaryGetNewFile" result
    result' <- (newBoxed Ggit.DiffBinaryFile.DiffBinaryFile) result
    touchManagedPtr binary
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffBinaryGetNewFileMethodInfo
instance (signature ~ (m 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 Ggit.DiffBinaryFile.DiffBinaryFile
    {- ^ __Returns:__ the contents of the old file. -}
diffBinaryGetOldFile binary = liftIO $ do
    binary' <- unsafeManagedPtrGetPtr binary
    result <- ggit_diff_binary_get_old_file binary'
    checkUnexpectedReturnNULL "diffBinaryGetOldFile" result
    result' <- (newBoxed Ggit.DiffBinaryFile.DiffBinaryFile) result
    touchManagedPtr binary
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffBinaryGetOldFileMethodInfo
instance (signature ~ (m 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 DiffBinary
    {- ^ __Returns:__ a 'GI.Ggit.Structs.DiffBinary.DiffBinary'. -}
diffBinaryRef binary = liftIO $ do
    binary' <- unsafeManagedPtrGetPtr binary
    result <- ggit_diff_binary_ref binary'
    checkUnexpectedReturnNULL "diffBinaryRef" result
    result' <- (wrapBoxed DiffBinary) result
    touchManagedPtr binary
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffBinaryRefMethodInfo
instance (signature ~ (m 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 defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffBinaryUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo DiffBinaryUnrefMethodInfo DiffBinary signature where
    overloadedMethod _ = diffBinaryUnref

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
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