[Xapian-tickets] [Xapian] #448: Allow usage of custom stemmers
Xapian
nobody at xapian.org
Mon Apr 12 14:19:48 BST 2010
#448: Allow usage of custom stemmers
-------------------------+--------------------------------------------------
Reporter: esizikov | Owner: olly
Type: enhancement | Status: reopened
Priority: normal | Milestone: 1.2.x
Component: Library API | Version: 1.0.17
Severity: normal | Resolution:
Keywords: | Blockedby:
Platform: All | Blocking:
-------------------------+--------------------------------------------------
Comment(by esizikov):
If we'd like to be able to subclass our own stemmer in the SWIG-wrapped
languages we need the {{{Xapian::StemImplementation}}} to be a "director":
{{{%feature("director") Xapian::StemImplementation;}}}
This doesn't work and the SWIG fails with
{{{
/home/esizikov/svn/xapian/xapian-core/include/xapian/stem.h:41:
Warning(473): Returning a pointer or reference in a director method is not
recommended.
}}}
When trying to enable the "director" feature for the only {{{operator()}}}
we really need from this interface class (like {{{%feature("director")
Xapian::StemImplementation::operator();}}}) I've got the error like:
{{{
modern/xapian_wrap.cc:34173: error: '_swig_thread_allow' was not declared
in this scope
}}}
In the generated modern/xapian_wrap.cc we have:
{{{
#!cpp
...
director = SWIG_DIRECTOR_CAST(arg1);
upcall = (director && (director->swig_get_self()==swig_obj[0]));
try {
{
try {
if (upcall) {
Swig::DirectorPureVirtualException::raise("Xapian::StemImplementation::operator
()");
} else {
result = (arg1)->operator ()((std::string const &)*arg2);
}
} catch (...) {
SWIG_PYTHON_THREAD_END_ALLOW;
Xapian::SetPythonException();
SWIG_fail;
}
}
} catch (Swig::DirectorException&) {
SWIG_fail;
}
...
}}}
As you can see {{{SWIG_PYTHON_THREAD_END_ALLOW;}}} is used without a
proper initialization. It would be OK if the generated code looks like
this:
{{{
#!cpp
...
director = SWIG_DIRECTOR_CAST(arg1);
upcall = (director && (director->swig_get_self()==swig_obj[0]));
try {
SWIG_PYTHON_THREAD_BEGIN_ALLOW;
{
try {
if (upcall) {
Swig::DirectorPureVirtualException::raise("Xapian::StemImplementation::operator
()");
} else {
result = (arg1)->operator ()((std::string const &)*arg2);
}
} catch (...) {
SWIG_PYTHON_THREAD_END_ALLOW;
Xapian::SetPythonException();
SWIG_fail;
}
}
SWIG_PYTHON_THREAD_END_ALLOW;
} catch (Swig::DirectorException&) {
SWIG_fail;
}
...
}}}
Seems like be a SWIG bug.
--
Ticket URL: <http://trac.xapian.org/ticket/448#comment:20>
Xapian <http://xapian.org/>
Xapian
More information about the Xapian-tickets
mailing list