Automatic wrapper generation; PGPLOT

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Automatic wrapper generation; PGPLOT

Gary Holt-2
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

        http://www.klab.caltech.edu/~holt/matwrap/

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
arguments.

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
http://www.perl.com/.  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
[hidden email] http://www.klab.caltech.edu/~holt/


Reply | Threaded
Open this post in threaded view
|

Re: Automatic wrapper generation; PGPLOT

Michael Martins-2
On 14 Oct 1997, Gary Holt wrote:

Hello world

First I want to say that this library is an excellent idea for a plotting
library for octave!

> 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
>
> http://www.klab.caltech.edu/~holt/matwrap/ 
 
> 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.

I have tried to use this very interesting and nice idea on an ALPHA
machine with OSF4.0 without success. I can create the .oct file with
mkoctfile but octave terminates with a "segmentation fault" on the first
pg Command (pgpage) from the demo. Also other pg commands don't work.

Has someone success with the pg-library and octave ?

Ciao
        Michael

--
|\  /|  Dr. Michael Martins, Freie Universitaet Berlin
| \/ |  Institut fuer Experimentalphysik
| |\/|  Arnimallee 14,            Tel.: +49-30-838 2688
| |  |  D-14195 Berlin, Germany     Email: [hidden email]