Package sfc :: Package codegeneration :: Module codeformatting
[hide private]
[frames] | no frames]

Module codeformatting

source code

General utilities for code generation.

Classes [hide private]
  CodeFormatter
Utility class for assembling code strings into a multiline string.
Functions [hide private]
 
indent(text, n=1)
Indent a text n times.
source code
 
row_major_index_string(i, shape)
Constructs an index string for a row major (C type) indexing of a flattened tensor of rank 0, 1, or 2.
source code
 
optimize_floats(code)
Optimize storage size of floating point numbers by removing unneeded trailing zeros.
source code
 
function_signature(name, return_type="void", args=[], virtual=False, inline=False, const=False, classname=None)
Render function signature from arguments.
source code
 
gen_token_code(token, rule=default_code_rule) source code
 
gen_token_prints(tokens, indent=" ") source code
 
gen_symbol_declarations(symbols) source code
 
gen_token_declarations(tokens) source code
 
gen_token_definitions(tokens) source code
 
gen_const_token_definitions(tokens) source code
 
gen_token_assignments(tokens) source code
 
gen_token_additions(tokens) source code
 
gen_switch(argument, cases, default_case=None, braces=False) source code
 
outline(name, tokens, targets, deps) source code
 
test_outliner() source code
 
_test() source code
Variables [hide private]
  indent_size = 4
  default_code_rule = r"double %(symbol)s = %(value)s;"
Function Details [hide private]

indent(text, n=1)

source code 

Indent a text n times. Text can also be a list of strings, or recursively a list of lists of strings.