3.1.1 Wrapsets

A wrapset is roughly an object that holds a representation of all the
C types, constants, and functions what one is willing to “wrap”.
Wrapset specifications as seen in See A Simple Example, are in fact a piece
of Scheme code that creates a wrapset object, adds a number of C
functions, types, etc. to be wrapped and then generates code for this
wrapset. The code generation phase will be described in more details
in See G-Wrap's Code Generation API.

Wrapset are instances of the <gw-wrapset> class. Since G-Wrap
can generate code for more than one implementation (at least
theoretically), each particular back-end defines a sub-class of this
class. For instance, the Guile back-end defines the
<gw-guile-wrapset> class in the (g-wrap guile) module.

When creating your own wrapset, you will have to create a sub-class of
<gw-wrapset> with appropriate parameters, and then instantiate
it. For instance, you may write:

This creates a new wrapset for Guile, whose name is
my-new-wrapset and which depends on the standard wrapset
(see C Types Provided in the Standard Wrapset) and on the wrapset
named my-other-wrapset. Each of the wrapset
<my-new-wrapset> depends on must be visible at this point,
typically by using the modules that define them:

Of course, the module that defines <my-other-wrapset> does not
need to be called (my-other-wrapset) but sticking to this
naming scheme is usually a good idea.

The main methods that apply to <gw-wrapset> objects are listed
below. Note that if you are simply willing to use G-Wrap’s high-level
API (see G-Wrap's High-level API), you certainly do not need to
know them, except initialize.

method: initialize(wrapset <gw-wrapset>) . args

Initialize wrapset, an newly created instance of
<gw-wrapset>. This method is part of the GOOPS meta-object
protocol (see Instance Creation Protocol in The GNU Guile Reference Manual).

Since you will actually always use your own sub-class of
<gw-wrapset> (e.g. <my-new-wrapset>), you will want to
specialize this method in order to perform initialization steps which
are specific to your wrapset. In particular, this is where you will
add new wrapped types, add wrapped functions, specify a Guile module
name and a shared library name:

Return a list of <gw-wrapset> instances representing the
wrapsets wrapset depends on. This wrapsets correspond to those
named in the #:dependencies named parameter that was passed
when defining a sub-class of <gw-wrapset> (see above).

method: add-type!(ws <gw-wrapset>) (type <gw-type>)

Add the wrapped type type to the list of wrapped type of
ws.

method: add-function!(ws <gw-wrapset>) (function <gw-function>)

Add the wrapped function function to the list of functions
wrapped by ws.

method: add-constant!(ws <gw-wrapset>) (constant <gw-constant>)

Add the wrapped constant constant to the list of constants
wrapped by ws.

method: for-each-typeproc (ws <gw-wrapset>)

For each type (i.e. <gw-type> instance) wrapped by ws
call proc (a procedure or generic function). The result is
unspecified.