{- | Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte License : LGPL-2.1 Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc) Represents a blame. -} #define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \ && !defined(__HADDOCK_VERSION__)) module GI.Ggit.Objects.Blame ( -- * Exported types Blame(..) , IsBlame , toBlame , noBlame , -- * Methods -- ** fromBuffer #method:fromBuffer# #if ENABLE_OVERLOADING BlameFromBufferMethodInfo , #endif blameFromBuffer , -- ** getFlags #method:getFlags# blameGetFlags , -- ** getHunkByIndex #method:getHunkByIndex# #if ENABLE_OVERLOADING BlameGetHunkByIndexMethodInfo , #endif blameGetHunkByIndex , -- ** getHunkByLine #method:getHunkByLine# #if ENABLE_OVERLOADING BlameGetHunkByLineMethodInfo , #endif blameGetHunkByLine , -- ** getHunkCount #method:getHunkCount# #if ENABLE_OVERLOADING BlameGetHunkCountMethodInfo , #endif blameGetHunkCount , -- ** setFlags #method:setFlags# blameSetFlags , ) 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.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 qualified GI.GObject.Objects.Object as GObject.Object import {-# SOURCE #-} qualified GI.Ggit.Flags as Ggit.Flags import {-# SOURCE #-} qualified GI.Ggit.Objects.Native as Ggit.Native import {-# SOURCE #-} qualified GI.Ggit.Objects.ObjectFactoryBase as Ggit.ObjectFactoryBase import {-# SOURCE #-} qualified GI.Ggit.Structs.BlameHunk as Ggit.BlameHunk import {-# SOURCE #-} qualified GI.Ggit.Structs.BlameOptions as Ggit.BlameOptions -- | Memory-managed wrapper type. newtype Blame = Blame (ManagedPtr Blame) foreign import ccall "ggit_blame_get_type" c_ggit_blame_get_type :: IO GType instance GObject Blame where gobjectType = c_ggit_blame_get_type -- | Type class for types which can be safely cast to `Blame`, for instance with `toBlame`. class (GObject o, O.IsDescendantOf Blame o) => IsBlame o instance (GObject o, O.IsDescendantOf Blame o) => IsBlame o instance O.HasParentTypes Blame type instance O.ParentTypes Blame = '[Ggit.Native.Native, Ggit.ObjectFactoryBase.ObjectFactoryBase, GObject.Object.Object] -- | Cast to `Blame`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`. toBlame :: (MonadIO m, IsBlame o) => o -> m Blame toBlame = liftIO . unsafeCastTo Blame -- | A convenience alias for `Nothing` :: `Maybe` `Blame`. noBlame :: Maybe Blame noBlame = Nothing #if ENABLE_OVERLOADING type family ResolveBlameMethod (t :: Symbol) (o :: *) :: * where ResolveBlameMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo ResolveBlameMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo ResolveBlameMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo ResolveBlameMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo ResolveBlameMethod "fromBuffer" o = BlameFromBufferMethodInfo ResolveBlameMethod "getv" o = GObject.Object.ObjectGetvMethodInfo ResolveBlameMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo ResolveBlameMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo ResolveBlameMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo ResolveBlameMethod "ref" o = GObject.Object.ObjectRefMethodInfo ResolveBlameMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo ResolveBlameMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo ResolveBlameMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo ResolveBlameMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo ResolveBlameMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo ResolveBlameMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo ResolveBlameMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo ResolveBlameMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo ResolveBlameMethod "getHunkByIndex" o = BlameGetHunkByIndexMethodInfo ResolveBlameMethod "getHunkByLine" o = BlameGetHunkByLineMethodInfo ResolveBlameMethod "getHunkCount" o = BlameGetHunkCountMethodInfo ResolveBlameMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo ResolveBlameMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo ResolveBlameMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo ResolveBlameMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo ResolveBlameMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveBlameMethod t Blame, O.MethodInfo info Blame p) => OL.IsLabel t (Blame -> 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 #if ENABLE_OVERLOADING instance O.HasAttributeList Blame type instance O.AttributeList Blame = BlameAttributeList type BlameAttributeList = ('[ '("native", Ggit.Native.NativeNativePropertyInfo)] :: [(Symbol, *)]) #endif #if ENABLE_OVERLOADING #endif #if ENABLE_OVERLOADING type instance O.SignalList Blame = BlameSignalList type BlameSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, *)]) #endif -- method Blame::from_buffer -- method type : OrdinaryMethod -- Args : [Arg {argCName = "blame", argType = TInterface (Name {namespace = "Ggit", name = "Blame"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitBlame.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buffer", argType = TCArray False (-1) 2 (TBasicType TUInt8), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the contents of the file.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "buffer_length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the buffer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [Arg {argCName = "buffer_length", argType = TBasicType TUInt64, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the length of the buffer.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- returnType : Just (TInterface (Name {namespace = "Ggit", name = "Blame"})) -- throws : True -- Skip return : False foreign import ccall "ggit_blame_from_buffer" ggit_blame_from_buffer :: Ptr Blame -> -- blame : TInterface (Name {namespace = "Ggit", name = "Blame"}) Ptr Word8 -> -- buffer : TCArray False (-1) 2 (TBasicType TUInt8) Word64 -> -- buffer_length : TBasicType TUInt64 Ptr (Ptr GError) -> -- error IO (Ptr Blame) {- | Get blame data for a file that has been modified in memory. /@blame@/ is a pre-calculated blame for the in-odb history of the file. This means that once a file blame is completed (which can be expensitve), updating the buffer blame is very fast. Lines that differ between the buffer and the committed version are marked as having a zero id for their @/ggit_blame_hunk_get_final_commit_id/@. -} blameFromBuffer :: (B.CallStack.HasCallStack, MonadIO m, IsBlame a) => a {- ^ /@blame@/: a 'GI.Ggit.Objects.Blame.Blame'. -} -> ByteString {- ^ /@buffer@/: the contents of the file. -} -> m (Maybe Blame) {- ^ __Returns:__ a 'GI.Ggit.Objects.Blame.Blame' or 'Nothing'. /(Can throw 'Data.GI.Base.GError.GError')/ -} blameFromBuffer blame buffer = liftIO $ do let bufferLength = fromIntegral $ B.length buffer blame' <- unsafeManagedPtrCastPtr blame buffer' <- packByteString buffer onException (do result <- propagateGError $ ggit_blame_from_buffer blame' buffer' bufferLength maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapObject Blame) result' return result'' touchManagedPtr blame freeMem buffer' return maybeResult ) (do freeMem buffer' ) #if ENABLE_OVERLOADING data BlameFromBufferMethodInfo instance (signature ~ (ByteString -> m (Maybe Blame)), MonadIO m, IsBlame a) => O.MethodInfo BlameFromBufferMethodInfo a signature where overloadedMethod _ = blameFromBuffer #endif -- method Blame::get_hunk_by_index -- method type : OrdinaryMethod -- Args : [Arg {argCName = "blame", argType = TInterface (Name {namespace = "Ggit", name = "Blame"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "idx", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Ggit", name = "BlameHunk"})) -- throws : False -- Skip return : False foreign import ccall "ggit_blame_get_hunk_by_index" ggit_blame_get_hunk_by_index :: Ptr Blame -> -- blame : TInterface (Name {namespace = "Ggit", name = "Blame"}) Word32 -> -- idx : TBasicType TUInt32 IO (Ptr Ggit.BlameHunk.BlameHunk) {- | /No description available in the introspection data./ -} blameGetHunkByIndex :: (B.CallStack.HasCallStack, MonadIO m, IsBlame a) => a -> Word32 -> m Ggit.BlameHunk.BlameHunk blameGetHunkByIndex blame idx = liftIO $ do blame' <- unsafeManagedPtrCastPtr blame result <- ggit_blame_get_hunk_by_index blame' idx checkUnexpectedReturnNULL "blameGetHunkByIndex" result result' <- (wrapBoxed Ggit.BlameHunk.BlameHunk) result touchManagedPtr blame return result' #if ENABLE_OVERLOADING data BlameGetHunkByIndexMethodInfo instance (signature ~ (Word32 -> m Ggit.BlameHunk.BlameHunk), MonadIO m, IsBlame a) => O.MethodInfo BlameGetHunkByIndexMethodInfo a signature where overloadedMethod _ = blameGetHunkByIndex #endif -- method Blame::get_hunk_by_line -- method type : OrdinaryMethod -- Args : [Arg {argCName = "blame", argType = TInterface (Name {namespace = "Ggit", name = "Blame"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "line", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Ggit", name = "BlameHunk"})) -- throws : False -- Skip return : False foreign import ccall "ggit_blame_get_hunk_by_line" ggit_blame_get_hunk_by_line :: Ptr Blame -> -- blame : TInterface (Name {namespace = "Ggit", name = "Blame"}) Word32 -> -- line : TBasicType TUInt32 IO (Ptr Ggit.BlameHunk.BlameHunk) {- | /No description available in the introspection data./ -} blameGetHunkByLine :: (B.CallStack.HasCallStack, MonadIO m, IsBlame a) => a -> Word32 -> m Ggit.BlameHunk.BlameHunk blameGetHunkByLine blame line = liftIO $ do blame' <- unsafeManagedPtrCastPtr blame result <- ggit_blame_get_hunk_by_line blame' line checkUnexpectedReturnNULL "blameGetHunkByLine" result result' <- (wrapBoxed Ggit.BlameHunk.BlameHunk) result touchManagedPtr blame return result' #if ENABLE_OVERLOADING data BlameGetHunkByLineMethodInfo instance (signature ~ (Word32 -> m Ggit.BlameHunk.BlameHunk), MonadIO m, IsBlame a) => O.MethodInfo BlameGetHunkByLineMethodInfo a signature where overloadedMethod _ = blameGetHunkByLine #endif -- method Blame::get_hunk_count -- method type : OrdinaryMethod -- Args : [Arg {argCName = "blame", argType = TInterface (Name {namespace = "Ggit", name = "Blame"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Nothing, sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TBasicType TUInt32) -- throws : False -- Skip return : False foreign import ccall "ggit_blame_get_hunk_count" ggit_blame_get_hunk_count :: Ptr Blame -> -- blame : TInterface (Name {namespace = "Ggit", name = "Blame"}) IO Word32 {- | /No description available in the introspection data./ -} blameGetHunkCount :: (B.CallStack.HasCallStack, MonadIO m, IsBlame a) => a -> m Word32 blameGetHunkCount blame = liftIO $ do blame' <- unsafeManagedPtrCastPtr blame result <- ggit_blame_get_hunk_count blame' touchManagedPtr blame return result #if ENABLE_OVERLOADING data BlameGetHunkCountMethodInfo instance (signature ~ (m Word32), MonadIO m, IsBlame a) => O.MethodInfo BlameGetHunkCountMethodInfo a signature where overloadedMethod _ = blameGetHunkCount #endif -- method Blame::get_flags -- method type : MemberFunction -- Args : [Arg {argCName = "blame_options", argType = TInterface (Name {namespace = "Ggit", name = "BlameOptions"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitBlameOptions.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Just (TInterface (Name {namespace = "Ggit", name = "BlameFlags"})) -- throws : False -- Skip return : False foreign import ccall "ggit_blame_get_flags" ggit_blame_get_flags :: Ptr Ggit.BlameOptions.BlameOptions -> -- blame_options : TInterface (Name {namespace = "Ggit", name = "BlameOptions"}) IO CUInt {- | Get the blame options flags. -} blameGetFlags :: (B.CallStack.HasCallStack, MonadIO m) => Ggit.BlameOptions.BlameOptions {- ^ /@blameOptions@/: a 'GI.Ggit.Structs.BlameOptions.BlameOptions'. -} -> m [Ggit.Flags.BlameFlags] {- ^ __Returns:__ a 'GI.Ggit.Flags.BlameFlags'. -} blameGetFlags blameOptions = liftIO $ do blameOptions' <- unsafeManagedPtrGetPtr blameOptions result <- ggit_blame_get_flags blameOptions' let result' = wordToGFlags result touchManagedPtr blameOptions return result' #if ENABLE_OVERLOADING #endif -- method Blame::set_flags -- method type : MemberFunction -- Args : [Arg {argCName = "blame_options", argType = TInterface (Name {namespace = "Ggit", name = "BlameOptions"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitBlameOptions.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "flags", argType = TInterface (Name {namespace = "Ggit", name = "BlameFlags"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitBlameFlags.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}] -- Lengths : [] -- returnType : Nothing -- throws : False -- Skip return : False foreign import ccall "ggit_blame_set_flags" ggit_blame_set_flags :: Ptr Ggit.BlameOptions.BlameOptions -> -- blame_options : TInterface (Name {namespace = "Ggit", name = "BlameOptions"}) CUInt -> -- flags : TInterface (Name {namespace = "Ggit", name = "BlameFlags"}) IO () {- | Set the blame options flags. -} blameSetFlags :: (B.CallStack.HasCallStack, MonadIO m) => Ggit.BlameOptions.BlameOptions {- ^ /@blameOptions@/: a 'GI.Ggit.Structs.BlameOptions.BlameOptions'. -} -> [Ggit.Flags.BlameFlags] {- ^ /@flags@/: a 'GI.Ggit.Flags.BlameFlags'. -} -> m () blameSetFlags blameOptions flags = liftIO $ do blameOptions' <- unsafeManagedPtrGetPtr blameOptions let flags' = gflagsToWord flags ggit_blame_set_flags blameOptions' flags' touchManagedPtr blameOptions return () #if ENABLE_OVERLOADING #endif