copilot-0.26: A stream DSL for writing embedded C monitors.

Language.Copilot.AdHocC

Description

Helper functions for writing free-form C code.

Synopsis

Documentation

varDecl :: Type -> [String] -> StringSource

Takes a type and a list of variable names and declares them.

arrDecl :: Type -> [(String, Int)] -> StringSource

Takes a type and a list of array names and their sizes declares them.

varInit :: Show a => Type -> String -> a -> StringSource

Takes a type and a variable and initializes it. It is YOUR responsibility to ensure that val is of type t.

arrayInit :: Show a => Type -> String -> [a] -> StringSource

Takes a type and an array and initializes it. It is YOUR responsibility to ensure that vals is of type t.

funcDecl :: Maybe Type -> String -> [Type] -> StringSource

Declare function prototypes, given a return type, a function name, and a | list of argument types. Use Nothing for a return type of void.

includeBracket :: String -> StringSource

Add an include of a library

includeQuote :: String -> StringSource

Add an include of a header file

printfNewline :: String -> [String] -> StringSource

printf, with and without a newline (nl) character.