{-# 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 file.

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

module GI.Ggit.Structs.DiffBinaryFile
    (

-- * Exported types
    DiffBinaryFile(..)                      ,
    noDiffBinaryFile                        ,


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

#if defined(ENABLE_OVERLOADING)
    ResolveDiffBinaryFileMethod             ,
#endif


-- ** getBinaryType #method:getBinaryType#

#if defined(ENABLE_OVERLOADING)
    DiffBinaryFileGetBinaryTypeMethodInfo   ,
#endif
    diffBinaryFileGetBinaryType             ,


-- ** getData #method:getData#

#if defined(ENABLE_OVERLOADING)
    DiffBinaryFileGetDataMethodInfo         ,
#endif
    diffBinaryFileGetData                   ,


-- ** getInflatedSize #method:getInflatedSize#

#if defined(ENABLE_OVERLOADING)
    DiffBinaryFileGetInflatedSizeMethodInfo ,
#endif
    diffBinaryFileGetInflatedSize           ,


-- ** ref #method:ref#

#if defined(ENABLE_OVERLOADING)
    DiffBinaryFileRefMethodInfo             ,
#endif
    diffBinaryFileRef                       ,


-- ** unref #method:unref#

#if defined(ENABLE_OVERLOADING)
    DiffBinaryFileUnrefMethodInfo           ,
#endif
    diffBinaryFileUnref                     ,




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

-- | Memory-managed wrapper type.
newtype DiffBinaryFile = DiffBinaryFile (ManagedPtr DiffBinaryFile)
    deriving (Eq)
foreign import ccall "ggit_diff_binary_file_get_type" c_ggit_diff_binary_file_get_type ::
    IO GType

instance BoxedObject DiffBinaryFile where
    boxedType _ = c_ggit_diff_binary_file_get_type

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



-- | A convenience alias for `Nothing` :: `Maybe` `DiffBinaryFile`.
noDiffBinaryFile :: Maybe DiffBinaryFile
noDiffBinaryFile = Nothing


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

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

foreign import ccall "ggit_diff_binary_file_get_binary_type" ggit_diff_binary_file_get_binary_type ::
    Ptr DiffBinaryFile ->                   -- file : TInterface (Name {namespace = "Ggit", name = "DiffBinaryFile"})
    IO CUInt

-- | Gets the t'GI.Ggit.Enums.DiffBinaryType' for /@file@/.
diffBinaryFileGetBinaryType ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffBinaryFile
    -- ^ /@file@/: a t'GI.Ggit.Structs.DiffBinaryFile.DiffBinaryFile'.
    -> m Ggit.Enums.DiffBinaryType
    -- ^ __Returns:__ the file\'s binary type.
diffBinaryFileGetBinaryType file = liftIO $ do
    file' <- unsafeManagedPtrGetPtr file
    result <- ggit_diff_binary_file_get_binary_type file'
    let result' = (toEnum . fromIntegral) result
    touchManagedPtr file
    return result'

#if defined(ENABLE_OVERLOADING)
data DiffBinaryFileGetBinaryTypeMethodInfo
instance (signature ~ (m Ggit.Enums.DiffBinaryType), MonadIO m) => O.MethodInfo DiffBinaryFileGetBinaryTypeMethodInfo DiffBinaryFile signature where
    overloadedMethod = diffBinaryFileGetBinaryType

#endif

-- method DiffBinaryFile::get_data
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "file"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "DiffBinaryFile" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitDiffBinaryFile."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "size"
--           , argType = TBasicType TUInt32
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "location to return size of byte data."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt8)
-- throws : False
-- Skip return : False

foreign import ccall "ggit_diff_binary_file_get_data" ggit_diff_binary_file_get_data ::
    Ptr DiffBinaryFile ->                   -- file : TInterface (Name {namespace = "Ggit", name = "DiffBinaryFile"})
    Word32 ->                               -- size : TBasicType TUInt32
    IO Word8

-- | Get the binary data. This data should not be modified.
diffBinaryFileGetData ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffBinaryFile
    -- ^ /@file@/: a t'GI.Ggit.Structs.DiffBinaryFile.DiffBinaryFile'.
    -> Word32
    -- ^ /@size@/: location to return size of byte data.
    -> m Word8
    -- ^ __Returns:__ a pointer to the binary data, or 'P.Nothing'.
diffBinaryFileGetData file size = liftIO $ do
    file' <- unsafeManagedPtrGetPtr file
    result <- ggit_diff_binary_file_get_data file' size
    touchManagedPtr file
    return result

#if defined(ENABLE_OVERLOADING)
data DiffBinaryFileGetDataMethodInfo
instance (signature ~ (Word32 -> m Word8), MonadIO m) => O.MethodInfo DiffBinaryFileGetDataMethodInfo DiffBinaryFile signature where
    overloadedMethod = diffBinaryFileGetData

#endif

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

foreign import ccall "ggit_diff_binary_file_get_inflated_size" ggit_diff_binary_file_get_inflated_size ::
    Ptr DiffBinaryFile ->                   -- file : TInterface (Name {namespace = "Ggit", name = "DiffBinaryFile"})
    IO Word32

-- | Gets the length of the binary data after inflation.
diffBinaryFileGetInflatedSize ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffBinaryFile
    -- ^ /@file@/: a t'GI.Ggit.Structs.DiffBinaryFile.DiffBinaryFile'.
    -> m Word32
    -- ^ __Returns:__ the length of the binary data after inflation.
diffBinaryFileGetInflatedSize file = liftIO $ do
    file' <- unsafeManagedPtrGetPtr file
    result <- ggit_diff_binary_file_get_inflated_size file'
    touchManagedPtr file
    return result

#if defined(ENABLE_OVERLOADING)
data DiffBinaryFileGetInflatedSizeMethodInfo
instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo DiffBinaryFileGetInflatedSizeMethodInfo DiffBinaryFile signature where
    overloadedMethod = diffBinaryFileGetInflatedSize

#endif

-- method DiffBinaryFile::ref
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "file"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "DiffBinaryFile" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitDiff." , 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_file_ref" ggit_diff_binary_file_ref ::
    Ptr DiffBinaryFile ->                   -- file : TInterface (Name {namespace = "Ggit", name = "DiffBinaryFile"})
    IO (Ptr DiffBinaryFile)

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

#if defined(ENABLE_OVERLOADING)
data DiffBinaryFileRefMethodInfo
instance (signature ~ (m DiffBinaryFile), MonadIO m) => O.MethodInfo DiffBinaryFileRefMethodInfo DiffBinaryFile signature where
    overloadedMethod = diffBinaryFileRef

#endif

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

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

#if defined(ENABLE_OVERLOADING)
data DiffBinaryFileUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo DiffBinaryFileUnrefMethodInfo DiffBinaryFile signature where
    overloadedMethod = diffBinaryFileUnref

#endif

#if defined(ENABLE_OVERLOADING)
type family ResolveDiffBinaryFileMethod (t :: Symbol) (o :: *) :: * where
    ResolveDiffBinaryFileMethod "ref" o = DiffBinaryFileRefMethodInfo
    ResolveDiffBinaryFileMethod "unref" o = DiffBinaryFileUnrefMethodInfo
    ResolveDiffBinaryFileMethod "getBinaryType" o = DiffBinaryFileGetBinaryTypeMethodInfo
    ResolveDiffBinaryFileMethod "getData" o = DiffBinaryFileGetDataMethodInfo
    ResolveDiffBinaryFileMethod "getInflatedSize" o = DiffBinaryFileGetInflatedSizeMethodInfo
    ResolveDiffBinaryFileMethod l o = O.MethodResolutionFailed l o

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

#endif