{- | 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 patch object. -} module GI.Ggit.Structs.Patch ( -- * Exported types Patch(..) , noPatch , -- * Methods -- ** getDelta #method:getDelta# #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) PatchGetDeltaMethodInfo , #endif patchGetDelta , -- ** getHunk #method:getHunk# #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) PatchGetHunkMethodInfo , #endif patchGetHunk , -- ** getLineStats #method:getLineStats# #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) PatchGetLineStatsMethodInfo , #endif patchGetLineStats , -- ** getNumHunks #method:getNumHunks# #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) PatchGetNumHunksMethodInfo , #endif patchGetNumHunks , -- ** getNumLinesInHunk #method:getNumLinesInHunk# #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) PatchGetNumLinesInHunkMethodInfo , #endif patchGetNumLinesInHunk , -- ** newFromBlobs #method:newFromBlobs# patchNewFromBlobs , -- ** newFromDiff #method:newFromDiff# patchNewFromDiff , -- ** ref #method:ref# #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) PatchRefMethodInfo , #endif patchRef , -- ** toStream #method:toStream# #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) PatchToStreamMethodInfo , #endif patchToStream , -- ** toString #method:toString# #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) PatchToStringMethodInfo , #endif patchToString , -- ** unref #method:unref# #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) 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.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.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 newtype Patch = Patch (ManagedPtr Patch) foreign import ccall "ggit_patch_get_type" c_ggit_patch_get_type :: IO GType instance BoxedObject Patch where boxedType _ = c_ggit_patch_get_type noPatch :: Maybe Patch noPatch = Nothing #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) 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 'GI.Ggit.Objects.Blob.Blob' to diff from. -} -> Maybe (T.Text) {- ^ /@oldAsPath@/: treat /@oldBlob@/ as if it had this filename, or 'Nothing', -} -> Maybe (b) {- ^ /@newBlob@/: a 'GI.Ggit.Objects.Blob.Blob' to diff to. -} -> Maybe (T.Text) {- ^ /@newAsPath@/: treat /@newBlob@/ as if it had this filename, or 'Nothing', -} -> Maybe (c) {- ^ /@diffOptions@/: a 'GI.Ggit.Objects.DiffOptions.DiffOptions', or 'Nothing'. -} -> m Patch {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} patchNewFromBlobs oldBlob oldAsPath newBlob newAsPath diffOptions = liftIO $ do maybeOldBlob <- case oldBlob of Nothing -> return nullPtr Just jOldBlob -> do jOldBlob' <- unsafeManagedPtrCastPtr jOldBlob return jOldBlob' maybeOldAsPath <- case oldAsPath of Nothing -> return nullPtr Just jOldAsPath -> do jOldAsPath' <- textToCString jOldAsPath return jOldAsPath' maybeNewBlob <- case newBlob of Nothing -> return nullPtr Just jNewBlob -> do jNewBlob' <- unsafeManagedPtrCastPtr jNewBlob return jNewBlob' maybeNewAsPath <- case newAsPath of Nothing -> return nullPtr Just jNewAsPath -> do jNewAsPath' <- textToCString jNewAsPath return jNewAsPath' maybeDiffOptions <- case diffOptions of Nothing -> return nullPtr Just jDiffOptions -> do jDiffOptions' <- unsafeManagedPtrCastPtr jDiffOptions return jDiffOptions' onException (do result <- propagateGError $ ggit_patch_new_from_blobs maybeOldBlob maybeOldAsPath maybeNewBlob maybeNewAsPath maybeDiffOptions checkUnexpectedReturnNULL "patchNewFromBlobs" result result' <- (wrapBoxed Patch) result whenJust oldBlob touchManagedPtr whenJust newBlob touchManagedPtr whenJust diffOptions touchManagedPtr freeMem maybeOldAsPath freeMem maybeNewAsPath return result' ) (do freeMem maybeOldAsPath freeMem maybeNewAsPath ) #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) #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 '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 'GI.Ggit.Objects.Diff.Diff'. -} -> Word64 {- ^ /@idx@/: index into diff list. -} -> m Patch {- ^ __Returns:__ a newly created 'GI.Ggit.Structs.Patch.Patch'. /(Can throw 'Data.GI.Base.GError.GError')/ -} patchNewFromDiff diff idx = liftIO $ do diff' <- unsafeManagedPtrCastPtr diff onException (do result <- propagateGError $ ggit_patch_new_from_diff diff' idx checkUnexpectedReturnNULL "patchNewFromDiff" result result' <- (wrapBoxed Patch) result touchManagedPtr diff return result' ) (do return () ) #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) #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 'GI.Ggit.Structs.Patch.Patch'. -} -> m Ggit.DiffDelta.DiffDelta {- ^ __Returns:__ the 'GI.Ggit.Structs.DiffDelta.DiffDelta' of the patch. -} patchGetDelta patch = liftIO $ do patch' <- unsafeManagedPtrGetPtr patch result <- ggit_patch_get_delta patch' checkUnexpectedReturnNULL "patchGetDelta" result result' <- (wrapBoxed Ggit.DiffDelta.DiffDelta) result touchManagedPtr patch return result' #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) data PatchGetDeltaMethodInfo instance (signature ~ (m 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 'GI.Ggit.Structs.Patch.Patch' -} -> Word64 {- ^ /@idx@/: the hunk index. -} -> m Ggit.DiffHunk.DiffHunk {- ^ __Returns:__ a new 'GI.Ggit.Structs.DiffHunk.DiffHunk' or 'Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/ -} patchGetHunk patch idx = liftIO $ do patch' <- unsafeManagedPtrGetPtr patch onException (do result <- propagateGError $ ggit_patch_get_hunk patch' idx checkUnexpectedReturnNULL "patchGetHunk" result result' <- (wrapBoxed Ggit.DiffHunk.DiffHunk) result touchManagedPtr patch return result' ) (do return () ) #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) data PatchGetHunkMethodInfo instance (signature ~ (Word64 -> m 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 'GI.Ggit.Structs.Patch.Patch'. -} -> m ((Word64, Word64, Word64)) {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} patchGetLineStats patch = liftIO $ do patch' <- unsafeManagedPtrGetPtr patch totalContext <- allocMem :: IO (Ptr Word64) totalAdditions <- allocMem :: IO (Ptr Word64) totalDeletions <- allocMem :: IO (Ptr Word64) onException (do _ <- propagateGError $ ggit_patch_get_line_stats patch' totalContext totalAdditions totalDeletions totalContext' <- peek totalContext totalAdditions' <- peek totalAdditions totalDeletions' <- peek totalDeletions touchManagedPtr patch freeMem totalContext freeMem totalAdditions freeMem totalDeletions return (totalContext', totalAdditions', totalDeletions') ) (do freeMem totalContext freeMem totalAdditions freeMem totalDeletions ) #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) 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 'GI.Ggit.Structs.Patch.Patch'. -} -> m Word64 {- ^ __Returns:__ the number of hunks. -} patchGetNumHunks patch = liftIO $ do patch' <- unsafeManagedPtrGetPtr patch result <- ggit_patch_get_num_hunks patch' touchManagedPtr patch return result #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) 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 'GI.Ggit.Structs.Patch.Patch'. -} -> Word64 {- ^ /@hunk@/: the hunk index. -} -> m Int32 {- ^ __Returns:__ the number of lines. -} patchGetNumLinesInHunk patch hunk = liftIO $ do patch' <- unsafeManagedPtrGetPtr patch result <- ggit_patch_get_num_lines_in_hunk patch' hunk touchManagedPtr patch return result #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) 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 'GI.Ggit.Structs.Patch.Patch'. -} -> m Patch {- ^ __Returns:__ a 'GI.Ggit.Structs.Patch.Patch'. -} patchRef patch = liftIO $ do patch' <- unsafeManagedPtrGetPtr patch result <- ggit_patch_ref patch' checkUnexpectedReturnNULL "patchRef" result result' <- (newBoxed Patch) result touchManagedPtr patch return result' #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) data PatchRefMethodInfo instance (signature ~ (m 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 'GI.Ggit.Structs.Patch.Patch'. -} -> a {- ^ /@stream@/: a 'GI.Gio.Objects.OutputStream.OutputStream'. -} -> m () {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -} patchToStream patch stream = liftIO $ do patch' <- unsafeManagedPtrGetPtr patch stream' <- unsafeManagedPtrCastPtr stream onException (do _ <- propagateGError $ ggit_patch_to_stream patch' stream' touchManagedPtr patch touchManagedPtr stream return () ) (do return () ) #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) 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 'GI.Ggit.Structs.Patch.Patch'. -} -> m T.Text {- ^ __Returns:__ the content of a patch as a single diff text. /(Can throw 'Data.GI.Base.GError.GError')/ -} patchToString patch = liftIO $ do patch' <- unsafeManagedPtrGetPtr patch onException (do result <- propagateGError $ ggit_patch_to_string patch' checkUnexpectedReturnNULL "patchToString" result result' <- cstringToText result freeMem result touchManagedPtr patch return result' ) (do return () ) #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) data PatchToStringMethodInfo instance (signature ~ (m 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 'GI.Ggit.Structs.Patch.Patch'. -} -> m () patchUnref patch = liftIO $ do patch' <- unsafeManagedPtrGetPtr patch ggit_patch_unref patch' touchManagedPtr patch return () #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) data PatchUnrefMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo PatchUnrefMethodInfo Patch signature where overloadedMethod _ = patchUnref #endif #if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__) 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) => O.IsLabelProxy t (Patch -> p) where fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info) #if MIN_VERSION_base(4,9,0) instance (info ~ ResolvePatchMethod t Patch, O.MethodInfo info Patch p) => O.IsLabel t (Patch -> 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