[Xapian-discuss] PHP Fatal error while indexing Wikipedia
Olly Betts
olly at survex.com
Fri Jan 4 02:48:10 GMT 2008
On Fri, Jan 04, 2008 at 02:24:38AM +0000, James Aylett wrote:
> 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.
Yes, I just did a quick test, and indeed these do need to be done after
the python classes have been defined.
> > 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.
It'll help if we want to do this for WritableDatabase, since that
is a subclass of Database and I don't think PHP5 supports multiple
inheritance.
> > 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.
I'd worry it might be slow too.
> 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 :-)
Shouldn't be too bad - we "just" need to store it on the class node and
then print it out at the appropriate moment.
Cheers,
Olly
More information about the Xapian-discuss
mailing list