{- |
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 #GHookList struct represents a list of hook functions.
-}

module GI.GLib.Structs.HookList
    ( 

-- * Exported types
    HookList(..)                            ,
    noHookList                              ,


 -- * Methods
-- ** hookListClear
    hookListClear                           ,


-- ** hookListInit
    hookListInit                            ,


-- ** hookListInvoke
    hookListInvoke                          ,


-- ** hookListInvokeCheck
    hookListInvokeCheck                     ,




 -- * Properties
-- ** Dummy3
    hookListReadDummy3                      ,


-- ** HookSize
    hookListReadHookSize                    ,


-- ** Hooks
    hookListReadHooks                       ,


-- ** IsSetup
    hookListReadIsSetup                     ,


-- ** SeqId
    hookListReadSeqId                       ,




    ) 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 HookList = HookList (ForeignPtr HookList)
noHookList :: Maybe HookList
noHookList = Nothing

hookListReadSeqId :: HookList -> IO Word64
hookListReadSeqId s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 0) :: IO Word64
    return val

hookListReadHookSize :: HookList -> IO Word32
hookListReadHookSize s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 8) :: IO Word32
    return val

hookListReadIsSetup :: HookList -> IO Word32
hookListReadIsSetup s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 12) :: IO Word32
    return val

hookListReadHooks :: HookList -> IO Hook
hookListReadHooks s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 16) :: IO (Ptr Hook)
    val' <- (newPtr 64 Hook) val
    return val'

hookListReadDummy3 :: HookList -> IO (Ptr ())
hookListReadDummy3 s = withManagedPtr s $ \ptr -> do
    val <- peek (ptr `plusPtr` 24) :: IO (Ptr ())
    return val

-- XXX Skipped getter for "HookList:finalize_hook" :: Not implemented: "Wrapping foreign callbacks is not supported yet"

-- XXX Skipped getter for "HookList:dummy" :: Not implemented: "Don't know how to unpack C array of type TCArray False 2 (-1) (TBasicType TVoid)"

-- method HookList::clear
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_hook_list_clear" g_hook_list_clear :: 
    Ptr HookList ->                         -- _obj : TInterface "GLib" "HookList"
    IO ()


hookListClear ::
    (MonadIO m) =>
    HookList ->                             -- _obj
    m ()
hookListClear _obj = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_hook_list_clear _obj'
    touchManagedPtr _obj
    return ()

-- method HookList::init
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "hook_size", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "hook_size", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_hook_list_init" g_hook_list_init :: 
    Ptr HookList ->                         -- _obj : TInterface "GLib" "HookList"
    Word32 ->                               -- hook_size : TBasicType TUInt32
    IO ()


hookListInit ::
    (MonadIO m) =>
    HookList ->                             -- _obj
    Word32 ->                               -- hook_size
    m ()
hookListInit _obj hook_size = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    g_hook_list_init _obj' hook_size
    touchManagedPtr _obj
    return ()

-- method HookList::invoke
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "may_recurse", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "may_recurse", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_hook_list_invoke" g_hook_list_invoke :: 
    Ptr HookList ->                         -- _obj : TInterface "GLib" "HookList"
    CInt ->                                 -- may_recurse : TBasicType TBoolean
    IO ()


hookListInvoke ::
    (MonadIO m) =>
    HookList ->                             -- _obj
    Bool ->                                 -- may_recurse
    m ()
hookListInvoke _obj may_recurse = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let may_recurse' = (fromIntegral . fromEnum) may_recurse
    g_hook_list_invoke _obj' may_recurse'
    touchManagedPtr _obj
    return ()

-- method HookList::invoke_check
-- method type : OrdinaryMethod
-- Args : [Arg {argName = "_obj", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "may_recurse", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "_obj", argType = TInterface "GLib" "HookList", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "may_recurse", argType = TBasicType TBoolean, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "g_hook_list_invoke_check" g_hook_list_invoke_check :: 
    Ptr HookList ->                         -- _obj : TInterface "GLib" "HookList"
    CInt ->                                 -- may_recurse : TBasicType TBoolean
    IO ()


hookListInvokeCheck ::
    (MonadIO m) =>
    HookList ->                             -- _obj
    Bool ->                                 -- may_recurse
    m ()
hookListInvokeCheck _obj may_recurse = liftIO $ do
    let _obj' = unsafeManagedPtrGetPtr _obj
    let may_recurse' = (fromIntegral . fromEnum) may_recurse
    g_hook_list_invoke_check _obj' may_recurse'
    touchManagedPtr _obj
    return ()