diff options
author | Ben Murdoch <benm@google.com> | 2009-11-23 14:25:39 +0000 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2009-11-24 12:18:38 +0000 |
commit | 073888a8dc1673fa90ca33226485b7bb0e19d460 (patch) | |
tree | 683884483e92f509d6a5d0954189cb143435f677 | |
parent | ecf268d482528c4778b1bca2eea6a2d49e477c3f (diff) | |
download | external_webkit-073888a8dc1673fa90ca33226485b7bb0e19d460.zip external_webkit-073888a8dc1673fa90ca33226485b7bb0e19d460.tar.gz external_webkit-073888a8dc1673fa90ca33226485b7bb0e19d460.tar.bz2 |
Unfork WebCore/bridge/jni.
Change-Id: I973e6b03286b1d8f6e6325a2b31d0cf9e99d19b3
-rw-r--r-- | WebCore/bridge/jni/jni_class.cpp | 4 | ||||
-rw-r--r-- | WebCore/bridge/jni/jni_instance.cpp | 8 | ||||
-rw-r--r-- | WebCore/bridge/jni/jni_instance.h | 19 | ||||
-rw-r--r-- | WebCore/bridge/jni/jni_runtime.cpp | 3 | ||||
-rw-r--r-- | WebCore/bridge/jni/jni_utility.cpp | 6 | ||||
-rw-r--r-- | WebCore/bridge/jni/jni_utility.h | 17 | ||||
-rw-r--r-- | WebKit/android/jni/WebCoreFrameBridge.cpp | 10 |
7 files changed, 22 insertions, 45 deletions
diff --git a/WebCore/bridge/jni/jni_class.cpp b/WebCore/bridge/jni/jni_class.cpp index 9c7f300..6728e7b 100644 --- a/WebCore/bridge/jni/jni_class.cpp +++ b/WebCore/bridge/jni/jni_class.cpp @@ -85,12 +85,10 @@ JavaClass::JavaClass(jobject anInstance) methodList->append(aMethod); env->DeleteLocalRef(aJMethod); } -#if PLATFORM(ANDROID) - // TODO : Upstream to webkit.org for all platforms. + env->DeleteLocalRef(fields); env->DeleteLocalRef(methods); env->DeleteLocalRef(aClass); -#endif } JavaClass::~JavaClass() { diff --git a/WebCore/bridge/jni/jni_instance.cpp b/WebCore/bridge/jni/jni_instance.cpp index e3b857d..d0bcfcb 100644 --- a/WebCore/bridge/jni/jni_instance.cpp +++ b/WebCore/bridge/jni/jni_instance.cpp @@ -28,10 +28,6 @@ #if ENABLE(MAC_JAVA_BRIDGE) -#if PLATFORM(ANDROID) -#include <assert.h> -#endif - #include "jni_class.h" #include "jni_runtime.h" #include "jni_utility.h" @@ -41,6 +37,10 @@ #include <runtime/Error.h> #include <runtime/JSLock.h> +#if PLATFORM(ANDROID) +#include <assert.h> +#endif + #ifdef NDEBUG #define JS_LOG(formatAndArgs...) ((void)0) #else diff --git a/WebCore/bridge/jni/jni_instance.h b/WebCore/bridge/jni/jni_instance.h index 96dda7d..049bfdb 100644 --- a/WebCore/bridge/jni/jni_instance.h +++ b/WebCore/bridge/jni/jni_instance.h @@ -33,12 +33,6 @@ #include <JavaVM/jni.h> -#if PLATFORM(ANDROID) -namespace android { -class WeakJavaInstance; -} -#endif - namespace JSC { namespace Bindings { @@ -52,9 +46,10 @@ friend class JavaArray; friend class JavaField; friend class JavaInstance; friend class JavaMethod; -#if PLATFORM(ANDROID) -friend class android::WeakJavaInstance; -#endif + +public: + jobject instance() const { return _instance; } + void setInstance(jobject instance) { _instance = instance; } protected: JObjectWrapper(jobject instance); @@ -98,14 +93,10 @@ public: JSValue booleanValue() const; protected: + JavaInstance(jobject instance, PassRefPtr<RootObject>); virtual void virtualBegin(); virtual void virtualEnd(); -#if !PLATFORM(ANDROID) // Submit patch to webkit.org -private: -#endif - JavaInstance(jobject instance, PassRefPtr<RootObject>); - RefPtr<JObjectWrapper> _instance; mutable JavaClass *_class; }; diff --git a/WebCore/bridge/jni/jni_runtime.cpp b/WebCore/bridge/jni/jni_runtime.cpp index 50fe351..d7d0696 100644 --- a/WebCore/bridge/jni/jni_runtime.cpp +++ b/WebCore/bridge/jni/jni_runtime.cpp @@ -284,10 +284,7 @@ JavaMethod::JavaMethod (JNIEnv *env, jobject aMethod) jclass modifierClass = env->FindClass("java/lang/reflect/Modifier"); int modifiers = callJNIMethod<jint>(aMethod, "getModifiers", "()I"); _isStatic = (bool)callJNIStaticMethod<jboolean>(modifierClass, "isStatic", "(I)Z", modifiers); -#if PLATFORM(ANDROID) - // TODO : Upstream to webkit.org for all platforms. env->DeleteLocalRef(modifierClass); -#endif } JavaMethod::~JavaMethod() diff --git a/WebCore/bridge/jni/jni_utility.cpp b/WebCore/bridge/jni/jni_utility.cpp index e1eb736..fa63a42 100644 --- a/WebCore/bridge/jni/jni_utility.cpp +++ b/WebCore/bridge/jni/jni_utility.cpp @@ -28,7 +28,7 @@ #if ENABLE(MAC_JAVA_BRIDGE) -#if PLATFORM(ANDROID) +// TODO: ANDROID We need to merge this file with the V8 version. #if USE(JSC) #include "jni_runtime.h" #include "runtime_array.h" @@ -36,7 +36,6 @@ #include <runtime/JSArray.h> #include <runtime/JSLock.h> #endif -#endif #include <dlfcn.h> @@ -352,7 +351,7 @@ jvalue getJNIField( jobject obj, JNIType type, const char *name, const char *sig return result; } -#if PLATFORM(ANDROID) +// TODO: ANDROID we need to merge this file with the V8 version. #if USE(JSC) static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray, const char* javaClassName) { @@ -584,7 +583,6 @@ jvalue convertValueToJValue(ExecState* exec, JSValue value, JNIType _JNIType, co return result; } #endif // USE(JSC) -#endif // PLATFORM(ANDROID) } // end of namespace Bindings diff --git a/WebCore/bridge/jni/jni_utility.h b/WebCore/bridge/jni/jni_utility.h index e46dbc4..57a0500 100644 --- a/WebCore/bridge/jni/jni_utility.h +++ b/WebCore/bridge/jni/jni_utility.h @@ -28,12 +28,11 @@ #if ENABLE(MAC_JAVA_BRIDGE) -#include <JavaVM/jni.h> -#if PLATFORM(ANDROID) +// TODO: ANDROID we need to merge this file with the V8 version. #if USE(JSC) #include <runtime/JSValue.h> #endif -#endif +#include <JavaVM/jni.h> // The order of these items can not be modified as they are tightly // bound with the JVM on Mac OSX. If new types need to be added, they @@ -57,12 +56,11 @@ typedef enum { namespace JSC { -#if PLATFORM(ANDROID) +// TODO: ANDROID we need to merge this file with the V8 version. #if USE(JSC) class ExecState; class JSObject; #endif -#endif namespace Bindings { @@ -80,11 +78,10 @@ JNIType JNITypeFromClassName(const char *name); JNIType JNITypeFromPrimitiveType(char type); const char *signatureFromPrimitiveType(JNIType type); -#if PLATFORM(ANDROID) +// TODO: ANDROID we need to merge this file with the V8 version. #if USE(JSC) jvalue convertValueToJValue(ExecState*, JSValue, JNIType, const char* javaClassName); #endif -#endif jvalue getJNIField(jobject obj, JNIType type, const char *name, const char *signature); @@ -228,11 +225,8 @@ static T callJNIMethodV(jobject obj, const char *name, const char *sig, va_list jmethodID mid = env->GetMethodID(cls, name, sig); if ( mid != NULL ) { -#if PLATFORM(ANDROID) - // TODO : Upstream to webkit.org for all platforms. // Avoids references to cls without popping the local frame. env->DeleteLocalRef(cls); -#endif return JNICaller<T>::callV(obj, mid, args); } else @@ -294,11 +288,10 @@ T callJNIStaticMethod(jclass cls, const char* methodName, const char* methodSign return result; } -#if PLATFORM(ANDROID) +// TODO: ANDROID we need to merge this file with the V8 version. #if USE(JSC) bool dispatchJNICall(ExecState*, const void* targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue* args, jvalue& result, const char* callingURL, JSValue& exceptionDescription); #endif -#endif } // namespace Bindings diff --git a/WebKit/android/jni/WebCoreFrameBridge.cpp b/WebKit/android/jni/WebCoreFrameBridge.cpp index 65913ab..f88bf1b 100644 --- a/WebKit/android/jni/WebCoreFrameBridge.cpp +++ b/WebKit/android/jni/WebCoreFrameBridge.cpp @@ -1163,13 +1163,13 @@ protected: { JNIEnv* env = JSC::Bindings::getJNIEnv(); // JavaInstance creates a global ref to instance in its constructor. - env->DeleteGlobalRef(_instance->_instance); + env->DeleteGlobalRef(_instance->instance()); // Set the object to our WeakReference wrapper. - _instance->_instance = adoptGlobalRef(env, instance); + _instance->setInstance(adoptGlobalRef(env, instance)); } virtual void virtualBegin() { - _weakRef = _instance->_instance; + _weakRef = _instance->instance(); JNIEnv* env = JSC::Bindings::getJNIEnv(); // This is odd. getRealObject returns an AutoJObject which is used to // cleanly create and delete a local reference. But, here we need to @@ -1178,7 +1178,7 @@ protected: // and delete the local reference in virtualEnd(). _realObject = getRealObject(env, _weakRef).release(); // Point to the real object - _instance->_instance = _realObject; + _instance->setInstance(_realObject); // Call the base class method INHERITED::virtualBegin(); } @@ -1189,7 +1189,7 @@ protected: // Get rid of the local reference to the real object. JSC::Bindings::getJNIEnv()->DeleteLocalRef(_realObject); // Point back to the WeakReference. - _instance->_instance = _weakRef; + _instance->setInstance(_weakRef); } private: |