You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by va...@apache.org on 2009/10/16 22:18:22 UTC

svn commit: r826068 - in /lucene/pylucene/branches/pylucene_2_4/jcc: ./ CHANGES jcc/sources/JArray.h jcc/sources/functions.cpp

Author: vajda
Date: Fri Oct 16 20:18:22 2009
New Revision: 826068

URL: http://svn.apache.org/viewvc?rev=826068&view=rev
Log:
fixed bug with passing list of extension objects

Modified:
    lucene/pylucene/branches/pylucene_2_4/jcc/   (props changed)
    lucene/pylucene/branches/pylucene_2_4/jcc/CHANGES
    lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/JArray.h
    lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/functions.cpp

Propchange: lucene/pylucene/branches/pylucene_2_4/jcc/
------------------------------------------------------------------------------
    svn:mergeinfo = /lucene/pylucene/trunk/jcc:826057

Modified: lucene/pylucene/branches/pylucene_2_4/jcc/CHANGES
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/pylucene_2_4/jcc/CHANGES?rev=826068&r1=826067&r2=826068&view=diff
==============================================================================
--- lucene/pylucene/branches/pylucene_2_4/jcc/CHANGES (original)
+++ lucene/pylucene/branches/pylucene_2_4/jcc/CHANGES Fri Oct 16 20:18:22 2009
@@ -9,6 +9,7 @@
  - added support for --rename to workaround python flattened namespace clashes
  - fixed bug with Enumeration/Iterator template function instantiation
  - removed -framework Python from darwin link flags in setup.py
+ - fixed bug with passing list of extension objects
 
 Version 2.1 -> 2.2
 ------------------

Modified: lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/JArray.h
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/JArray.h?rev=826068&r1=826067&r2=826068&view=diff
==============================================================================
--- lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/JArray.h (original)
+++ lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/JArray.h Fri Oct 16 20:18:22 2009
@@ -112,30 +112,8 @@
     }
 
 #ifdef PYTHON
-    JArray<jobject>(jclass cls, PyObject *sequence) : java::lang::Object(env->get_vm_env()->NewObjectArray(PySequence_Length(sequence), cls, NULL)) {
-        length = env->getArrayLength((jobjectArray) this$);
-
-        for (int i = 0; i < length; i++) {
-            PyObject *obj = PySequence_GetItem(sequence, i);
-
-            if (obj == NULL)
-                break;
-
-            if (!PyObject_TypeCheck(obj, &JObject$$Type))
-            {
-                PyErr_SetObject(PyExc_TypeError, obj);
-                break;
-            }
-
-            jobject jobj = ((t_JObject *) obj)->object.this$;
-
-            Py_DECREF(obj);
-            try {
-                env->setObjectArrayElement((jobjectArray) this$, i, jobj);
-            } catch (JCCEnv::exception e) {
-                PyErr_SetJavaError(e.throwable);
-            }
-        }
+    JArray<jobject>(jclass cls, PyObject *sequence) : java::lang::Object(fromPySequence(cls, sequence)) {
+        length = this$ ? env->getArrayLength((jobjectArray) this$) : 0;
     }
 
     PyObject *toSequence(PyObject *(*wrapfn)(const jobject&))

Modified: lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/functions.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/functions.cpp?rev=826068&r1=826067&r2=826068&view=diff
==============================================================================
--- lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/functions.cpp (original)
+++ lucene/pylucene/branches/pylucene_2_4/jcc/jcc/sources/functions.cpp Fri Oct 16 20:18:22 2009
@@ -182,10 +182,21 @@
                       if (PySequence_Length(arg) > 0)
                       {
                           PyObject *obj = PySequence_GetItem(arg, 0);
-                          int ok =
-                              (obj == Py_None ||
-                               (PyObject_TypeCheck(obj, &Object$$Type) &&
-                                vm_env->IsInstanceOf(((t_Object *) obj)->object.this$, cls)));
+                          int ok = 0;
+
+                          if (obj == Py_None)
+                              ok = 1;
+                          else if (PyObject_TypeCheck(obj, &Object$$Type) &&
+                                   vm_env->IsInstanceOf(((t_Object *) obj)->object.this$, cls))
+                              ok = 1;
+                          else if (PyObject_TypeCheck(obj, &FinalizerProxy$$Type))
+                          {
+                              PyObject *o = ((t_fp *) obj)->object;
+
+                              if (PyObject_TypeCheck(o, &Object$$Type) &&
+                                  vm_env->IsInstanceOf(((t_Object *) o)->object.this$, cls))
+                                  ok = 1;
+                          }
 
                           Py_DECREF(obj);
                           if (ok)