lucene-pylucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject svn commit: r1787671 - in /lucene/pylucene/trunk/jcc: CHANGES _jcc3/java/lang/String.cpp jcc3/sources/JCCEnv.cpp jcc3/sources/JCCEnv.h jcc3/sources/jcc.cpp
Date Sun, 19 Mar 2017 23:12:52 GMT
Author: vajda
Date: Sun Mar 19 23:12:52 2017
New Revision: 1787671

URL: http://svn.apache.org/viewvc?rev=1787671&view=rev
Log:
removed superfluous string functions

Modified:
    lucene/pylucene/trunk/jcc/CHANGES
    lucene/pylucene/trunk/jcc/_jcc3/java/lang/String.cpp
    lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.cpp
    lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.h
    lucene/pylucene/trunk/jcc/jcc3/sources/jcc.cpp

Modified: lucene/pylucene/trunk/jcc/CHANGES
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/CHANGES?rev=1787671&r1=1787670&r2=1787671&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/CHANGES (original)
+++ lucene/pylucene/trunk/jcc/CHANGES Sun Mar 19 23:12:52 2017
@@ -1,6 +1,7 @@
 Version 2.23 -> 3.0
 -------------------
  - added support for Python 3.6 (with RĂ¼diger Meier and Thomas Koch)
+ - python3: fixed bugs with surrogate pairs (now supported for the first time)
  - 
  
 Version 2.22 -> 2.23

Modified: lucene/pylucene/trunk/jcc/_jcc3/java/lang/String.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/_jcc3/java/lang/String.cpp?rev=1787671&r1=1787670&r2=1787671&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/_jcc3/java/lang/String.cpp (original)
+++ lucene/pylucene/trunk/jcc/_jcc3/java/lang/String.cpp Sun Mar 19 23:12:52 2017
@@ -99,7 +99,8 @@ namespace java {
               case 1:
                 if (!PyArg_ParseTuple(args, "s", &bytes))
                     return -1;
-                INT_CALL(self->object = String(env->fromUTF8(bytes)));
+                INT_CALL(self->object = String(
+                    env->get_vm_env()->NewStringUTF(bytes)));
                 break;
               default:
                 PyErr_SetString(PyExc_ValueError, "invalid args");

Modified: lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.cpp?rev=1787671&r1=1787670&r2=1787671&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.cpp (original)
+++ lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.cpp Sun Mar 19 23:12:52 2017
@@ -951,15 +951,6 @@ char *JCCEnv::getClassPath()
     return classpath;
 }
 
-jstring JCCEnv::fromUTF8(const char *bytes) const
-{
-    jstring str = get_vm_env()->NewStringUTF(bytes);
-
-    reportException();
-
-    return str;
-}
-
 jstring JCCEnv::fromUTF32(const uint32_t *chars, jsize len) const
 {
     std::vector<jchar> jchars;
@@ -984,56 +975,6 @@ jstring JCCEnv::fromUTF32(const uint32_t
     return str;
 }
 
-char *JCCEnv::toUTF8(jstring str) const
-{
-    JNIEnv *vm_env = get_vm_env();
-    int len = vm_env->GetStringUTFLength(str);
-    char *bytes = (char *) malloc(len + 1);
-    jboolean isCopy = 0;
-    const char *utf = vm_env->GetStringUTFChars(str, &isCopy);
-
-    if (!bytes)
-        return NULL;
-
-    memcpy(bytes, utf, len);
-    bytes[len] = '\0';
-
-    vm_env->ReleaseStringUTFChars(str, utf);
-
-    return bytes;
-}
-
-char *JCCEnv::toString(jobject obj) const
-{
-    try {
-        return obj
-            ? toUTF8((jstring) callObjectMethod(obj, _mids[mid_obj_toString]))
-            : NULL;
-    } catch (int e) {
-        switch (e) {
-          case _EXC_PYTHON:
-            return NULL;
-          case _EXC_JAVA: {
-              JNIEnv *vm_env = get_vm_env();
-
-              vm_env->ExceptionDescribe();
-              vm_env->ExceptionClear();
-
-              return NULL;
-          }
-          default:
-            throw;
-        }
-    }
-}
-
-char *JCCEnv::getClassName(jobject obj) const
-{
-    return obj
-        ? toString(callObjectMethod(obj, _mids[mid_obj_getClass]))
-        : NULL;
-}
-
 #ifdef PYTHON
 
 jstring JCCEnv::fromPyString(PyObject *object) const
@@ -1064,7 +1005,8 @@ jstring JCCEnv::fromPyString(PyObject *o
           }
 
           case PyUnicode_1BYTE_KIND:
-              return fromUTF8((const char *) PyUnicode_1BYTE_DATA(object));
+              return get_vm_env()->NewStringUTF(
+                  (const char *) PyUnicode_1BYTE_DATA(object));
 
           case PyUnicode_2BYTE_KIND: {
               Py_ssize_t len = PyUnicode_GET_LENGTH(object);
@@ -1082,7 +1024,7 @@ jstring JCCEnv::fromPyString(PyObject *o
         }
     }
     else if (PyBytes_Check(object))
-        return fromUTF8(PyBytes_AS_STRING(object));
+        return get_vm_env()->NewStringUTF(PyBytes_AS_STRING(object));
 
 
     PyObject *tuple = Py_BuildValue("(sO)", "expected a string", object);
@@ -1160,13 +1102,13 @@ PyObject *JCCEnv::toPyUnicode(jobject ob
 {
     try {
         if (obj)
-          return fromJString(
-              (jstring) callObjectMethod(obj, _mids[mid_obj_toString]), 0);
+            return fromJString((jstring) callObjectMethod(
+                obj, _mids[mid_obj_toString]), 0);
         Py_RETURN_NONE;
     } catch (int e) {
         switch (e) {
           case _EXC_PYTHON:
-            return NULL;
+              return NULL;
           case _EXC_JAVA: {
               JNIEnv *vm_env = get_vm_env();
 
@@ -1181,6 +1123,13 @@ PyObject *JCCEnv::toPyUnicode(jobject ob
     }
 }
 
+PyObject *JCCEnv::getClassName(jobject obj) const
+{
+    if (obj)
+        return toPyUnicode(callObjectMethod(obj, _mids[mid_obj_getClass]));
+    Py_RETURN_NONE;
+}
+
 /* may be called from finalizer thread which has no vm_env thread local */
 void JCCEnv::finalizeObject(JNIEnv *jenv, PyObject *obj)
 {

Modified: lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.h
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.h?rev=1787671&r1=1787670&r2=1787671&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.h (original)
+++ lucene/pylucene/trunk/jcc/jcc3/sources/JCCEnv.h Sun Mar 19 23:12:52 2017
@@ -280,17 +280,14 @@ public:
     void setClassPath(const char *classPath);
     char *getClassPath();
 
-    jstring fromUTF8(const char *bytes) const;
     jstring fromUTF32(const uint32_t *chars, jsize len) const;
-    char *toUTF8(jstring str) const;
-    char *toString(jobject obj) const;
-    char *getClassName(jobject obj) const;
 #ifdef PYTHON
     jclass getPythonExceptionClass() const;
     bool restorePythonException(jthrowable throwable) const;
     jstring fromPyString(PyObject *object) const;
     PyObject *fromJString(jstring js, int delete_local_ref) const;
     PyObject *toPyUnicode(jobject obj) const;
+    PyObject *getClassName(jobject obj) const;
     void finalizeObject(JNIEnv *jenv, PyObject *obj);
 #endif
 

Modified: lucene/pylucene/trunk/jcc/jcc3/sources/jcc.cpp
URL: http://svn.apache.org/viewvc/lucene/pylucene/trunk/jcc/jcc3/sources/jcc.cpp?rev=1787671&r1=1787670&r2=1787671&view=diff
==============================================================================
--- lucene/pylucene/trunk/jcc/jcc3/sources/jcc.cpp (original)
+++ lucene/pylucene/trunk/jcc/jcc3/sources/jcc.cpp Sun Mar 19 23:12:52 2017
@@ -227,8 +227,7 @@ static PyObject *t_jccenv__dumpRefs(PyOb
          iter++) {
         if (classes)  // return dict of { class name: instance count }
         {
-            char *name = env->getClassName(iter->second.global);
-            PyObject *key = PyUnicode_FromString(name);
+            PyObject *key = env->getClassName(iter->second.global);
             PyObject *value = PyDict_GetItem(result, key);
 
             if (value == NULL)
@@ -239,8 +238,6 @@ static PyObject *t_jccenv__dumpRefs(PyOb
             PyDict_SetItem(result, key, value);
             Py_DECREF(key);
             Py_DECREF(value);
-
-            delete name;
         }
         else if (values)  // return list of (value string, ref count)
         {



Mime
View raw message