diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-16 08:53:22 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-16 08:53:22 -0700 |
commit | eb7090d25469ad3c01164f9155908dd21279d74e (patch) | |
tree | 3cf527c59139a675c085683108e7f1381b0b3839 /V8Binding | |
parent | 9b6dda97f056112bed1755d9d49c34d709db299c (diff) | |
parent | 0e3a923bc0925b8bcbd58b3ce14719c286a93250 (diff) | |
download | external_webkit-eb7090d25469ad3c01164f9155908dd21279d74e.zip external_webkit-eb7090d25469ad3c01164f9155908dd21279d74e.tar.gz external_webkit-eb7090d25469ad3c01164f9155908dd21279d74e.tar.bz2 |
Merge change 7500
* changes:
Convert Java string to JavaScript string.
Diffstat (limited to 'V8Binding')
-rw-r--r-- | V8Binding/jni/jni_instance.cpp | 2 | ||||
-rw-r--r-- | V8Binding/jni/jni_npobject.cpp | 2 | ||||
-rw-r--r-- | V8Binding/jni/jni_utility.cpp | 12 | ||||
-rw-r--r-- | V8Binding/jni/jni_utility.h | 2 |
4 files changed, 13 insertions, 5 deletions
diff --git a/V8Binding/jni/jni_instance.cpp b/V8Binding/jni/jni_instance.cpp index e2151a9..6b83764 100644 --- a/V8Binding/jni/jni_instance.cpp +++ b/V8Binding/jni/jni_instance.cpp @@ -149,7 +149,7 @@ bool JavaInstance::invokeMethod(const char* methodName, const NPVariant* args, u getJNIEnv()->DeleteLocalRef(obj); } - convertJValueToNPVariant(result, jMethod->JNIReturnType(), resultValue); + convertJValueToNPVariant(result, jMethod->JNIReturnType(), jMethod->returnType(), resultValue); free (jArgs); return true; diff --git a/V8Binding/jni/jni_npobject.cpp b/V8Binding/jni/jni_npobject.cpp index 662ea7c..d826826 100644 --- a/V8Binding/jni/jni_npobject.cpp +++ b/V8Binding/jni/jni_npobject.cpp @@ -150,7 +150,7 @@ bool JavaNPObject_GetProperty(NPObject* obj, NPIdentifier identifier, NPVariant* field->type()); getJNIEnv()->DeleteLocalRef(local_ref); - convertJValueToNPVariant(value, field->getJNIType(), result); + convertJValueToNPVariant(value, field->getJNIType(), field->type(), result); return true; } diff --git a/V8Binding/jni/jni_utility.cpp b/V8Binding/jni/jni_utility.cpp index 90cf603..8b907a4 100644 --- a/V8Binding/jni/jni_utility.cpp +++ b/V8Binding/jni/jni_utility.cpp @@ -469,7 +469,7 @@ jvalue convertNPVariantToJValue(NPVariant value, JNIType _JNIType, const char* j } -void convertJValueToNPVariant(jvalue value, JNIType _JNIType, NPVariant* result) +void convertJValueToNPVariant(jvalue value, JNIType _JNIType, const char* javaTypeName, NPVariant* result) { switch (_JNIType){ case void_type: { @@ -479,7 +479,15 @@ void convertJValueToNPVariant(jvalue value, JNIType _JNIType, NPVariant* result) case object_type: { if (value.l != 0) { - OBJECT_TO_NPVARIANT(JavaInstanceToNPObject(new JavaInstance(value.l)), *result); + if (strcmp(javaTypeName, "java.lang.String") == 0) { + const char* v = getCharactersFromJString((jstring)value.l); + // s is freed in NPN_ReleaseVariantValue (see npruntime.cpp) + const char* s = strdup(v); + releaseCharactersForJString((jstring)value.l, v); + STRINGZ_TO_NPVARIANT(s, *result); + } else { + OBJECT_TO_NPVARIANT(JavaInstanceToNPObject(new JavaInstance(value.l)), *result); + } } else { VOID_TO_NPVARIANT(*result); diff --git a/V8Binding/jni/jni_utility.h b/V8Binding/jni/jni_utility.h index bb755bf..917e3d1 100644 --- a/V8Binding/jni/jni_utility.h +++ b/V8Binding/jni/jni_utility.h @@ -67,7 +67,7 @@ JNIType JNITypeFromPrimitiveType(char type); const char *signatureFromPrimitiveType(JNIType type); jvalue convertNPVariantToJValue(NPVariant, JNIType, const char* javaClassName); -void convertJValueToNPVariant(jvalue, JNIType, NPVariant*); +void convertJValueToNPVariant(jvalue, JNIType, const char* javaClassName, NPVariant*); jvalue getJNIField(jobject obj, JNIType type, const char *name, const char *signature); |