{-# 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 patch object.

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

module GI.Ggit.Structs.Patch
    ( 

-- * Exported types
    Patch(..)                               ,
    noPatch                                 ,


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

#if defined(ENABLE_OVERLOADING)
    ResolvePatchMethod                      ,
#endif


-- ** getDelta #method:getDelta#

#if defined(ENABLE_OVERLOADING)
    PatchGetDeltaMethodInfo                 ,
#endif
    patchGetDelta                           ,


-- ** getHunk #method:getHunk#

#if defined(ENABLE_OVERLOADING)
    PatchGetHunkMethodInfo                  ,
#endif
    patchGetHunk                            ,


-- ** getLineStats #method:getLineStats#

#if defined(ENABLE_OVERLOADING)
    PatchGetLineStatsMethodInfo             ,
#endif
    patchGetLineStats                       ,


-- ** getNumHunks #method:getNumHunks#

#if defined(ENABLE_OVERLOADING)
    PatchGetNumHunksMethodInfo              ,
#endif
    patchGetNumHunks                        ,


-- ** getNumLinesInHunk #method:getNumLinesInHunk#

#if defined(ENABLE_OVERLOADING)
    PatchGetNumLinesInHunkMethodInfo        ,
#endif
    patchGetNumLinesInHunk                  ,


-- ** newFromBlobs #method:newFromBlobs#

    patchNewFromBlobs                       ,


-- ** newFromDiff #method:newFromDiff#

    patchNewFromDiff                        ,


-- ** ref #method:ref#

#if defined(ENABLE_OVERLOADING)
    PatchRefMethodInfo                      ,
#endif
    patchRef                                ,


-- ** toStream #method:toStream#

#if defined(ENABLE_OVERLOADING)
    PatchToStreamMethodInfo                 ,
#endif
    patchToStream                           ,


-- ** toString #method:toString#

#if defined(ENABLE_OVERLOADING)
    PatchToStringMethodInfo                 ,
#endif
    patchToString                           ,


-- ** unref #method:unref#

#if defined(ENABLE_OVERLOADING)
    PatchUnrefMethodInfo                    ,
#endif
    patchUnref                              ,




    ) 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.Objects.Blob as Ggit.Blob
import {-# SOURCE #-} qualified GI.Ggit.Objects.Diff as Ggit.Diff
import {-# SOURCE #-} qualified GI.Ggit.Objects.DiffOptions as Ggit.DiffOptions
import {-# SOURCE #-} qualified GI.Ggit.Structs.DiffDelta as Ggit.DiffDelta
import {-# SOURCE #-} qualified GI.Ggit.Structs.DiffHunk as Ggit.DiffHunk
import qualified GI.Gio.Objects.OutputStream as Gio.OutputStream

-- | Memory-managed wrapper type.
newtype Patch = Patch (ManagedPtr Patch)
    deriving (Patch -> Patch -> Bool
(Patch -> Patch -> Bool) -> (Patch -> Patch -> Bool) -> Eq Patch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Patch -> Patch -> Bool
$c/= :: Patch -> Patch -> Bool
== :: Patch -> Patch -> Bool
$c== :: Patch -> Patch -> Bool
Eq)
foreign import ccall "ggit_patch_get_type" c_ggit_patch_get_type :: 
    IO GType

instance BoxedObject Patch where
    boxedType :: Patch -> IO GType
boxedType _ = IO GType
c_ggit_patch_get_type

-- | Convert 'Patch' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue Patch where
    toGValue :: Patch -> IO GValue
toGValue o :: Patch
o = do
        GType
gtype <- IO GType
c_ggit_patch_get_type
        Patch -> (Ptr Patch -> IO GValue) -> IO GValue
forall a c.
(HasCallStack, ManagedPtrNewtype a) =>
a -> (Ptr a -> IO c) -> IO c
B.ManagedPtr.withManagedPtr Patch
o (GType -> (GValue -> Ptr Patch -> IO ()) -> Ptr Patch -> IO GValue
forall a. GType -> (GValue -> a -> IO ()) -> a -> IO GValue
B.GValue.buildGValue GType
gtype GValue -> Ptr Patch -> IO ()
forall a. GValue -> Ptr a -> IO ()
B.GValue.set_boxed)
        
    fromGValue :: GValue -> IO Patch
fromGValue gv :: GValue
gv = do
        Ptr Patch
ptr <- GValue -> IO (Ptr Patch)
forall b. GValue -> IO (Ptr b)
B.GValue.get_boxed GValue
gv :: IO (Ptr Patch)
        (ManagedPtr Patch -> Patch) -> Ptr Patch -> IO Patch
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
B.ManagedPtr.newBoxed ManagedPtr Patch -> Patch
Patch Ptr Patch
ptr
        
    

-- | A convenience alias for `Nothing` :: `Maybe` `Patch`.
noPatch :: Maybe Patch
noPatch :: Maybe Patch
noPatch = Maybe Patch
forall a. Maybe a
Nothing


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

-- method Patch::new_from_blobs
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "old_blob"
--           , argType = TInterface Name { namespace = "Ggit" , name = "Blob" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitBlob to diff from."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "old_as_path"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "treat @old_blob as if it had this filename, or %NULL,"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "new_blob"
--           , argType = TInterface Name { namespace = "Ggit" , name = "Blob" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitBlob to diff to."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "new_as_path"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "treat @new_blob as if it had this filename, or %NULL,"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "diff_options"
--           , argType =
--               TInterface Name { namespace = "Ggit" , name = "DiffOptions" }
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitDiffOptions, or %NULL."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Ggit" , name = "Patch" })
-- throws : True
-- Skip return : False

foreign import ccall "ggit_patch_new_from_blobs" ggit_patch_new_from_blobs :: 
    Ptr Ggit.Blob.Blob ->                   -- old_blob : TInterface (Name {namespace = "Ggit", name = "Blob"})
    CString ->                              -- old_as_path : TBasicType TUTF8
    Ptr Ggit.Blob.Blob ->                   -- new_blob : TInterface (Name {namespace = "Ggit", name = "Blob"})
    CString ->                              -- new_as_path : TBasicType TUTF8
    Ptr Ggit.DiffOptions.DiffOptions ->     -- diff_options : TInterface (Name {namespace = "Ggit", name = "DiffOptions"})
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Patch)

-- | Directly generate a patch from the difference between two blobs.
-- 
-- This is just like 'GI.Ggit.Objects.Diff.diffBlobs' except it generates a patch object
-- for the difference instead of directly making callbacks.  You can use the
-- standard ggit_patch accessor functions to read the patch data, and
-- you must call ggit_patch_unref on the patch when done.
patchNewFromBlobs ::
    (B.CallStack.HasCallStack, MonadIO m, Ggit.Blob.IsBlob a, Ggit.Blob.IsBlob b, Ggit.DiffOptions.IsDiffOptions c) =>
    Maybe (a)
    -- ^ /@oldBlob@/: a t'GI.Ggit.Objects.Blob.Blob' to diff from.
    -> Maybe (T.Text)
    -- ^ /@oldAsPath@/: treat /@oldBlob@/ as if it had this filename, or 'P.Nothing',
    -> Maybe (b)
    -- ^ /@newBlob@/: a t'GI.Ggit.Objects.Blob.Blob' to diff to.
    -> Maybe (T.Text)
    -- ^ /@newAsPath@/: treat /@newBlob@/ as if it had this filename, or 'P.Nothing',
    -> Maybe (c)
    -- ^ /@diffOptions@/: a t'GI.Ggit.Objects.DiffOptions.DiffOptions', or 'P.Nothing'.
    -> m (Maybe Patch)
    -- ^ __Returns:__ a newly created t'GI.Ggit.Structs.Patch.Patch' or 'P.Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/
patchNewFromBlobs :: Maybe a
-> Maybe Text
-> Maybe b
-> Maybe Text
-> Maybe c
-> m (Maybe Patch)
patchNewFromBlobs oldBlob :: Maybe a
oldBlob oldAsPath :: Maybe Text
oldAsPath newBlob :: Maybe b
newBlob newAsPath :: Maybe Text
newAsPath diffOptions :: Maybe c
diffOptions = IO (Maybe Patch) -> m (Maybe Patch)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Patch) -> m (Maybe Patch))
-> IO (Maybe Patch) -> m (Maybe Patch)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Blob
maybeOldBlob <- case Maybe a
oldBlob of
        Nothing -> Ptr Blob -> IO (Ptr Blob)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Blob
forall a. Ptr a
nullPtr
        Just jOldBlob :: a
jOldBlob -> do
            Ptr Blob
jOldBlob' <- a -> IO (Ptr Blob)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
jOldBlob
            Ptr Blob -> IO (Ptr Blob)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Blob
jOldBlob'
    Ptr CChar
maybeOldAsPath <- case Maybe Text
oldAsPath of
        Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
        Just jOldAsPath :: Text
jOldAsPath -> do
            Ptr CChar
jOldAsPath' <- Text -> IO (Ptr CChar)
textToCString Text
jOldAsPath
            Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jOldAsPath'
    Ptr Blob
maybeNewBlob <- case Maybe b
newBlob of
        Nothing -> Ptr Blob -> IO (Ptr Blob)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Blob
forall a. Ptr a
nullPtr
        Just jNewBlob :: b
jNewBlob -> do
            Ptr Blob
jNewBlob' <- b -> IO (Ptr Blob)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr b
jNewBlob
            Ptr Blob -> IO (Ptr Blob)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr Blob
jNewBlob'
    Ptr CChar
maybeNewAsPath <- case Maybe Text
newAsPath of
        Nothing -> Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
forall a. Ptr a
nullPtr
        Just jNewAsPath :: Text
jNewAsPath -> do
            Ptr CChar
jNewAsPath' <- Text -> IO (Ptr CChar)
textToCString Text
jNewAsPath
            Ptr CChar -> IO (Ptr CChar)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CChar
jNewAsPath'
    Ptr DiffOptions
maybeDiffOptions <- case Maybe c
diffOptions of
        Nothing -> Ptr DiffOptions -> IO (Ptr DiffOptions)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr DiffOptions
forall a. Ptr a
nullPtr
        Just jDiffOptions :: c
jDiffOptions -> do
            Ptr DiffOptions
jDiffOptions' <- c -> IO (Ptr DiffOptions)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr c
jDiffOptions
            Ptr DiffOptions -> IO (Ptr DiffOptions)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr DiffOptions
jDiffOptions'
    IO (Maybe Patch) -> IO () -> IO (Maybe Patch)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Patch
result <- (Ptr (Ptr GError) -> IO (Ptr Patch)) -> IO (Ptr Patch)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Patch)) -> IO (Ptr Patch))
-> (Ptr (Ptr GError) -> IO (Ptr Patch)) -> IO (Ptr Patch)
forall a b. (a -> b) -> a -> b
$ Ptr Blob
-> Ptr CChar
-> Ptr Blob
-> Ptr CChar
-> Ptr DiffOptions
-> Ptr (Ptr GError)
-> IO (Ptr Patch)
ggit_patch_new_from_blobs Ptr Blob
maybeOldBlob Ptr CChar
maybeOldAsPath Ptr Blob
maybeNewBlob Ptr CChar
maybeNewAsPath Ptr DiffOptions
maybeDiffOptions
        Maybe Patch
maybeResult <- Ptr Patch -> (Ptr Patch -> IO Patch) -> IO (Maybe Patch)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Patch
result ((Ptr Patch -> IO Patch) -> IO (Maybe Patch))
-> (Ptr Patch -> IO Patch) -> IO (Maybe Patch)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Patch
result' -> do
            Patch
result'' <- ((ManagedPtr Patch -> Patch) -> Ptr Patch -> IO Patch
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Patch -> Patch
Patch) Ptr Patch
result'
            Patch -> IO Patch
forall (m :: * -> *) a. Monad m => a -> m a
return Patch
result''
        Maybe a -> (a -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe a
oldBlob a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Maybe b -> (b -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe b
newBlob b -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Maybe c -> (c -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe c
diffOptions c -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeOldAsPath
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeNewAsPath
        Maybe Patch -> IO (Maybe Patch)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Patch
maybeResult
     ) (do
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeOldAsPath
        Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
maybeNewAsPath
     )

#if defined(ENABLE_OVERLOADING)
#endif

-- method Patch::new_from_diff
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "diff"
--           , argType = TInterface Name { namespace = "Ggit" , name = "Diff" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitDiff." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "idx"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "index into diff list."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Ggit" , name = "Patch" })
-- throws : True
-- Skip return : False

foreign import ccall "ggit_patch_new_from_diff" ggit_patch_new_from_diff :: 
    Ptr Ggit.Diff.Diff ->                   -- diff : TInterface (Name {namespace = "Ggit", name = "Diff"})
    Word64 ->                               -- idx : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Patch)

-- | The t'GI.Ggit.Structs.Patch.Patch' is a newly created object contains the text diffs
-- for the delta.  You have to call 'GI.Ggit.Structs.Patch.patchUnref' when you are
-- done with it.  You can use the patch object to loop over all the hunks
-- and lines in the diff of the one delta.
patchNewFromDiff ::
    (B.CallStack.HasCallStack, MonadIO m, Ggit.Diff.IsDiff a) =>
    a
    -- ^ /@diff@/: a t'GI.Ggit.Objects.Diff.Diff'.
    -> Word64
    -- ^ /@idx@/: index into diff list.
    -> m (Maybe Patch)
    -- ^ __Returns:__ a newly created t'GI.Ggit.Structs.Patch.Patch' or 'P.Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/
patchNewFromDiff :: a -> Word64 -> m (Maybe Patch)
patchNewFromDiff diff :: a
diff idx :: Word64
idx = IO (Maybe Patch) -> m (Maybe Patch)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Patch) -> m (Maybe Patch))
-> IO (Maybe Patch) -> m (Maybe Patch)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Diff
diff' <- a -> IO (Ptr Diff)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
diff
    IO (Maybe Patch) -> IO () -> IO (Maybe Patch)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Patch
result <- (Ptr (Ptr GError) -> IO (Ptr Patch)) -> IO (Ptr Patch)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Patch)) -> IO (Ptr Patch))
-> (Ptr (Ptr GError) -> IO (Ptr Patch)) -> IO (Ptr Patch)
forall a b. (a -> b) -> a -> b
$ Ptr Diff -> Word64 -> Ptr (Ptr GError) -> IO (Ptr Patch)
ggit_patch_new_from_diff Ptr Diff
diff' Word64
idx
        Maybe Patch
maybeResult <- Ptr Patch -> (Ptr Patch -> IO Patch) -> IO (Maybe Patch)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Patch
result ((Ptr Patch -> IO Patch) -> IO (Maybe Patch))
-> (Ptr Patch -> IO Patch) -> IO (Maybe Patch)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Patch
result' -> do
            Patch
result'' <- ((ManagedPtr Patch -> Patch) -> Ptr Patch -> IO Patch
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Patch -> Patch
Patch) Ptr Patch
result'
            Patch -> IO Patch
forall (m :: * -> *) a. Monad m => a -> m a
return Patch
result''
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
diff
        Maybe Patch -> IO (Maybe Patch)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Patch
maybeResult
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
#endif

-- method Patch::get_delta
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "patch"
--           , argType = TInterface Name { namespace = "Ggit" , name = "Patch" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitPatch." , 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_patch_get_delta" ggit_patch_get_delta :: 
    Ptr Patch ->                            -- patch : TInterface (Name {namespace = "Ggit", name = "Patch"})
    IO (Ptr Ggit.DiffDelta.DiffDelta)

-- | Get the diff delta corresponding to the patch.
patchGetDelta ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Patch
    -- ^ /@patch@/: a t'GI.Ggit.Structs.Patch.Patch'.
    -> m (Maybe Ggit.DiffDelta.DiffDelta)
    -- ^ __Returns:__ the t'GI.Ggit.Structs.DiffDelta.DiffDelta' of the patch or 'P.Nothing'.
patchGetDelta :: Patch -> m (Maybe DiffDelta)
patchGetDelta patch :: Patch
patch = IO (Maybe DiffDelta) -> m (Maybe DiffDelta)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe DiffDelta) -> m (Maybe DiffDelta))
-> IO (Maybe DiffDelta) -> m (Maybe DiffDelta)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Patch
patch' <- Patch -> IO (Ptr Patch)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Patch
patch
    Ptr DiffDelta
result <- Ptr Patch -> IO (Ptr DiffDelta)
ggit_patch_get_delta Ptr Patch
patch'
    Maybe DiffDelta
maybeResult <- Ptr DiffDelta
-> (Ptr DiffDelta -> IO DiffDelta) -> IO (Maybe DiffDelta)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr DiffDelta
result ((Ptr DiffDelta -> IO DiffDelta) -> IO (Maybe DiffDelta))
-> (Ptr DiffDelta -> IO DiffDelta) -> IO (Maybe DiffDelta)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr DiffDelta
result' -> do
        DiffDelta
result'' <- ((ManagedPtr DiffDelta -> DiffDelta)
-> Ptr DiffDelta -> IO DiffDelta
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr DiffDelta -> DiffDelta
Ggit.DiffDelta.DiffDelta) Ptr DiffDelta
result'
        DiffDelta -> IO DiffDelta
forall (m :: * -> *) a. Monad m => a -> m a
return DiffDelta
result''
    Patch -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Patch
patch
    Maybe DiffDelta -> IO (Maybe DiffDelta)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe DiffDelta
maybeResult

#if defined(ENABLE_OVERLOADING)
data PatchGetDeltaMethodInfo
instance (signature ~ (m (Maybe Ggit.DiffDelta.DiffDelta)), MonadIO m) => O.MethodInfo PatchGetDeltaMethodInfo Patch signature where
    overloadedMethod = patchGetDelta

#endif

-- method Patch::get_hunk
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "patch"
--           , argType = TInterface Name { namespace = "Ggit" , name = "Patch" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitPatch" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "idx"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the hunk index." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Ggit" , name = "DiffHunk" })
-- throws : True
-- Skip return : False

foreign import ccall "ggit_patch_get_hunk" ggit_patch_get_hunk :: 
    Ptr Patch ->                            -- patch : TInterface (Name {namespace = "Ggit", name = "Patch"})
    Word64 ->                               -- idx : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Ggit.DiffHunk.DiffHunk)

-- | Get the /@idx@/\'th hunk in the patch.
patchGetHunk ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Patch
    -- ^ /@patch@/: a t'GI.Ggit.Structs.Patch.Patch'
    -> Word64
    -- ^ /@idx@/: the hunk index.
    -> m (Maybe Ggit.DiffHunk.DiffHunk)
    -- ^ __Returns:__ a new t'GI.Ggit.Structs.DiffHunk.DiffHunk' or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
patchGetHunk :: Patch -> Word64 -> m (Maybe DiffHunk)
patchGetHunk patch :: Patch
patch idx :: Word64
idx = IO (Maybe DiffHunk) -> m (Maybe DiffHunk)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe DiffHunk) -> m (Maybe DiffHunk))
-> IO (Maybe DiffHunk) -> m (Maybe DiffHunk)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Patch
patch' <- Patch -> IO (Ptr Patch)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Patch
patch
    IO (Maybe DiffHunk) -> IO () -> IO (Maybe DiffHunk)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr DiffHunk
result <- (Ptr (Ptr GError) -> IO (Ptr DiffHunk)) -> IO (Ptr DiffHunk)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr DiffHunk)) -> IO (Ptr DiffHunk))
-> (Ptr (Ptr GError) -> IO (Ptr DiffHunk)) -> IO (Ptr DiffHunk)
forall a b. (a -> b) -> a -> b
$ Ptr Patch -> Word64 -> Ptr (Ptr GError) -> IO (Ptr DiffHunk)
ggit_patch_get_hunk Ptr Patch
patch' Word64
idx
        Maybe DiffHunk
maybeResult <- Ptr DiffHunk
-> (Ptr DiffHunk -> IO DiffHunk) -> IO (Maybe DiffHunk)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr DiffHunk
result ((Ptr DiffHunk -> IO DiffHunk) -> IO (Maybe DiffHunk))
-> (Ptr DiffHunk -> IO DiffHunk) -> IO (Maybe DiffHunk)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr DiffHunk
result' -> do
            DiffHunk
result'' <- ((ManagedPtr DiffHunk -> DiffHunk) -> Ptr DiffHunk -> IO DiffHunk
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr DiffHunk -> DiffHunk
Ggit.DiffHunk.DiffHunk) Ptr DiffHunk
result'
            DiffHunk -> IO DiffHunk
forall (m :: * -> *) a. Monad m => a -> m a
return DiffHunk
result''
        Patch -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Patch
patch
        Maybe DiffHunk -> IO (Maybe DiffHunk)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe DiffHunk
maybeResult
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data PatchGetHunkMethodInfo
instance (signature ~ (Word64 -> m (Maybe Ggit.DiffHunk.DiffHunk)), MonadIO m) => O.MethodInfo PatchGetHunkMethodInfo Patch signature where
    overloadedMethod = patchGetHunk

#endif

-- method Patch::get_line_stats
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "patch"
--           , argType = TInterface Name { namespace = "Ggit" , name = "Patch" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitPatch." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "total_context"
--           , argType = TBasicType TUInt64
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "return value for the number of context lines."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "total_additions"
--           , argType = TBasicType TUInt64
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "return value for the number of added lines."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "total_deletions"
--           , argType = TBasicType TUInt64
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "return value for the number of deleted lines."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ggit_patch_get_line_stats" ggit_patch_get_line_stats :: 
    Ptr Patch ->                            -- patch : TInterface (Name {namespace = "Ggit", name = "Patch"})
    Ptr Word64 ->                           -- total_context : TBasicType TUInt64
    Ptr Word64 ->                           -- total_additions : TBasicType TUInt64
    Ptr Word64 ->                           -- total_deletions : TBasicType TUInt64
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Get the line statistics of the patch.
patchGetLineStats ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Patch
    -- ^ /@patch@/: a t'GI.Ggit.Structs.Patch.Patch'.
    -> m ((Word64, Word64, Word64))
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
patchGetLineStats :: Patch -> m (Word64, Word64, Word64)
patchGetLineStats patch :: Patch
patch = IO (Word64, Word64, Word64) -> m (Word64, Word64, Word64)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Word64, Word64, Word64) -> m (Word64, Word64, Word64))
-> IO (Word64, Word64, Word64) -> m (Word64, Word64, Word64)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Patch
patch' <- Patch -> IO (Ptr Patch)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Patch
patch
    Ptr Word64
totalContext <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr Word64
totalAdditions <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    Ptr Word64
totalDeletions <- IO (Ptr Word64)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word64)
    IO (Word64, Word64, Word64) -> IO () -> IO (Word64, Word64, Word64)
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Patch
-> Ptr Word64
-> Ptr Word64
-> Ptr Word64
-> Ptr (Ptr GError)
-> IO CInt
ggit_patch_get_line_stats Ptr Patch
patch' Ptr Word64
totalContext Ptr Word64
totalAdditions Ptr Word64
totalDeletions
        Word64
totalContext' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
totalContext
        Word64
totalAdditions' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
totalAdditions
        Word64
totalDeletions' <- Ptr Word64 -> IO Word64
forall a. Storable a => Ptr a -> IO a
peek Ptr Word64
totalDeletions
        Patch -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Patch
patch
        Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
totalContext
        Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
totalAdditions
        Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
totalDeletions
        (Word64, Word64, Word64) -> IO (Word64, Word64, Word64)
forall (m :: * -> *) a. Monad m => a -> m a
return (Word64
totalContext', Word64
totalAdditions', Word64
totalDeletions')
     ) (do
        Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
totalContext
        Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
totalAdditions
        Ptr Word64 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word64
totalDeletions
     )

#if defined(ENABLE_OVERLOADING)
data PatchGetLineStatsMethodInfo
instance (signature ~ (m ((Word64, Word64, Word64))), MonadIO m) => O.MethodInfo PatchGetLineStatsMethodInfo Patch signature where
    overloadedMethod = patchGetLineStats

#endif

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

foreign import ccall "ggit_patch_get_num_hunks" ggit_patch_get_num_hunks :: 
    Ptr Patch ->                            -- patch : TInterface (Name {namespace = "Ggit", name = "Patch"})
    IO Word64

-- | Get the number of hunks in the patch.
patchGetNumHunks ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Patch
    -- ^ /@patch@/: a t'GI.Ggit.Structs.Patch.Patch'.
    -> m Word64
    -- ^ __Returns:__ the number of hunks.
patchGetNumHunks :: Patch -> m Word64
patchGetNumHunks patch :: Patch
patch = IO Word64 -> m Word64
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word64 -> m Word64) -> IO Word64 -> m Word64
forall a b. (a -> b) -> a -> b
$ do
    Ptr Patch
patch' <- Patch -> IO (Ptr Patch)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Patch
patch
    Word64
result <- Ptr Patch -> IO Word64
ggit_patch_get_num_hunks Ptr Patch
patch'
    Patch -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Patch
patch
    Word64 -> IO Word64
forall (m :: * -> *) a. Monad m => a -> m a
return Word64
result

#if defined(ENABLE_OVERLOADING)
data PatchGetNumHunksMethodInfo
instance (signature ~ (m Word64), MonadIO m) => O.MethodInfo PatchGetNumHunksMethodInfo Patch signature where
    overloadedMethod = patchGetNumHunks

#endif

-- method Patch::get_num_lines_in_hunk
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "patch"
--           , argType = TInterface Name { namespace = "Ggit" , name = "Patch" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitPatch." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "hunk"
--           , argType = TBasicType TUInt64
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the hunk index." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TInt)
-- throws : False
-- Skip return : False

foreign import ccall "ggit_patch_get_num_lines_in_hunk" ggit_patch_get_num_lines_in_hunk :: 
    Ptr Patch ->                            -- patch : TInterface (Name {namespace = "Ggit", name = "Patch"})
    Word64 ->                               -- hunk : TBasicType TUInt64
    IO Int32

-- | Get the number of lines in /@hunk@/.
patchGetNumLinesInHunk ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Patch
    -- ^ /@patch@/: a t'GI.Ggit.Structs.Patch.Patch'.
    -> Word64
    -- ^ /@hunk@/: the hunk index.
    -> m Int32
    -- ^ __Returns:__ the number of lines.
patchGetNumLinesInHunk :: Patch -> Word64 -> m Int32
patchGetNumLinesInHunk patch :: Patch
patch hunk :: Word64
hunk = IO Int32 -> m Int32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Int32 -> m Int32) -> IO Int32 -> m Int32
forall a b. (a -> b) -> a -> b
$ do
    Ptr Patch
patch' <- Patch -> IO (Ptr Patch)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Patch
patch
    Int32
result <- Ptr Patch -> Word64 -> IO Int32
ggit_patch_get_num_lines_in_hunk Ptr Patch
patch' Word64
hunk
    Patch -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Patch
patch
    Int32 -> IO Int32
forall (m :: * -> *) a. Monad m => a -> m a
return Int32
result

#if defined(ENABLE_OVERLOADING)
data PatchGetNumLinesInHunkMethodInfo
instance (signature ~ (Word64 -> m Int32), MonadIO m) => O.MethodInfo PatchGetNumLinesInHunkMethodInfo Patch signature where
    overloadedMethod = patchGetNumLinesInHunk

#endif

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

foreign import ccall "ggit_patch_ref" ggit_patch_ref :: 
    Ptr Patch ->                            -- patch : TInterface (Name {namespace = "Ggit", name = "Patch"})
    IO (Ptr Patch)

-- | Atomically increments the reference count of /@patch@/ by one.
-- This function is MT-safe and may be called from any thread.
patchRef ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Patch
    -- ^ /@patch@/: a t'GI.Ggit.Structs.Patch.Patch'.
    -> m (Maybe Patch)
    -- ^ __Returns:__ a t'GI.Ggit.Structs.Patch.Patch' or 'P.Nothing'.
patchRef :: Patch -> m (Maybe Patch)
patchRef patch :: Patch
patch = IO (Maybe Patch) -> m (Maybe Patch)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Patch) -> m (Maybe Patch))
-> IO (Maybe Patch) -> m (Maybe Patch)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Patch
patch' <- Patch -> IO (Ptr Patch)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Patch
patch
    Ptr Patch
result <- Ptr Patch -> IO (Ptr Patch)
ggit_patch_ref Ptr Patch
patch'
    Maybe Patch
maybeResult <- Ptr Patch -> (Ptr Patch -> IO Patch) -> IO (Maybe Patch)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr Patch
result ((Ptr Patch -> IO Patch) -> IO (Maybe Patch))
-> (Ptr Patch -> IO Patch) -> IO (Maybe Patch)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr Patch
result' -> do
        Patch
result'' <- ((ManagedPtr Patch -> Patch) -> Ptr Patch -> IO Patch
forall a.
(HasCallStack, BoxedObject a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
newBoxed ManagedPtr Patch -> Patch
Patch) Ptr Patch
result'
        Patch -> IO Patch
forall (m :: * -> *) a. Monad m => a -> m a
return Patch
result''
    Patch -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Patch
patch
    Maybe Patch -> IO (Maybe Patch)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Patch
maybeResult

#if defined(ENABLE_OVERLOADING)
data PatchRefMethodInfo
instance (signature ~ (m (Maybe Patch)), MonadIO m) => O.MethodInfo PatchRefMethodInfo Patch signature where
    overloadedMethod = patchRef

#endif

-- method Patch::to_stream
-- method type : OrdinaryMethod
-- Args: [ Arg
--           { argCName = "patch"
--           , argType = TInterface Name { namespace = "Ggit" , name = "Patch" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GgitPatch." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "stream"
--           , argType =
--               TInterface Name { namespace = "Gio" , name = "OutputStream" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GOutputStream." , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "ggit_patch_to_stream" ggit_patch_to_stream :: 
    Ptr Patch ->                            -- patch : TInterface (Name {namespace = "Ggit", name = "Patch"})
    Ptr Gio.OutputStream.OutputStream ->    -- stream : TInterface (Name {namespace = "Gio", name = "OutputStream"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Write the contents of a patch to the provided stream.
patchToStream ::
    (B.CallStack.HasCallStack, MonadIO m, Gio.OutputStream.IsOutputStream a) =>
    Patch
    -- ^ /@patch@/: a t'GI.Ggit.Structs.Patch.Patch'.
    -> a
    -- ^ /@stream@/: a t'GI.Gio.Objects.OutputStream.OutputStream'.
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
patchToStream :: Patch -> a -> m ()
patchToStream patch :: Patch
patch stream :: a
stream = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Patch
patch' <- Patch -> IO (Ptr Patch)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Patch
patch
    Ptr OutputStream
stream' <- a -> IO (Ptr OutputStream)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
stream
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Patch -> Ptr OutputStream -> Ptr (Ptr GError) -> IO CInt
ggit_patch_to_stream Ptr Patch
patch' Ptr OutputStream
stream'
        Patch -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Patch
patch
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
stream
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data PatchToStreamMethodInfo
instance (signature ~ (a -> m ()), MonadIO m, Gio.OutputStream.IsOutputStream a) => O.MethodInfo PatchToStreamMethodInfo Patch signature where
    overloadedMethod = patchToStream

#endif

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

foreign import ccall "ggit_patch_to_string" ggit_patch_to_string :: 
    Ptr Patch ->                            -- patch : TInterface (Name {namespace = "Ggit", name = "Patch"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Gets the content of a patch as a single diff text.
patchToString ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Patch
    -- ^ /@patch@/: a t'GI.Ggit.Structs.Patch.Patch'.
    -> m (Maybe T.Text)
    -- ^ __Returns:__ the content of a patch as a single diff text or 'P.Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/
patchToString :: Patch -> m (Maybe Text)
patchToString patch :: Patch
patch = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr Patch
patch' <- Patch -> IO (Ptr Patch)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Patch
patch
    IO (Maybe Text) -> IO () -> IO (Maybe Text)
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr CChar
result <- (Ptr (Ptr GError) -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr CChar)) -> IO (Ptr CChar))
-> (Ptr (Ptr GError) -> IO (Ptr CChar)) -> IO (Ptr CChar)
forall a b. (a -> b) -> a -> b
$ Ptr Patch -> Ptr (Ptr GError) -> IO (Ptr CChar)
ggit_patch_to_string Ptr Patch
patch'
        Maybe Text
maybeResult <- Ptr CChar -> (Ptr CChar -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr CChar
result ((Ptr CChar -> IO Text) -> IO (Maybe Text))
-> (Ptr CChar -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \result' :: Ptr CChar
result' -> do
            Text
result'' <- HasCallStack => Ptr CChar -> IO Text
Ptr CChar -> IO Text
cstringToText Ptr CChar
result'
            Ptr CChar -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CChar
result'
            Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
        Patch -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Patch
patch
        Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )

#if defined(ENABLE_OVERLOADING)
data PatchToStringMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m) => O.MethodInfo PatchToStringMethodInfo Patch signature where
    overloadedMethod = patchToString

#endif

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

foreign import ccall "ggit_patch_unref" ggit_patch_unref :: 
    Ptr Patch ->                            -- patch : TInterface (Name {namespace = "Ggit", name = "Patch"})
    IO ()

-- | Atomically decrements the reference count of /@patch@/ by one.
-- If the reference count drops to 0, /@patch@/ is freed.
patchUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Patch
    -- ^ /@patch@/: a t'GI.Ggit.Structs.Patch.Patch'.
    -> m ()
patchUnref :: Patch -> m ()
patchUnref patch :: Patch
patch = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Patch
patch' <- Patch -> IO (Ptr Patch)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Patch
patch
    Ptr Patch -> IO ()
ggit_patch_unref Ptr Patch
patch'
    Patch -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Patch
patch
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()

#if defined(ENABLE_OVERLOADING)
data PatchUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo PatchUnrefMethodInfo Patch signature where
    overloadedMethod = patchUnref

#endif

#if defined(ENABLE_OVERLOADING)
type family ResolvePatchMethod (t :: Symbol) (o :: *) :: * where
    ResolvePatchMethod "ref" o = PatchRefMethodInfo
    ResolvePatchMethod "toStream" o = PatchToStreamMethodInfo
    ResolvePatchMethod "toString" o = PatchToStringMethodInfo
    ResolvePatchMethod "unref" o = PatchUnrefMethodInfo
    ResolvePatchMethod "getDelta" o = PatchGetDeltaMethodInfo
    ResolvePatchMethod "getHunk" o = PatchGetHunkMethodInfo
    ResolvePatchMethod "getLineStats" o = PatchGetLineStatsMethodInfo
    ResolvePatchMethod "getNumHunks" o = PatchGetNumHunksMethodInfo
    ResolvePatchMethod "getNumLinesInHunk" o = PatchGetNumLinesInHunkMethodInfo
    ResolvePatchMethod l o = O.MethodResolutionFailed l o

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

#endif