{-# LANGUAGE TypeApplications #-}


-- | Copyright  : Will Thompson and Iñaki García Etxebarria
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria
-- 
-- An event hook that runs a WpTransition, implemented with closures.

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Wp.Objects.AsyncEventHook
    ( 

-- * Exported types
    AsyncEventHook(..)                      ,
    IsAsyncEventHook                        ,
    toAsyncEventHook                        ,


 -- * Methods
-- | 
-- 
--  === __Click to display all available methods, including inherited ones__
-- ==== Methods
-- [addInterestFull]("GI.Wp.Objects.InterestEventHook#g:method:addInterestFull"), [bindProperty]("GI.GObject.Objects.Object#g:method:bindProperty"), [bindPropertyFull]("GI.GObject.Objects.Object#g:method:bindPropertyFull"), [finish]("GI.Wp.Objects.EventHook#g:method:finish"), [forceFloating]("GI.GObject.Objects.Object#g:method:forceFloating"), [freezeNotify]("GI.GObject.Objects.Object#g:method:freezeNotify"), [getv]("GI.GObject.Objects.Object#g:method:getv"), [isFloating]("GI.GObject.Objects.Object#g:method:isFloating"), [notify]("GI.GObject.Objects.Object#g:method:notify"), [notifyByPspec]("GI.GObject.Objects.Object#g:method:notifyByPspec"), [ref]("GI.GObject.Objects.Object#g:method:ref"), [refSink]("GI.GObject.Objects.Object#g:method:refSink"), [run]("GI.Wp.Objects.EventHook#g:method:run"), [runDispose]("GI.GObject.Objects.Object#g:method:runDispose"), [runsForEvent]("GI.Wp.Objects.EventHook#g:method:runsForEvent"), [stealData]("GI.GObject.Objects.Object#g:method:stealData"), [stealQdata]("GI.GObject.Objects.Object#g:method:stealQdata"), [thawNotify]("GI.GObject.Objects.Object#g:method:thawNotify"), [unref]("GI.GObject.Objects.Object#g:method:unref"), [watchClosure]("GI.GObject.Objects.Object#g:method:watchClosure").
-- 
-- ==== Getters
-- [getData]("GI.GObject.Objects.Object#g:method:getData"), [getMatchingEventTypes]("GI.Wp.Objects.EventHook#g:method:getMatchingEventTypes"), [getName]("GI.Wp.Objects.EventHook#g:method:getName"), [getProperty]("GI.GObject.Objects.Object#g:method:getProperty"), [getQdata]("GI.GObject.Objects.Object#g:method:getQdata"), [getRunsAfterHooks]("GI.Wp.Objects.EventHook#g:method:getRunsAfterHooks"), [getRunsBeforeHooks]("GI.Wp.Objects.EventHook#g:method:getRunsBeforeHooks").
-- 
-- ==== Setters
-- [setData]("GI.GObject.Objects.Object#g:method:setData"), [setDataFull]("GI.GObject.Objects.Object#g:method:setDataFull"), [setProperty]("GI.GObject.Objects.Object#g:method:setProperty").

#if defined(ENABLE_OVERLOADING)
    ResolveAsyncEventHookMethod             ,
#endif

-- ** new #method:new#

    asyncEventHookNew                       ,




 -- * Properties


-- ** executeStep #attr:executeStep#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    AsyncEventHookExecuteStepPropertyInfo   ,
#endif
#if defined(ENABLE_OVERLOADING)
    asyncEventHookExecuteStep               ,
#endif
    constructAsyncEventHookExecuteStep      ,


-- ** getNextStep #attr:getNextStep#
-- | /No description available in the introspection data./

#if defined(ENABLE_OVERLOADING)
    AsyncEventHookGetNextStepPropertyInfo   ,
#endif
#if defined(ENABLE_OVERLOADING)
    asyncEventHookGetNextStep               ,
#endif
    constructAsyncEventHookGetNextStep      ,




    ) 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.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GArray as B.GArray
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GHashTable as B.GHT
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 Control.Monad.IO.Class as MIO
import qualified Data.Coerce as Coerce
import qualified Data.Text as T
import qualified Data.Kind as DK
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 qualified GHC.Records as R
import qualified Data.Word as DW
import qualified Data.Int as DI
import qualified System.Posix.Types as SPT
import qualified Foreign.C.Types as FCT

-- Workaround for https://gitlab.haskell.org/ghc/ghc/-/issues/23392
#if MIN_VERSION_base(4,18,0)
import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.MainContext as GLib.MainContext
import qualified GI.GLib.Structs.Source as GLib.Source
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Callbacks as Gio.Callbacks
import qualified GI.Gio.Interfaces.AsyncResult as Gio.AsyncResult
import qualified GI.Gio.Objects.Cancellable as Gio.Cancellable
import qualified GI.Wp.Callbacks as Wp.Callbacks
import {-# SOURCE #-} qualified GI.Wp.Enums as Wp.Enums
import {-# SOURCE #-} qualified GI.Wp.Flags as Wp.Flags
import {-# SOURCE #-} qualified GI.Wp.Objects.Conf as Wp.Conf
import {-# SOURCE #-} qualified GI.Wp.Objects.Core as Wp.Core
import {-# SOURCE #-} qualified GI.Wp.Objects.EventDispatcher as Wp.EventDispatcher
import {-# SOURCE #-} qualified GI.Wp.Objects.EventHook as Wp.EventHook
import {-# SOURCE #-} qualified GI.Wp.Objects.InterestEventHook as Wp.InterestEventHook
import {-# SOURCE #-} qualified GI.Wp.Objects.Object as Wp.Object
import {-# SOURCE #-} qualified GI.Wp.Objects.ObjectManager as Wp.ObjectManager
import {-# SOURCE #-} qualified GI.Wp.Structs.Event as Wp.Event
import {-# SOURCE #-} qualified GI.Wp.Structs.Iterator as Wp.Iterator
import {-# SOURCE #-} qualified GI.Wp.Structs.IteratorMethods as Wp.IteratorMethods
import {-# SOURCE #-} qualified GI.Wp.Structs.ObjectInterest as Wp.ObjectInterest
import {-# SOURCE #-} qualified GI.Wp.Structs.Properties as Wp.Properties
import {-# SOURCE #-} qualified GI.Wp.Structs.SpaJson as Wp.SpaJson

#else
import qualified GI.GObject.Objects.Object as GObject.Object
import {-# SOURCE #-} qualified GI.Wp.Objects.EventHook as Wp.EventHook
import {-# SOURCE #-} qualified GI.Wp.Objects.InterestEventHook as Wp.InterestEventHook

#endif

-- | Memory-managed wrapper type.
newtype AsyncEventHook = AsyncEventHook (SP.ManagedPtr AsyncEventHook)
    deriving (Eq)

instance SP.ManagedPtrNewtype AsyncEventHook where
    toManagedPtr (AsyncEventHook p) = p

foreign import ccall "wp_async_event_hook_get_type"
    c_wp_async_event_hook_get_type :: IO B.Types.GType

instance B.Types.TypedObject AsyncEventHook where
    glibType = c_wp_async_event_hook_get_type

instance B.Types.GObject AsyncEventHook

-- | Type class for types which can be safely cast to t'AsyncEventHook', for instance with `toAsyncEventHook`.
class (SP.GObject o, O.IsDescendantOf AsyncEventHook o) => IsAsyncEventHook o
instance (SP.GObject o, O.IsDescendantOf AsyncEventHook o) => IsAsyncEventHook o

instance O.HasParentTypes AsyncEventHook
type instance O.ParentTypes AsyncEventHook = '[Wp.InterestEventHook.InterestEventHook, Wp.EventHook.EventHook, GObject.Object.Object]

-- | Cast to t'AsyncEventHook', for types for which this is known to be safe. For general casts, use 'Data.GI.Base.ManagedPtr.castTo'.
toAsyncEventHook :: (MIO.MonadIO m, IsAsyncEventHook o) => o -> m AsyncEventHook
toAsyncEventHook = MIO.liftIO . B.ManagedPtr.unsafeCastTo AsyncEventHook

-- | Convert t'AsyncEventHook' to and from t'Data.GI.Base.GValue.GValue'. See 'Data.GI.Base.GValue.toGValue' and 'Data.GI.Base.GValue.fromGValue'.
instance B.GValue.IsGValue (Maybe AsyncEventHook) where
    gvalueGType_ = c_wp_async_event_hook_get_type
    gvalueSet_ gv P.Nothing = B.GValue.set_object gv (FP.nullPtr :: FP.Ptr AsyncEventHook)
    gvalueSet_ gv (P.Just obj) = B.ManagedPtr.withManagedPtr obj (B.GValue.set_object gv)
    gvalueGet_ gv = do
        ptr <- B.GValue.get_object gv :: IO (FP.Ptr AsyncEventHook)
        if ptr /= FP.nullPtr
        then P.Just <$> B.ManagedPtr.newObject AsyncEventHook ptr
        else return P.Nothing
        
    

#if defined(ENABLE_OVERLOADING)
type family ResolveAsyncEventHookMethod (t :: Symbol) (o :: DK.Type) :: DK.Type where
    ResolveAsyncEventHookMethod "addInterestFull" o = Wp.InterestEventHook.InterestEventHookAddInterestFullMethodInfo
    ResolveAsyncEventHookMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveAsyncEventHookMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveAsyncEventHookMethod "finish" o = Wp.EventHook.EventHookFinishMethodInfo
    ResolveAsyncEventHookMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveAsyncEventHookMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveAsyncEventHookMethod "getv" o = GObject.Object.ObjectGetvMethodInfo
    ResolveAsyncEventHookMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveAsyncEventHookMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveAsyncEventHookMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveAsyncEventHookMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveAsyncEventHookMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveAsyncEventHookMethod "run" o = Wp.EventHook.EventHookRunMethodInfo
    ResolveAsyncEventHookMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveAsyncEventHookMethod "runsForEvent" o = Wp.EventHook.EventHookRunsForEventMethodInfo
    ResolveAsyncEventHookMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveAsyncEventHookMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveAsyncEventHookMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveAsyncEventHookMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveAsyncEventHookMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveAsyncEventHookMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveAsyncEventHookMethod "getMatchingEventTypes" o = Wp.EventHook.EventHookGetMatchingEventTypesMethodInfo
    ResolveAsyncEventHookMethod "getName" o = Wp.EventHook.EventHookGetNameMethodInfo
    ResolveAsyncEventHookMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveAsyncEventHookMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveAsyncEventHookMethod "getRunsAfterHooks" o = Wp.EventHook.EventHookGetRunsAfterHooksMethodInfo
    ResolveAsyncEventHookMethod "getRunsBeforeHooks" o = Wp.EventHook.EventHookGetRunsBeforeHooksMethodInfo
    ResolveAsyncEventHookMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveAsyncEventHookMethod "setDataFull" o = GObject.Object.ObjectSetDataFullMethodInfo
    ResolveAsyncEventHookMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveAsyncEventHookMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveAsyncEventHookMethod t AsyncEventHook, O.OverloadedMethod info AsyncEventHook p) => OL.IsLabel t (AsyncEventHook -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod @info
#else
    fromLabel _ = O.overloadedMethod @info
#endif

#if MIN_VERSION_base(4,13,0)
instance (info ~ ResolveAsyncEventHookMethod t AsyncEventHook, O.OverloadedMethod info AsyncEventHook p, R.HasField t AsyncEventHook p) => R.HasField t AsyncEventHook p where
    getField = O.overloadedMethod @info

#endif

instance (info ~ ResolveAsyncEventHookMethod t AsyncEventHook, O.OverloadedMethodInfo info AsyncEventHook) => OL.IsLabel t (O.MethodProxy info AsyncEventHook) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.MethodProxy
#else
    fromLabel _ = O.MethodProxy
#endif

#endif

-- VVV Prop "execute-step"
   -- Type: TGClosure Nothing
   -- Flags: [PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

-- | Construct a t'GValueConstruct' with valid value for the “@execute-step@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructAsyncEventHookExecuteStep :: (IsAsyncEventHook o, MIO.MonadIO m) => GClosure a -> m (GValueConstruct o)
constructAsyncEventHookExecuteStep val = MIO.liftIO $ do
    MIO.liftIO $ B.Properties.constructObjectPropertyClosure "execute-step" (P.Just val)

#if defined(ENABLE_OVERLOADING)
data AsyncEventHookExecuteStepPropertyInfo
instance AttrInfo AsyncEventHookExecuteStepPropertyInfo where
    type AttrAllowedOps AsyncEventHookExecuteStepPropertyInfo = '[ 'AttrConstruct, 'AttrClear]
    type AttrBaseTypeConstraint AsyncEventHookExecuteStepPropertyInfo = IsAsyncEventHook
    type AttrSetTypeConstraint AsyncEventHookExecuteStepPropertyInfo = (~) (GClosure ())
    type AttrTransferTypeConstraint AsyncEventHookExecuteStepPropertyInfo = (~) (GClosure ())
    type AttrTransferType AsyncEventHookExecuteStepPropertyInfo = GClosure ()
    type AttrGetType AsyncEventHookExecuteStepPropertyInfo = ()
    type AttrLabel AsyncEventHookExecuteStepPropertyInfo = "execute-step"
    type AttrOrigin AsyncEventHookExecuteStepPropertyInfo = AsyncEventHook
    attrGet = undefined
    attrSet = undefined
    attrPut = undefined
    attrTransfer _ v = do
        return v
    attrConstruct = constructAsyncEventHookExecuteStep
    attrClear = undefined
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.AsyncEventHook.executeStep"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-AsyncEventHook.html#g:attr:executeStep"
        })
#endif

-- VVV Prop "get-next-step"
   -- Type: TGClosure Nothing
   -- Flags: [PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

-- | Construct a t'GValueConstruct' with valid value for the “@get-next-step@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
constructAsyncEventHookGetNextStep :: (IsAsyncEventHook o, MIO.MonadIO m) => GClosure a -> m (GValueConstruct o)
constructAsyncEventHookGetNextStep val = MIO.liftIO $ do
    MIO.liftIO $ B.Properties.constructObjectPropertyClosure "get-next-step" (P.Just val)

#if defined(ENABLE_OVERLOADING)
data AsyncEventHookGetNextStepPropertyInfo
instance AttrInfo AsyncEventHookGetNextStepPropertyInfo where
    type AttrAllowedOps AsyncEventHookGetNextStepPropertyInfo = '[ 'AttrConstruct, 'AttrClear]
    type AttrBaseTypeConstraint AsyncEventHookGetNextStepPropertyInfo = IsAsyncEventHook
    type AttrSetTypeConstraint AsyncEventHookGetNextStepPropertyInfo = (~) (GClosure ())
    type AttrTransferTypeConstraint AsyncEventHookGetNextStepPropertyInfo = (~) (GClosure ())
    type AttrTransferType AsyncEventHookGetNextStepPropertyInfo = GClosure ()
    type AttrGetType AsyncEventHookGetNextStepPropertyInfo = ()
    type AttrLabel AsyncEventHookGetNextStepPropertyInfo = "get-next-step"
    type AttrOrigin AsyncEventHookGetNextStepPropertyInfo = AsyncEventHook
    attrGet = undefined
    attrSet = undefined
    attrPut = undefined
    attrTransfer _ v = do
        return v
    attrConstruct = constructAsyncEventHookGetNextStep
    attrClear = undefined
    dbgAttrInfo = P.Just (O.ResolvedSymbolInfo {
        O.resolvedSymbolName = "GI.Wp.Objects.AsyncEventHook.getNextStep"
        , O.resolvedSymbolURL = "https://hackage.haskell.org/package/gi-wireplumber-0.5.14.2/docs/GI-Wp-Objects-AsyncEventHook.html#g:attr:getNextStep"
        })
#endif

#if defined(ENABLE_OVERLOADING)
instance O.HasAttributeList AsyncEventHook
type instance O.AttributeList AsyncEventHook = AsyncEventHookAttributeList
type AsyncEventHookAttributeList = ('[ '("dispatcher", Wp.EventHook.EventHookDispatcherPropertyInfo), '("executeStep", AsyncEventHookExecuteStepPropertyInfo), '("getNextStep", AsyncEventHookGetNextStepPropertyInfo), '("name", Wp.EventHook.EventHookNamePropertyInfo), '("runsAfterHooks", Wp.EventHook.EventHookRunsAfterHooksPropertyInfo), '("runsBeforeHooks", Wp.EventHook.EventHookRunsBeforeHooksPropertyInfo)] :: [(Symbol, DK.Type)])
#endif

#if defined(ENABLE_OVERLOADING)
asyncEventHookExecuteStep :: AttrLabelProxy "executeStep"
asyncEventHookExecuteStep = AttrLabelProxy

asyncEventHookGetNextStep :: AttrLabelProxy "getNextStep"
asyncEventHookGetNextStep = AttrLabelProxy

#endif

#if defined(ENABLE_OVERLOADING)
type instance O.SignalList AsyncEventHook = AsyncEventHookSignalList
type AsyncEventHookSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo)] :: [(Symbol, DK.Type)])

#endif

-- method AsyncEventHook::new
-- method type : Constructor
-- Args: [ Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , argCType = Just "const gchar*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the name of the hook"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "before"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , argCType = Just "const gchar**"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "an array of hook names that should run after this hook"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "after"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , argCType = Just "const gchar**"
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "an array of hook names that should run before this hook"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "get_next_step"
--           , argType = TGClosure Nothing
--           , argCType = Just "GClosure*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the closure to invoke to get the next step"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "execute_step"
--           , argType = TGClosure Nothing
--           , argCType = Just "GClosure*"
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the closure to invoke to execute the step"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , argCallbackUserData = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "Wp" , name = "AsyncEventHook" })
-- throws : False
-- Skip return : False

foreign import ccall "wp_async_event_hook_new" wp_async_event_hook_new :: 
    CString ->                              -- name : TBasicType TUTF8
    Ptr CString ->                          -- before : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr CString ->                          -- after : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr (GClosure ()) ->                    -- get_next_step : TGClosure Nothing
    Ptr (GClosure ()) ->                    -- execute_step : TGClosure Nothing
    IO (Ptr AsyncEventHook)

-- | Constructs a new async event hook.
asyncEventHookNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@name@/: the name of the hook
    -> Maybe ([T.Text])
    -- ^ /@before@/: an array of hook names that should run after this hook
    -> Maybe ([T.Text])
    -- ^ /@after@/: an array of hook names that should run before this hook
    -> GClosure a
    -- ^ /@getNextStep@/: the closure to invoke to get the next step
    -> GClosure b
    -- ^ /@executeStep@/: the closure to invoke to execute the step
    -> m AsyncEventHook
    -- ^ __Returns:__ a new async event hook
asyncEventHookNew name before after getNextStep executeStep = liftIO $ do
    name' <- textToCString name
    maybeBefore <- case before of
        Nothing -> return FP.nullPtr
        Just jBefore -> do
            jBefore' <- packZeroTerminatedUTF8CArray jBefore
            return jBefore'
    maybeAfter <- case after of
        Nothing -> return FP.nullPtr
        Just jAfter -> do
            jAfter' <- packZeroTerminatedUTF8CArray jAfter
            return jAfter'
    getNextStep' <- unsafeManagedPtrCastPtr getNextStep
    executeStep' <- unsafeManagedPtrCastPtr executeStep
    result <- wp_async_event_hook_new name' maybeBefore maybeAfter getNextStep' executeStep'
    checkUnexpectedReturnNULL "asyncEventHookNew" result
    result' <- (wrapObject AsyncEventHook) result
    touchManagedPtr getNextStep
    touchManagedPtr executeStep
    freeMem name'
    mapZeroTerminatedCArray freeMem maybeBefore
    freeMem maybeBefore
    mapZeroTerminatedCArray freeMem maybeAfter
    freeMem maybeAfter
    return result'

#if defined(ENABLE_OVERLOADING)
#endif


