-
Notifications
You must be signed in to change notification settings - Fork 0
WFC options and opimizations
There are several options to modify different aspects of how WFC
generates the code for a .wfc
file. These options can be categorized
as follows:
- general optimization flags
- target specific flags
- general generation options
- implementaton options
- field specific settings
- function naming
- documentation options
WFC provides several options to determine the way the code is generated.
The general optimization switch -O
provides following options:
-
-Or
: this is the default, which optimizes the code for readability for manual code review -
-Os
: optimize for low ROM and RAM consumption -
-O2
: optimize for speed
-
endian
: target endian to use (unknown,little,big) -
VarIntBits
: data type for varint_t (default: 64)
The following options are provided for project integration purposes.
-
codelib
: add code library file or directory -
declare
: add custom declaration to the generated .h file -
asserts
: include asserts -
libfile
: basename of files for extern library functions -
debug
: generate debugging/logging interface
WFC allows certain implementation variants for the generated code. Therefore, the following options are available:
-
BaseClass
: name of Base Class for common virtual interface -
namespace
: namespace of generated code (default: ) -
SubClasses
: generate nested classes instead of mangled names -
UnknownField
: skip/assert unknown fields while parsing (default: skip) -
ErrorHandling
: error handling concept: assert, cancel (default), throw -
bytestype
: implementation type for 'bytes':std::string
(default), -
stringtype
: implementation type forstring
:std::string
(default), C(const char *)
, -
header
: #include header file <file.h> or "file.h" in generated .h file -
enummap
: use std::map to resolve enum names -
enumnames
: allow use of enum names in setByName functions -
genlib
: generate wfc library -
gnux
: allow GNU extensions in generated code -fid0 : allow use of field ID 0 (should only be used for types other than variable length integers) -
withEqual
: generate operator == for object comparison -
withUnequal
: generate operator != for object comparison -
SortMembers
: sort member variables by: id (default), name, type, size, unsorted -
wfclib
: wfc library functions scope: inline, static, extern -
inline
: comma separated list of methods to inline: has, get, set
The following options provide means to modify specific aspects of implementation of fields on the class level.
-
arraysize
: use array of size instead of vector for repeated fields -
storage
: storage type of message fields (regular, static, virtual) -
unset
: in-range value that marks the field as unset (omits valid bit generation) -
bytestype
: implementation type for 'bytes':std::string
(default), -
stringtype
: implementation type forstring
:std::string
(default), C(const char *)
, -
intsize
: number of bits of default integer types -
packed
: generate a single tag/length pair for all array elements -
parse_ascii
: function that provides ascii parsing for that field (used by setByName) -
to_ascii
: function for generating a custom ASCII output for that field -
to_json
: function for generating a custom JSON output for that field
There are several options to control the name of the generated functions. This is simply to support different naming conventions and code styles.
Available options for setting functions names are:
-
AddPrefix
: prefix to use for add methods -
ClearName
: name of clear methods -
ClearPrefix
: prefix to use for clear methods -
fromMemory
: produce/omit code for parsing memory -
GetPrefix
: prefix to use for get methods -
HasPrefix
: prefix to use for has methods -
calcSize
: set name of function for calculating size on wire; "" to omit generation -
toASCII
: name of function for generating human readable ASCII output -
toJSON
: name of function for generating JSON output -
toMemory
: name of function for serializing to memory; "" to omit generation -
toSink
: name of function for serializing with sink interface; "" to omit generation -
toString
: name of function for serializing to std::string; "" to omit generation -
toWire
: name of function for serializing via function 'wireput'; "" to omit generation -
MutablePrefix
: prefix to use for mutable methods reasons -
SetByName
: name of function for setting by name with ASCII input (default: setByName) -
SetPrefix
: prefix to use for set methods
The generated code makes use of functions that are implemented in the wfc core library. These functions can be set to be replaced by other functions with the following options:
-
ascii_bytes
: function for printing bytes in toASCII (default:ascii_bytes
) -
ascii_indent
: function to create indentions in toASCII (default:ascii_indent
) -
ascii_string
: function for printing strings in toASCII (default:ascii_string
) -
wireput
: function for puting data on the wire -
wiresize
: library function to use aswiresize
function -
json_indent
: statement for JSON indention
For adding comments or providing general information about the generated code, the following options are available:
-
author
: author of source file Code -
copyright
: year of copyright of source file -
email
: e-mail address of copyright holder or author -
comments
: generate comments