diff options
author | Ben Murdoch <benm@google.com> | 2011-06-02 12:07:03 +0100 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2011-06-10 10:47:21 +0100 |
commit | 2daae5fd11344eaa88a0d92b0f6d65f8d2255c00 (patch) | |
tree | e4964fbd1cb70599f7718ff03e50ea1dab33890b /Source/WebCore/bridge | |
parent | 87bdf0060a247bfbe668342b87e0874182e0ffa9 (diff) | |
download | external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.zip external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.gz external_webkit-2daae5fd11344eaa88a0d92b0f6d65f8d2255c00.tar.bz2 |
Merge WebKit at r84325: Initial merge by git.
Change-Id: Ic1a909300ecc0a13ddc6b4e784371d2ac6e3d59b
Diffstat (limited to 'Source/WebCore/bridge')
32 files changed, 277 insertions, 123 deletions
diff --git a/Source/WebCore/bridge/c/CRuntimeObject.h b/Source/WebCore/bridge/c/CRuntimeObject.h index 85815fb..c96887a 100644 --- a/Source/WebCore/bridge/c/CRuntimeObject.h +++ b/Source/WebCore/bridge/c/CRuntimeObject.h @@ -44,7 +44,7 @@ public: static const ClassInfo s_info; - static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } diff --git a/Source/WebCore/bridge/c/c_instance.cpp b/Source/WebCore/bridge/c/c_instance.cpp index 21fae4f..d0fa3cf 100644 --- a/Source/WebCore/bridge/c/c_instance.cpp +++ b/Source/WebCore/bridge/c/c_instance.cpp @@ -43,7 +43,6 @@ #include <runtime/Error.h> #include <runtime/FunctionPrototype.h> #include <runtime/JSLock.h> -#include <runtime/JSNumberCell.h> #include <runtime/PropertyNameArray.h> #include <wtf/Assertions.h> #include <wtf/StdLibExtras.h> @@ -120,7 +119,7 @@ public: ASSERT(inherits(&s_info)); } - static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } diff --git a/Source/WebCore/bridge/jni/JavaMethod.h b/Source/WebCore/bridge/jni/JavaMethod.h index f15b653..5068693 100644 --- a/Source/WebCore/bridge/jni/JavaMethod.h +++ b/Source/WebCore/bridge/jni/JavaMethod.h @@ -42,6 +42,8 @@ typedef const char* RuntimeType; class JavaMethod : public Method { public: + virtual ~JavaMethod() {} + virtual String name() const = 0; virtual RuntimeType returnTypeClassName() const = 0; virtual String parameterAt(int) const = 0; diff --git a/Source/WebCore/bridge/jni/JobjectWrapper.h b/Source/WebCore/bridge/jni/JobjectWrapper.h index 28ce56e..9cc4b27 100644 --- a/Source/WebCore/bridge/jni/JobjectWrapper.h +++ b/Source/WebCore/bridge/jni/JobjectWrapper.h @@ -38,7 +38,9 @@ namespace Bindings { class JobjectWrapper { friend class JavaArray; friend class JavaField; +friend class JavaFieldJobject; friend class JavaInstance; +friend class JavaInstanceJobject; public: jobject instance() const { return m_instance; } diff --git a/Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp b/Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp index 806efa6..ab64132 100644 --- a/Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp +++ b/Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp @@ -124,7 +124,7 @@ public: ASSERT(inherits(&s_info)); } - static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } diff --git a/Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.h b/Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.h index 03f116f..8a3612f 100644 --- a/Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.h +++ b/Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.h @@ -42,7 +42,7 @@ public: static const ClassInfo s_info; - static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } diff --git a/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp b/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp index e2ef2ce..4c9e240 100644 --- a/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp +++ b/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp @@ -28,7 +28,7 @@ #if ENABLE(JAVA_BRIDGE) -#include "JavaInstanceV8.h" +#include "JavaInstanceJobjectV8.h" #include "JavaNPObjectV8.h" #if PLATFORM(ANDROID) #include "npruntime_impl.h" @@ -424,7 +424,7 @@ JavaValue jvalueToJavaValue(const jvalue& value, const JavaType& type) case JavaTypeVoid: break; case JavaTypeObject: - result.m_objectValue = new JavaInstance(value.l); + result.m_objectValue = new JavaInstanceJobject(value.l); break; case JavaTypeString: { @@ -476,8 +476,11 @@ jvalue javaValueToJvalue(const JavaValue& value) case JavaTypeArray: #endif case JavaTypeObject: - if (value.m_objectValue) - result.l = value.m_objectValue->javaInstance(); + if (value.m_objectValue) { + // This method is used only by JavaInstanceJobject, so we know the + // derived type of the object. + result.l = static_cast<JavaInstanceJobject*>(value.m_objectValue.get())->javaInstance(); + } break; case JavaTypeString: // This creates a local reference to a new String object, which will diff --git a/Source/WebCore/bridge/jni/v8/JavaClassV8.cpp b/Source/WebCore/bridge/jni/v8/JavaClassJobjectV8.cpp index 24d05f3..40bfd63 100644 --- a/Source/WebCore/bridge/jni/v8/JavaClassV8.cpp +++ b/Source/WebCore/bridge/jni/v8/JavaClassJobjectV8.cpp @@ -24,16 +24,16 @@ */ #include "config.h" -#include "JavaClassV8.h" +#include "JavaClassJobjectV8.h" #if ENABLE(JAVA_BRIDGE) -#include "JavaFieldV8.h" +#include "JavaFieldJobjectV8.h" #include "JavaMethodJobject.h" using namespace JSC::Bindings; -JavaClass::JavaClass(jobject anInstance) +JavaClassJobject::JavaClassJobject(jobject anInstance) { jobject aClass = callJNIMethod<jobject>(anInstance, "getClass", "()Ljava/lang/Class;"); @@ -42,34 +42,28 @@ JavaClass::JavaClass(jobject anInstance) return; } - int i; JNIEnv* env = getJNIEnv(); // Get the fields jarray fields = static_cast<jarray>(callJNIMethod<jobject>(aClass, "getFields", "()[Ljava/lang/reflect/Field;")); int numFields = env->GetArrayLength(fields); - for (i = 0; i < numFields; i++) { + for (int i = 0; i < numFields; i++) { jobject aJField = env->GetObjectArrayElement(static_cast<jobjectArray>(fields), i); - JavaField* aField = new JavaField(env, aJField); // deleted in the JavaClass destructor - { - m_fields.set(aField->name().utf8(), aField); - } + JavaField* aField = new JavaFieldJobject(env, aJField); // deleted in the JavaClass destructor + m_fields.set(aField->name(), aField); env->DeleteLocalRef(aJField); } // Get the methods jarray methods = static_cast<jarray>(callJNIMethod<jobject>(aClass, "getMethods", "()[Ljava/lang/reflect/Method;")); int numMethods = env->GetArrayLength(methods); - for (i = 0; i < numMethods; i++) { + for (int i = 0; i < numMethods; i++) { jobject aJMethod = env->GetObjectArrayElement(static_cast<jobjectArray>(methods), i); JavaMethod* aMethod = new JavaMethodJobject(env, aJMethod); // deleted in the JavaClass destructor - MethodList* methodList; - { - methodList = m_methods.get(aMethod->name()); - if (!methodList) { - methodList = new MethodList(); - m_methods.set(aMethod->name(), methodList); - } + MethodList* methodList = m_methods.get(aMethod->name()); + if (!methodList) { + methodList = new MethodList(); + m_methods.set(aMethod->name(), methodList); } methodList->append(aMethod); env->DeleteLocalRef(aJMethod); @@ -79,7 +73,7 @@ JavaClass::JavaClass(jobject anInstance) env->DeleteLocalRef(aClass); } -JavaClass::~JavaClass() +JavaClassJobject::~JavaClassJobject() { deleteAllValues(m_fields); m_fields.clear(); @@ -93,7 +87,7 @@ JavaClass::~JavaClass() m_methods.clear(); } -MethodList JavaClass::methodsNamed(const char* name) const +MethodList JavaClassJobject::methodsNamed(const char* name) const { MethodList* methodList = m_methods.get(name); @@ -102,7 +96,7 @@ MethodList JavaClass::methodsNamed(const char* name) const return MethodList(); } -JavaField* JavaClass::fieldNamed(const char* name) const +JavaField* JavaClassJobject::fieldNamed(const char* name) const { return m_fields.get(name); } diff --git a/Source/WebCore/bridge/jni/v8/JavaClassJobjectV8.h b/Source/WebCore/bridge/jni/v8/JavaClassJobjectV8.h new file mode 100644 index 0000000..d27ca97 --- /dev/null +++ b/Source/WebCore/bridge/jni/v8/JavaClassJobjectV8.h @@ -0,0 +1,59 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JavaClassJobjectV8_h +#define JavaClassJobjectV8_h + +#if ENABLE(JAVA_BRIDGE) + +#include "JNIUtility.h" +#include "JavaClassV8.h" + +namespace JSC { + +namespace Bindings { + +class JavaClassJobject : public JavaClass { +public: + JavaClassJobject(jobject); + virtual ~JavaClassJobject(); + + // JavaClass implementation + virtual MethodList methodsNamed(const char* name) const; + virtual JavaField* fieldNamed(const char* name) const; + +private: + typedef HashMap<WTF::String, MethodList*> MethodListMap; + MethodListMap m_methods; + FieldMap m_fields; +}; + +} // namespace Bindings + +} // namespace JSC + +#endif // ENABLE(JAVA_BRIDGE) + +#endif // JavaClassJobjectV8_h diff --git a/Source/WebCore/bridge/jni/v8/JavaClassV8.h b/Source/WebCore/bridge/jni/v8/JavaClassV8.h index 6b03b2d..e60ca2d 100644 --- a/Source/WebCore/bridge/jni/v8/JavaClassV8.h +++ b/Source/WebCore/bridge/jni/v8/JavaClassV8.h @@ -28,11 +28,10 @@ #if ENABLE(JAVA_BRIDGE) -#include "JNIUtility.h" -#include "PlatformString.h" #include <wtf/HashMap.h> #include <wtf/Vector.h> #include <wtf/text/StringHash.h> +#include <wtf/text/WTFString.h> namespace JSC { @@ -42,20 +41,14 @@ class JavaField; class JavaMethod; typedef Vector<JavaMethod*> MethodList; -typedef HashMap<WTF::String, MethodList*> MethodListMap; typedef HashMap<WTF::String, JavaField*> FieldMap; class JavaClass { public: - JavaClass(jobject); - ~JavaClass(); + virtual ~JavaClass() {} - MethodList methodsNamed(const char* name) const; - JavaField* fieldNamed(const char* name) const; - -private: - MethodListMap m_methods; - FieldMap m_fields; + virtual MethodList methodsNamed(const char* name) const = 0; + virtual JavaField* fieldNamed(const char* name) const = 0; }; } // namespace Bindings diff --git a/Source/WebCore/bridge/jni/v8/JavaFieldV8.cpp b/Source/WebCore/bridge/jni/v8/JavaFieldJobjectV8.cpp index 2a6dd0b..0fe5837 100644 --- a/Source/WebCore/bridge/jni/v8/JavaFieldV8.cpp +++ b/Source/WebCore/bridge/jni/v8/JavaFieldJobjectV8.cpp @@ -24,13 +24,13 @@ */ #include "config.h" -#include "JavaFieldV8.h" +#include "JavaFieldJobjectV8.h" #if ENABLE(JAVA_BRIDGE) using namespace JSC::Bindings; -JavaField::JavaField(JNIEnv* env, jobject aField) +JavaFieldJobject::JavaFieldJobject(JNIEnv* env, jobject aField) { // Get field type jobject fieldType = callJNIMethod<jobject>(aField, "getType", "()Ljava/lang/Class;"); diff --git a/Source/WebCore/bridge/jni/v8/JavaFieldJobjectV8.h b/Source/WebCore/bridge/jni/v8/JavaFieldJobjectV8.h new file mode 100644 index 0000000..32c7857 --- /dev/null +++ b/Source/WebCore/bridge/jni/v8/JavaFieldJobjectV8.h @@ -0,0 +1,61 @@ +/* + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JavaFieldJobjectV8_h +#define JavaFieldJobjectV8_h + +#if ENABLE(JAVA_BRIDGE) + +#include "JavaFieldV8.h" +#include "JavaString.h" +#include "JobjectWrapper.h" + +namespace JSC { + +namespace Bindings { + +class JavaFieldJobject : public JavaField { +public: + JavaFieldJobject(JNIEnv*, jobject); + + // JavaField implementation + virtual String name() const { return m_name.impl(); } + virtual const char* typeClassName() const { return m_typeClassName.utf8(); } + virtual JavaType type() const { return m_type; } + +private: + JavaString m_name; + JavaString m_typeClassName; + JavaType m_type; + RefPtr<JobjectWrapper> m_field; +}; + +} // namespace Bindings + +} // namespace JSC + +#endif // ENABLE(JAVA_BRIDGE) + +#endif // JavaFieldJobjectV8_h diff --git a/Source/WebCore/bridge/jni/v8/JavaFieldV8.h b/Source/WebCore/bridge/jni/v8/JavaFieldV8.h index defed60..3c24cf5 100644 --- a/Source/WebCore/bridge/jni/v8/JavaFieldV8.h +++ b/Source/WebCore/bridge/jni/v8/JavaFieldV8.h @@ -28,8 +28,8 @@ #if ENABLE(JAVA_BRIDGE) -#include "JavaString.h" -#include "JobjectWrapper.h" +#include "JNIUtility.h" +#include <wtf/text/WTFString.h> namespace JSC { @@ -37,17 +37,11 @@ namespace Bindings { class JavaField { public: - JavaField(JNIEnv*, jobject aField); + virtual ~JavaField() {} - const JavaString& name() const { return m_name; } - const char* typeClassName() const { return m_typeClassName.utf8(); } - JavaType type() const { return m_type; } - -private: - JavaString m_name; - JavaString m_typeClassName; - JavaType m_type; - RefPtr<JobjectWrapper> m_field; + virtual String name() const = 0; + virtual const char* typeClassName() const = 0; + virtual JavaType type() const = 0; }; } // namespace Bindings diff --git a/Source/WebCore/bridge/jni/v8/JavaInstanceV8.cpp b/Source/WebCore/bridge/jni/v8/JavaInstanceJobjectV8.cpp index d1075ae..8221eff 100644 --- a/Source/WebCore/bridge/jni/v8/JavaInstanceV8.cpp +++ b/Source/WebCore/bridge/jni/v8/JavaInstanceJobjectV8.cpp @@ -25,52 +25,46 @@ */ #include "config.h" -#include "JavaInstanceV8.h" +#include "JavaInstanceJobjectV8.h" #if ENABLE(JAVA_BRIDGE) #include "JNIUtilityPrivate.h" -#include "JavaClassV8.h" +#include "JavaClassJobjectV8.h" #include "JavaFieldV8.h" #include "JavaMethod.h" #include <wtf/OwnArrayPtr.h> +#include <wtf/PassOwnPtr.h> #include <wtf/text/CString.h> using namespace JSC::Bindings; -JavaInstance::JavaInstance(jobject instance) +JavaInstanceJobject::JavaInstanceJobject(jobject instance) + : m_instance(new JobjectWrapper(instance)) { - m_instance = new JobjectWrapper(instance); - m_class = 0; -} - -JavaInstance::~JavaInstance() -{ - m_instance = 0; - delete m_class; } #define NUM_LOCAL_REFS 64 -void JavaInstance::virtualBegin() +void JavaInstanceJobject::begin() { getJNIEnv()->PushLocalFrame(NUM_LOCAL_REFS); } -void JavaInstance::virtualEnd() +void JavaInstanceJobject::end() { getJNIEnv()->PopLocalFrame(0); } -JavaClass* JavaInstance::getClass() const +JavaClass* JavaInstanceJobject::getClass() const { if (!m_class) - m_class = new JavaClass(javaInstance()); - return m_class; + m_class = adoptPtr(new JavaClassJobject(javaInstance())); + return m_class.get(); } -JavaValue JavaInstance::invokeMethod(const JavaMethod* method, JavaValue* args) +JavaValue JavaInstanceJobject::invokeMethod(const JavaMethod* method, JavaValue* args) { ASSERT(getClass()->methodsNamed(method->name().utf8().data()).find(method) != notFound); unsigned int numParams = method->numParameters(); @@ -81,10 +75,10 @@ JavaValue JavaInstance::invokeMethod(const JavaMethod* method, JavaValue* args) return jvalueToJavaValue(result, method->returnType()); } -JavaValue JavaInstance::getField(const JavaField* field) +JavaValue JavaInstanceJobject::getField(const JavaField* field) { - ASSERT(getClass()->fieldNamed(field->name().utf8()) == field); - return jvalueToJavaValue(getJNIField(javaInstance(), field->type(), field->name().utf8(), field->typeClassName()), field->type()); + ASSERT(getClass()->fieldNamed(field->name().utf8().data()) == field); + return jvalueToJavaValue(getJNIField(javaInstance(), field->type(), field->name().utf8().data(), field->typeClassName()), field->type()); } #endif // ENABLE(JAVA_BRIDGE) diff --git a/Source/WebCore/bridge/jni/v8/JavaInstanceJobjectV8.h b/Source/WebCore/bridge/jni/v8/JavaInstanceJobjectV8.h new file mode 100644 index 0000000..9f86037 --- /dev/null +++ b/Source/WebCore/bridge/jni/v8/JavaInstanceJobjectV8.h @@ -0,0 +1,69 @@ +/* + * Copyright (C) 2003, 2008, 2010 Apple Inc. All rights reserved. + * Copyright 2010, The Android Open Source Project + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY + * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef JavaInstanceJobjectV8_h +#define JavaInstanceJobjectV8_h + +#if ENABLE(JAVA_BRIDGE) + +#include "JNIUtility.h" +#include "JavaInstanceV8.h" +#include "JobjectWrapper.h" + +#include <wtf/OwnPtr.h> +#include <wtf/RefPtr.h> + +using namespace WTF; + +namespace JSC { + +namespace Bindings { + +class JavaInstanceJobject : public JavaInstance { +public: + JavaInstanceJobject(jobject instance); + + // JavaInstance implementation + virtual JavaClass* getClass() const; + virtual JavaValue invokeMethod(const JavaMethod*, JavaValue* args); + virtual JavaValue getField(const JavaField*); + virtual void begin(); + virtual void end(); + + jobject javaInstance() const { return m_instance->m_instance; } + +protected: + RefPtr<JobjectWrapper> m_instance; + mutable OwnPtr<JavaClass> m_class; +}; + +} // namespace Bindings + +} // namespace JSC + +#endif // ENABLE(JAVA_BRIDGE) + +#endif // JavaInstanceJobjectV8_h diff --git a/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h b/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h index b1150f8..7436de7 100644 --- a/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h +++ b/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h @@ -29,13 +29,8 @@ #if ENABLE(JAVA_BRIDGE) -#include "JNIUtility.h" #include "JavaValueV8.h" -#include "JobjectWrapper.h" -#include "npruntime.h" - #include <wtf/RefCounted.h> -#include <wtf/RefPtr.h> using namespace WTF; @@ -49,28 +44,19 @@ class JavaMethod; class JavaInstance : public RefCounted<JavaInstance> { public: - JavaInstance(jobject instance); - virtual ~JavaInstance(); + virtual ~JavaInstance() {} - JavaClass* getClass() const; + virtual JavaClass* getClass() const = 0; // args must be an array of length greater than or equal to the number of // arguments expected by the method. - JavaValue invokeMethod(const JavaMethod*, JavaValue* args); - JavaValue getField(const JavaField*); - jobject javaInstance() const { return m_instance->m_instance; } + virtual JavaValue invokeMethod(const JavaMethod*, JavaValue* args) = 0; + virtual JavaValue getField(const JavaField*) = 0; // These functions are called before and after the main entry points into // the native implementations. They can be used to establish and cleanup // any needed state. - void begin() { virtualBegin(); } - void end() { virtualEnd(); } - -protected: - RefPtr<JobjectWrapper> m_instance; - mutable JavaClass* m_class; - - virtual void virtualBegin(); - virtual void virtualEnd(); + virtual void begin() = 0; + virtual void end() = 0; }; } // namespace Bindings diff --git a/Source/WebCore/bridge/jsc/BridgeJSC.h b/Source/WebCore/bridge/jsc/BridgeJSC.h index c44faf1..95a3973 100644 --- a/Source/WebCore/bridge/jsc/BridgeJSC.h +++ b/Source/WebCore/bridge/jsc/BridgeJSC.h @@ -124,7 +124,7 @@ protected: RefPtr<RootObject> m_rootObject; private: - WeakGCPtr<RuntimeObject> m_runtimeObject; + Weak<RuntimeObject> m_runtimeObject; }; class Array { diff --git a/Source/WebCore/bridge/objc/ObjCRuntimeObject.h b/Source/WebCore/bridge/objc/ObjCRuntimeObject.h index b29a333..f8eada7 100644 --- a/Source/WebCore/bridge/objc/ObjCRuntimeObject.h +++ b/Source/WebCore/bridge/objc/ObjCRuntimeObject.h @@ -42,7 +42,7 @@ public: static const ClassInfo s_info; - static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } diff --git a/Source/WebCore/bridge/objc/objc_instance.mm b/Source/WebCore/bridge/objc/objc_instance.mm index 4f93cfa..61c67cb 100644 --- a/Source/WebCore/bridge/objc/objc_instance.mm +++ b/Source/WebCore/bridge/objc/objc_instance.mm @@ -184,7 +184,7 @@ public: ASSERT(inherits(&s_info)); } - static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } diff --git a/Source/WebCore/bridge/objc/objc_runtime.h b/Source/WebCore/bridge/objc/objc_runtime.h index 4ef0afd..eded2fe 100644 --- a/Source/WebCore/bridge/objc/objc_runtime.h +++ b/Source/WebCore/bridge/objc/objc_runtime.h @@ -103,7 +103,7 @@ public: return globalObject->objectPrototype(); } - static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } diff --git a/Source/WebCore/bridge/qt/qt_class.cpp b/Source/WebCore/bridge/qt/qt_class.cpp index 3c1836a..c3d8b27 100644 --- a/Source/WebCore/bridge/qt/qt_class.cpp +++ b/Source/WebCore/bridge/qt/qt_class.cpp @@ -87,7 +87,7 @@ JSValue QtClass::fallbackObject(ExecState* exec, Instance* inst, const Identifie QMetaMethod m = m_metaObject->method(index); if (m.access() != QMetaMethod::Private) { QtRuntimeMetaMethod* val = new (exec) QtRuntimeMetaMethod(exec, identifier, static_cast<QtInstance*>(inst), index, normal, false); - qtinst->m_methods.insert(name, val); + qtinst->m_methods.insert(name, WriteBarrier<JSObject>(exec->globalData(), qtinst->createRuntimeObject(exec), val)); return val; } } @@ -106,7 +106,7 @@ JSValue QtClass::fallbackObject(ExecState* exec, Instance* inst, const Identifie if (normal == QByteArray::fromRawData(signature, iter)) { QtRuntimeMetaMethod* val = new (exec) QtRuntimeMetaMethod(exec, identifier, static_cast<QtInstance*>(inst), index, normal, false); - qtinst->m_methods.insert(name, val); + qtinst->m_methods.insert(name, WriteBarrier<JSObject>(exec->globalData(), qtinst->createRuntimeObject(exec), val)); return val; } } diff --git a/Source/WebCore/bridge/qt/qt_instance.cpp b/Source/WebCore/bridge/qt/qt_instance.cpp index 91ae40f..2d29e01 100644 --- a/Source/WebCore/bridge/qt/qt_instance.cpp +++ b/Source/WebCore/bridge/qt/qt_instance.cpp @@ -59,7 +59,7 @@ public: instance->markAggregate(markStack); } - static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } @@ -151,12 +151,12 @@ void QtInstance::removeCachedMethod(JSObject* method) if (m_defaultMethod.get() == method) m_defaultMethod.clear(); - for (QHash<QByteArray, DeprecatedPtr<JSObject> >::Iterator it = m_methods.begin(), - end = m_methods.end(); it != end; ++it) + for (QHash<QByteArray, WriteBarrier<JSObject> >::Iterator it = m_methods.begin(), end = m_methods.end(); it != end; ++it) { if (it.value().get() == method) { m_methods.erase(it); return; } + } } QtInstance* QtInstance::getInstance(JSObject* object) @@ -189,10 +189,8 @@ void QtInstance::markAggregate(MarkStack& markStack) { if (m_defaultMethod) markStack.append(&m_defaultMethod); - foreach (DeprecatedPtr<JSObject> val, m_methods.values()) { - if (val) - markStack.append(&val); - } + for (QHash<QByteArray, WriteBarrier<JSObject> >::Iterator it = m_methods.begin(), end = m_methods.end(); it != end; ++it) + markStack.append(&it.value()); } void QtInstance::begin() diff --git a/Source/WebCore/bridge/qt/qt_instance.h b/Source/WebCore/bridge/qt/qt_instance.h index 003c801..b802500 100644 --- a/Source/WebCore/bridge/qt/qt_instance.h +++ b/Source/WebCore/bridge/qt/qt_instance.h @@ -83,7 +83,7 @@ private: mutable QtClass* m_class; QPointer<QObject> m_object; QObject* m_hashkey; - mutable QHash<QByteArray, DeprecatedPtr<JSObject> > m_methods; + mutable QHash<QByteArray, WriteBarrier<JSObject> > m_methods; mutable QHash<QString, QtField*> m_fields; mutable WriteBarrier<QtRuntimeMetaMethod> m_defaultMethod; QScriptEngine::ValueOwnership m_ownership; diff --git a/Source/WebCore/bridge/qt/qt_pixmapruntime.cpp b/Source/WebCore/bridge/qt/qt_pixmapruntime.cpp index da3e383..c498637 100644 --- a/Source/WebCore/bridge/qt/qt_pixmapruntime.cpp +++ b/Source/WebCore/bridge/qt/qt_pixmapruntime.cpp @@ -150,7 +150,7 @@ public: static const ClassInfo s_info; - static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } diff --git a/Source/WebCore/bridge/qt/qt_runtime.h b/Source/WebCore/bridge/qt/qt_runtime.h index 85b34b8..fa5ce62 100644 --- a/Source/WebCore/bridge/qt/qt_runtime.h +++ b/Source/WebCore/bridge/qt/qt_runtime.h @@ -22,7 +22,7 @@ #include "BridgeJSC.h" #include "Completion.h" -#include "Global.h" +#include "Strong.h" #include "runtime_method.h" #include <qbytearray.h> @@ -153,7 +153,7 @@ public: return globalObject->functionPrototype(); } - static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } @@ -229,8 +229,8 @@ private: RefPtr<QtInstance> m_instance; int m_signalIndex; QObject* m_originalObject; // only used as a key, not dereferenced - Global<JSObject> m_thisObject; - Global<JSObject> m_funcObject; + Strong<JSObject> m_thisObject; + Strong<JSObject> m_funcObject; }; QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type hint, int *distance); diff --git a/Source/WebCore/bridge/runtime_array.cpp b/Source/WebCore/bridge/runtime_array.cpp index a138660..e3c8f57 100644 --- a/Source/WebCore/bridge/runtime_array.cpp +++ b/Source/WebCore/bridge/runtime_array.cpp @@ -40,7 +40,7 @@ const ClassInfo RuntimeArray::s_info = { "RuntimeArray", &JSArray::s_info, 0, 0 RuntimeArray::RuntimeArray(ExecState* exec, Bindings::Array* array) // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object // We need to pass in the right global object for "array". - : JSArray(deprecatedGetDOMStructure<RuntimeArray>(exec)) + : JSArray(exec->globalData(), deprecatedGetDOMStructure<RuntimeArray>(exec)) { ASSERT(inherits(&s_info)); setSubclassData(array); diff --git a/Source/WebCore/bridge/runtime_array.h b/Source/WebCore/bridge/runtime_array.h index 9555545..8fd3052 100644 --- a/Source/WebCore/bridge/runtime_array.h +++ b/Source/WebCore/bridge/runtime_array.h @@ -58,7 +58,7 @@ public: return globalObject->arrayPrototype(); } - static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } diff --git a/Source/WebCore/bridge/runtime_method.cpp b/Source/WebCore/bridge/runtime_method.cpp index 4b5ecff..297fb6b 100644 --- a/Source/WebCore/bridge/runtime_method.cpp +++ b/Source/WebCore/bridge/runtime_method.cpp @@ -43,7 +43,7 @@ ASSERT_CLASS_FITS_IN_CELL(RuntimeMethod); const ClassInfo RuntimeMethod::s_info = { "RuntimeMethod", &InternalFunction::s_info, 0, 0 }; -RuntimeMethod::RuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, const Identifier& ident, Bindings::MethodList& m) +RuntimeMethod::RuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, const Identifier& ident, Bindings::MethodList& m) // Callers will need to pass in the right global object corresponding to this native object "m". : InternalFunction(&exec->globalData(), globalObject, structure, ident) , _methodList(new MethodList(m)) diff --git a/Source/WebCore/bridge/runtime_method.h b/Source/WebCore/bridge/runtime_method.h index 9df796e..712a305 100644 --- a/Source/WebCore/bridge/runtime_method.h +++ b/Source/WebCore/bridge/runtime_method.h @@ -35,7 +35,7 @@ namespace JSC { class RuntimeMethod : public InternalFunction { public: - RuntimeMethod(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, const Identifier& name, Bindings::MethodList&); + RuntimeMethod(ExecState*, JSGlobalObject*, Structure*, const Identifier& name, Bindings::MethodList&); Bindings::MethodList* methods() const { return _methodList.get(); } static const ClassInfo s_info; @@ -45,7 +45,7 @@ public: return globalObject->functionPrototype(); } - static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } diff --git a/Source/WebCore/bridge/runtime_object.cpp b/Source/WebCore/bridge/runtime_object.cpp index de1964a..79bcbce 100644 --- a/Source/WebCore/bridge/runtime_object.cpp +++ b/Source/WebCore/bridge/runtime_object.cpp @@ -38,7 +38,7 @@ namespace Bindings { const ClassInfo RuntimeObject::s_info = { "RuntimeObject", &JSObjectWithGlobalObject::s_info, 0, 0 }; -RuntimeObject::RuntimeObject(ExecState*, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, PassRefPtr<Instance> instance) +RuntimeObject::RuntimeObject(ExecState*, JSGlobalObject* globalObject, Structure* structure, PassRefPtr<Instance> instance) : JSObjectWithGlobalObject(globalObject, structure) , m_instance(instance) { diff --git a/Source/WebCore/bridge/runtime_object.h b/Source/WebCore/bridge/runtime_object.h index bb6d051..8998102 100644 --- a/Source/WebCore/bridge/runtime_object.h +++ b/Source/WebCore/bridge/runtime_object.h @@ -35,7 +35,7 @@ namespace Bindings { class RuntimeObject : public JSObjectWithGlobalObject { public: - RuntimeObject(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, PassRefPtr<Instance>); + RuntimeObject(ExecState*, JSGlobalObject*, Structure*, PassRefPtr<Instance>); virtual ~RuntimeObject(); virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&); @@ -61,7 +61,7 @@ public: return globalObject->objectPrototype(); } - static PassRefPtr<Structure> createStructure(JSGlobalData& globalData, JSValue prototype) + static Structure* createStructure(JSGlobalData& globalData, JSValue prototype) { return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info); } diff --git a/Source/WebCore/bridge/runtime_root.h b/Source/WebCore/bridge/runtime_root.h index feade45..f1ea671 100644 --- a/Source/WebCore/bridge/runtime_root.h +++ b/Source/WebCore/bridge/runtime_root.h @@ -29,7 +29,7 @@ #if PLATFORM(MAC) #include "jni_jsobject.h" #endif -#include <collector/handles/Global.h> +#include <heap/Strong.h> #include <runtime/WeakGCMap.h> #include <wtf/Forward.h> @@ -86,7 +86,7 @@ private: bool m_isValid; const void* m_nativeHandle; - Global<JSGlobalObject> m_globalObject; + Strong<JSGlobalObject> m_globalObject; ProtectCountSet m_protectCountSet; WeakGCMap<RuntimeObject*, RuntimeObject> m_runtimeObjects; // Really need a WeakGCSet, but this will do. |