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

Safe HaskellNone
LanguageHaskell2010

Foreign.Hoppy.Generator.Language.Cpp

Description

Shared portion of the C++ code generator. Usable by binding definitions.

Synopsis

Documentation

externalNameToCpp :: ExtName -> String Source #

Returns the C++ binding function name for an external name.

classDeleteFnCppName :: Class -> String Source #

Returns the C++ binding function name of the wrapper for the delete method for a class.

classCastFnCppName :: Class -> Class -> String Source #

classCastFnCppName fromCls toCls returns the name of the generated C++ function that casts a pointer from fromCls to toCls.

callbackClassName :: Callback -> String Source #

Returns the name of the outer, copyable class for a callback.

callbackImplClassName :: Callback -> String Source #

Returns the name of the internal, non-copyable implementation 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.

toArgName :: Int -> String Source #

Returns a distinct argument variable name for each nonnegative number.

toArgNameAlt :: Int -> String Source #

Same as toArgName, but with distinct names, with with similarity between toArgName n and toArgNameAlt n.

exceptionIdArgName :: String Source #

The C++ variable name to use for the exception ID argument in a gateway function.

exceptionPtrArgName :: String Source #

The C++ variable name to use for the exception pointer argument in a gateway function.

exceptionVarName :: String Source #

The C++ variable name to use in a catch statement in a gateway function.

exceptionRethrowFnName :: String Source #

The name of the C++ function that receives an exception from a foreign language and throws it in C++.

newtype Chunk Source #

A chunk is a string that contains an arbitrary portion of C++ code. The only requirement is that chunk boundaries are also C++ token boundaries, because the generator monad automates the process of inserting whitespace between chunk boundaries where necessary.

Constructors

Chunk 

runChunkWriter :: Writer [Chunk] a -> (a, String) Source #

Runs a Chunk writer, combining them with combineChunks to form a single string.

evalChunkWriter :: Writer [Chunk] a -> a Source #

Runs a Chunk writer and returns the monad's value.

execChunkWriter :: Writer [Chunk] a -> String Source #

Runs a Chunk writer and returns the written log.

runChunkWriterT :: Monad m => WriterT [Chunk] m a -> m (a, String) Source #

Runs a Chunk writer transformer, combining them with combineChunks to form a single string.

evalChunkWriterT :: Monad m => WriterT [Chunk] m a -> m a Source #

Runs a Chunk writer transformer and returns the monad's value.

execChunkWriterT :: Monad m => WriterT [Chunk] m a -> m String Source #

Runs a Chunk writer transformer and returns the written log.

say :: MonadWriter [Chunk] m => String -> m () Source #

Emits a single Chunk.

says :: MonadWriter [Chunk] m => [String] -> m () Source #

Emits a Chunk for each string in a list.

sayVar :: MonadWriter [Chunk] m => String -> Maybe [String] -> Type -> m () Source #

sayVar name maybeParamNames t speaks a variable declaration of the form <type> <name>, where <name> is the given name, and <type> is rendered by giving maybeParamNames and t to sayType.

This function is useful for generating variable declarations, declarations with assignments, and function prototypes and definitions.

sayType :: MonadWriter [Chunk] m => Maybe [String] -> Type -> m () Source #

sayType maybeParamNames t renders t in C++ syntax. If t is a fnT, then maybeParamNames will provide variable names for parameters, if present.