[Xapian-devel] Bindings and overloading
James Aylett
james-xapian at tartarus.org
Thu Jun 3 15:25:57 BST 2004
On Thu, Jun 03, 2004 at 02:38:40PM +0100, Alex Bowley wrote:
> > Several of the Query constructors work fine for me in python. Which
> > ones are giving you problems? (And do you mean 'prints errors', or
> > 'throws exceptions'?)
>
> The constructor that takes any number of Querys of strings, demarked by
> iterators: http://www.xapian.org/docs/apidoc/html/classXapian_1_1Query.html#a7
>
> It prints errors like the following:
>
> sh-2.05b$ python test-xapian3.py
> Traceback (most recent call last):
> File "test-xapian3.py", line 30, in ?
> q3=xapian.Query(xapian.Query.OP_PHRASE,'bodega','sell','fish')
> File
> "/lmn/tools/search/python/python-2.3.3/lib/python2.3/site-packages/xapian.py",
> line 452, in __init__
> _swig_setattr(self, Query, 'this', _xapian.new_Query(*args))
> TypeError: No matching function for overloaded 'new_Query'
That wouldn't work with Query(Query::op, Iterator, Iterator) anyway,
because (a) it has too many parameters, and (b) they're the wrong
type.
This constructor isn't wrapped because it uses templates:
----------------------------------------------------------------------
template<class Iterator>
Query (Query::op op_, Iterator qbegin, Iterator qend);
template<class SubQ>
Query (Query::op op_, SubQ q);
----------------------------------------------------------------------
which SWIG finds pretty much impossible to deal with.
There is an attempt to allow the following type of constructor:
q = xapian.Query(xapian.Query.OP_PHRASE, ['bodega', 'sell', 'fish'])
but it doesn't work because (I think) we're either not instantiating
the right template, or possibly because we're missing a typemap. I'm
looking at this at the moment, but I don't know how much time I can
devote to it.
(Also, it works on vector<Query*> not vector<string&>, so you'd need
to do something horrible like:
q = xapian.Query(xapian.Query.OP_PHRASE, [xapian.Query('bodega'),
...
])
which isn't very pleasant.)
J
--
/--------------------------------------------------------------------------\
James Aylett xapian.org
james at tartarus.org uncertaintydivision.org
More information about the Xapian-devel
mailing list