Safe Haskell | None |
---|---|
Language | Haskell2010 |
Shared portion of the C++ code generator. Usable by binding definitions.
Synopsis
- externalNameToCpp :: ExtName -> String
- classDeleteFnCppName :: Class -> String
- classCastFnCppName :: Class -> Class -> String
- callbackClassName :: Callback -> String
- callbackImplClassName :: Callback -> String
- callbackFnName :: Callback -> String
- toArgName :: Int -> String
- toArgNameAlt :: Int -> String
- exceptionIdArgName :: String
- exceptionPtrArgName :: String
- exceptionVarName :: String
- exceptionRethrowFnName :: String
- newtype Chunk = Chunk {}
- runChunkWriter :: Writer [Chunk] a -> (a, String)
- evalChunkWriter :: Writer [Chunk] a -> a
- execChunkWriter :: Writer [Chunk] a -> String
- runChunkWriterT :: Monad m => WriterT [Chunk] m a -> m (a, String)
- evalChunkWriterT :: Monad m => WriterT [Chunk] m a -> m a
- execChunkWriterT :: Monad m => WriterT [Chunk] m a -> m String
- say :: MonadWriter [Chunk] m => String -> m ()
- says :: MonadWriter [Chunk] m => [String] -> m ()
- sayIdentifier :: MonadWriter [Chunk] m => Identifier -> m ()
- sayVar :: MonadWriter [Chunk] m => String -> Maybe [String] -> Type -> m ()
- sayType :: MonadWriter [Chunk] m => Maybe [String] -> Type -> m ()
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++.
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.
runChunkWriter :: Writer [Chunk] a -> (a, String) Source #
Runs a Chunk
writer, combining them with combineChunks
to form a single
string.
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.
sayIdentifier :: MonadWriter [Chunk] m => Identifier -> m () Source #
Emits an Identifier
.
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.