Next: , Up: G-Wrap's Code Generation API   [Contents][Index]

3.3.1 Overview of the Code Generation Methods

Unless stated otherwise, the code generation methods all have a name ending in -cg. Most of them take a wrapset as their first argument (i.e. instances of a sub-class of <gw-wrapset>), some of them don’t.

All code generation methods must return a code tree, that is a list whose elements are either strings, lists of strings, or a special forms. The strings and list of strings must be valid C code. Special forms are lists that are automatically expanded to produce C code when a tree is written to a file. The valid special forms are the following:

Special CG Form: gw:error? c-error-var [error-value]

This special form expands to C code that tests whether the C variable named c-error-var (a string) denotes a G-Wrap error status. If error-value is provided, it must be a symbol denoting one of the various G-Wrap run-time error conditions:


an error condition that does not fit in the other names;


a memory management exception;


a range exception (e.g. for integer conversion);


a type exception (e.g. wrong return type);


a wrong-number-of-arguments exception;


a range exception for one of the arguments;


a type exception for one of the arguments.

If error-value is provided, this special form expands to code that checks whether the C variable named c-error-var denotes an error condition equal to error-value.

Special CG Form: gw:error error-type [args]

Expands to C code that raises a G-Wrap run-time error of type error-type, with error-specific arguments args. error-type must be a symbol whose value is one of those described above.

Next: , Up: G-Wrap's Code Generation API   [Contents][Index]