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

Olly Betts olly at survex.com
Mon Apr 17 00:53:33 BST 2006


On Sun, Apr 16, 2006 at 08:54:22AM +0100, Paul Dixon wrote:
> > OK, I've reworked it...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
> 
> Looks great!

I've now improved it to wrap static member functions too.

I could easily wrap non-member functions, but I need to sort out the
naming there (since their "flat" names are the same as the PHP-wrapped
names but I still want to wrap some of them so I can return resources
wrapped in the appropriate PHP proxy object (e.g. inmemory_open should
really return a XapianWritableDatabase object).

Perhaps the best way to address these is to create a dummy "Xapian"
class with all the non-member functions as static methods.  Daniel
wrapped the functions and constants in a Xapian class in his OO
bindings, and it does means everything we wrap is in a pseudo namespace,
which is cleaner.

> I've been wondering how best to add Iterator support to those
> auto-generated classes. Perhaps the cleanest way is to have a separate
> file which extends the generated classes, e.g.
> [snip]

This could be addressed using SWIG's typemaps I think.  We'd still
effectively need some hand-written custom code which would be very
similar to that you posted, but it would allow us to call the wrapped
classes XapianDocument and XapianTermIterator which is more natural for
the user.  I'll take a look.

Cheers,
    Olly



More information about the Xapian-discuss mailing list