Re: Are you aware of SWIG?

From: Date: Fri, 17 May 2002 20:12:55 +0000
Subject: Re: Are you aware of SWIG?
References: 1  Groups: php.pear.dev php.pear.general 
Request: Send a blank email to pear-dev+get-6210@lists.php.net to get a copy of this message
Hi Sam --- Sam Liddicott <sam.liddicott@ananova.com> wrote: > I thought it may be useful to keep you up to date on SWIG. (www.swig.org) Yep, had been using to wrap some simple libs. Mainly to get a feeling on how it performs for PHP (used it before for Java). Some days ago I mentioned the GIFPlot example lib that comes in SWIG on pear-dev. That can be a useful and good example for a tutorial on how to use SWIG to add extensions to PHP. > Swig, given any C or C++ library with header files and an optional swig > interface file can generate modules for PHP, Perl, Python, Java, Guile etc > etc. > > I've done a lot of work on swig-php (in cvs) in conjunction with earlier > work done by Richard Palmer and consider it very useful for generating php > modules. > > It has the ability to wrap C++ classes and C structs as native PHP objects > if required > It no longer uses PHP-coded shadow classes but C-coded PHP shadow classes. > Return swig values are now PHP resources and not ghastly > swig-pointer-strings. That is good. I had not tested the CVS code from SWIG but the latest release, and that did used those "ghastly swig-pointer-strings" which did not work well with some libs I was testing. > It also has the ability to autmatically generate config.m4 and Makefile.in > for C or C++ modules so that the output of SWIG is enough that only PHPIZE > needs running before compiling the new php module. *This* is great. Not knowing too much about M4, I get more misses than hits when manually editing config.m4 > To generate a complete PHP module from an installed library I just have to > do: > > # swig -c++ -php4 -phpfull -withlibs "xapian omqueryparser" \ > -withincs om/om.h -shadow \ > -o xapian/xapian_wrap.cpp ../swig/xapian.i > > # cd xapian && phpize && ./configure && make && make install > > > I'm developing in for use by the xapian search engine system > (www.xapian.org) which is based on the open-sourced commercial SmartLogik > product. > > Anyway, as PEAR can include C modules I was wondering if some of the rules > could be relaxed regarding coding standards. > By this I mean the "code" for a SWIG'd C module for PHP really consists just > of the special swig .i file; the C/C++ code generated may not be pretty to > look at. > I know, the generated code is not pretty, but it works ;-), will try the CVS version of SWIG this weekend on a couple of libs I got my eye on. > Comments? > > Sam Just one more, pehaps you should've also CC'ed pear-dev, in particular w/ respect to the coding standards. I am cc'ing this response to the devel list. ===== --- Jesus M. Castagnetto (jcastagnetto@yahoo.com) Research: http://metallo.scripps.edu/ Personal: http://www.castagnetto.org/ __________________________________________________ Do You Yahoo!? LAUNCH - Your Yahoo! Music Experience http://launch.yahoo.com

« previous php.pear.dev (#6210) next »