lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r770882 - in /lucene/pylucene/trunk/jcc: CHANGES jcc/python.py jcc/sources/functions.h
Date Sat, 02 May 2009 02:24:38 GMT
Author: vajda
Date: Sat May  2 02:24:37 2009
New Revision: 770882

URL: http://svn.apache.org/viewvc?rev=770882&view=rev
Log:
 - fixed bug with Enumeration/Iterator template function instantiation

Modified:
    lucene/pylucene/trunk/jcc/CHANGES
    lucene/pylucene/trunk/jcc/jcc/python.py
    lucene/pylucene/trunk/jcc/jcc/sources/functions.h

Modified: lucene/pylucene/trunk/jcc/CHANGES
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/CHANGES?rev=770882&r1=770881&r2=770882&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/CHANGES (original)
+++ lucene/pylucene/trunk/jcc/CHANGES Sat May  2 02:24:37 2009
@@ -7,6 +7,7 @@
  - added --wininst to enable use of bdist_wininst with distutils (Jonas Maurus)
  - added --help to describe command line options (Jonas Maurus)
  - added support for --rename to workaround python flattened namespace clashes
+ - fixed bug with Enumeration/Iterator template function instantiation
  - 
 
 Version 2.1 -> 2.2

Modified: lucene/pylucene/trunk/jcc/jcc/python.py
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/python.py?rev=770882&r1=770881&r2=770882&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/python.py (original)
+++ lucene/pylucene/trunk/jcc/jcc/python.py Sat May  2 02:24:37 2009
@@ -711,7 +711,7 @@
         if iteratorExt:
             tp_iter = 'get_extension_iterator'
         else:
-            tp_iter = 'get_iterator<t_%s>' %(names[-1])
+            tp_iter = '((PyObject *(*)(t_%s *)) get_iterator<t_%s>)' %(names[-1], names[-1])
         tp_iternext = '0'
     elif nextMethod and iterator.isAssignableFrom(cls):
         tp_iter = 'PyObject_SelfIter'
@@ -720,7 +720,7 @@
         if nextExt:
             tp_iternext = 'get_extension_next'
         else:
-            tp_iternext = '(get_iterator_next<%s%st_%s,%s>)' %(ns, sep, n, returnName)
+            tp_iternext = '((PyObject *(*)(java::util::t_Iterator *)) get_iterator_next<java::util::t_Iterator,%s%st_%s,%s>)'
%(ns, sep, n, returnName)
     elif nextElementMethod and enumeration.isAssignableFrom(cls):
         tp_iter = 'PyObject_SelfIter'
         returnName = typename(nextElementMethod.getReturnType(), cls, False)
@@ -728,7 +728,7 @@
         if nextElementExt:
             tp_iternext = 'get_extension_nextElement'
         else:
-            tp_iternext = '(get_enumeration_nextElement<%s%st_%s,%s>)' %(ns, sep, n,
returnName)
+            tp_iternext = '((PyObject *(*)(java::util::t_Enumeration *)) get_enumeration_nextElement<java::util::t_Enumeration,%s%st_%s,%s>)'
%(ns, sep, n, returnName)
     elif nextMethod:
         tp_iter = 'PyObject_SelfIter'
         returnName = typename(nextMethod.getReturnType(), cls, False)
@@ -736,7 +736,7 @@
         if nextExt:
             tp_iternext = 'get_extension_next'
         else:
-            tp_iternext = '(get_next<t_%s,%s%st_%s,%s>)' %(names[-1], ns, sep, n, returnName)
+            tp_iternext = '((PyObject *(*)(t_%s *)) get_next<t_%s,%s%st_%s,%s>)' %(names[-1],
names[-1], ns, sep, n, returnName)
     else:
         tp_iter = '0'
         tp_iternext = '0'

Modified: lucene/pylucene/trunk/jcc/jcc/sources/functions.h
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/sources/functions.h?rev=770882&r1=770881&r2=770882&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/sources/functions.h (original)
+++ lucene/pylucene/trunk/jcc/jcc/sources/functions.h Sat May  2 02:24:37 2009
@@ -93,20 +93,19 @@
 PyObject *callSuper(PyTypeObject *type, PyObject *self,
                     const char *name, PyObject *args, int cardinality);
 
-template<class T> PyObject *get_iterator(PyObject *self)
+template<class T> PyObject *get_iterator(T *self)
 {
     java::util::Iterator iterator((jobject) NULL);
 
-    OBJ_CALL(iterator = (((T *) self)->object.iterator()));
+    OBJ_CALL(iterator = self->object.iterator());
     return java::util::t_Iterator::wrap_Object(iterator);
 }
 
-template<class U, class V> PyObject *get_iterator_next(PyObject *self)
+template<class T, class U, class V> PyObject *get_iterator_next(T *self)
 {
-    java::util::t_Iterator *iterator = (java::util::t_Iterator *) self;
     jboolean hasNext;
 
-    OBJ_CALL(hasNext = iterator->object.hasNext());
+    OBJ_CALL(hasNext = self->object.hasNext());
     if (!hasNext)
     {
         PyErr_SetNone(PyExc_StopIteration);
@@ -114,7 +113,7 @@
     }
 
     V next((jobject) NULL);
-    OBJ_CALL(next = iterator->object.next());
+    OBJ_CALL(next = self->object.next());
 
     jclass cls = java::lang::String::initializeClass();
     if (env->get_vm_env()->IsInstanceOf(next.this$, cls))
@@ -123,12 +122,11 @@
     return U::wrap_Object(next);
 }
 
-template<class U, class V> PyObject *get_enumeration_nextElement(PyObject *self)
+template<class T, class U, class V> PyObject *get_enumeration_nextElement(T *self)
 {
-    java::util::t_Enumeration *enumeration = (java::util::t_Enumeration *) self;
     jboolean hasMoreElements;
 
-    OBJ_CALL(hasMoreElements = enumeration->object.hasMoreElements());
+    OBJ_CALL(hasMoreElements = self->object.hasMoreElements());
     if (!hasMoreElements)
     {
         PyErr_SetNone(PyExc_StopIteration);
@@ -136,7 +134,7 @@
     }
 
     V next((jobject) NULL);
-    OBJ_CALL(next = enumeration->object.nextElement());
+    OBJ_CALL(next = self->object.nextElement());
 
     jclass cls = java::lang::String::initializeClass();
     if (env->get_vm_env()->IsInstanceOf(next.this$, cls))
@@ -145,12 +143,11 @@
     return U::wrap_Object(next);
 }
 
-template<class T, class U, class V> PyObject *get_next(PyObject *self)
+template<class T, class U, class V> PyObject *get_next(T *self)
 {
-    T *iterator = (T *) self;
     V next((jobject) NULL);
 
-    OBJ_CALL(next = iterator->object.next());
+    OBJ_CALL(next = self->object.next());
     if (!next)
     {
         PyErr_SetNone(PyExc_StopIteration);



Mime
View raw message