{- |
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 the hunk of a diff.
-}

module GI.Ggit.Structs.DiffHunk
    ( 

-- * Exported types
    DiffHunk(..)                            ,
    noDiffHunk                              ,


 -- * Methods
-- ** getHeader #method:getHeader#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffHunkGetHeaderMethodInfo             ,
#endif
    diffHunkGetHeader                       ,


-- ** getNewLines #method:getNewLines#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffHunkGetNewLinesMethodInfo           ,
#endif
    diffHunkGetNewLines                     ,


-- ** getNewStart #method:getNewStart#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffHunkGetNewStartMethodInfo           ,
#endif
    diffHunkGetNewStart                     ,


-- ** getOldLines #method:getOldLines#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffHunkGetOldLinesMethodInfo           ,
#endif
    diffHunkGetOldLines                     ,


-- ** getOldStart #method:getOldStart#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffHunkGetOldStartMethodInfo           ,
#endif
    diffHunkGetOldStart                     ,


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


-- ** unref #method:unref#
#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
    DiffHunkUnrefMethodInfo                 ,
#endif
    diffHunkUnref                           ,




    ) 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


newtype DiffHunk = DiffHunk (ManagedPtr DiffHunk)
foreign import ccall "ggit_diff_hunk_get_type" c_ggit_diff_hunk_get_type :: 
    IO GType

instance BoxedObject DiffHunk where
    boxedType _ = c_ggit_diff_hunk_get_type

noDiffHunk :: Maybe DiffHunk
noDiffHunk = Nothing


#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
instance O.HasAttributeList DiffHunk
type instance O.AttributeList DiffHunk = DiffHunkAttributeList
type DiffHunkAttributeList = ('[ ] :: [(Symbol, *)])
#endif

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

foreign import ccall "ggit_diff_hunk_get_header" ggit_diff_hunk_get_header :: 
    Ptr DiffHunk ->                         -- hunk : TInterface (Name {namespace = "Ggit", name = "DiffHunk"})
    IO CString

{- |
/No description available in the introspection data./
-}
diffHunkGetHeader ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffHunk
    -> m T.Text
diffHunkGetHeader hunk = liftIO $ do
    hunk' <- unsafeManagedPtrGetPtr hunk
    result <- ggit_diff_hunk_get_header hunk'
    checkUnexpectedReturnNULL "diffHunkGetHeader" result
    result' <- cstringToText result
    touchManagedPtr hunk
    return result'

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffHunkGetHeaderMethodInfo
instance (signature ~ (m T.Text), MonadIO m) => O.MethodInfo DiffHunkGetHeaderMethodInfo DiffHunk signature where
    overloadedMethod _ = diffHunkGetHeader

#endif

-- method DiffHunk::get_new_lines
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "hunk", argType = TInterface (Name {namespace = "Ggit", name = "DiffHunk"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffHunk.", 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_diff_hunk_get_new_lines" ggit_diff_hunk_get_new_lines :: 
    Ptr DiffHunk ->                         -- hunk : TInterface (Name {namespace = "Ggit", name = "DiffHunk"})
    IO Int32

{- |
Gets the number of lines in the new file.
-}
diffHunkGetNewLines ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffHunk
    {- ^ /@hunk@/: a 'GI.Ggit.Structs.DiffHunk.DiffHunk'. -}
    -> m Int32
    {- ^ __Returns:__ the number of lines in the new file. -}
diffHunkGetNewLines hunk = liftIO $ do
    hunk' <- unsafeManagedPtrGetPtr hunk
    result <- ggit_diff_hunk_get_new_lines hunk'
    touchManagedPtr hunk
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffHunkGetNewLinesMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo DiffHunkGetNewLinesMethodInfo DiffHunk signature where
    overloadedMethod _ = diffHunkGetNewLines

#endif

-- method DiffHunk::get_new_start
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "hunk", argType = TInterface (Name {namespace = "Ggit", name = "DiffHunk"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffHunk.", 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_diff_hunk_get_new_start" ggit_diff_hunk_get_new_start :: 
    Ptr DiffHunk ->                         -- hunk : TInterface (Name {namespace = "Ggit", name = "DiffHunk"})
    IO Int32

{- |
Gets the starting line number in the new file.
-}
diffHunkGetNewStart ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffHunk
    {- ^ /@hunk@/: a 'GI.Ggit.Structs.DiffHunk.DiffHunk'. -}
    -> m Int32
    {- ^ __Returns:__ the starting line number in the new file. -}
diffHunkGetNewStart hunk = liftIO $ do
    hunk' <- unsafeManagedPtrGetPtr hunk
    result <- ggit_diff_hunk_get_new_start hunk'
    touchManagedPtr hunk
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffHunkGetNewStartMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo DiffHunkGetNewStartMethodInfo DiffHunk signature where
    overloadedMethod _ = diffHunkGetNewStart

#endif

-- method DiffHunk::get_old_lines
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "hunk", argType = TInterface (Name {namespace = "Ggit", name = "DiffHunk"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffHunk.", 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_diff_hunk_get_old_lines" ggit_diff_hunk_get_old_lines :: 
    Ptr DiffHunk ->                         -- hunk : TInterface (Name {namespace = "Ggit", name = "DiffHunk"})
    IO Int32

{- |
Gets the number of lines in the old file.
-}
diffHunkGetOldLines ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffHunk
    {- ^ /@hunk@/: a 'GI.Ggit.Structs.DiffHunk.DiffHunk'. -}
    -> m Int32
    {- ^ __Returns:__ the number of lines in the old file. -}
diffHunkGetOldLines hunk = liftIO $ do
    hunk' <- unsafeManagedPtrGetPtr hunk
    result <- ggit_diff_hunk_get_old_lines hunk'
    touchManagedPtr hunk
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffHunkGetOldLinesMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo DiffHunkGetOldLinesMethodInfo DiffHunk signature where
    overloadedMethod _ = diffHunkGetOldLines

#endif

-- method DiffHunk::get_old_start
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "hunk", argType = TInterface (Name {namespace = "Ggit", name = "DiffHunk"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitDiffHunk.", 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_diff_hunk_get_old_start" ggit_diff_hunk_get_old_start :: 
    Ptr DiffHunk ->                         -- hunk : TInterface (Name {namespace = "Ggit", name = "DiffHunk"})
    IO Int32

{- |
Gets the starting line number in the old file.
-}
diffHunkGetOldStart ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffHunk
    {- ^ /@hunk@/: a 'GI.Ggit.Structs.DiffHunk.DiffHunk'. -}
    -> m Int32
    {- ^ __Returns:__ the starting line number in the old file. -}
diffHunkGetOldStart hunk = liftIO $ do
    hunk' <- unsafeManagedPtrGetPtr hunk
    result <- ggit_diff_hunk_get_old_start hunk'
    touchManagedPtr hunk
    return result

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffHunkGetOldStartMethodInfo
instance (signature ~ (m Int32), MonadIO m) => O.MethodInfo DiffHunkGetOldStartMethodInfo DiffHunk signature where
    overloadedMethod _ = diffHunkGetOldStart

#endif

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

foreign import ccall "ggit_diff_hunk_ref" ggit_diff_hunk_ref :: 
    Ptr DiffHunk ->                         -- hunk : TInterface (Name {namespace = "Ggit", name = "DiffHunk"})
    IO (Ptr DiffHunk)

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

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffHunkRefMethodInfo
instance (signature ~ (m DiffHunk), MonadIO m) => O.MethodInfo DiffHunkRefMethodInfo DiffHunk signature where
    overloadedMethod _ = diffHunkRef

#endif

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

{- |
Atomically decrements the reference count of /@hunk@/ by one.
If the reference count drops to 0, /@hunk@/ is freed.
-}
diffHunkUnref ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    DiffHunk
    {- ^ /@hunk@/: a 'GI.Ggit.Structs.DiffHunk.DiffHunk'. -}
    -> m ()
diffHunkUnref hunk = liftIO $ do
    hunk' <- unsafeManagedPtrGetPtr hunk
    ggit_diff_hunk_unref hunk'
    touchManagedPtr hunk
    return ()

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
data DiffHunkUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo DiffHunkUnrefMethodInfo DiffHunk signature where
    overloadedMethod _ = diffHunkUnref

#endif

#if defined(ENABLE_OVERLOADING) && !defined(__HADDOCK_VERSION__)
type family ResolveDiffHunkMethod (t :: Symbol) (o :: *) :: * where
    ResolveDiffHunkMethod "ref" o = DiffHunkRefMethodInfo
    ResolveDiffHunkMethod "unref" o = DiffHunkUnrefMethodInfo
    ResolveDiffHunkMethod "getHeader" o = DiffHunkGetHeaderMethodInfo
    ResolveDiffHunkMethod "getNewLines" o = DiffHunkGetNewLinesMethodInfo
    ResolveDiffHunkMethod "getNewStart" o = DiffHunkGetNewStartMethodInfo
    ResolveDiffHunkMethod "getOldLines" o = DiffHunkGetOldLinesMethodInfo
    ResolveDiffHunkMethod "getOldStart" o = DiffHunkGetOldStartMethodInfo
    ResolveDiffHunkMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveDiffHunkMethod t DiffHunk, O.MethodInfo info DiffHunk p) => O.IsLabelProxy t (DiffHunk -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveDiffHunkMethod t DiffHunk, O.MethodInfo info DiffHunk p) => O.IsLabel t (DiffHunk -> 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