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

Re: [MacPerl]How to access C/C++ routines..



Hi, Carlos

Based on your criteria of "quick to implement", I suggest using SWIG.

SWIG handles structs (and also 'typedef struct') as a matter of course,
and you can also have it set up struct constructors (nothing to do with
C++). I'm not sure about the unions - I'll play with this a bit and post
the results. Worst comes to worst, this might be the one thing where you
have to do some unavoidable work setting up a new SWIG typemap.

Using XS on Unix isn't much worse, but unfortunately you would have to
do *all* of the work concerning struct translations yourself.

Your library is on Solaris, I think you said, so you'd want to do the final
stuff on Unix, but if you want to experiment with SWIG on your Mac, just
download MacSWIG. The functionality of MacSWIG is exactly the same as
Unix SWIG - same output for same input. I suggest extracting one function
from ESSAPI.H, along with the structs that it uses, putting them in a SWIG
".i" file, and running SWIG on them. Just to see what it does.

SWIG comes with a well-written batch of docs in PDF, so you'll likely be
able to produce a Perl wrapper to look at in only a few hours from the
time of download.

For MacPerl folks in general: I'm going to have a short tutorial on using
MacSWIG for MacPerl (i.e. getting from MacSWIG output to a working
extension) in a few weeks, but if you want to get a jump, you can basically
take a build procedure from my Mac_XS tutorial, ignore the xsubpp .xs->.c
part, and just put in the C wrapper file produced by SWIG instead. MacSWIG
itself is exceptionally easy to use.

Arved


---------------------------------------------------------------
 This mail was sent through the Nova Scotia Provincial Server.
 http://nsaccess.ns.ca/mail/ (in development)

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org