gi-glib-0.2.46.13: GI/GLib/Structs/Hook.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)
The #GHook struct represents a single hook function in a #GHookList.
-}
module GI.GLib.Structs.Hook
(
-- * Exported types
Hook(..) ,
newZeroHook ,
noHook ,
-- * Methods
-- ** hookCompareIds
HookCompareIdsMethodInfo ,
hookCompareIds ,
-- ** hookDestroy
hookDestroy ,
-- ** hookDestroyLink
hookDestroyLink ,
-- ** hookFree
hookFree ,
-- ** hookInsertBefore
hookInsertBefore ,
-- ** hookPrepend
hookPrepend ,
-- ** hookUnref
hookUnref ,
-- * Properties
-- ** Data
hookReadData ,
-- ** Flags
hookReadFlags ,
-- ** Func
hookReadFunc ,
-- ** HookId
hookReadHookId ,
-- ** Next
hookReadNext ,
-- ** Prev
hookReadPrev ,
-- ** RefCount
hookReadRefCount ,
) 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 Hook = Hook (ForeignPtr Hook)
-- | Construct a `Hook` struct initialized to zero.
newZeroHook :: MonadIO m => m Hook
newZeroHook = liftIO $ callocBytes 64 >>= wrapPtr Hook
noHook :: Maybe Hook
noHook = Nothing
hookReadData :: Hook -> IO (Ptr ())
hookReadData s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 0) :: IO (Ptr ())
return val
hookReadNext :: Hook -> IO Hook
hookReadNext s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 8) :: IO (Ptr Hook)
val' <- (newPtr 64 Hook) val
return val'
hookReadPrev :: Hook -> IO Hook
hookReadPrev s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 16) :: IO (Ptr Hook)
val' <- (newPtr 64 Hook) val
return val'
hookReadRefCount :: Hook -> IO Word32
hookReadRefCount s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 24) :: IO Word32
return val
hookReadHookId :: Hook -> IO Word64
hookReadHookId s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 32) :: IO Word64
return val
hookReadFlags :: Hook -> IO Word32
hookReadFlags s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 40) :: IO Word32
return val
hookReadFunc :: Hook -> IO (Ptr ())
hookReadFunc s = withManagedPtr s $ \ptr -> do
val <- peek (ptr `plusPtr` 48) :: IO (Ptr ())
return val
-- XXX Skipped getter for "Hook:destroy" :: Not implemented: "Wrapping foreign callbacks is not supported yet"
-- method Hook::compare_ids
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "_obj", argType = TInterface "GLib" "Hook", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "sibling", argType = TInterface "GLib" "Hook", 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_hook_compare_ids" g_hook_compare_ids ::
Ptr Hook -> -- _obj : TInterface "GLib" "Hook"
Ptr Hook -> -- sibling : TInterface "GLib" "Hook"
IO Int32
hookCompareIds ::
(MonadIO m) =>
Hook -- _obj
-> Hook -- sibling
-> m Int32 -- result
hookCompareIds _obj sibling = liftIO $ do
let _obj' = unsafeManagedPtrGetPtr _obj
let sibling' = unsafeManagedPtrGetPtr sibling
result <- g_hook_compare_ids _obj' sibling'
touchManagedPtr _obj
touchManagedPtr sibling
return result
data HookCompareIdsMethodInfo
instance (signature ~ (Hook -> m Int32), MonadIO m) => MethodInfo HookCompareIdsMethodInfo Hook signature where
overloadedMethod _ = hookCompareIds
-- method Hook::destroy
-- method type : MemberFunction
-- Args : [Arg {argCName = "hook_list", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hook_id", argType = TBasicType TUInt64, 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_hook_destroy" g_hook_destroy ::
Ptr HookList -> -- hook_list : TInterface "GLib" "HookList"
Word64 -> -- hook_id : TBasicType TUInt64
IO CInt
hookDestroy ::
(MonadIO m) =>
HookList -- hookList
-> Word64 -- hookId
-> m Bool -- result
hookDestroy hookList hookId = liftIO $ do
let hookList' = unsafeManagedPtrGetPtr hookList
result <- g_hook_destroy hookList' hookId
let result' = (/= 0) result
touchManagedPtr hookList
return result'
-- method Hook::destroy_link
-- method type : MemberFunction
-- Args : [Arg {argCName = "hook_list", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hook", argType = TInterface "GLib" "Hook", 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_hook_destroy_link" g_hook_destroy_link ::
Ptr HookList -> -- hook_list : TInterface "GLib" "HookList"
Ptr Hook -> -- hook : TInterface "GLib" "Hook"
IO ()
hookDestroyLink ::
(MonadIO m) =>
HookList -- hookList
-> Hook -- hook
-> m () -- result
hookDestroyLink hookList hook = liftIO $ do
let hookList' = unsafeManagedPtrGetPtr hookList
let hook' = unsafeManagedPtrGetPtr hook
g_hook_destroy_link hookList' hook'
touchManagedPtr hookList
touchManagedPtr hook
return ()
-- method Hook::free
-- method type : MemberFunction
-- Args : [Arg {argCName = "hook_list", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hook", argType = TInterface "GLib" "Hook", 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_hook_free" g_hook_free ::
Ptr HookList -> -- hook_list : TInterface "GLib" "HookList"
Ptr Hook -> -- hook : TInterface "GLib" "Hook"
IO ()
hookFree ::
(MonadIO m) =>
HookList -- hookList
-> Hook -- hook
-> m () -- result
hookFree hookList hook = liftIO $ do
let hookList' = unsafeManagedPtrGetPtr hookList
let hook' = unsafeManagedPtrGetPtr hook
g_hook_free hookList' hook'
touchManagedPtr hookList
touchManagedPtr hook
return ()
-- method Hook::insert_before
-- method type : MemberFunction
-- Args : [Arg {argCName = "hook_list", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "sibling", argType = TInterface "GLib" "Hook", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hook", argType = TInterface "GLib" "Hook", 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_hook_insert_before" g_hook_insert_before ::
Ptr HookList -> -- hook_list : TInterface "GLib" "HookList"
Ptr Hook -> -- sibling : TInterface "GLib" "Hook"
Ptr Hook -> -- hook : TInterface "GLib" "Hook"
IO ()
hookInsertBefore ::
(MonadIO m) =>
HookList -- hookList
-> Hook -- sibling
-> Hook -- hook
-> m () -- result
hookInsertBefore hookList sibling hook = liftIO $ do
let hookList' = unsafeManagedPtrGetPtr hookList
let sibling' = unsafeManagedPtrGetPtr sibling
let hook' = unsafeManagedPtrGetPtr hook
g_hook_insert_before hookList' sibling' hook'
touchManagedPtr hookList
touchManagedPtr sibling
touchManagedPtr hook
return ()
-- method Hook::prepend
-- method type : MemberFunction
-- Args : [Arg {argCName = "hook_list", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hook", argType = TInterface "GLib" "Hook", 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_hook_prepend" g_hook_prepend ::
Ptr HookList -> -- hook_list : TInterface "GLib" "HookList"
Ptr Hook -> -- hook : TInterface "GLib" "Hook"
IO ()
hookPrepend ::
(MonadIO m) =>
HookList -- hookList
-> Hook -- hook
-> m () -- result
hookPrepend hookList hook = liftIO $ do
let hookList' = unsafeManagedPtrGetPtr hookList
let hook' = unsafeManagedPtrGetPtr hook
g_hook_prepend hookList' hook'
touchManagedPtr hookList
touchManagedPtr hook
return ()
-- method Hook::unref
-- method type : MemberFunction
-- Args : [Arg {argCName = "hook_list", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "hook", argType = TInterface "GLib" "Hook", 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_hook_unref" g_hook_unref ::
Ptr HookList -> -- hook_list : TInterface "GLib" "HookList"
Ptr Hook -> -- hook : TInterface "GLib" "Hook"
IO ()
hookUnref ::
(MonadIO m) =>
HookList -- hookList
-> Hook -- hook
-> m () -- result
hookUnref hookList hook = liftIO $ do
let hookList' = unsafeManagedPtrGetPtr hookList
let hook' = unsafeManagedPtrGetPtr hook
g_hook_unref hookList' hook'
touchManagedPtr hookList
touchManagedPtr hook
return ()
type family ResolveHookMethod (t :: Symbol) (o :: *) :: * where
ResolveHookMethod "compareIds" o = HookCompareIdsMethodInfo
ResolveHookMethod l o = MethodResolutionFailed l o
instance (info ~ ResolveHookMethod t Hook, MethodInfo info Hook p) => IsLabelProxy t (Hook -> p) where
fromLabelProxy _ = overloadedMethod (MethodProxy :: MethodProxy info)
#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveHookMethod t Hook, MethodInfo info Hook p) => IsLabel t (Hook -> p) where
fromLabel _ = overloadedMethod (MethodProxy :: MethodProxy info)
#endif