{-# LANGUAGE TypeApplications #-}
#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif
module GI.OSTree.Structs.CollectionRef
(
CollectionRef(..) ,
newZeroCollectionRef ,
noCollectionRef ,
#if defined(ENABLE_OVERLOADING)
ResolveCollectionRefMethod ,
#endif
#if defined(ENABLE_OVERLOADING)
CollectionRefDupMethodInfo ,
#endif
collectionRefDup ,
collectionRefDupv ,
collectionRefEqual ,
#if defined(ENABLE_OVERLOADING)
CollectionRefFreeMethodInfo ,
#endif
collectionRefFree ,
collectionRefFreev ,
collectionRefHash ,
collectionRefNew ,
clearCollectionRefCollectionId ,
#if defined(ENABLE_OVERLOADING)
collectionRef_collectionId ,
#endif
getCollectionRefCollectionId ,
setCollectionRefCollectionId ,
clearCollectionRefRefName ,
#if defined(ENABLE_OVERLOADING)
collectionRef_refName ,
#endif
getCollectionRefRefName ,
setCollectionRefRefName ,
) 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
newtype CollectionRef = CollectionRef (ManagedPtr CollectionRef)
deriving (Eq)
foreign import ccall "ostree_collection_ref_get_type" c_ostree_collection_ref_get_type ::
IO GType
instance BoxedObject CollectionRef where
boxedType _ = c_ostree_collection_ref_get_type
instance B.GValue.IsGValue CollectionRef where
toGValue o = do
gtype <- c_ostree_collection_ref_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 CollectionRef)
B.ManagedPtr.newBoxed CollectionRef ptr
newZeroCollectionRef :: MonadIO m => m CollectionRef
newZeroCollectionRef = liftIO $ callocBoxedBytes 8 >>= wrapBoxed CollectionRef
instance tag ~ 'AttrSet => Constructible CollectionRef tag where
new _ attrs = do
o <- newZeroCollectionRef
GI.Attributes.set o attrs
return o
noCollectionRef :: Maybe CollectionRef
noCollectionRef = Nothing
getCollectionRefCollectionId :: MonadIO m => CollectionRef -> m (Maybe T.Text)
getCollectionRefCollectionId s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO CString
result <- SP.convertIfNonNull val $ \val' -> do
val'' <- cstringToText val'
return val''
return result
setCollectionRefCollectionId :: MonadIO m => CollectionRef -> CString -> m ()
setCollectionRefCollectionId s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 0) (val :: CString)
clearCollectionRefCollectionId :: MonadIO m => CollectionRef -> m ()
clearCollectionRefCollectionId s = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 0) (FP.nullPtr :: CString)
#if defined(ENABLE_OVERLOADING)
data CollectionRefCollectionIdFieldInfo
instance AttrInfo CollectionRefCollectionIdFieldInfo where
type AttrBaseTypeConstraint CollectionRefCollectionIdFieldInfo = (~) CollectionRef
type AttrAllowedOps CollectionRefCollectionIdFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint CollectionRefCollectionIdFieldInfo = (~) CString
type AttrTransferTypeConstraint CollectionRefCollectionIdFieldInfo = (~)CString
type AttrTransferType CollectionRefCollectionIdFieldInfo = CString
type AttrGetType CollectionRefCollectionIdFieldInfo = Maybe T.Text
type AttrLabel CollectionRefCollectionIdFieldInfo = "collection_id"
type AttrOrigin CollectionRefCollectionIdFieldInfo = CollectionRef
attrGet = getCollectionRefCollectionId
attrSet = setCollectionRefCollectionId
attrConstruct = undefined
attrClear = clearCollectionRefCollectionId
attrTransfer _ v = do
return v
collectionRef_collectionId :: AttrLabelProxy "collectionId"
collectionRef_collectionId = AttrLabelProxy
#endif
getCollectionRefRefName :: MonadIO m => CollectionRef -> m (Maybe T.Text)
getCollectionRefRefName s = liftIO $ withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 4) :: IO CString
result <- SP.convertIfNonNull val $ \val' -> do
val'' <- cstringToText val'
return val''
return result
setCollectionRefRefName :: MonadIO m => CollectionRef -> CString -> m ()
setCollectionRefRefName s val = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 4) (val :: CString)
clearCollectionRefRefName :: MonadIO m => CollectionRef -> m ()
clearCollectionRefRefName s = liftIO $ withManagedPtr s $ \ptr -> do
poke (ptr `plusPtr` 4) (FP.nullPtr :: CString)
#if defined(ENABLE_OVERLOADING)
data CollectionRefRefNameFieldInfo
instance AttrInfo CollectionRefRefNameFieldInfo where
type AttrBaseTypeConstraint CollectionRefRefNameFieldInfo = (~) CollectionRef
type AttrAllowedOps CollectionRefRefNameFieldInfo = '[ 'AttrSet, 'AttrGet, 'AttrClear]
type AttrSetTypeConstraint CollectionRefRefNameFieldInfo = (~) CString
type AttrTransferTypeConstraint CollectionRefRefNameFieldInfo = (~)CString
type AttrTransferType CollectionRefRefNameFieldInfo = CString
type AttrGetType CollectionRefRefNameFieldInfo = Maybe T.Text
type AttrLabel CollectionRefRefNameFieldInfo = "ref_name"
type AttrOrigin CollectionRefRefNameFieldInfo = CollectionRef
attrGet = getCollectionRefRefName
attrSet = setCollectionRefRefName
attrConstruct = undefined
attrClear = clearCollectionRefRefName
attrTransfer _ v = do
return v
collectionRef_refName :: AttrLabelProxy "refName"
collectionRef_refName = AttrLabelProxy
#endif
#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList CollectionRef
type instance O.AttributeList CollectionRef = CollectionRefAttributeList
type CollectionRefAttributeList = ('[ '("collectionId", CollectionRefCollectionIdFieldInfo), '("refName", CollectionRefRefNameFieldInfo)] :: [(Symbol, *)])
#endif
foreign import ccall "ostree_collection_ref_new" ostree_collection_ref_new ::
CString ->
CString ->
IO (Ptr CollectionRef)
collectionRefNew ::
(B.CallStack.HasCallStack, MonadIO m) =>
Maybe (T.Text)
-> T.Text
-> m (Maybe CollectionRef)
collectionRefNew collectionId refName = liftIO $ do
maybeCollectionId <- case collectionId of
Nothing -> return nullPtr
Just jCollectionId -> do
jCollectionId' <- textToCString jCollectionId
return jCollectionId'
refName' <- textToCString refName
result <- ostree_collection_ref_new maybeCollectionId refName'
maybeResult <- convertIfNonNull result $ \result' -> do
result'' <- (wrapBoxed CollectionRef) result'
return result''
freeMem maybeCollectionId
freeMem refName'
return maybeResult
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "ostree_collection_ref_dup" ostree_collection_ref_dup ::
Ptr CollectionRef ->
IO (Ptr CollectionRef)
collectionRefDup ::
(B.CallStack.HasCallStack, MonadIO m) =>
CollectionRef
-> m CollectionRef
collectionRefDup ref = liftIO $ do
ref' <- unsafeManagedPtrGetPtr ref
result <- ostree_collection_ref_dup ref'
checkUnexpectedReturnNULL "collectionRefDup" result
result' <- (wrapBoxed CollectionRef) result
touchManagedPtr ref
return result'
#if defined(ENABLE_OVERLOADING)
data CollectionRefDupMethodInfo
instance (signature ~ (m CollectionRef), MonadIO m) => O.MethodInfo CollectionRefDupMethodInfo CollectionRef signature where
overloadedMethod = collectionRefDup
#endif
foreign import ccall "ostree_collection_ref_free" ostree_collection_ref_free ::
Ptr CollectionRef ->
IO ()
collectionRefFree ::
(B.CallStack.HasCallStack, MonadIO m) =>
CollectionRef
-> m ()
collectionRefFree ref = liftIO $ do
ref' <- B.ManagedPtr.disownBoxed ref
ostree_collection_ref_free ref'
touchManagedPtr ref
return ()
#if defined(ENABLE_OVERLOADING)
data CollectionRefFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => O.MethodInfo CollectionRefFreeMethodInfo CollectionRef signature where
overloadedMethod = collectionRefFree
#endif
foreign import ccall "ostree_collection_ref_dupv" ostree_collection_ref_dupv ::
Ptr (Ptr CollectionRef) ->
IO (Ptr (Ptr CollectionRef))
collectionRefDupv ::
(B.CallStack.HasCallStack, MonadIO m) =>
[CollectionRef]
-> m [CollectionRef]
collectionRefDupv refs = liftIO $ do
refs' <- mapM unsafeManagedPtrGetPtr refs
refs'' <- packZeroTerminatedPtrArray refs'
result <- ostree_collection_ref_dupv refs''
checkUnexpectedReturnNULL "collectionRefDupv" result
result' <- unpackZeroTerminatedPtrArray result
result'' <- mapM (wrapBoxed CollectionRef) result'
freeMem result
mapM_ touchManagedPtr refs
freeMem refs''
return result''
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "ostree_collection_ref_equal" ostree_collection_ref_equal ::
Ptr () ->
Ptr () ->
IO CInt
collectionRefEqual ::
(B.CallStack.HasCallStack, MonadIO m) =>
Ptr ()
-> Ptr ()
-> m Bool
collectionRefEqual ref1 ref2 = liftIO $ do
result <- ostree_collection_ref_equal ref1 ref2
let result' = (/= 0) result
return result'
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "ostree_collection_ref_freev" ostree_collection_ref_freev ::
Ptr (Ptr CollectionRef) ->
IO ()
collectionRefFreev ::
(B.CallStack.HasCallStack, MonadIO m) =>
[CollectionRef]
-> m ()
collectionRefFreev refs = liftIO $ do
refs' <- mapM B.ManagedPtr.disownBoxed refs
refs'' <- packZeroTerminatedPtrArray refs'
ostree_collection_ref_freev refs''
mapM_ touchManagedPtr refs
return ()
#if defined(ENABLE_OVERLOADING)
#endif
foreign import ccall "ostree_collection_ref_hash" ostree_collection_ref_hash ::
Ptr () ->
IO Word32
collectionRefHash ::
(B.CallStack.HasCallStack, MonadIO m) =>
Ptr ()
-> m Word32
collectionRefHash ref = liftIO $ do
result <- ostree_collection_ref_hash ref
return result
#if defined(ENABLE_OVERLOADING)
#endif
#if defined(ENABLE_OVERLOADING)
type family ResolveCollectionRefMethod (t :: Symbol) (o :: *) :: * where
ResolveCollectionRefMethod "dup" o = CollectionRefDupMethodInfo
ResolveCollectionRefMethod "free" o = CollectionRefFreeMethodInfo
ResolveCollectionRefMethod l o = O.MethodResolutionFailed l o
instance (info ~ ResolveCollectionRefMethod t CollectionRef, O.MethodInfo info CollectionRef p) => OL.IsLabel t (CollectionRef -> p) where
#if MIN_VERSION_base(4,10,0)
fromLabel = O.overloadedMethod @info
#else
fromLabel _ = O.overloadedMethod @info
#endif
#endif