{-# 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 reflog. #if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__)) #define ENABLE_OVERLOADING #endif module GI.Ggit.Structs.Reflog ( -- * Exported types Reflog(..) , noReflog , -- * Methods -- ** Overloaded methods #method:Overloaded methods# #if defined(ENABLE_OVERLOADING) ResolveReflogMethod , #endif -- ** append #method:append# #if defined(ENABLE_OVERLOADING) ReflogAppendMethodInfo , #endif reflogAppend , -- ** getEntryCount #method:getEntryCount# #if defined(ENABLE_OVERLOADING) ReflogGetEntryCountMethodInfo , #endif reflogGetEntryCount , -- ** getEntryFromIndex #method:getEntryFromIndex# #if defined(ENABLE_OVERLOADING) ReflogGetEntryFromIndexMethodInfo , #endif reflogGetEntryFromIndex , -- ** ref #method:ref# #if defined(ENABLE_OVERLOADING) ReflogRefMethodInfo , #endif reflogRef , -- ** rename #method:rename# #if defined(ENABLE_OVERLOADING) ReflogRenameMethodInfo , #endif reflogRename , -- ** unref #method:unref# #if defined(ENABLE_OVERLOADING) ReflogUnrefMethodInfo , #endif reflogUnref , -- ** write #method:write# #if defined(ENABLE_OVERLOADING) ReflogWriteMethodInfo , #endif reflogWrite , ) 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.Signature as Ggit.Signature import {-# SOURCE #-} qualified GI.Ggit.Structs.OId as Ggit.OId import {-# SOURCE #-} qualified GI.Ggit.Structs.ReflogEntry as Ggit.ReflogEntry -- | Memory-managed wrapper type. newtype Reflog = Reflog (ManagedPtr Reflog) deriving (Eq) foreign import ccall "ggit_reflog_get_type" c_ggit_reflog_get_type :: IO GType instance BoxedObject Reflog where boxedType _ = c_ggit_reflog_get_type -- | Convert 'Reflog' to and from 'Data.GI.Base.GValue.GValue' with 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'. instance B.GValue.IsGValue Reflog where toGValue o = do gtype <- c_ggit_reflog_get_type B.ManagedPtr.withManagedPtr o (B.GValue.buildGValue gtype B.GValue.set_boxed) fromGValue gv = do ptr <- B.GValue.get_boxed gv :: IO (Ptr Reflog) B.ManagedPtr.newBoxed Reflog ptr -- | A convenience alias for `Nothing` :: `Maybe` `Reflog`. noReflog :: Maybe Reflog noReflog = Nothing #if defined(ENABLE_OVERLOADING) instance O.HasAttributeList Reflog type instance O.AttributeList Reflog = ReflogAttributeList type ReflogAttributeList = ('[ ] :: [(Symbol, *)]) #endif -- method Reflog::append -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "reflog" -- , argType = -- TInterface Name { namespace = "Ggit" , name = "Reflog" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitReflog." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "oid" -- , argType = TInterface Name { namespace = "Ggit" , name = "OId" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitOId." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "committer" -- , argType = -- TInterface Name { namespace = "Ggit" , name = "Signature" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitSignature." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "message" -- , argType = TBasicType TUTF8 -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "the message." , 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_reflog_append" ggit_reflog_append :: Ptr Reflog -> -- reflog : TInterface (Name {namespace = "Ggit", name = "Reflog"}) Ptr Ggit.OId.OId -> -- oid : TInterface (Name {namespace = "Ggit", name = "OId"}) Ptr Ggit.Signature.Signature -> -- committer : TInterface (Name {namespace = "Ggit", name = "Signature"}) CString -> -- message : TBasicType TUTF8 Ptr (Ptr GError) -> -- error IO CInt -- | Creates a reflog entry. reflogAppend :: (B.CallStack.HasCallStack, MonadIO m, Ggit.Signature.IsSignature a) => Reflog -- ^ /@reflog@/: a t'GI.Ggit.Structs.Reflog.Reflog'. -> Ggit.OId.OId -- ^ /@oid@/: a t'GI.Ggit.Structs.OId.OId'. -> a -- ^ /@committer@/: a t'GI.Ggit.Objects.Signature.Signature'. -> T.Text -- ^ /@message@/: the message. -> m () -- ^ /(Can throw 'Data.GI.Base.GError.GError')/ reflogAppend reflog oid committer message = liftIO $ do reflog' <- unsafeManagedPtrGetPtr reflog oid' <- unsafeManagedPtrGetPtr oid committer' <- unsafeManagedPtrCastPtr committer message' <- textToCString message onException (do _ <- propagateGError $ ggit_reflog_append reflog' oid' committer' message' touchManagedPtr reflog touchManagedPtr oid touchManagedPtr committer freeMem message' return () ) (do freeMem message' ) #if defined(ENABLE_OVERLOADING) data ReflogAppendMethodInfo instance (signature ~ (Ggit.OId.OId -> a -> T.Text -> m ()), MonadIO m, Ggit.Signature.IsSignature a) => O.MethodInfo ReflogAppendMethodInfo Reflog signature where overloadedMethod = reflogAppend #endif -- method Reflog::get_entry_count -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "reflog" -- , argType = -- TInterface Name { namespace = "Ggit" , name = "Reflog" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitReflog." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TBasicType TUInt) -- throws : False -- Skip return : False foreign import ccall "ggit_reflog_get_entry_count" ggit_reflog_get_entry_count :: Ptr Reflog -> -- reflog : TInterface (Name {namespace = "Ggit", name = "Reflog"}) IO Word32 -- | Gets the number of log entries in /@reflog@/. reflogGetEntryCount :: (B.CallStack.HasCallStack, MonadIO m) => Reflog -- ^ /@reflog@/: a t'GI.Ggit.Structs.Reflog.Reflog'. -> m Word32 -- ^ __Returns:__ the number of log entries. reflogGetEntryCount reflog = liftIO $ do reflog' <- unsafeManagedPtrGetPtr reflog result <- ggit_reflog_get_entry_count reflog' touchManagedPtr reflog return result #if defined(ENABLE_OVERLOADING) data ReflogGetEntryCountMethodInfo instance (signature ~ (m Word32), MonadIO m) => O.MethodInfo ReflogGetEntryCountMethodInfo Reflog signature where overloadedMethod = reflogGetEntryCount #endif -- method Reflog::get_entry_from_index -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "reflog" -- , argType = -- TInterface Name { namespace = "Ggit" , name = "Reflog" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitReflog." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "idx" -- , argType = TBasicType TUInt -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "the position to lookup." -- , sinceVersion = Nothing -- } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just -- (TInterface Name { namespace = "Ggit" , name = "ReflogEntry" }) -- throws : False -- Skip return : False foreign import ccall "ggit_reflog_get_entry_from_index" ggit_reflog_get_entry_from_index :: Ptr Reflog -> -- reflog : TInterface (Name {namespace = "Ggit", name = "Reflog"}) Word32 -> -- idx : TBasicType TUInt IO (Ptr Ggit.ReflogEntry.ReflogEntry) -- | Gets the t'GI.Ggit.Structs.ReflogEntry.ReflogEntry' at /@idx@/ in /@reflog@/, or 'P.Nothing' if not found. reflogGetEntryFromIndex :: (B.CallStack.HasCallStack, MonadIO m) => Reflog -- ^ /@reflog@/: a t'GI.Ggit.Structs.Reflog.Reflog'. -> Word32 -- ^ /@idx@/: the position to lookup. -> m (Maybe Ggit.ReflogEntry.ReflogEntry) -- ^ __Returns:__ the reflog entry at the index, or 'P.Nothing' if not found. reflogGetEntryFromIndex reflog idx = liftIO $ do reflog' <- unsafeManagedPtrGetPtr reflog result <- ggit_reflog_get_entry_from_index reflog' idx maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (wrapBoxed Ggit.ReflogEntry.ReflogEntry) result' return result'' touchManagedPtr reflog return maybeResult #if defined(ENABLE_OVERLOADING) data ReflogGetEntryFromIndexMethodInfo instance (signature ~ (Word32 -> m (Maybe Ggit.ReflogEntry.ReflogEntry)), MonadIO m) => O.MethodInfo ReflogGetEntryFromIndexMethodInfo Reflog signature where overloadedMethod = reflogGetEntryFromIndex #endif -- method Reflog::ref -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "reflog" -- , argType = -- TInterface Name { namespace = "Ggit" , name = "Reflog" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitReflog." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Just (TInterface Name { namespace = "Ggit" , name = "Reflog" }) -- throws : False -- Skip return : False foreign import ccall "ggit_reflog_ref" ggit_reflog_ref :: Ptr Reflog -> -- reflog : TInterface (Name {namespace = "Ggit", name = "Reflog"}) IO (Ptr Reflog) -- | Atomically increments the reference count of /@reflog@/ by one. -- This function is MT-safe and may be called from any thread. reflogRef :: (B.CallStack.HasCallStack, MonadIO m) => Reflog -- ^ /@reflog@/: a t'GI.Ggit.Structs.Reflog.Reflog'. -> m (Maybe Reflog) -- ^ __Returns:__ the passed in t'GI.Ggit.Structs.Reflog.Reflog' or 'P.Nothing'. reflogRef reflog = liftIO $ do reflog' <- unsafeManagedPtrGetPtr reflog result <- ggit_reflog_ref reflog' maybeResult <- convertIfNonNull result $ \result' -> do result'' <- (newBoxed Reflog) result' return result'' touchManagedPtr reflog return maybeResult #if defined(ENABLE_OVERLOADING) data ReflogRefMethodInfo instance (signature ~ (m (Maybe Reflog)), MonadIO m) => O.MethodInfo ReflogRefMethodInfo Reflog signature where overloadedMethod = reflogRef #endif -- method Reflog::rename -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "reflog" -- , argType = -- TInterface Name { namespace = "Ggit" , name = "Reflog" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitReflog." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- , Arg -- { argCName = "new_name" -- , argType = TBasicType TUTF8 -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "the new name of the reference." -- , 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_reflog_rename" ggit_reflog_rename :: Ptr Reflog -> -- reflog : TInterface (Name {namespace = "Ggit", name = "Reflog"}) CString -> -- new_name : TBasicType TUTF8 Ptr (Ptr GError) -> -- error IO CInt -- | Renames the reflog for to /@newName@/, on error /@error@/ is set. reflogRename :: (B.CallStack.HasCallStack, MonadIO m) => Reflog -- ^ /@reflog@/: a t'GI.Ggit.Structs.Reflog.Reflog'. -> T.Text -- ^ /@newName@/: the new name of the reference. -> m () -- ^ /(Can throw 'Data.GI.Base.GError.GError')/ reflogRename reflog newName = liftIO $ do reflog' <- unsafeManagedPtrGetPtr reflog newName' <- textToCString newName onException (do _ <- propagateGError $ ggit_reflog_rename reflog' newName' touchManagedPtr reflog freeMem newName' return () ) (do freeMem newName' ) #if defined(ENABLE_OVERLOADING) data ReflogRenameMethodInfo instance (signature ~ (T.Text -> m ()), MonadIO m) => O.MethodInfo ReflogRenameMethodInfo Reflog signature where overloadedMethod = reflogRename #endif -- method Reflog::unref -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "reflog" -- , argType = -- TInterface Name { namespace = "Ggit" , name = "Reflog" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitReflog." , sinceVersion = Nothing } -- , argScope = ScopeTypeInvalid -- , argClosure = -1 -- , argDestroy = -1 -- , argCallerAllocates = False -- , transfer = TransferNothing -- } -- ] -- Lengths: [] -- returnType: Nothing -- throws : False -- Skip return : False foreign import ccall "ggit_reflog_unref" ggit_reflog_unref :: Ptr Reflog -> -- reflog : TInterface (Name {namespace = "Ggit", name = "Reflog"}) IO () -- | Atomically decrements the reference count of /@reflog@/ by one. -- If the reference count drops to 0, /@reflog@/ is freed. reflogUnref :: (B.CallStack.HasCallStack, MonadIO m) => Reflog -- ^ /@reflog@/: a t'GI.Ggit.Structs.Reflog.Reflog'. -> m () reflogUnref reflog = liftIO $ do reflog' <- unsafeManagedPtrGetPtr reflog ggit_reflog_unref reflog' touchManagedPtr reflog return () #if defined(ENABLE_OVERLOADING) data ReflogUnrefMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo ReflogUnrefMethodInfo Reflog signature where overloadedMethod = reflogUnref #endif -- method Reflog::write -- method type : OrdinaryMethod -- Args: [ Arg -- { argCName = "reflog" -- , argType = -- TInterface Name { namespace = "Ggit" , name = "Reflog" } -- , direction = DirectionIn -- , mayBeNull = False -- , argDoc = -- Documentation -- { rawDocText = Just "a #GgitReflog." , 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_reflog_write" ggit_reflog_write :: Ptr Reflog -> -- reflog : TInterface (Name {namespace = "Ggit", name = "Reflog"}) Ptr (Ptr GError) -> -- error IO CInt -- | Write the reflog to disk. reflogWrite :: (B.CallStack.HasCallStack, MonadIO m) => Reflog -- ^ /@reflog@/: a t'GI.Ggit.Structs.Reflog.Reflog'. -> m () -- ^ /(Can throw 'Data.GI.Base.GError.GError')/ reflogWrite reflog = liftIO $ do reflog' <- unsafeManagedPtrGetPtr reflog onException (do _ <- propagateGError $ ggit_reflog_write reflog' touchManagedPtr reflog return () ) (do return () ) #if defined(ENABLE_OVERLOADING) data ReflogWriteMethodInfo instance (signature ~ (m ()), MonadIO m) => O.MethodInfo ReflogWriteMethodInfo Reflog signature where overloadedMethod = reflogWrite #endif #if defined(ENABLE_OVERLOADING) type family ResolveReflogMethod (t :: Symbol) (o :: *) :: * where ResolveReflogMethod "append" o = ReflogAppendMethodInfo ResolveReflogMethod "ref" o = ReflogRefMethodInfo ResolveReflogMethod "rename" o = ReflogRenameMethodInfo ResolveReflogMethod "unref" o = ReflogUnrefMethodInfo ResolveReflogMethod "write" o = ReflogWriteMethodInfo ResolveReflogMethod "getEntryCount" o = ReflogGetEntryCountMethodInfo ResolveReflogMethod "getEntryFromIndex" o = ReflogGetEntryFromIndexMethodInfo ResolveReflogMethod l o = O.MethodResolutionFailed l o instance (info ~ ResolveReflogMethod t Reflog, O.MethodInfo info Reflog p) => OL.IsLabel t (Reflog -> p) where #if MIN_VERSION_base(4,10,0) fromLabel = O.overloadedMethod @info #else fromLabel _ = O.overloadedMethod @info #endif #endif