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

Sam Liddicott sam at liddicott.com
Mon Apr 17 09:14:30 BST 2006


Olly Betts wrote:
> 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.
>
>   
[for some reason reply-to-all missed Olly's address - weird - I had to 
add it by hand - maybe it was the "Sender" header]
It looks like a pretty complete job.

I'm wondering why swig_coerce_param couldn't be done in the generated C 
code that coerces all the other parameters into string and integer 
types. Not that I worship C but when I re-wrote swig-php I took out all 
the php code generation cos it wasn't really needed.

This is a question of mere idle curiosity and not in any sense a hint 
that you should have done it some other way - its none of my business as 
I'm not writing any of the code, so cheers for picking this up anyway.

Sam


More information about the Xapian-discuss mailing list