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

Safe HaskellNone
LanguageHaskell2010

Foreign.Hoppy.Generator.Types

Contents

Description

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

Qualifiers

constT :: Type -> Type Source #

A const version of another type.

Primtive types

voidT :: Type Source #

C++ void, Haskell ().

ptrT :: Type -> Type Source #

A pointer to another type.

refT :: Type -> Type Source #

A reference to another type.

fnT :: [Type] -> Type -> Type Source #

Numeric types

boolT :: Type Source #

C++ bool, Haskell Bool.

C++ has sizeof(bool) == 1, whereas Haskell can > 1, so we have to convert.

boolT' :: Type Source #

C++ bool, Haskell CBool.

charT :: Type Source #

C++ char, Haskell CChar.

ucharT :: Type Source #

C++ unsigned char, Haskell CUChar.

wcharT :: Type Source #

C++ wchar_t, Haskell CWchar.

shortT :: Type Source #

C++ short int, Haskell CShort.

ushortT :: Type Source #

C++ unsigned short int, Haskell CUShort.

intT :: Type Source #

C++ int, Haskell Int. See also intT'.

intT' :: Type Source #

C++ int, Haskell CInt. See also intT.

uintT :: Type Source #

C++ unsigned int, Haskell CUInt.

longT :: Type Source #

C++ long int, Haskell CLong.

ulongT :: Type Source #

C++ unsigned long int, Haskell CULong.

llongT :: Type Source #

C++ long long int, Haskell CLLong.

ullongT :: Type Source #

C++ unsigned long long int, Haskell CULLong.

floatT :: Type Source #

C++ float, Haskell Float. See also floatT'.

floatT' :: Type Source #

C++ float, Haskell CFloat. See also floatT.

doubleT :: Type Source #

C++ double, Haskell Double. See also doubleT'.

doubleT' :: Type Source #

C++ double, Haskell CDouble. See also doubleT.

int8T :: Type Source #

C++ int8_t, Haskell Int8.

int16T :: Type Source #

C++ int16_t, Haskell Int16.

int32T :: Type Source #

C++ int32_t, Haskell Int32.

int64T :: Type Source #

C++ int64_t, Haskell Int64.

word8T :: Type Source #

C++ uint8_t, Haskell Word8.

word16T :: Type Source #

C++ uint16_t, Haskell Word16.

word32T :: Type Source #

C++ uint32_t, Haskell Word32.

word64T :: Type Source #

C++ uint64_t, Haskell Word64.

ptrdiffT :: Type Source #

C++ ptrdiff_t, Haskell CPtrdiff.

sizeT :: Type Source #

C++ size_t, Haskell CSize.

ssizeT :: Type Source #

C++ ssize_t, Haskell CSsize.

Custom numeric types

makeNumericType Source #

Arguments

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

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

-> ConversionMethod (Generator ())

Method to use to convert a Haskell value to a value to be passed over the FFI. See conversionSpecHaskellToCppFn.

-> ConversionMethod (Generator ())

Method to use to convert a value received over the FFI into a Haskell value. See conversionSpecHaskellFromCppFn.

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

objT :: Class -> Type Source #

An instance of a class. When used in a parameter or return type and not wrapped in a ptrT or refT, this is a by-value object.

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.