gi-glib-0.2.46.13: GI/GLib/Structs/Queue.hs
{- |
Copyright : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
Contains the public fields of a
[Queue][glib-Double-ended-Queues].
-}
module GI.GLib.Structs.Queue
(
-- * Exported types
Queue(..) ,
newZeroQueue ,
noQueue ,
-- * Methods
-- ** queueClear
QueueClearMethodInfo ,
queueClear ,
-- ** queueFree
QueueFreeMethodInfo ,
queueFree ,
-- ** queueFreeFull
QueueFreeFullMethodInfo ,
queueFreeFull ,
-- ** queueGetLength
QueueGetLengthMethodInfo ,
queueGetLength ,
-- ** queueIndex
QueueIndexMethodInfo ,
queueIndex ,
-- ** queueInit
QueueInitMethodInfo ,
queueInit ,
-- ** queueIsEmpty
QueueIsEmptyMethodInfo ,
queueIsEmpty ,
-- ** queuePushHead
QueuePushHeadMethodInfo ,
queuePushHead ,
-- ** queuePushNth
QueuePushNthMethodInfo ,
queuePushNth ,
-- ** queuePushTail
QueuePushTailMethodInfo ,
queuePushTail ,
-- ** queueRemove
QueueRemoveMethodInfo ,
queueRemove ,
-- ** queueRemoveAll
QueueRemoveAllMethodInfo ,
queueRemoveAll ,
-- ** queueReverse
QueueReverseMethodInfo ,
queueReverse ,
-- * Properties
-- ** Head
queueReadHead ,
-- ** Length
queueReadLength ,
-- ** Tail
queueReadTail ,
) where
import Prelude ()
import Data.GI.Base.ShortPrelude
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import GI.GLib.Types
import GI.GLib.Callbacks
newtype Queue = Queue (ForeignPtr Queue)
-- | Construct a `Queue` struct initialized to zero.
newZeroQueue :: MonadIO m => m Queue
newZeroQueue = liftIO $ callocBytes 24 >>= wrapPtr Queue
noQueue :: Maybe Queue
noQueue = Nothing
queueReadHead :: Queue -> IO ([Ptr ()])
queueReadHead s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO (Ptr (GList (Ptr ())))
val' <- unpackGList val
return val'
queueReadTail :: Queue -> IO ([Ptr ()])
queueReadTail s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO (Ptr (GList (Ptr ())))
val' <- unpackGList val
return val'
queueReadLength :: Queue -> IO Word32
queueReadLength s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 16) :: IO Word32
return val
-- method Queue::clear
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Queue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_queue_clear" g_queue_clear ::
Ptr Queue -> -- _obj : TInterface "GLib" "Queue"
IO ()
queueClear ::
(MonadIO m) =>
Queue -- _obj
-> m () -- result
queueClear _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_queue_clear _obj'
touchManagedPtr _obj
return ()
data QueueClearMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo QueueClearMethodInfo Queue signature where
overloadedMethod _ = queueClear
-- method Queue::free
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Queue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_queue_free" g_queue_free ::
Ptr Queue -> -- _obj : TInterface "GLib" "Queue"
IO ()
queueFree ::
(MonadIO m) =>
Queue -- _obj
-> m () -- result
queueFree _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_queue_free _obj'
touchManagedPtr _obj
return ()
data QueueFreeMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo QueueFreeMethodInfo Queue signature where
overloadedMethod _ = queueFree
-- method Queue::free_full
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Queue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "free_func", argType = TInterface "GLib" "DestroyNotify", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_queue_free_full" g_queue_free_full ::
Ptr Queue -> -- _obj : TInterface "GLib" "Queue"
FunPtr DestroyNotifyC -> -- free_func : TInterface "GLib" "DestroyNotify"
IO ()
queueFreeFull ::
(MonadIO m) =>
Queue -- _obj
-> DestroyNotify -- freeFunc
-> m () -- result
queueFreeFull _obj freeFunc = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
ptrfreeFunc <- callocMem :: IO (Ptr (FunPtr DestroyNotifyC))
freeFunc' <- mkDestroyNotify (destroyNotifyWrapper (Just ptrfreeFunc) freeFunc)
poke ptrfreeFunc freeFunc'
g_queue_free_full _obj' freeFunc'
touchManagedPtr _obj
return ()
data QueueFreeFullMethodInfo
instance (signature ~ (DestroyNotify -> m ()), MonadIO m) => MethodInfo QueueFreeFullMethodInfo Queue signature where
overloadedMethod _ = queueFreeFull
-- method Queue::get_length
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Queue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False
foreign import ccall "g_queue_get_length" g_queue_get_length ::
Ptr Queue -> -- _obj : TInterface "GLib" "Queue"
IO Word32
queueGetLength ::
(MonadIO m) =>
Queue -- _obj
-> m Word32 -- result
queueGetLength _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- g_queue_get_length _obj'
touchManagedPtr _obj
return result
data QueueGetLengthMethodInfo
instance (signature ~ (m Word32), MonadIO m) => MethodInfo QueueGetLengthMethodInfo Queue signature where
overloadedMethod _ = queueGetLength
-- method Queue::index
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Queue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TInt32
-- throws : False
-- Skip return : False
foreign import ccall "g_queue_index" g_queue_index ::
Ptr Queue -> -- _obj : TInterface "GLib" "Queue"
Ptr () -> -- data : TBasicType TVoid
IO Int32
queueIndex ::
(MonadIO m) =>
Queue -- _obj
-> Ptr () -- data_
-> m Int32 -- result
queueIndex _obj data_ = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- g_queue_index _obj' data_
touchManagedPtr _obj
return result
data QueueIndexMethodInfo
instance (signature ~ (Ptr () -> m Int32), MonadIO m) => MethodInfo QueueIndexMethodInfo Queue signature where
overloadedMethod _ = queueIndex
-- method Queue::init
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Queue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_queue_init" g_queue_init ::
Ptr Queue -> -- _obj : TInterface "GLib" "Queue"
IO ()
queueInit ::
(MonadIO m) =>
Queue -- _obj
-> m () -- result
queueInit _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_queue_init _obj'
touchManagedPtr _obj
return ()
data QueueInitMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo QueueInitMethodInfo Queue signature where
overloadedMethod _ = queueInit
-- method Queue::is_empty
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Queue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False
foreign import ccall "g_queue_is_empty" g_queue_is_empty ::
Ptr Queue -> -- _obj : TInterface "GLib" "Queue"
IO CInt
queueIsEmpty ::
(MonadIO m) =>
Queue -- _obj
-> m Bool -- result
queueIsEmpty _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- g_queue_is_empty _obj'
let result' = (/= 0) result
touchManagedPtr _obj
return result'
data QueueIsEmptyMethodInfo
instance (signature ~ (m Bool), MonadIO m) => MethodInfo QueueIsEmptyMethodInfo Queue signature where
overloadedMethod _ = queueIsEmpty
-- method Queue::push_head
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Queue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_queue_push_head" g_queue_push_head ::
Ptr Queue -> -- _obj : TInterface "GLib" "Queue"
Ptr () -> -- data : TBasicType TVoid
IO ()
queuePushHead ::
(MonadIO m) =>
Queue -- _obj
-> Ptr () -- data_
-> m () -- result
queuePushHead _obj data_ = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_queue_push_head _obj' data_
touchManagedPtr _obj
return ()
data QueuePushHeadMethodInfo
instance (signature ~ (Ptr () -> m ()), MonadIO m) => MethodInfo QueuePushHeadMethodInfo Queue signature where
overloadedMethod _ = queuePushHead
-- method Queue::push_nth
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Queue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "n", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_queue_push_nth" g_queue_push_nth ::
Ptr Queue -> -- _obj : TInterface "GLib" "Queue"
Ptr () -> -- data : TBasicType TVoid
Int32 -> -- n : TBasicType TInt32
IO ()
queuePushNth ::
(MonadIO m) =>
Queue -- _obj
-> Ptr () -- data_
-> Int32 -- n
-> m () -- result
queuePushNth _obj data_ n = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_queue_push_nth _obj' data_ n
touchManagedPtr _obj
return ()
data QueuePushNthMethodInfo
instance (signature ~ (Ptr () -> Int32 -> m ()), MonadIO m) => MethodInfo QueuePushNthMethodInfo Queue signature where
overloadedMethod _ = queuePushNth
-- method Queue::push_tail
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Queue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_queue_push_tail" g_queue_push_tail ::
Ptr Queue -> -- _obj : TInterface "GLib" "Queue"
Ptr () -> -- data : TBasicType TVoid
IO ()
queuePushTail ::
(MonadIO m) =>
Queue -- _obj
-> Ptr () -- data_
-> m () -- result
queuePushTail _obj data_ = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_queue_push_tail _obj' data_
touchManagedPtr _obj
return ()
data QueuePushTailMethodInfo
instance (signature ~ (Ptr () -> m ()), MonadIO m) => MethodInfo QueuePushTailMethodInfo Queue signature where
overloadedMethod _ = queuePushTail
-- method Queue::remove
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Queue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False
foreign import ccall "g_queue_remove" g_queue_remove ::
Ptr Queue -> -- _obj : TInterface "GLib" "Queue"
Ptr () -> -- data : TBasicType TVoid
IO CInt
queueRemove ::
(MonadIO m) =>
Queue -- _obj
-> Ptr () -- data_
-> m Bool -- result
queueRemove _obj data_ = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- g_queue_remove _obj' data_
let result' = (/= 0) result
touchManagedPtr _obj
return result'
data QueueRemoveMethodInfo
instance (signature ~ (Ptr () -> m Bool), MonadIO m) => MethodInfo QueueRemoveMethodInfo Queue signature where
overloadedMethod _ = queueRemove
-- method Queue::remove_all
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Queue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "data", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False
foreign import ccall "g_queue_remove_all" g_queue_remove_all ::
Ptr Queue -> -- _obj : TInterface "GLib" "Queue"
Ptr () -> -- data : TBasicType TVoid
IO Word32
queueRemoveAll ::
(MonadIO m) =>
Queue -- _obj
-> Ptr () -- data_
-> m Word32 -- result
queueRemoveAll _obj data_ = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
result <- g_queue_remove_all _obj' data_
touchManagedPtr _obj
return result
data QueueRemoveAllMethodInfo
instance (signature ~ (Ptr () -> m Word32), MonadIO m) => MethodInfo QueueRemoveAllMethodInfo Queue signature where
overloadedMethod _ = queueRemoveAll
-- method Queue::reverse
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Queue", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False
foreign import ccall "g_queue_reverse" g_queue_reverse ::
Ptr Queue -> -- _obj : TInterface "GLib" "Queue"
IO ()
queueReverse ::
(MonadIO m) =>
Queue -- _obj
-> m () -- result
queueReverse _obj = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
g_queue_reverse _obj'
touchManagedPtr _obj
return ()
data QueueReverseMethodInfo
instance (signature ~ (m ()), MonadIO m) => MethodInfo QueueReverseMethodInfo Queue signature where
overloadedMethod _ = queueReverse
type family ResolveQueueMethod (t :: Symbol) (o :: *) :: * where
ResolveQueueMethod "clear" o = QueueClearMethodInfo
ResolveQueueMethod "free" o = QueueFreeMethodInfo
ResolveQueueMethod "freeFull" o = QueueFreeFullMethodInfo
ResolveQueueMethod "index" o = QueueIndexMethodInfo
ResolveQueueMethod "init" o = QueueInitMethodInfo
ResolveQueueMethod "isEmpty" o = QueueIsEmptyMethodInfo
ResolveQueueMethod "pushHead" o = QueuePushHeadMethodInfo
ResolveQueueMethod "pushNth" o = QueuePushNthMethodInfo
ResolveQueueMethod "pushTail" o = QueuePushTailMethodInfo
ResolveQueueMethod "remove" o = QueueRemoveMethodInfo
ResolveQueueMethod "removeAll" o = QueueRemoveAllMethodInfo
ResolveQueueMethod "reverse" o = QueueReverseMethodInfo
ResolveQueueMethod "getLength" o = QueueGetLengthMethodInfo
ResolveQueueMethod l o = MethodResolutionFailed l o
instance (info ~ ResolveQueueMethod t Queue, MethodInfo info Queue p) => IsLabelProxy t (Queue -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveQueueMethod t Queue, MethodInfo info Queue p) => IsLabel t (Queue -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif