Safe Haskell | None |
---|---|
Language | Haskell2010 |
Interface for defining foreign language callbacks.
Synopsis
- data Callback
- callbackT :: Callback -> Type
- makeCallback :: IsParameter p => ExtName -> [p] -> Type -> Callback
- callbackExtName :: Callback -> ExtName
- callbackParams :: Callback -> [Parameter]
- callbackReturn :: Callback -> Type
- callbackReqs :: Callback -> Reqs
- callbackAddendum :: Callback -> Addendum
- callbackThrows :: Callback -> Maybe Bool
- callbackSetThrows :: Bool -> Callback -> Callback
- cppCallbackToTFn :: Callback -> Generator Type
- callbackClassName :: Callback -> String
- callbackImplClassName :: Callback -> String
- callbackFnName :: Callback -> String
- hsCallbackToTFn :: HsTypeSide -> Callback -> Generator Type
- toHsCallbackCtorName :: Callback -> Generator String
- toHsCallbackCtorName' :: Callback -> String
- toHsCallbackNewFunPtrFnName :: Callback -> Generator String
- toHsCallbackNewFunPtrFnName' :: Callback -> String
Data type
A non-C++ function that can be invoked via a C++ functor or function pointer.
Use this data type's HasReqs
instance to add extra requirements, however
manually adding requirements for parameter and return types is not necessary.
Instances
Eq Callback Source # | |
Show Callback Source # | |
HasAddendum Callback Source # | |
Defined in Foreign.Hoppy.Generator.Spec.Callback | |
Exportable Callback Source # | |
Defined in Foreign.Hoppy.Generator.Spec.Callback toExport :: Callback -> Export Source # castExport :: (Typeable Callback, Exportable b, Typeable b) => Callback -> Maybe b Source # sayExportCpp :: SayExportMode -> Callback -> Generator () Source # sayExportHaskell :: SayExportMode -> Callback -> Generator () Source # | |
HasExtNames Callback Source # | |
Defined in Foreign.Hoppy.Generator.Spec.Callback getPrimaryExtName :: Callback -> ExtName Source # getNestedExtNames :: Callback -> [ExtName] Source # | |
HasReqs Callback Source # | |
Construction
:: IsParameter p | |
=> ExtName | |
-> [p] | Parameter types. |
-> Type | Return type. |
-> Callback |
Creates a binding for constructing callbacks into foreign code.
Properties
callbackExtName :: Callback -> ExtName Source #
The callback's external name.
callbackParams :: Callback -> [Parameter] Source #
The callback's parameters.
callbackReturn :: Callback -> Type Source #
The callback's return type.
callbackReqs :: Callback -> Reqs Source #
Extra requirements for the callback.
callbackAddendum :: Callback -> Addendum Source #
The callback's addendum.
Exceptions
callbackThrows :: Callback -> Maybe Bool Source #
Whether the callback supports throwing C++ exceptions from Haskell into
C++ during its execution. When absent, the value is inherited from
moduleCallbacksThrow
and interfaceCallbacksThrow
.
callbackSetThrows :: Bool -> Callback -> Callback Source #
Sets whether a callback supports handling thrown C++ exceptions and passing them into C++.
C++ generator
cppCallbackToTFn :: Callback -> Generator Type Source #
Constructs the function type for a callback. A callback that throws has additional parameters.
Keep this in sync with hsCallbackToTFn
.
Names
callbackClassName :: Callback -> String Source #
Returns the name of the outer, copyable C++ class for a callback.
callbackImplClassName :: Callback -> String Source #
Returns the name of the internal, non-copyable implementation C++ class for a callback.
callbackFnName :: Callback -> String Source #
Returns the name of the C++ binding function that creates a C++ callback wrapper object from a function pointer to foreign code.
Haskell generator
hsCallbackToTFn :: HsTypeSide -> Callback -> Generator Type Source #
Constructs the function type for a callback. For Haskell, the type depends on the side; the C++ side has additional parameters.
Keep this in sync with cppCallbackToTFn
.
Names
toHsCallbackCtorName :: Callback -> Generator String Source #
The name of the function that takes a Haskell function and wraps it in a callback object. This is internal to the binding; normal users can pass Haskell functions to be used as callbacks inplicitly.
toHsCallbackCtorName' :: Callback -> String Source #
Pure version of toHsCallbackCtorName
that doesn't create a qualified
name.
toHsCallbackNewFunPtrFnName :: Callback -> Generator String Source #
The name of the function that takes a Haskell function with Haskell-side
types and wraps it in a FunPtr
that does appropriate
conversions to and from C-side types.
toHsCallbackNewFunPtrFnName' :: Callback -> String Source #
Pure version of toHsCallbackNewFunPtrFnName
that doesn't create a qualified
name.