[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Automatic wrapper generation; PGPLOT

From: Gary Holt
Subject: Automatic wrapper generation; PGPLOT
Date: 14 Oct 1997 20:12:07 -0000

There has been some discussion about incorporating various subroutine
libraries into octave.  One difficulty is that it's a pain to write all
the wrapper functions to convert from octave's internal format into the
calling sequence the packages want.  For example, the pgplot plotting
library includes 100 functions, and it would be extremely tedious to
write all the interface by hand.

To solve this problem, I wrote a wrapper generator called "matwrap" for
octave and matlab.  You simply give it a .h file describing your C++
classes and functions, and it writes all of the code necessary to call
any global functions or public member functions from Matlab or octave.
You don't have to know anything about the internals of matlab or octave
to use it.  The distribution is available from

The wrapper generator was inspired by Dave Beazley's SWIG wrapper
generator, which is very good for non-matrix languages like perl or
python.  Matwrap has a number of additional features for matrix
languages.  For example, it automatically vectorizes your functions.  It
also can naturally support functions which take vector or matrix

As an example of its use, I wrapped the entire pgplot plotting library
for octave.  If you just want to call pgplot from octave but you don't
care about generating wrappers for other functions, you can pick up the
pgplot wrapper from the URL above.

The code supports a variety of types (e.g., double, float, int, char *,
char, and pointers to arbitrary structures).  Inheritance is also
supported for pointers.  It's pretty flexible; it was designed so that a
wide variety of functions from various libraries can be wrapped.
Currently, function pointers and two-dimensional arrays formed by
vectors of pointers are not supported.  (Two dimensional arrays with the
usual Fortran memory layout are supported.)

The wrapper generator is written in perl; you need a recent version.
I've only tested with version 5.004.  Perl is available from  I've developed this on unix, but it should work
with small modifications on other platforms.

This is the first time I've released it (version 0.4).  I'm sure there
are bugs.  Comments and suggestions are welcome.

Gary Holt                       (626)-395-2882

reply via email to

[Prev in Thread] Current Thread [Next in Thread]