2.1. Introduction
WrapGen is a c program used to generate repetitive parts
of the package code for gpmi. It is intended to be highly portable thus
written in plain c.
WrapGen works from a list file and generates .include, .c and .h files.
2.2. Lists
Lists contains multiline records describing functions or events. When a line
starts with a non-whitespace character, it is the beginning of a new
function or event definition. Each function or event may have at most
32 parameters listed under the definition. A line describing a parameter
starts with at least one whitespace (2 tabs is the default recommended
style).
Both functions and parameters have type. Function name and type
are separated by whitespaces. An event's type does not matter, it
defaults to void (yet, would be changed in the future).
Comments are lines starting with '#' or ';' characters. It's allowed
to have empty lines anywhere in the file. Actually you separate two
definitions by an empty line: when the parameter list of a function or
an event ends, you have to have at least one empty line.
A list looks like this:
# Leet functions:
Function1 type
param1 type
param2 type
Function2 type
param1 type
# Lame functions:
Function3 type
Function4 type
param1 type
param2 type
2.3. Generators
2.3.0. Prefixes
- ! dynamic type, free() after use (for keywords and strings only)
- @ multiple keywords are allowed (for keywords only)
- ^ use const for the definition (for parameters only)
2.3.1. Function wrapper generator
Function and parameter types describe what type the gpmi
function will return or the parameter will hold.
Recognized types at the moment:
- int
- string (= char *)
- double
- void
- uint (= unsigned int)
- ptr (= void *)
Everything else than listed above is treated as a keyword and resolved
using the keyword hashes.
Each type may have a number of prefixes.
2.3.2. Event wrapper generator
Parameters are used to generate the header of the event handler routine
and for converting parameters for text calls. Valid types are the same
as for function wrappers.
String is resolved to (char *) and is static (?).
2.3.3. Keyword lists
If your package exports keywords, you need to supply a list of
your keyword tables. You don't need to list possible keyword entries.
A keyword table definition is a line starting with a "@" (would be changed
later) followed by the keyword table name, than arbitrary number of
white spaces and the keyword table type. Valid types are those
that gpmi's keyword API can handle.
An example is:
@directions int
2.3.4. markers
The list file may contain markers to split the list in parts.
A marker is a line starting with $$$. We are using 3 markers at the time:
$$$Keywords, $$$Functions and $$$Events. We collect function records
below the functions marker and events below the events marker.
Under $$$Keywords the keyword tables are listed.