[Xapian-devel] PHP Latest

Olly Betts olly at survex.com
Wed Apr 19 03:45:26 BST 2006


This thread has reached the realms that users probably aren't interested
in, so I'm moving it to xapian-devel.

Latest version:

http://www.oligarchy.co.uk/xapian/patches/swig-php-gen-oo-wrappers6.patch
http://www.oligarchy.co.uk/xapian/patches/xapian6.phps
http://www.oligarchy.co.uk/xapian/patches/xapian_wrap6.cc

The changes are:

The patch now handles the case where all overloaded forms of the
constructor take one parameter in the same way the v5 patch handled
a non-overloaded constructor taking one parameter.

The "swig_coerce_param" helper has gone!  I had a look at Sam's
suggestion to do this in the wrapper code, and it's actually very
easy.  So for example, now WritableDatabase_add_document accepts a
XapianDocument PHP object happily and reads the resource for the
object's $swig_ptr.  I was a bit astonished when this worked on
the first attempt!  Even the "Query(OP, ARRAY_OF_QUERIES)" ctor
works without extra effort.

Functions/methods with no optional parameters and the same number of
parameters in each overload now get parameter lists instead of using
func_get_args and call_user_func_array.  Currently the arguments are
just called $arg0, $arg1, ... but they should use the C++ parameter
names for documentation purpose (I just wanted to avoid having to worry
for now about names being invalid in PHP or clashing with something).
It's also unclear what to do for overloaded methods if a parameter
name varies in each overloaded version.  Perhaps call it
"$foo_or_bar_or_baz" if it has names "foo", "bar", and "baz" in
different overloads?

Could you try timing this one?  I suspect it'll be much nearer your
hand-coded wrappers in performance.

> > - in Paul's wrapper, functions like swig_coerce_param and 
> > swig_wrap_return were members of the base class. I think it is a better 
> > solution than putting them global.
> 
> Then I can't call them from function wrappers though...

Now there's just swig_wrap_return.  It could be a static method of the
base class actually, but I wonder if it's not better to just inline a
conversion to the known return type (except in the case of overloaded
methods with covariant return types perhaps).

> > The PHP function "is_a" (used in coerce_param) is deprecated in PHP5 ans 
> > is replace by "instanceof".
> >    if ($value instanceof XapianSwigBase) $value=$value->swig_ptr;
> 
> OK, changed.

And now removed altogether, so this is no longer very interesting:

> [...] it'd also be interesting to check the timings with instanceof
> instead of is_a

Cheers,
    Olly



More information about the Xapian-devel mailing list