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 21:58:21 UTC

svn commit: r826057 - in /lucene/pylucene/trunk/jcc: CHANGES jcc/sources/JArray.h jcc/sources/functions.cpp

Author: vajda
Date: Fri Oct 16 19:58:21 2009
New Revision: 826057

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

Modified:
    lucene/pylucene/trunk/jcc/CHANGES
    lucene/pylucene/trunk/jcc/jcc/sources/JArray.h
    lucene/pylucene/trunk/jcc/jcc/sources/functions.cpp

Modified: lucene/pylucene/trunk/jcc/CHANGES
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/CHANGES?rev=826057&r1=826056&r2=826057&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/CHANGES (original)
+++ lucene/pylucene/trunk/jcc/CHANGES Fri Oct 16 19:58:21 2009
@@ -6,6 +6,7 @@
  - default value to initVM's classpath parameter now is importing module's
  - added (partial) support for Java generics
  - added 'string_' property to JArray('byte') instances to extract byte string
+ - fixed bug with passing list of extension objects
  - 
 
 Version 2.3 -> 2.4

Modified: lucene/pylucene/trunk/jcc/jcc/sources/JArray.h
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/sources/JArray.h?rev=826057&r1=826056&r2=826057&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/sources/JArray.h (original)
+++ lucene/pylucene/trunk/jcc/jcc/sources/JArray.h Fri Oct 16 19:58:21 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/trunk/jcc/jcc/sources/functions.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc/sources/functions.cpp?rev=826057&r1=826056&r2=826057&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc/sources/functions.cpp (original)
+++ lucene/pylucene/trunk/jcc/jcc/sources/functions.cpp Fri Oct 16 19:58:21 2009
@@ -206,10 +206,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)