| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Foreign.Hoppy.Generator.Language.Cpp
Description
Shared portion of the C++ code generator. Usable by binding definitions.
- 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 #
Returns the C++ binding function name for an external name.
classDeleteFnCppName :: Class -> String #
Returns the C++ binding function name of the wrapper for the delete method for a class.
classCastFnCppName :: Class -> Class -> String #
classCastFnCppName fromCls toCls returns the name of the generated C++
function that casts a pointer from fromCls to toCls.
callbackClassName :: Callback -> String #
Returns the name of the outer, copyable class for a callback.
callbackImplClassName :: Callback -> String #
Returns the name of the internal, non-copyable implementation class for a callback.
callbackFnName :: Callback -> String #
Returns the name of the C++ binding function that creates a C++ callback wrapper object from a function pointer to foreign code.
toArgNameAlt :: Int -> String #
Same as toArgName, but with distinct names, with with similarity between
toArgName n and toArgNameAlt n.
exceptionIdArgName :: String #
The C++ variable name to use for the exception ID argument in a gateway function.
exceptionPtrArgName :: String #
The C++ variable name to use for the exception pointer argument in a gateway function.
The C++ variable name to use in a catch statement in a gateway function.
exceptionRethrowFnName :: String #
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.
Constructors
| Chunk | |
Fields | |
runChunkWriter :: Writer [Chunk] a -> (a, String) #
Runs a Chunk writer, combining them with combineChunks to form a single
string.
evalChunkWriter :: Writer [Chunk] a -> a #
Runs a Chunk writer and returns the monad's value.
runChunkWriterT :: Monad m => WriterT [Chunk] m a -> m (a, String) #
Runs a Chunk writer transformer, combining them with combineChunks to
form a single string.
evalChunkWriterT :: Monad m => WriterT [Chunk] m a -> m a #
Runs a Chunk writer transformer and returns the monad's value.
execChunkWriterT :: Monad m => WriterT [Chunk] m a -> m String #
Runs a Chunk writer transformer and returns the written log.
sayIdentifier :: MonadWriter [Chunk] m => Identifier -> m () #
Emits an Identifier.
sayVar :: MonadWriter [Chunk] m => String -> Maybe [String] -> Type -> m () #
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.