[Xapian-discuss] Query::Query() in PHP, also QueryParser::prefixes

James Aylett james-xapian@tartarus.org
Thu, 27 May 2004 17:42:26 +0100


On Thu, May 27, 2004 at 04:38:44PM +0100, Francis Irving wrote:

> On Wed, May 26, 2004 at 11:19:07PM +0100, James Aylett wrote:
> > > I've attempted to fix this by modifying xapian.i.  I can't get the
> > > %rename clause to work for a constructor.
> > 
> > It's now called %name, I think. I've managed to get it working for
> > constructors in the past, but admittedly not for a while.
> 
> Aha!  Thank you.  Much more success.  I've tried this.
> 
> %name(QueryCombine) Xapian::Query::Query(Xapian::Query::Query::op op_,
> %const Xapian::Query::Query & left, const Xapian::Query::Query &
> %right);
> 
> It makes a PHP function called query_querycombine.  Unfortunately,
> the function takes a spurious extra Query argument as its first
> parameter.  SWIG thinks it is a member function, rather than a
> constructor.
> 
> $query = query_querycombine($querydummy, Query_OP_AND, $query1, $query2); 
> 
> It works though!

Weird. We should be able to get it to turn into query_new_combine()
without the $querydummy parameter.

Hmm ... try new_QueryCombine() without the dummy parameter - it's
possible that this won't create a shadow class, but just the internal
wrapped class. Try it, and see what happens :)
 
> > It doesn't for PHP4, no. We have a plan to resolve this (and hence make
> > the PHP4 bindings more useful).
> 
> Anything particular I can do to help?  I have to hack /something/ to
> get things working over the next week, and I may as well hack even
> a small thing in the format you expect.  Or else I'll make do with
> query_querycombine above ;)

Basically, there'll be a conditional branch in xapian.i every time we
meet an overloaded method or constructor. If you can %name away all
the conflicts in xapian.i and send me a diff, I can whirl that into a
useful patch so PHP4 will Just Work Like That in future.

J

-- 
/--------------------------------------------------------------------------\
  James Aylett                                                  xapian.org
  james@tartarus.org                               uncertaintydivision.org