Re: Are you aware of SWIG?
| From: | Stig S. Bakken | Date: | Sat, 18 May 2002 11:28:03 +0000 |
| Subject: | Re: Are you aware of SWIG? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-1406@lists.php.net to get a copy of this message | ||
On Fri, 2002-05-17 at 12:30, Sam Liddicott wrote:
> I thought it may be useful to keep you up to date on SWIG. (www.swig.org)
>
> 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.
>
> 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.
>
> 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.
>
> Comments?
Coding standards exist to help code maintenance, but since nobody is
going to "maintain" generated code, there is no point in applying coding
standards for those (that would be unreasonable anyway).
- Stig