hoppy-generator-0.7.1: C++ FFI generator - Code generator

Safe HaskellNone
LanguageHaskell2010

Foreign.Hoppy.Generator.Spec.Callback

Contents

Description

Interface for defining foreign language callbacks.

Synopsis

Data type

data Callback Source #

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 # 
Instance details

Defined in Foreign.Hoppy.Generator.Spec.Callback

Show Callback Source # 
Instance details

Defined in Foreign.Hoppy.Generator.Spec.Callback

HasAddendum Callback Source # 
Instance details

Defined in Foreign.Hoppy.Generator.Spec.Callback

Exportable Callback Source # 
Instance details

Defined in Foreign.Hoppy.Generator.Spec.Callback

HasExtNames Callback Source # 
Instance details

Defined in Foreign.Hoppy.Generator.Spec.Callback

HasReqs Callback Source # 
Instance details

Defined in Foreign.Hoppy.Generator.Spec.Callback

callbackT :: Callback -> Type Source #

Constructs a type value for a callback.

Construction

makeCallback Source #

Arguments

:: 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.