From 57c8461053c0453b46424be586b758e85d2bbd51 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Tue, 5 Apr 2016 14:47:00 +0200 Subject: [PATCH] remove const_char, as Cython supports const from 0.18 --- jnius/jni.pxi | 28 +++++++++++++--------------- jnius/jnius_jvm_dlopen.pxi | 9 +++------ 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/jnius/jni.pxi b/jnius/jni.pxi index 4e6c546..ea21640 100644 --- a/jnius/jni.pxi +++ b/jnius/jni.pxi @@ -26,7 +26,6 @@ cdef extern from "jni.h": ctypedef jobject jweak ctypedef jint jsize - ctypedef char const_char "const_char" ctypedef jchar const_jchar "const jchar" ctypedef jbyte const_jbyte "const jbyte" ctypedef jbyte const_jint "const jint" @@ -37,8 +36,8 @@ cdef extern from "jni.h": ctypedef jdouble const_jdouble "const jdouble" ctypedef struct JNINativeMethod: - const_char* name - const_char* signature + const char* name + const char* signature void* fnPtr ctypedef JNINativeMethod const_JNINativeMethod "const JNINativeMethod" @@ -73,7 +72,7 @@ cdef extern from "jni.h": ctypedef struct JNINativeInterface: jint *GetVersion(JNIEnv *) - jclass (*DefineClass)(JNIEnv*, const_char*, jobject, const_jbyte*, + jclass (*DefineClass)(JNIEnv*, const char*, jobject, const_jbyte*, jsize) jclass (*FindClass)(JNIEnv*, char*) @@ -89,11 +88,11 @@ cdef extern from "jni.h": jobject (*ToReflectedField)(JNIEnv*, jclass, jfieldID, jboolean) jint (*Throw)(JNIEnv*, jthrowable) - jint (*ThrowNew)(JNIEnv *, jclass, const_char *) + jint (*ThrowNew)(JNIEnv *, jclass, const char *) jthrowable (*ExceptionOccurred)(JNIEnv*) void (*ExceptionDescribe)(JNIEnv*) void (*ExceptionClear)(JNIEnv*) - void (*FatalError)(JNIEnv*, const_char*) + void (*FatalError)(JNIEnv*, const char*) jint (*PushLocalFrame)(JNIEnv*, jint) jobject (*PopLocalFrame)(JNIEnv*, jobject) @@ -113,7 +112,7 @@ cdef extern from "jni.h": jclass (*GetObjectClass)(JNIEnv*, jobject) jboolean (*IsInstanceOf)(JNIEnv*, jobject, jclass) - jmethodID (*GetMethodID)(JNIEnv*, jclass, const_char*, const_char*) + jmethodID (*GetMethodID)(JNIEnv*, jclass, const char*, const char*) jobject (*CallObjectMethod)(JNIEnv*, jobject, jmethodID, ...) nogil jobject (*CallObjectMethodV)(JNIEnv*, jobject, jmethodID, va_list) nogil @@ -207,7 +206,7 @@ cdef extern from "jni.h": void (*CallNonvirtualVoidMethodA)(JNIEnv*, jobject, jclass, jmethodID, jvalue*) nogil - jfieldID (*GetFieldID)(JNIEnv*, jclass, const_char*, const_char*) + jfieldID (*GetFieldID)(JNIEnv*, jclass, const char*, const char*) jobject (*GetObjectField)(JNIEnv*, jobject, jfieldID) jboolean (*GetBooleanField)(JNIEnv*, jobject, jfieldID) @@ -229,8 +228,8 @@ cdef extern from "jni.h": void (*SetFloatField)(JNIEnv*, jobject, jfieldID, jfloat) void (*SetDoubleField)(JNIEnv*, jobject, jfieldID, jdouble) - jmethodID (*GetStaticMethodID)(JNIEnv*, jclass, const_char*, - const_char*) nogil + jmethodID (*GetStaticMethodID)(JNIEnv*, jclass, const char*, + const char*) nogil jobject (*CallStaticObjectMethod)(JNIEnv*, jclass, jmethodID, ...) nogil jobject (*CallStaticObjectMethodV)(JNIEnv*, jclass, jmethodID, va_list) nogil @@ -265,8 +264,8 @@ cdef extern from "jni.h": void (*CallStaticVoidMethodV)(JNIEnv*, jclass, jmethodID, va_list) nogil void (*CallStaticVoidMethodA)(JNIEnv*, jclass, jmethodID, jvalue*) nogil - jfieldID (*GetStaticFieldID)(JNIEnv*, jclass, const_char*, - const_char*) + jfieldID (*GetStaticFieldID)(JNIEnv*, jclass, const char*, + const char*) jobject (*GetStaticObjectField)(JNIEnv*, jclass, jfieldID) jboolean (*GetStaticBooleanField)(JNIEnv*, jclass, jfieldID) @@ -295,8 +294,8 @@ cdef extern from "jni.h": jstring (*NewStringUTF)(JNIEnv*, char*) jsize (*GetStringUTFLength)(JNIEnv*, jstring) # JNI spec says this returns const_jbyte*, but that's inconsistent - const_char* (*GetStringUTFChars)(JNIEnv*, jstring, jboolean*) - void (*ReleaseStringUTFChars)(JNIEnv*, jstring, const_char*) + const char* (*GetStringUTFChars)(JNIEnv*, jstring, jboolean*) + void (*ReleaseStringUTFChars)(JNIEnv*, jstring, const char*) jsize (*GetArrayLength)(JNIEnv*, jarray) jobjectArray (*NewObjectArray)(JNIEnv*, jsize, jclass, jobject) jobject (*GetObjectArrayElement)(JNIEnv*, jobjectArray, jsize) @@ -402,4 +401,3 @@ cdef extern from "jni.h": ctypedef struct JNIInvokeInterface: jint (*AttachCurrentThread)(JavaVM *, JNIEnv **, void *) jint (*DetachCurrentThread)(JavaVM *) - diff --git a/jnius/jnius_jvm_dlopen.pxi b/jnius/jnius_jvm_dlopen.pxi index 9fce931..7557c87 100644 --- a/jnius/jnius_jvm_dlopen.pxi +++ b/jnius/jnius_jvm_dlopen.pxi @@ -1,13 +1,10 @@ include "config.pxi" import os -cdef extern from *: - ctypedef char const_char "const char" - cdef extern from 'dlfcn.h' nogil: - void* dlopen(const_char *filename, int flag) + void* dlopen(const char *filename, int flag) char *dlerror() - void *dlsym(void *handle, const_char *symbol) + void *dlsym(void *handle, const char *symbol) int dlclose(void *handle) unsigned int RTLD_LAZY @@ -52,7 +49,7 @@ cdef void create_jnienv() except *: lib_path = str_for_c(os.path.join(JAVA_HOME, JNIUS_LIB_SUFFIX.decode("utf-8"))) ELSE: lib_path = str_for_c(os.path.join(JAVA_HOME, JNIUS_LIB_SUFFIX)) - + cdef void *handle = dlopen(lib_path, RTLD_NOW | RTLD_GLOBAL) if handle == NULL: raise SystemError("Error calling dlopen({0}: {1}".format(lib_path, dlerror()))