gi-ggit-1.0.4: GI/Ggit/Structs/Note.hs
{- |
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 note object.
-}
#define ENABLE_OVERLOADING (MIN_VERSION_haskell_gi_overloading(1,0,0) \
&& !defined(__HADDOCK_VERSION__))
module GI.Ggit.Structs.Note
(
-- * Exported types
Note(..) ,
noNote ,
-- * Methods
-- ** getId #method:getId#
#if ENABLE_OVERLOADING
NoteGetIdMethodInfo ,
#endif
noteGetId ,
-- ** getMessage #method:getMessage#
#if ENABLE_OVERLOADING
NoteGetMessageMethodInfo ,
#endif
noteGetMessage ,
-- ** ref #method:ref#
#if ENABLE_OVERLOADING
NoteRefMethodInfo ,
#endif
noteRef ,
-- ** unref #method:unref#
#if ENABLE_OVERLOADING
NoteUnrefMethodInfo ,
#endif
noteUnref ,
) 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 {-# SOURCE #-} qualified GI.Ggit.Structs.OId as Ggit.OId
-- | Memory-managed wrapper type.
newtype Note = Note (ManagedPtr Note)
foreign import ccall "ggit_note_get_type" c_ggit_note_get_type ::
IO GType
instance BoxedObject Note where
boxedType _ = c_ggit_note_get_type
-- | A convenience alias for `Nothing` :: `Maybe` `Note`.
noNote :: Maybe Note
noNote = Nothing
#if ENABLE_OVERLOADING
instance O.HasAttributeList Note
type instance O.AttributeList Note = NoteAttributeList
type NoteAttributeList = ('[ ] :: [(Symbol, *)])
#endif
-- method Note::get_id
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "note", argType = TInterface (Name {namespace = "Ggit", name = "Note"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitNote.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "OId"}))
-- throws : False
-- Skip return : False
foreign import ccall "ggit_note_get_id" ggit_note_get_id ::
Ptr Note -> -- note : TInterface (Name {namespace = "Ggit", name = "Note"})
IO (Ptr Ggit.OId.OId)
{- |
Gets the note object\'s id.
-}
noteGetId ::
(B.CallStack.HasCallStack, MonadIO m) =>
Note
{- ^ /@note@/: a 'GI.Ggit.Structs.Note.Note'. -}
-> m (Maybe Ggit.OId.OId)
{- ^ __Returns:__ the object\'s id or 'Nothing'. -}
noteGetId note = liftIO $ do
note' <- unsafeManagedPtrGetPtr note
result <- ggit_note_get_id note'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (newBoxed Ggit.OId.OId) result'
return result''
touchManagedPtr note
return maybeResult
#if ENABLE_OVERLOADING
data NoteGetIdMethodInfo
instance (signature ~ (m (Maybe Ggit.OId.OId)), MonadIO m) => O.MethodInfo NoteGetIdMethodInfo Note signature where
overloadedMethod _ = noteGetId
#endif
-- method Note::get_message
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "note", argType = TInterface (Name {namespace = "Ggit", name = "Note"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitNote.", 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_note_get_message" ggit_note_get_message ::
Ptr Note -> -- note : TInterface (Name {namespace = "Ggit", name = "Note"})
IO CString
{- |
Gets the note message.
-}
noteGetMessage ::
(B.CallStack.HasCallStack, MonadIO m) =>
Note
{- ^ /@note@/: a 'GI.Ggit.Structs.Note.Note'. -}
-> m (Maybe T.Text)
{- ^ __Returns:__ the note message or 'Nothing'. -}
noteGetMessage note = liftIO $ do
note' <- unsafeManagedPtrGetPtr note
result <- ggit_note_get_message note'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- cstringToText result'
return result''
touchManagedPtr note
return maybeResult
#if ENABLE_OVERLOADING
data NoteGetMessageMethodInfo
instance (signature ~ (m (Maybe T.Text)), MonadIO m) => O.MethodInfo NoteGetMessageMethodInfo Note signature where
overloadedMethod _ = noteGetMessage
#endif
-- method Note::ref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "note", argType = TInterface (Name {namespace = "Ggit", name = "Note"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitNote.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Ggit", name = "Note"}))
-- throws : False
-- Skip return : False
foreign import ccall "ggit_note_ref" ggit_note_ref ::
Ptr Note -> -- note : TInterface (Name {namespace = "Ggit", name = "Note"})
IO (Ptr Note)
{- |
Atomically increments the reference count of /@note@/ by one.
This function is MT-safe and may be called from any thread.
-}
noteRef ::
(B.CallStack.HasCallStack, MonadIO m) =>
Note
{- ^ /@note@/: a 'GI.Ggit.Structs.Note.Note'. -}
-> m (Maybe Note)
{- ^ __Returns:__ a 'GI.Ggit.Structs.Note.Note' or 'Nothing'. -}
noteRef note = liftIO $ do
note' <- unsafeManagedPtrGetPtr note
result <- ggit_note_ref note'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (newBoxed Note) result'
return result''
touchManagedPtr note
return maybeResult
#if ENABLE_OVERLOADING
data NoteRefMethodInfo
instance (signature ~ (m (Maybe Note)), MonadIO m) => O.MethodInfo NoteRefMethodInfo Note signature where
overloadedMethod _ = noteRef
#endif
-- method Note::unref
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "note", argType = TInterface (Name {namespace = "Ggit", name = "Note"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GgitNote.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False
foreign import ccall "ggit_note_unref" ggit_note_unref ::
Ptr Note -> -- note : TInterface (Name {namespace = "Ggit", name = "Note"})
IO ()
{- |
Atomically decrements the reference count of /@note@/ by one.
If the reference count drops to 0, /@note@/ is freed.
-}
noteUnref ::
(B.CallStack.HasCallStack, MonadIO m) =>
Note
{- ^ /@note@/: a 'GI.Ggit.Structs.Note.Note'. -}
-> m ()
noteUnref note = liftIO $ do
note' <- unsafeManagedPtrGetPtr note
ggit_note_unref note'
touchManagedPtr note
return ()
#if ENABLE_OVERLOADING
data NoteUnrefMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo NoteUnrefMethodInfo Note signature where
overloadedMethod _ = noteUnref
#endif
#if ENABLE_OVERLOADING
type family ResolveNoteMethod (t :: Symbol) (o :: *) :: * where
ResolveNoteMethod "ref" o = NoteRefMethodInfo
ResolveNoteMethod "unref" o = NoteUnrefMethodInfo
ResolveNoteMethod "getId" o = NoteGetIdMethodInfo
ResolveNoteMethod "getMessage" o = NoteGetMessageMethodInfo
ResolveNoteMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveNoteMethod t Note, O.MethodInfo info Note p) => OL.IsLabel t (Note -> 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