[Xapian-discuss] Another PHP 5 wrapper...

Olly Betts olly at survex.com
Sun Apr 16 02:51:49 BST 2006


On Fri, Apr 14, 2006 at 04:11:46AM +0100, Olly Betts wrote:
> I've been having a hack this evening, and now have a version of SWIG
> which can generate PHP wrapper classes around the flat bindings which
> are something close to what we want (using some of Paul's tricks for
> coercing arguments, etc).
> 
> It needs some cleaning up (in particular, I think I've finally worked
> out where I should have hooked in the new code and it's not where I
> actually put it!) But it's well past time I went to bed, so that'll have
> to wait.

OK, I've reworked it.  Here's the patch against SWIG CVS HEAD (which
should apply cleanly or with minimal jiggling to SWIG 1.3.29):

http://www.oligarchy.co.uk/xapian/patches/swig-php-gen-oo-wrappers4.patch

And here's the wrapper file it produces for Xapian (renamed to .phps so
you can view it!):

http://www.oligarchy.co.uk/xapian/patches/xapian.phps

I've used Paul's ideas for coercing parameters and return values, except
that I'm generating wrapper methods so I can skip doing that when I know
it won't be needed (currently the check errs on the side of coercing
when it sometimes isn't needed which doesn't affect correctness, but
just adds a small overhead).

I don't currently wrap non-member functions or static member functions
(not because it's hard, I just wanted to get a modified smoketest.php
to work and it exercise either of these currently).

Both the patch and generated code are a bit rough around the edges, but
comments and suggestions are most welcome.

I'm not renaming methods to lowerCamelCase yet (I've written and
submitted a patch to add support for this to SWIG so it's easy enough to
do once that gets applied).

Cheers,
    Olly



More information about the Xapian-discuss mailing list