Unifex v0.1.0 Unifex.NativeCodeGenerator View Source
Module responsible for C code genearation based on Unifex specs
Link to this section Summary
Link to this section Types
Link to this section Functions
Link to this function
gen(content, flags)
View Source
gen(String.Chars.t() | [String.Chars.t()], charlist()) :: String.t() | [String.t()]
Helper for generating code. Uses sigil_g/2
underneath.
It supports all the flags supported by sigil_g/2
and the following ones:
j(joiner)
- joins list of strings usingjoiner
- n - alias for
j(\n)
If passed a list and flags supported by sigil_g/2
, each flag will be executed
on each element of the list, until the list is joined by using j
or n
flag.
Link to this function
generate_code(name, specs)
View Source
generate_code(name :: String.t(), specs :: Unifex.SpecsParser.parsed_specs_t()) :: {code_t(), code_t()}
Generates C boilerplate for a native code based on a spec
Takes the name for the .c
and .h
files and the specs
parsed by Unifex.SpecsParser.parse_specs()/1
and generates code of header
and source code, returning them in a tuple of 2 strings.
Sigil used for indentation of generated code.
By itself it does nothing, but has very useful flags:
r
trims trailing whitespaces of each line and removes subsequent empty linest
trims the stringi
indents all but the first line. Helpful when used inside string interpolation that already has been indentedI
indents every line of string