[Xapian-tickets] [Xapian] #401: Weight cannot be subclassed in bindings

Xapian nobody at xapian.org
Mon Sep 14 13:59:35 BST 2009


#401: Weight cannot be subclassed in bindings
-----------------------------+----------------------------------------------
 Reporter:  james            |       Owner:  olly    
     Type:  enhancement      |      Status:  assigned
 Priority:  normal           |   Milestone:  1.2.0   
Component:  Xapian-bindings  |     Version:          
 Severity:  normal           |    Keywords:          
Blockedby:                   |    Platform:  All     
 Blocking:                   |  
-----------------------------+----------------------------------------------
Changes (by olly):

  * status:  new => assigned
  * milestone:  => 1.2.0


Old description:

> Originally this was because the Weight API was incompatible with
> available SWIG features. From 1.1, the API has changed; however it is
> still not possible to trivially wrap the class for directors.
>
> Firstly, SWIG warns:
>
> /Users/jaylett/projects/xapian/trunk/xapian-
> core/include/xapian/weight.h:163: Warning(473): Returning a pointer or
> reference in a director method is not recommended.
>
> (this is usually promoted to an error.)
>
> Secondly, compiling the output has errors:
>
> modern/xapian_wrap.cc: In function ‘PyObject*
> _wrap_Weight_init(PyObject*, PyObject*)’:
> modern/xapian_wrap.cc:24352: error: ‘_swig_thread_allow’ was not declared
> in this scope
> modern/xapian_wrap.cc: In function ‘PyObject*
> _wrap_Weight_name(PyObject*, PyObject*)’:
> modern/xapian_wrap.cc:24429: error: ‘_swig_thread_allow’ was not declared
> in this scope
> modern/xapian_wrap.cc: In function ‘PyObject*
> _wrap_Weight_serialise(PyObject*, PyObject*)’:
> modern/xapian_wrap.cc:24472: error: ‘_swig_thread_allow’ was not declared
> in this scope
> modern/xapian_wrap.cc: In function ‘PyObject*
> _wrap_Weight_unserialise(PyObject*, PyObject*)’:
> modern/xapian_wrap.cc:24527: error: ‘_swig_thread_allow’ was not declared
> in this scope
> modern/xapian_wrap.cc: In function ‘PyObject*
> _wrap_Weight_get_sumpart(PyObject*, PyObject*)’:
> modern/xapian_wrap.cc:24596: error: ‘_swig_thread_allow’ was not declared
> in this scope
> modern/xapian_wrap.cc: In function ‘PyObject*
> _wrap_Weight_get_maxpart(PyObject*, PyObject*)’:
> modern/xapian_wrap.cc:24639: error: ‘_swig_thread_allow’ was not declared
> in this scope
> modern/xapian_wrap.cc: In function ‘PyObject*
> _wrap_Weight_get_sumextra(PyObject*, PyObject*)’:
> modern/xapian_wrap.cc:24689: error: ‘_swig_thread_allow’ was not declared
> in this scope
> modern/xapian_wrap.cc: In function ‘PyObject*
> _wrap_Weight_get_maxextra(PyObject*, PyObject*)’:
> modern/xapian_wrap.cc:24732: error: ‘_swig_thread_allow’ was not declared
> in this scope

New description:

 Originally this was because the Weight API was incompatible with available
 SWIG features. From 1.1, the API has changed; however it is still not
 possible to trivially wrap the class for directors.

 Firstly, SWIG warns:

 /Users/jaylett/projects/xapian/trunk/xapian-
 core/include/xapian/weight.h:163: Warning(473): Returning a pointer or
 reference in a director method is not recommended.

 (this is usually promoted to an error.)

 Secondly, compiling the output has errors:

 {{{
 modern/xapian_wrap.cc: In function ‘PyObject* _wrap_Weight_init(PyObject*,
 PyObject*)’:
 modern/xapian_wrap.cc:24352: error: ‘_swig_thread_allow’ was not declared
 in this scope
 modern/xapian_wrap.cc: In function ‘PyObject* _wrap_Weight_name(PyObject*,
 PyObject*)’:
 modern/xapian_wrap.cc:24429: error: ‘_swig_thread_allow’ was not declared
 in this scope
 modern/xapian_wrap.cc: In function ‘PyObject*
 _wrap_Weight_serialise(PyObject*, PyObject*)’:
 modern/xapian_wrap.cc:24472: error: ‘_swig_thread_allow’ was not declared
 in this scope
 modern/xapian_wrap.cc: In function ‘PyObject*
 _wrap_Weight_unserialise(PyObject*, PyObject*)’:
 modern/xapian_wrap.cc:24527: error: ‘_swig_thread_allow’ was not declared
 in this scope
 modern/xapian_wrap.cc: In function ‘PyObject*
 _wrap_Weight_get_sumpart(PyObject*, PyObject*)’:
 modern/xapian_wrap.cc:24596: error: ‘_swig_thread_allow’ was not declared
 in this scope
 modern/xapian_wrap.cc: In function ‘PyObject*
 _wrap_Weight_get_maxpart(PyObject*, PyObject*)’:
 modern/xapian_wrap.cc:24639: error: ‘_swig_thread_allow’ was not declared
 in this scope
 modern/xapian_wrap.cc: In function ‘PyObject*
 _wrap_Weight_get_sumextra(PyObject*, PyObject*)’:
 modern/xapian_wrap.cc:24689: error: ‘_swig_thread_allow’ was not declared
 in this scope
 modern/xapian_wrap.cc: In function ‘PyObject*
 _wrap_Weight_get_maxextra(PyObject*, PyObject*)’:
 modern/xapian_wrap.cc:24732: error: ‘_swig_thread_allow’ was not declared
 in this scope
 }}}

--

Comment:

 Hmm, I think SWIG is correct and this API isn't suitable for fully
 wrapping as-is.

 I'm not sure how to implement {{{MyWeight::unserialise()}}} in Python (or
 whatever) as it needs to return an object which can be deleted with the
 C++ delete operator.

 It is only needed for remote operation, and the weight subclass would need
 to be registered with the server, which isn't currently really feasible.
 We should probably just do what we do for {{{PostingSource}}} and use
 %ignore on unserialise() and let the default implementation be used (which
 throws an exception).

 Not sure about the _swig_thread_allow errors.

 Marking for considering in 1.2.x, though if there's a patch which works
 before 1.2.0, it's probably worth considering.

-- 
Ticket URL: <http://trac.xapian.org/ticket/401#comment:1>
Xapian <http://xapian.org/>
Xapian



More information about the Xapian-tickets mailing list