{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- Represents a diff binary.

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

module GI.Ggit.Structs.DiffBinary
    (

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


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

#if defined(ENABLE_OVERLOADING)
    ResolveDiffBinaryMethod                 ,
#endif


-- ** getNewFile #method:getNewFile#

#if defined(ENABLE_OVERLOADING)
    DiffBinaryGetNewFileMethodInfo          ,
#endif
    diffBinaryGetNewFile                    ,


-- ** getOldFile #method:getOldFile#

#if defined(ENABLE_OVERLOADING)
    DiffBinaryGetOldFileMethodInfo          ,
#endif
    diffBinaryGetOldFile                    ,


-- ** ref #method:ref#

#if defined(ENABLE_OVERLOADING)
    DiffBinaryRefMethodInfo                 ,
#endif
    diffBinaryRef                           ,


-- ** unref #method:unref#

#if defined(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.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.DiffBinaryFile as Ggit.DiffBinaryFile

-- | Memory-managed wrapper type.
newtype DiffBinary = DiffBinary (ManagedPtr DiffBinary)
    deriving (Eq)
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

-- | Convert 'DiffBinary' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue DiffBinary where
    toGValue o = do
        gtype <- c_ggit_diff_binary_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 DiffBinary)
        B.ManagedPtr.newBoxed DiffBinary ptr



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


#if defined(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 t'GI.Ggit.Structs.DiffBinaryFile.DiffBinaryFile' new file for /@binary@/.
diffBinaryGetNewFile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffBinary
    -- ^ /@binary@/: a t'GI.Ggit.Structs.DiffBinary.DiffBinary'.
    -> m (Maybe Ggit.DiffBinaryFile.DiffBinaryFile)
    -- ^ __Returns:__ the contents of the new file or 'P.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 defined(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 t'GI.Ggit.Structs.DiffBinaryFile.DiffBinaryFile' old file for /@binary@/.
diffBinaryGetOldFile ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffBinary
    -- ^ /@binary@/: a t'GI.Ggit.Structs.DiffBinary.DiffBinary'.
    -> m (Maybe Ggit.DiffBinaryFile.DiffBinaryFile)
    -- ^ __Returns:__ the contents of the old file or 'P.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 defined(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 t'GI.Ggit.Structs.DiffBinary.DiffBinary'.
    -> m (Maybe DiffBinary)
    -- ^ __Returns:__ a t'GI.Ggit.Structs.DiffBinary.DiffBinary' or 'P.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 defined(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 t'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)
data DiffBinaryUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo DiffBinaryUnrefMethodInfo DiffBinary signature where
    overloadedMethod = diffBinaryUnref

#endif

#if defined(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) => OL.IsLabel t (DiffBinary -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#endif