module Foreign.Hoppy.Generator.Types (
constT,
voidT,
ptrT,
refT,
fnT,
fnT',
boolT,
boolT',
charT,
ucharT,
wcharT,
shortT,
ushortT,
intT,
intT',
uintT,
longT,
ulongT,
llongT,
ullongT,
floatT,
floatT',
doubleT,
doubleT',
int8T,
int16T,
int32T,
int64T,
word8T,
word16T,
word32T,
word64T,
ptrdiffT,
sizeT,
ssizeT,
makeNumericType,
convertByCoercingIntegral,
convertByCoercingFloating,
manualT,
callbackT,
enumT,
objT,
objToHeapT,
toGcT,
) where
import {-# SOURCE #-} qualified Foreign.Hoppy.Generator.Language.Haskell as LH
import {-# SOURCE #-} Foreign.Hoppy.Generator.Spec.Callback (callbackT)
import {-# SOURCE #-} Foreign.Hoppy.Generator.Spec.Class (Class)
import {-# SOURCE #-} Foreign.Hoppy.Generator.Spec.Enum (enumT)
import {-# SOURCE #-} Foreign.Hoppy.Generator.Spec.Function (fnT, fnT')
import Foreign.Hoppy.Generator.Spec.Base
import Language.Haskell.Syntax (
HsName (HsIdent),
HsQName (UnQual),
HsType (HsTyCon),
)
voidT :: Type
voidT :: Type
voidT = Type
Internal_TVoid
boolT :: Type
boolT :: Type
boolT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"bool" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForPrelude
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyP.Bool")
(Generator HsType -> Maybe (Generator HsType)
forall a. a -> Maybe a
Just (Generator HsType -> Maybe (Generator HsType))
-> Generator HsType -> Maybe (Generator HsType)
forall a b. (a -> b) -> a -> b
$ do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CBool")
(Generator () -> ConversionMethod (Generator ())
forall c. c -> ConversionMethod c
CustomConversion (Generator () -> ConversionMethod (Generator ()))
-> Generator () -> ConversionMethod (Generator ())
forall a b. (a -> b) -> a -> b
$ do
HsImportSet -> Generator ()
LH.addImports (HsImportSet -> Generator ()) -> HsImportSet -> Generator ()
forall a b. (a -> b) -> a -> b
$ [HsImportSet] -> HsImportSet
forall a. Monoid a => [a] -> a
mconcat [String -> String -> HsImportSet
hsImport1 String
"Prelude" String
"(.)",
HsImportSet
hsImportForPrelude]
String -> Generator ()
LH.sayLn String
"\\x -> HoppyP.return $ if x then 1 else 0")
(Generator () -> ConversionMethod (Generator ())
forall c. c -> ConversionMethod c
CustomConversion (Generator () -> ConversionMethod (Generator ()))
-> Generator () -> ConversionMethod (Generator ())
forall a b. (a -> b) -> a -> b
$ do
HsImportSet -> Generator ()
LH.addImports (HsImportSet -> Generator ()) -> HsImportSet -> Generator ()
forall a b. (a -> b) -> a -> b
$ [HsImportSet] -> HsImportSet
forall a. Monoid a => [a] -> a
mconcat [String -> [String] -> HsImportSet
hsImports String
"Prelude" [String
"(.)", String
"(/=)"],
HsImportSet
hsImportForPrelude]
String -> Generator ()
LH.sayLn String
"(HoppyP.return . (/= 0))")
boolT' :: Type
boolT' :: Type
boolT' =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"bool" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CBool")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
charT :: Type
charT :: Type
charT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"char" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CChar")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
ucharT :: Type
ucharT :: Type
ucharT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"unsigned char" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CUChar")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
wcharT :: Type
wcharT :: Type
wcharT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"wchar_t" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CWchar")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
shortT :: Type
shortT :: Type
shortT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"short" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CShort")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
ushortT :: Type
ushortT :: Type
ushortT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"unsigned short" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CUShort")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
intT :: Type
intT :: Type
intT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"int" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForPrelude
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyP.Int")
(Generator HsType -> Maybe (Generator HsType)
forall a. a -> Maybe a
Just (Generator HsType -> Maybe (Generator HsType))
-> Generator HsType -> Maybe (Generator HsType)
forall a b. (a -> b) -> a -> b
$ do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CInt")
ConversionMethod (Generator ())
convertByCoercingIntegral ConversionMethod (Generator ())
convertByCoercingIntegral
intT' :: Type
intT' :: Type
intT' =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"int" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CInt")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
uintT :: Type
uintT :: Type
uintT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"unsigned int" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CUInt")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
longT :: Type
longT :: Type
longT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"long" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CLong")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
ulongT :: Type
ulongT :: Type
ulongT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"unsigned long" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CULong")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
llongT :: Type
llongT :: Type
llongT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"long long" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CLLong")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
ullongT :: Type
ullongT :: Type
ullongT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"unsigned long long" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CULLong")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
floatT :: Type
floatT :: Type
floatT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"float" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForPrelude
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyP.Float")
(Generator HsType -> Maybe (Generator HsType)
forall a. a -> Maybe a
Just (Generator HsType -> Maybe (Generator HsType))
-> Generator HsType -> Maybe (Generator HsType)
forall a b. (a -> b) -> a -> b
$ do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CFloat")
ConversionMethod (Generator ())
convertByCoercingFloating ConversionMethod (Generator ())
convertByCoercingFloating
floatT' :: Type
floatT' :: Type
floatT' =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"float" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"Foreign.C.CFloat")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
doubleT :: Type
doubleT :: Type
doubleT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"double" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForPrelude
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyP.Double")
(Generator HsType -> Maybe (Generator HsType)
forall a. a -> Maybe a
Just (Generator HsType -> Maybe (Generator HsType))
-> Generator HsType -> Maybe (Generator HsType)
forall a b. (a -> b) -> a -> b
$ do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CDouble")
ConversionMethod (Generator ())
convertByCoercingFloating ConversionMethod (Generator ())
convertByCoercingFloating
doubleT' :: Type
doubleT' :: Type
doubleT' =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"double" Reqs
forall a. Monoid a => a
mempty
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"Foreign.C.CDouble")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
int8T :: Type
int8T :: Type
int8T =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"int8_t" (Include -> Reqs
reqInclude (Include -> Reqs) -> Include -> Reqs
forall a b. (a -> b) -> a -> b
$ String -> Include
includeStd String
"cstdint")
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForInt
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyDI.Int8")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
int16T :: Type
int16T :: Type
int16T =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"int16_t" (Include -> Reqs
reqInclude (Include -> Reqs) -> Include -> Reqs
forall a b. (a -> b) -> a -> b
$ String -> Include
includeStd String
"cstdint")
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForInt
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyDI.Int16")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
int32T :: Type
int32T :: Type
int32T =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"int32_t" (Include -> Reqs
reqInclude (Include -> Reqs) -> Include -> Reqs
forall a b. (a -> b) -> a -> b
$ String -> Include
includeStd String
"cstdint")
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForInt
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyDI.Int32")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
int64T :: Type
int64T :: Type
int64T =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"int64_t" (Include -> Reqs
reqInclude (Include -> Reqs) -> Include -> Reqs
forall a b. (a -> b) -> a -> b
$ String -> Include
includeStd String
"cstdint")
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForInt
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyDI.Int64")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
word8T :: Type
word8T :: Type
word8T =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"uint8_t" (Include -> Reqs
reqInclude (Include -> Reqs) -> Include -> Reqs
forall a b. (a -> b) -> a -> b
$ String -> Include
includeStd String
"cstdint")
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForWord
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyDW.Word8")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
word16T :: Type
word16T :: Type
word16T =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"uint16_t" (Include -> Reqs
reqInclude (Include -> Reqs) -> Include -> Reqs
forall a b. (a -> b) -> a -> b
$ String -> Include
includeStd String
"cstdint")
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForWord
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyDW.Word16")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
word32T :: Type
word32T :: Type
word32T =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"uint32_t" (Include -> Reqs
reqInclude (Include -> Reqs) -> Include -> Reqs
forall a b. (a -> b) -> a -> b
$ String -> Include
includeStd String
"cstdint")
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForWord
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyDW.Word32")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
word64T :: Type
word64T :: Type
word64T =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"uint64_t" (Include -> Reqs
reqInclude (Include -> Reqs) -> Include -> Reqs
forall a b. (a -> b) -> a -> b
$ String -> Include
includeStd String
"cstdint")
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForWord
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyDW.Word64")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
ptrdiffT :: Type
ptrdiffT :: Type
ptrdiffT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"ptrdiff_t" (Include -> Reqs
reqInclude (Include -> Reqs) -> Include -> Reqs
forall a b. (a -> b) -> a -> b
$ String -> Include
includeStd String
"cstddef")
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CPtrdiff")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
sizeT :: Type
sizeT :: Type
sizeT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"size_t" (Include -> Reqs
reqInclude (Include -> Reqs) -> Include -> Reqs
forall a b. (a -> b) -> a -> b
$ String -> Include
includeStd String
"cstddef")
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForForeignC
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppyFC.CSize")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
ssizeT :: Type
ssizeT :: Type
ssizeT =
String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
"ssize_t" (Include -> Reqs
reqInclude (Include -> Reqs) -> Include -> Reqs
forall a b. (a -> b) -> a -> b
$ String -> Include
includeStd String
"cstddef")
(do HsImportSet -> Generator ()
LH.addImports HsImportSet
hsImportForSystemPosixTypes
HsType -> Generator HsType
forall (m :: * -> *) a. Monad m => a -> m a
return (HsType -> Generator HsType) -> HsType -> Generator HsType
forall a b. (a -> b) -> a -> b
$ HsQName -> HsType
HsTyCon (HsQName -> HsType) -> HsQName -> HsType
forall a b. (a -> b) -> a -> b
$ HsName -> HsQName
UnQual (HsName -> HsQName) -> HsName -> HsQName
forall a b. (a -> b) -> a -> b
$ String -> HsName
HsIdent String
"HoppySPT.CSsize")
Maybe (Generator HsType)
forall a. Maybe a
Nothing ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible ConversionMethod (Generator ())
forall c. ConversionMethod c
BinaryCompatible
makeNumericType ::
String
-> Reqs
-> LH.Generator HsType
-> Maybe (LH.Generator HsType)
-> ConversionMethod (LH.Generator ())
-> ConversionMethod (LH.Generator ())
-> Type
makeNumericType :: String
-> Reqs
-> Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> Type
makeNumericType String
cppName Reqs
cppReqs Generator HsType
hsTypeGen Maybe (Generator HsType)
hsCTypeGen ConversionMethod (Generator ())
convertToCpp ConversionMethod (Generator ())
convertFromCpp =
ConversionSpec -> Type
Internal_TManual ConversionSpec
spec
where spec :: ConversionSpec
spec =
(String -> ConversionSpecCpp -> ConversionSpec
makeConversionSpec String
cppName (ConversionSpecCpp -> ConversionSpec)
-> ConversionSpecCpp -> ConversionSpec
forall a b. (a -> b) -> a -> b
$ String -> Generator Reqs -> ConversionSpecCpp
makeConversionSpecCpp String
cppName (Generator Reqs -> ConversionSpecCpp)
-> Generator Reqs -> ConversionSpecCpp
forall a b. (a -> b) -> a -> b
$ Reqs -> Generator Reqs
forall (m :: * -> *) a. Monad m => a -> m a
return Reqs
cppReqs)
{ conversionSpecHaskell :: Maybe ConversionSpecHaskell
conversionSpecHaskell =
ConversionSpecHaskell -> Maybe ConversionSpecHaskell
forall a. a -> Maybe a
Just (ConversionSpecHaskell -> Maybe ConversionSpecHaskell)
-> ConversionSpecHaskell -> Maybe ConversionSpecHaskell
forall a b. (a -> b) -> a -> b
$ Generator HsType
-> Maybe (Generator HsType)
-> ConversionMethod (Generator ())
-> ConversionMethod (Generator ())
-> ConversionSpecHaskell
makeConversionSpecHaskell
Generator HsType
hsTypeGen
Maybe (Generator HsType)
hsCTypeGen
ConversionMethod (Generator ())
convertToCpp
ConversionMethod (Generator ())
convertFromCpp
}
convertByCoercingIntegral :: ConversionMethod (LH.Generator ())
convertByCoercingIntegral :: ConversionMethod (Generator ())
convertByCoercingIntegral = Generator () -> ConversionMethod (Generator ())
forall c. c -> ConversionMethod c
CustomConversion (Generator () -> ConversionMethod (Generator ()))
-> Generator () -> ConversionMethod (Generator ())
forall a b. (a -> b) -> a -> b
$ do
HsImportSet -> Generator ()
LH.addImports (HsImportSet -> Generator ()) -> HsImportSet -> Generator ()
forall a b. (a -> b) -> a -> b
$ [HsImportSet] -> HsImportSet
forall a. Monoid a => [a] -> a
mconcat [String -> String -> HsImportSet
hsImport1 String
"Prelude" String
"(.)",
HsImportSet
hsImportForPrelude,
HsImportSet
hsImportForRuntime]
String -> Generator ()
LH.sayLn String
"HoppyP.return . HoppyFHR.coerceIntegral"
convertByCoercingFloating :: ConversionMethod (LH.Generator ())
convertByCoercingFloating :: ConversionMethod (Generator ())
convertByCoercingFloating = Generator () -> ConversionMethod (Generator ())
forall c. c -> ConversionMethod c
CustomConversion (Generator () -> ConversionMethod (Generator ()))
-> Generator () -> ConversionMethod (Generator ())
forall a b. (a -> b) -> a -> b
$ do
HsImportSet -> Generator ()
LH.addImports (HsImportSet -> Generator ()) -> HsImportSet -> Generator ()
forall a b. (a -> b) -> a -> b
$ [HsImportSet] -> HsImportSet
forall a. Monoid a => [a] -> a
mconcat [String -> String -> HsImportSet
hsImport1 String
"Prelude" String
"(.)",
HsImportSet
hsImportForPrelude]
String -> Generator ()
LH.sayLn String
"HoppyP.return . HoppyP.realToFrac"
ptrT :: Type -> Type
ptrT :: Type -> Type
ptrT = Type -> Type
Internal_TPtr
refT :: Type -> Type
refT :: Type -> Type
refT = Type -> Type
Internal_TRef
objT :: Class -> Type
objT :: Class -> Type
objT = Class -> Type
Internal_TObj
objToHeapT :: Class -> Type
objToHeapT :: Class -> Type
objToHeapT = Class -> Type
Internal_TObjToHeap
toGcT :: Type -> Type
toGcT :: Type -> Type
toGcT = Type -> Type
Internal_TToGc
manualT :: ConversionSpec -> Type
manualT :: ConversionSpec -> Type
manualT = ConversionSpec -> Type
Internal_TManual
constT :: Type -> Type
constT :: Type -> Type
constT = Type -> Type
Internal_TConst