[Xapian-discuss] PHP Fatal error while indexing Wikipedia
James Aylett
james-xapian at tartarus.org
Fri Jan 4 02:24:38 GMT 2008
On Fri, Jan 04, 2008 at 01:41:05AM +0000, Olly Betts wrote:
> Originally, extra.i was for stuff which had to be included after SWIG
> had seen all the classes (since util.i needs to be seen first). I'm
> not sure if that's still the case or not though - it's only used by
> the python bindings, and they've evolved a lot over time. It might
> be that it now just exists so that the pythoncode gets better syntax
> colouring in vim!
python's extra.i is still inserting things into classes generated by
SWIG (notably things like __iter__() for MSet). I'm pretty sure
there's no other convenient way of getting that to work.
> > The question then is whether you can augment things
> > appropriately in PHP5.
>
> We don't want Enquire::get_mset() to return a "PHPXapianMSetIterator"
> as the user might want to have access to the XapianMSet object.
Hmm. We want the MSet to be able to act as an iterator. My knowledge
of how PHP does this is sketchy; I suspect it isn't going to be as
neat as python :-(
> What's really wanted is to replace the "unPHPy" XapianMSetIterator
> with a more "PHPy" version, and XapianMSet::begin() and end() with
> "foreach ($mset as $item) { ... }". I'm not very familiar with this
> area of PHP5, but it looks like we need to make XapianMSet inherit from
> IteratorAggregate and implement a getIterator() method.
That sounds reasonable. It's implements, not inherits, which may make
life easier.
> Currently there's no way to drop your own PHP code *inside* a generated
> class, but perhaps there should be - some of the other SWIG backends
> allow similar things.
We could avoid this with runkit, which allows dynamic manipulation of
PHP classes (eg: runkit_method_add($classname, $methodname, $args,
$code). It's a PECL extension though, which might cause problems (it
doesn't seem to be packaged for debian, for instance). It's all
experimental, too. Bah.
Adding this functionality to SWIG would be preferrable. If the #pragma
could operate within a class declaration, that would do it -
syntactically; I have no idea how much pain that is to implement :-)
J
--
/--------------------------------------------------------------------------\
James Aylett xapian.org
james at tartarus.org uncertaintydivision.org
More information about the Xapian-discuss
mailing list