Safe Haskell | None |
---|---|
Language | Haskell2010 |
Concrete C++ types. It is possible to represent invalid C++ types with these functions, but we try to catch these and fail cleanly as much as possible.
Synopsis
- constT :: Type -> Type
- voidT :: Type
- ptrT :: Type -> Type
- refT :: Type -> Type
- fnT :: [Type] -> Type -> Type
- fnT' :: [Parameter] -> Type -> Type
- boolT :: Type
- boolT' :: Type
- charT :: Type
- ucharT :: Type
- wcharT :: Type
- shortT :: Type
- ushortT :: Type
- intT :: Type
- intT' :: Type
- uintT :: Type
- longT :: Type
- ulongT :: Type
- llongT :: Type
- ullongT :: Type
- floatT :: Type
- floatT' :: Type
- doubleT :: Type
- doubleT' :: Type
- int8T :: Type
- int16T :: Type
- int32T :: Type
- int64T :: Type
- word8T :: Type
- word16T :: Type
- word32T :: Type
- word64T :: Type
- ptrdiffT :: Type
- sizeT :: Type
- ssizeT :: Type
- makeNumericType :: String -> Reqs -> Generator HsType -> Maybe (Generator HsType) -> ConversionMethod (Generator ()) -> ConversionMethod (Generator ()) -> Type
- convertByCoercingIntegral :: ConversionMethod (Generator ())
- convertByCoercingFloating :: ConversionMethod (Generator ())
- manualT :: ConversionSpec -> Type
- callbackT :: Callback -> Type
- enumT :: CppEnum -> Type
- objT :: Class -> Type
- objToHeapT :: Class -> Type
- toGcT :: Type -> Type
Qualifiers
Primtive types
Numeric types
C++ bool
, Haskell Bool
.
C++ has sizeof(bool) == 1, whereas Haskell can > 1, so we have to convert.
Custom numeric types
:: String | The name of the C++ type. |
-> Reqs | Includes necessary to use the C++ type. |
-> Generator HsType | Generator for rendering the Haskell type to be used, along with any
required imports. See |
-> Maybe (Generator HsType) | If there is a Haskell type distinct from the previous argument to be
used for passing over the FFI boundary, then provide it here. See
|
-> ConversionMethod (Generator ()) | Method to use to convert a Haskell value to a value to be passed over
the FFI. See |
-> ConversionMethod (Generator ()) | Method to use to convert a value received over the FFI into a Haskell
value. See |
-> Type |
Builds a new numeric type definition.
For convenience, convertByCoercingIntegral
and convertByCoercingFloating
may be used as conversion methods, for both ConversionMethod
arguments this
function takes.
convertByCoercingIntegral :: ConversionMethod (Generator ()) Source #
Conversion method for passing a numeric values to and from Haskell by using
Foreign.Hoppy.Runtime.coerceIntegral
.
convertByCoercingFloating :: ConversionMethod (Generator ()) Source #
Conversion method for passing a numeric values to and from Haskell by using
realToFrac
.
Complex types
manualT :: ConversionSpec -> Type Source #
Constructs a type from a specification of how to convert values.
objToHeapT :: Class -> Type Source #
A special case of objT
that is only allowed when passing objects from
C++ to a foreign language. Rather than looking at the object's
ClassConversion
, the object will be
copied to the heap, and a pointer to the heap object will be passed. The
object must be copy-constructable.
The foreign language owns the pointer, even for callback arguments.
toGcT :: Type -> Type Source #
This type transfers ownership of the object to the foreign language's garbage collector, and results in a managed pointer in the foreign language. This may only be used in one of the forms below, when passing data from C++ to a foreign language (i.e. in a C++ function return type or in a callback argument). In the first case, the temporary object is copied to the heap, and the result is a managed pointer to the heap object instead of the temporary.