summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/bridge
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/bridge')
-rw-r--r--Source/WebCore/bridge/NP_jsobject.cpp26
-rw-r--r--Source/WebCore/bridge/c/CRuntimeObject.cpp9
-rw-r--r--Source/WebCore/bridge/c/CRuntimeObject.h6
-rw-r--r--Source/WebCore/bridge/c/c_class.cpp1
-rw-r--r--Source/WebCore/bridge/c/c_instance.cpp12
-rw-r--r--Source/WebCore/bridge/c/c_runtime.cpp1
-rw-r--r--Source/WebCore/bridge/jni/JNIUtility.cpp4
-rw-r--r--Source/WebCore/bridge/jni/JNIUtility.h10
-rw-r--r--Source/WebCore/bridge/jni/JavaMethod.cpp (renamed from Source/WebCore/bridge/jni/JNIBridge.cpp)35
-rw-r--r--Source/WebCore/bridge/jni/JavaMethod.h (renamed from Source/WebCore/bridge/jni/JNIBridge.h)61
-rw-r--r--Source/WebCore/bridge/jni/JavaString.h75
-rw-r--r--Source/WebCore/bridge/jni/JobjectWrapper.cpp71
-rw-r--r--Source/WebCore/bridge/jni/JobjectWrapper.h71
-rw-r--r--Source/WebCore/bridge/jni/jni_jsobject.h2
-rw-r--r--Source/WebCore/bridge/jni/jni_jsobject.mm14
-rw-r--r--Source/WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp6
-rw-r--r--Source/WebCore/bridge/jni/jsc/JavaArrayJSC.cpp246
-rw-r--r--Source/WebCore/bridge/jni/jsc/JavaArrayJSC.h67
-rw-r--r--Source/WebCore/bridge/jni/jsc/JavaClassJSC.cpp8
-rw-r--r--Source/WebCore/bridge/jni/jsc/JavaClassJSC.h3
-rw-r--r--Source/WebCore/bridge/jni/jsc/JavaFieldJSC.cpp (renamed from Source/WebCore/bridge/jni/jsc/JNIBridgeJSC.cpp)211
-rw-r--r--Source/WebCore/bridge/jni/jsc/JavaFieldJSC.h (renamed from Source/WebCore/bridge/jni/jsc/JNIBridgeJSC.h)36
-rw-r--r--Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp47
-rw-r--r--Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.h38
-rw-r--r--Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.cpp9
-rw-r--r--Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.h6
-rw-r--r--Source/WebCore/bridge/jni/jsc/JavaStringJSC.h3
-rw-r--r--Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp18
-rw-r--r--Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.h7
-rw-r--r--Source/WebCore/bridge/jni/v8/JavaClassV8.cpp7
-rw-r--r--Source/WebCore/bridge/jni/v8/JavaClassV8.h11
-rw-r--r--Source/WebCore/bridge/jni/v8/JavaFieldV8.cpp (renamed from Source/WebCore/bridge/jni/v8/JNIBridgeV8.cpp)8
-rw-r--r--Source/WebCore/bridge/jni/v8/JavaFieldV8.h (renamed from Source/WebCore/bridge/jni/v8/JNIBridgeV8.h)16
-rw-r--r--Source/WebCore/bridge/jni/v8/JavaInstanceV8.cpp34
-rw-r--r--Source/WebCore/bridge/jni/v8/JavaInstanceV8.h36
-rw-r--r--Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp5
-rw-r--r--Source/WebCore/bridge/jni/v8/JavaNPObjectV8.h4
-rw-r--r--Source/WebCore/bridge/jni/v8/JavaStringV8.h24
-rw-r--r--Source/WebCore/bridge/jsc/BridgeJSC.cpp26
-rw-r--r--Source/WebCore/bridge/jsc/BridgeJSC.h3
-rw-r--r--Source/WebCore/bridge/npapi.h19
-rw-r--r--Source/WebCore/bridge/npruntime_internal.h1
-rw-r--r--Source/WebCore/bridge/nptypes.h125
-rw-r--r--Source/WebCore/bridge/objc/ObjCRuntimeObject.h6
-rw-r--r--Source/WebCore/bridge/objc/ObjCRuntimeObject.mm7
-rw-r--r--Source/WebCore/bridge/objc/objc_instance.mm12
-rw-r--r--Source/WebCore/bridge/objc/objc_runtime.h4
-rw-r--r--Source/WebCore/bridge/objc/objc_runtime.mm3
-rw-r--r--Source/WebCore/bridge/qt/qt_instance.cpp8
-rw-r--r--Source/WebCore/bridge/qt/qt_pixmapruntime.cpp8
-rw-r--r--Source/WebCore/bridge/qt/qt_runtime.cpp38
-rw-r--r--Source/WebCore/bridge/qt/qt_runtime.h10
-rw-r--r--Source/WebCore/bridge/runtime_array.cpp3
-rw-r--r--Source/WebCore/bridge/runtime_array.h11
-rw-r--r--Source/WebCore/bridge/runtime_method.cpp9
-rw-r--r--Source/WebCore/bridge/runtime_method.h8
-rw-r--r--Source/WebCore/bridge/runtime_object.cpp15
-rw-r--r--Source/WebCore/bridge/runtime_object.h9
-rw-r--r--Source/WebCore/bridge/runtime_root.cpp21
-rw-r--r--Source/WebCore/bridge/runtime_root.h6
-rw-r--r--Source/WebCore/bridge/testqtbindings.cpp2
61 files changed, 899 insertions, 703 deletions
diff --git a/Source/WebCore/bridge/NP_jsobject.cpp b/Source/WebCore/bridge/NP_jsobject.cpp
index 0780ad7..1aed505 100644
--- a/Source/WebCore/bridge/NP_jsobject.cpp
+++ b/Source/WebCore/bridge/NP_jsobject.cpp
@@ -189,10 +189,10 @@ bool _NPN_InvokeDefault(NPP, NPObject* o, const NPVariant* args, uint32_t argCou
MarkedArgumentBuffer argList;
getListFromVariantArgs(exec, args, argCount, rootObject, argList);
- ProtectedPtr<JSGlobalObject> globalObject = rootObject->globalObject();
- globalObject->globalData().timeoutChecker.start();
+ RefPtr<JSGlobalData> globalData(&exec->globalData());
+ globalData->timeoutChecker.start();
JSValue resultV = JSC::call(exec, function, callType, callData, function, argList);
- globalObject->globalData().timeoutChecker.stop();
+ globalData->timeoutChecker.stop();
// Convert and return the result of the function call.
convertValueToNPVariant(exec, resultV, result);
@@ -239,10 +239,10 @@ bool _NPN_Invoke(NPP npp, NPObject* o, NPIdentifier methodName, const NPVariant*
// Call the function object.
MarkedArgumentBuffer argList;
getListFromVariantArgs(exec, args, argCount, rootObject, argList);
- ProtectedPtr<JSGlobalObject> globalObject = rootObject->globalObject();
- globalObject->globalData().timeoutChecker.start();
+ RefPtr<JSGlobalData> globalData(&exec->globalData());
+ globalData->timeoutChecker.start();
JSValue resultV = JSC::call(exec, function, callType, callData, obj->imp, argList);
- globalObject->globalData().timeoutChecker.stop();
+ globalData->timeoutChecker.stop();
// Convert and return the result of the function call.
convertValueToNPVariant(exec, resultV, result);
@@ -273,10 +273,10 @@ bool _NPN_Evaluate(NPP instance, NPObject* o, NPString* s, NPVariant* variant)
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock(SilenceAssertionsOnly);
String scriptString = convertNPStringToUTF16(s);
- ProtectedPtr<JSGlobalObject> globalObject = rootObject->globalObject();
- globalObject->globalData().timeoutChecker.start();
- Completion completion = JSC::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(scriptString), JSC::JSValue());
- globalObject->globalData().timeoutChecker.stop();
+ RefPtr<JSGlobalData> globalData(&exec->globalData());
+ globalData->timeoutChecker.start();
+ Completion completion = JSC::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(scriptString), JSC::JSValue());
+ globalData->timeoutChecker.stop();
ComplType type = completion.complType();
JSValue result;
@@ -513,10 +513,10 @@ bool _NPN_Construct(NPP, NPObject* o, const NPVariant* args, uint32_t argCount,
MarkedArgumentBuffer argList;
getListFromVariantArgs(exec, args, argCount, rootObject, argList);
- ProtectedPtr<JSGlobalObject> globalObject = rootObject->globalObject();
- globalObject->globalData().timeoutChecker.start();
+ RefPtr<JSGlobalData> globalData(&exec->globalData());
+ globalData->timeoutChecker.start();
JSValue resultV = JSC::construct(exec, constructor, constructType, constructData, argList);
- globalObject->globalData().timeoutChecker.stop();
+ globalData->timeoutChecker.stop();
// Convert and return the result.
convertValueToNPVariant(exec, resultV, result);
diff --git a/Source/WebCore/bridge/c/CRuntimeObject.cpp b/Source/WebCore/bridge/c/CRuntimeObject.cpp
index 4be4982..d322df4 100644
--- a/Source/WebCore/bridge/c/CRuntimeObject.cpp
+++ b/Source/WebCore/bridge/c/CRuntimeObject.cpp
@@ -24,11 +24,13 @@
*/
#include "config.h"
+#include "CRuntimeObject.h"
#if ENABLE(NETSCAPE_PLUGIN_API)
-#include "CRuntimeObject.h"
+#include "JSDOMBinding.h"
#include "c_instance.h"
+#include "runtime/ObjectPrototype.h"
namespace JSC {
namespace Bindings {
@@ -36,8 +38,11 @@ namespace Bindings {
const ClassInfo CRuntimeObject::s_info = { "CRuntimeObject", &RuntimeObject::s_info, 0, 0 };
CRuntimeObject::CRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<CInstance> instance)
- : RuntimeObject(exec, globalObject, instance)
+ // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
+ // We need to pass in the right global object for "i".
+ : RuntimeObject(exec, globalObject, WebCore::deprecatedGetDOMStructure<CRuntimeObject>(exec), instance)
{
+ ASSERT(inherits(&s_info));
}
CRuntimeObject::~CRuntimeObject()
diff --git a/Source/WebCore/bridge/c/CRuntimeObject.h b/Source/WebCore/bridge/c/CRuntimeObject.h
index bcd39d3..267d71e 100644
--- a/Source/WebCore/bridge/c/CRuntimeObject.h
+++ b/Source/WebCore/bridge/c/CRuntimeObject.h
@@ -44,8 +44,10 @@ public:
static const ClassInfo s_info;
-private:
- virtual const ClassInfo* classInfo() const { return &s_info; }
+ static PassRefPtr<Structure> createStructure(JSValue prototype)
+ {
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
+ }
};
}
diff --git a/Source/WebCore/bridge/c/c_class.cpp b/Source/WebCore/bridge/c/c_class.cpp
index f4ae5ca..a808946 100644
--- a/Source/WebCore/bridge/c/c_class.cpp
+++ b/Source/WebCore/bridge/c/c_class.cpp
@@ -32,6 +32,7 @@
#include "c_instance.h"
#include "c_runtime.h"
#include "npruntime_impl.h"
+#include <runtime/ScopeChain.h>
#include <runtime/Identifier.h>
#include <runtime/JSLock.h>
#include <wtf/text/StringHash.h>
diff --git a/Source/WebCore/bridge/c/c_instance.cpp b/Source/WebCore/bridge/c/c_instance.cpp
index f1dd4e5..27affeb 100644
--- a/Source/WebCore/bridge/c/c_instance.cpp
+++ b/Source/WebCore/bridge/c/c_instance.cpp
@@ -31,6 +31,7 @@
#include "CRuntimeObject.h"
#include "IdentifierRep.h"
+#include "JSDOMBinding.h"
#include "c_class.h"
#include "c_runtime.h"
#include "c_utility.h"
@@ -40,6 +41,7 @@
#include <interpreter/CallFrame.h>
#include <runtime/ArgList.h>
#include <runtime/Error.h>
+#include <runtime/FunctionPrototype.h>
#include <runtime/JSLock.h>
#include <runtime/JSNumberCell.h>
#include <runtime/PropertyNameArray.h>
@@ -111,11 +113,17 @@ bool CInstance::supportsInvokeDefaultMethod() const
class CRuntimeMethod : public RuntimeMethod {
public:
CRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
- : RuntimeMethod(exec, globalObject, name, list)
+ // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
+ // We need to pass in the right global object for "i".
+ : RuntimeMethod(exec, globalObject, WebCore::deprecatedGetDOMStructure<CRuntimeMethod>(exec), name, list)
{
+ ASSERT(inherits(&s_info));
}
- virtual const ClassInfo* classInfo() const { return &s_info; }
+ static PassRefPtr<Structure> createStructure(JSValue prototype)
+ {
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
+ }
static const ClassInfo s_info;
};
diff --git a/Source/WebCore/bridge/c/c_runtime.cpp b/Source/WebCore/bridge/c/c_runtime.cpp
index e038cd4..f8c0dba 100644
--- a/Source/WebCore/bridge/c/c_runtime.cpp
+++ b/Source/WebCore/bridge/c/c_runtime.cpp
@@ -32,6 +32,7 @@
#include "c_instance.h"
#include "c_utility.h"
#include "npruntime_impl.h"
+#include <runtime/ScopeChain.h>
#include <runtime/JSLock.h>
namespace JSC {
diff --git a/Source/WebCore/bridge/jni/JNIUtility.cpp b/Source/WebCore/bridge/jni/JNIUtility.cpp
index 4b4f393..17cc038 100644
--- a/Source/WebCore/bridge/jni/JNIUtility.cpp
+++ b/Source/WebCore/bridge/jni/JNIUtility.cpp
@@ -90,7 +90,11 @@ JNIEnv* getJNIEnv()
} u;
jint jniError = 0;
+#if OS(ANDROID)
+ jniError = getJavaVM()->AttachCurrentThread(&u.env, 0);
+#else
jniError = getJavaVM()->AttachCurrentThread(&u.dummy, 0);
+#endif
if (jniError == JNI_OK)
return u.env;
LOG_ERROR("AttachCurrentThread failed, returned %ld", static_cast<long>(jniError));
diff --git a/Source/WebCore/bridge/jni/JNIUtility.h b/Source/WebCore/bridge/jni/JNIUtility.h
index 5fb2138..7b5d37c 100644
--- a/Source/WebCore/bridge/jni/JNIUtility.h
+++ b/Source/WebCore/bridge/jni/JNIUtility.h
@@ -28,13 +28,21 @@
#if ENABLE(JAVA_BRIDGE)
+#if OS(MAC_OS_X)
#include <JavaVM/jni.h>
+#else
+#include <jni.h>
+#endif
// 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
// should be added to the end. It is used in jni_obc.mm when calling
// through to the JVM. Newly added items need to be made compatible
// in that file.
+//
+// TODO: Strictly, these are not JNI types but simply Java types. The type
+// conversion logic used here needs improving and this enum will likely be
+// changed at that time. See https://bugs.webkit.org/show_bug.cgi?id=38745
typedef enum {
invalid_type = 0,
void_type,
@@ -54,8 +62,6 @@ namespace JSC {
namespace Bindings {
-class JavaParameter;
-
const char* getCharactersFromJString(jstring);
void releaseCharactersForJString(jstring, const char*);
diff --git a/Source/WebCore/bridge/jni/JNIBridge.cpp b/Source/WebCore/bridge/jni/JavaMethod.cpp
index c512ee7..55f29df 100644
--- a/Source/WebCore/bridge/jni/JNIBridge.cpp
+++ b/Source/WebCore/bridge/jni/JavaMethod.cpp
@@ -25,22 +25,18 @@
*/
#include "config.h"
-#include "JNIBridge.h"
+#include "JavaMethod.h"
#if ENABLE(JAVA_BRIDGE)
-#include <wtf/text/CString.h>
+#include "JavaString.h"
+
+#include <runtime/ScopeChain.h>
#include <wtf/text/StringBuilder.h>
using namespace JSC;
using namespace JSC::Bindings;
-JavaParameter::JavaParameter(JNIEnv* env, jstring type)
-{
- m_type = JavaString(env, type);
- m_JNIType = JNITypeFromClassName(m_type.utf8());
-}
-
JavaMethod::JavaMethod(JNIEnv* env, jobject aMethod)
{
// Get return type name
@@ -64,22 +60,18 @@ JavaMethod::JavaMethod(JNIEnv* env, jobject aMethod)
// Get parameters
if (jarray jparameters = static_cast<jarray>(callJNIMethod<jobject>(aMethod, "getParameterTypes", "()[Ljava/lang/Class;"))) {
- m_numParameters = env->GetArrayLength(jparameters);
- m_parameters = new JavaParameter[m_numParameters];
+ unsigned int numParams = env->GetArrayLength(jparameters);
- for (int i = 0; i < m_numParameters; i++) {
+ for (unsigned int i = 0; i < numParams; i++) {
jobject aParameter = env->GetObjectArrayElement(static_cast<jobjectArray>(jparameters), i);
jstring parameterName = static_cast<jstring>(callJNIMethod<jobject>(aParameter, "getName", "()Ljava/lang/String;"));
if (!parameterName)
parameterName = env->NewStringUTF("<Unknown>");
- m_parameters[i] = JavaParameter(env, parameterName);
+ m_parameters.append(JavaString(env, parameterName).impl());
env->DeleteLocalRef(aParameter);
env->DeleteLocalRef(parameterName);
}
env->DeleteLocalRef(jparameters);
- } else {
- m_numParameters = 0;
- m_parameters = 0;
}
// Created lazily.
@@ -96,8 +88,7 @@ JavaMethod::~JavaMethod()
{
if (m_signature)
fastFree(m_signature);
- delete[] m_parameters;
-};
+}
// JNI method signatures use '/' between components of a class name, but
// we get '.' between components from the reflection API.
@@ -130,15 +121,15 @@ const char* JavaMethod::signature() const
StringBuilder signatureBuilder;
signatureBuilder.append('(');
- for (int i = 0; i < m_numParameters; i++) {
- JavaParameter* aParameter = parameterAt(i);
- JNIType type = aParameter->getJNIType();
+ for (unsigned int i = 0; i < m_parameters.size(); i++) {
+ CString javaClassName = parameterAt(i).utf8();
+ JNIType type = JNITypeFromClassName(javaClassName.data());
if (type == array_type)
- appendClassName(signatureBuilder, aParameter->type());
+ appendClassName(signatureBuilder, javaClassName.data());
else {
signatureBuilder.append(signatureFromPrimitiveType(type));
if (type == object_type) {
- appendClassName(signatureBuilder, aParameter->type());
+ appendClassName(signatureBuilder, javaClassName.data());
signatureBuilder.append(';');
}
}
diff --git a/Source/WebCore/bridge/jni/JNIBridge.h b/Source/WebCore/bridge/jni/JavaMethod.h
index 4f5e6b7..39d04c9 100644
--- a/Source/WebCore/bridge/jni/JNIBridge.h
+++ b/Source/WebCore/bridge/jni/JavaMethod.h
@@ -24,19 +24,15 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef JNIBridge_h
-#define JNIBridge_h
+#ifndef JavaMethod_h
+#define JavaMethod_h
#if ENABLE(JAVA_BRIDGE)
#include "Bridge.h"
#include "JNIUtility.h"
-#if USE(JSC)
-#include "JavaStringJSC.h"
-#elif USE(V8)
-#include "JavaStringV8.h"
-#endif
+#include "JavaString.h"
namespace JSC {
@@ -44,48 +40,6 @@ namespace Bindings {
typedef const char* RuntimeType;
-class JavaString {
-public:
- JavaString()
- {
- m_impl.init();
- }
-
- JavaString(JNIEnv* e, jstring s)
- {
- m_impl.init(e, s);
- }
-
- JavaString(jstring s)
- {
- m_impl.init(getJNIEnv(), s);
- }
-
- const char* utf8() const { return m_impl.utf8(); }
- const jchar* uchars() const { return m_impl.uchars(); }
- int length() const { return m_impl.length(); }
-#if USE(JSC)
- operator UString() const { return m_impl.uString(); }
-#endif
-
-private:
- JavaStringImpl m_impl;
-};
-
-class JavaParameter {
-public:
- JavaParameter() : m_JNIType(invalid_type) { }
- JavaParameter(JNIEnv*, jstring type);
- virtual ~JavaParameter() { }
-
- RuntimeType type() const { return m_type.utf8(); }
- JNIType getJNIType() const { return m_JNIType; }
-
-private:
- JavaString m_type;
- JNIType m_JNIType;
-};
-
class JavaMethod : public Method {
public:
JavaMethod(JNIEnv*, jobject aMethod);
@@ -93,8 +47,8 @@ public:
const JavaString& name() const { return m_name; }
RuntimeType returnType() const { return m_returnType.utf8(); }
- JavaParameter* parameterAt(int i) const { return &m_parameters[i]; }
- int numParameters() const { return m_numParameters; }
+ const WTF::String& parameterAt(int i) const { return m_parameters[i]; }
+ int numParameters() const { return m_parameters.size(); }
const char* signature() const;
JNIType JNIReturnType() const;
@@ -104,8 +58,7 @@ public:
bool isStatic() const { return m_isStatic; }
private:
- JavaParameter* m_parameters;
- int m_numParameters;
+ Vector<WTF::String> m_parameters;
JavaString m_name;
mutable char* m_signature;
JavaString m_returnType;
@@ -120,4 +73,4 @@ private:
#endif // ENABLE(JAVA_BRIDGE)
-#endif // JNIBridge_h
+#endif // JavaMethod_h
diff --git a/Source/WebCore/bridge/jni/JavaString.h b/Source/WebCore/bridge/jni/JavaString.h
new file mode 100644
index 0000000..abf11c5
--- /dev/null
+++ b/Source/WebCore/bridge/jni/JavaString.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2003, 2004, 2005, 2007, 2009, 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:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 JavaString_h
+#define JavaString_h
+
+#if ENABLE(JAVA_BRIDGE)
+
+#include <wtf/text/WTFString.h>
+
+#if USE(JSC)
+#include "JavaStringJSC.h"
+#elif USE(V8)
+#include "JavaStringV8.h"
+#endif
+
+namespace JSC {
+
+namespace Bindings {
+
+class JavaString {
+public:
+ JavaString()
+ {
+ m_impl.init();
+ }
+
+ JavaString(JNIEnv* e, jstring s)
+ {
+ m_impl.init(e, s);
+ }
+
+ JavaString(jstring s)
+ {
+ m_impl.init(getJNIEnv(), s);
+ }
+
+ const char* utf8() const { return m_impl.utf8(); }
+ int length() const { return m_impl.length(); }
+ StringImpl* impl() const { return m_impl.impl(); }
+
+private:
+ JavaStringImpl m_impl;
+};
+
+} // namespace Bindings
+
+} // namespace JSC
+
+#endif // ENABLE(JAVA_BRIDGE)
+
+#endif // JavaString_h
diff --git a/Source/WebCore/bridge/jni/JobjectWrapper.cpp b/Source/WebCore/bridge/jni/JobjectWrapper.cpp
new file mode 100644
index 0000000..82cdb2a
--- /dev/null
+++ b/Source/WebCore/bridge/jni/JobjectWrapper.cpp
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2003, 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright 2011, 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.
+ */
+
+#include "config.h"
+#include "JobjectWrapper.h"
+
+#if ENABLE(JAVA_BRIDGE)
+
+#include <assert.h>
+
+using namespace JSC::Bindings;
+
+JobjectWrapper::JobjectWrapper(jobject instance)
+ : m_refCount(0)
+{
+ assert(instance);
+
+ // Cache the JNIEnv used to get the global ref for this java instanace.
+ // It'll be used to delete the reference.
+ m_env = getJNIEnv();
+
+ m_instance = m_env->NewGlobalRef(instance);
+
+ if (!m_instance)
+ LOG_ERROR("Could not get GlobalRef for %p", instance);
+}
+
+<<<<<<< HEAD:Source/WebCore/platform/network/android/NetworkStateNotifierAndroid.cpp
+// TODO: Upstream to webkit.org
+void NetworkStateNotifier::networkTypeChange(Connection::ConnectionType type)
+{
+ if (m_type == type)
+ return;
+
+ m_type = type;
+
+ if (m_networkStateChangedFunction)
+ m_networkStateChangedFunction();
+}
+
+=======
+JobjectWrapper::~JobjectWrapper()
+{
+ m_env->DeleteGlobalRef(m_instance);
+>>>>>>> WebKit at r80534:Source/WebCore/bridge/jni/JobjectWrapper.cpp
+}
+
+#endif // ENABLE(JAVA_BRIDGE)
diff --git a/Source/WebCore/bridge/jni/JobjectWrapper.h b/Source/WebCore/bridge/jni/JobjectWrapper.h
new file mode 100644
index 0000000..28ce56e
--- /dev/null
+++ b/Source/WebCore/bridge/jni/JobjectWrapper.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
+ * Copyright 2011, 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 JobjectWrapper_h
+#define JobjectWrapper_h
+
+#if ENABLE(JAVA_BRIDGE)
+
+#include "JNIUtility.h"
+
+namespace JSC {
+
+namespace Bindings {
+
+class JobjectWrapper {
+friend class JavaArray;
+friend class JavaField;
+friend class JavaInstance;
+
+public:
+ jobject instance() const { return m_instance; }
+ void setInstance(jobject instance) { m_instance = instance; }
+
+ void ref() { m_refCount++; }
+ void deref()
+ {
+ if (!--m_refCount)
+ delete this;
+ }
+
+protected:
+ JobjectWrapper(jobject);
+ ~JobjectWrapper();
+
+ jobject m_instance;
+
+private:
+ JNIEnv* m_env;
+ unsigned int m_refCount;
+};
+
+} // namespace Bindings
+
+} // namespace JSC
+
+#endif // ENABLE(JAVA_BRIDGE)
+
+#endif // JobjectWrapper_h
diff --git a/Source/WebCore/bridge/jni/jni_jsobject.h b/Source/WebCore/bridge/jni/jni_jsobject.h
index 34a78ba..d91473f 100644
--- a/Source/WebCore/bridge/jni/jni_jsobject.h
+++ b/Source/WebCore/bridge/jni/jni_jsobject.h
@@ -28,7 +28,7 @@
#if ENABLE(JAVA_BRIDGE)
-#include <JavaVM/jni.h>
+#include "JNIUtility.h"
#include <runtime/JSValue.h>
#include <wtf/RefPtr.h>
diff --git a/Source/WebCore/bridge/jni/jni_jsobject.mm b/Source/WebCore/bridge/jni/jni_jsobject.mm
index f8ec1c4..172559e 100644
--- a/Source/WebCore/bridge/jni/jni_jsobject.mm
+++ b/Source/WebCore/bridge/jni/jni_jsobject.mm
@@ -29,11 +29,11 @@
#if ENABLE(JAVA_BRIDGE)
#include "Frame.h"
-#include "JavaRuntimeObject.h"
-#include "JNIBridge.h"
#include "JNIUtility.h"
#include "JNIUtilityPrivate.h"
#include "JSDOMBinding.h"
+#include "JavaRuntimeObject.h"
+#include "JavaString.h"
#include "Logging.h"
#include "ScriptController.h"
#include "StringSourceProvider.h"
@@ -286,7 +286,7 @@ jobject JavaJSObject::call(jstring methodName, jobjectArray args) const
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock(SilenceAssertionsOnly);
- Identifier identifier(exec, JavaString(methodName));
+ Identifier identifier(exec, JavaString(methodName).impl());
JSValue function = _imp->get(exec, identifier);
CallData callData;
CallType callType = getCallData(function, callData);
@@ -316,7 +316,7 @@ jobject JavaJSObject::eval(jstring script) const
return 0;
rootObject->globalObject()->globalData().timeoutChecker.start();
- Completion completion = JSC::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(JavaString(script)), JSC::JSValue());
+ Completion completion = JSC::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(JavaString(script).impl()), JSC::JSValue());
rootObject->globalObject()->globalData().timeoutChecker.stop();
ComplType type = completion.complType();
@@ -341,7 +341,7 @@ jobject JavaJSObject::getMember(jstring memberName) const
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock(SilenceAssertionsOnly);
- JSValue result = _imp->get(exec, Identifier(exec, JavaString(memberName)));
+ JSValue result = _imp->get(exec, Identifier(exec, JavaString(memberName).impl()));
return convertValueToJObject(result);
}
@@ -358,7 +358,7 @@ void JavaJSObject::setMember(jstring memberName, jobject value) const
JSLock lock(SilenceAssertionsOnly);
PutPropertySlot slot;
- _imp->put(exec, Identifier(exec, JavaString(memberName)), convertJObjectToValue(exec, value), slot);
+ _imp->put(exec, Identifier(exec, JavaString(memberName).impl()), convertJObjectToValue(exec, value), slot);
}
@@ -372,7 +372,7 @@ void JavaJSObject::removeMember(jstring memberName) const
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock(SilenceAssertionsOnly);
- _imp->deleteProperty(exec, Identifier(exec, JavaString(memberName)));
+ _imp->deleteProperty(exec, Identifier(exec, JavaString(memberName).impl()));
}
diff --git a/Source/WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp b/Source/WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp
index bf19642..a8be0bd 100644
--- a/Source/WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp
+++ b/Source/WebCore/bridge/jni/jsc/JNIUtilityPrivate.cpp
@@ -29,11 +29,13 @@
#if ENABLE(JAVA_BRIDGE)
+#include "JavaArrayJSC.h"
+#include "JavaInstanceJSC.h"
#include "JavaRuntimeObject.h"
-#include "JNIBridgeJSC.h"
#include "jni_jsobject.h"
#include "runtime_array.h"
#include "runtime_object.h"
+#include "runtime_root.h"
#include <runtime/JSArray.h>
#include <runtime/JSLock.h>
@@ -197,7 +199,7 @@ jvalue convertValueToJValue(ExecState* exec, RootObject* rootObject, JSValue val
RuntimeArray* imp = static_cast<RuntimeArray*>(object);
JavaArray* array = static_cast<JavaArray*>(imp->getConcreteArray());
result.l = array->javaArray();
- } else if (object->classInfo() == &JSArray::info) {
+ } else if (object->classInfo() == &JSArray::s_info) {
// Input is a Javascript Array. We need to create it to a Java Array.
result.l = convertArrayInstanceToJavaArray(exec, asArray(value), javaClassName);
} else if ((!result.l && (!strcmp(javaClassName, "java.lang.Object")))
diff --git a/Source/WebCore/bridge/jni/jsc/JavaArrayJSC.cpp b/Source/WebCore/bridge/jni/jsc/JavaArrayJSC.cpp
new file mode 100644
index 0000000..db87baa
--- /dev/null
+++ b/Source/WebCore/bridge/jni/jsc/JavaArrayJSC.cpp
@@ -0,0 +1,246 @@
+/*
+ * Copyright (C) 2003, 2004, 2005, 2007, 2009 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:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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.
+ */
+
+#include "config.h"
+#include "JavaArrayJSC.h"
+
+#if ENABLE(JAVA_BRIDGE)
+
+#include "JNIUtilityPrivate.h"
+#include "JavaInstanceJSC.h"
+#include "JobjectWrapper.h"
+#include "Logging.h"
+#include "runtime_array.h"
+#include "runtime_object.h"
+#include "runtime_root.h"
+#include <runtime/Error.h>
+
+using namespace JSC;
+using namespace JSC::Bindings;
+using namespace WebCore;
+
+JSValue JavaArray::convertJObjectToArray(ExecState* exec, jobject anObject, const char* type, PassRefPtr<RootObject> rootObject)
+{
+ if (type[0] != '[')
+ return jsUndefined();
+
+ return new (exec) RuntimeArray(exec, new JavaArray(anObject, type, rootObject));
+}
+
+JavaArray::JavaArray(jobject array, const char* type, PassRefPtr<RootObject> rootObject)
+ : Array(rootObject)
+{
+ m_array = new JobjectWrapper(array);
+ // Java array are fixed length, so we can cache length.
+ JNIEnv* env = getJNIEnv();
+ m_length = env->GetArrayLength(static_cast<jarray>(m_array->m_instance));
+ m_type = strdup(type);
+}
+
+JavaArray::~JavaArray()
+{
+ free(const_cast<char*>(m_type));
+}
+
+RootObject* JavaArray::rootObject() const
+{
+ return m_rootObject && m_rootObject->isValid() ? m_rootObject.get() : 0;
+}
+
+void JavaArray::setValueAt(ExecState* exec, unsigned index, JSValue aValue) const
+{
+ JNIEnv* env = getJNIEnv();
+ char* javaClassName = 0;
+
+ JNIType arrayType = JNITypeFromPrimitiveType(m_type[1]);
+ if (m_type[1] == 'L') {
+ // The type of the array will be something like:
+ // "[Ljava.lang.string;". This is guaranteed, so no need
+ // for extra sanity checks.
+ javaClassName = strdup(&m_type[2]);
+ javaClassName[strchr(javaClassName, ';')-javaClassName] = 0;
+ }
+ jvalue aJValue = convertValueToJValue(exec, m_rootObject.get(), aValue, arrayType, javaClassName);
+
+ switch (arrayType) {
+ case object_type:
+ {
+ env->SetObjectArrayElement(static_cast<jobjectArray>(javaArray()), index, aJValue.l);
+ break;
+ }
+
+ case boolean_type:
+ {
+ env->SetBooleanArrayRegion(static_cast<jbooleanArray>(javaArray()), index, 1, &aJValue.z);
+ break;
+ }
+
+ case byte_type:
+ {
+ env->SetByteArrayRegion(static_cast<jbyteArray>(javaArray()), index, 1, &aJValue.b);
+ break;
+ }
+
+ case char_type:
+ {
+ env->SetCharArrayRegion(static_cast<jcharArray>(javaArray()), index, 1, &aJValue.c);
+ break;
+ }
+
+ case short_type:
+ {
+ env->SetShortArrayRegion(static_cast<jshortArray>(javaArray()), index, 1, &aJValue.s);
+ break;
+ }
+
+ case int_type:
+ {
+ env->SetIntArrayRegion(static_cast<jintArray>(javaArray()), index, 1, &aJValue.i);
+ break;
+ }
+
+ case long_type:
+ {
+ env->SetLongArrayRegion(static_cast<jlongArray>(javaArray()), index, 1, &aJValue.j);
+ }
+
+ case float_type:
+ {
+ env->SetFloatArrayRegion(static_cast<jfloatArray>(javaArray()), index, 1, &aJValue.f);
+ break;
+ }
+
+ case double_type:
+ {
+ env->SetDoubleArrayRegion(static_cast<jdoubleArray>(javaArray()), index, 1, &aJValue.d);
+ break;
+ }
+ default:
+ break;
+ }
+
+ if (javaClassName)
+ free(const_cast<char*>(javaClassName));
+}
+
+JSValue JavaArray::valueAt(ExecState* exec, unsigned index) const
+{
+ JNIEnv* env = getJNIEnv();
+ JNIType arrayType = JNITypeFromPrimitiveType(m_type[1]);
+ switch (arrayType) {
+ case object_type:
+ {
+ jobjectArray objectArray = static_cast<jobjectArray>(javaArray());
+ jobject anObject;
+ anObject = env->GetObjectArrayElement(objectArray, index);
+
+ // No object?
+ if (!anObject)
+ return jsNull();
+
+ // Nested array?
+ if (m_type[1] == '[')
+ return JavaArray::convertJObjectToArray(exec, anObject, m_type + 1, rootObject());
+ // or array of other object type?
+ return JavaInstance::create(anObject, rootObject())->createRuntimeObject(exec);
+ }
+
+ case boolean_type:
+ {
+ jbooleanArray booleanArray = static_cast<jbooleanArray>(javaArray());
+ jboolean aBoolean;
+ env->GetBooleanArrayRegion(booleanArray, index, 1, &aBoolean);
+ return jsBoolean(aBoolean);
+ }
+
+ case byte_type:
+ {
+ jbyteArray byteArray = static_cast<jbyteArray>(javaArray());
+ jbyte aByte;
+ env->GetByteArrayRegion(byteArray, index, 1, &aByte);
+ return jsNumber(aByte);
+ }
+
+ case char_type:
+ {
+ jcharArray charArray = static_cast<jcharArray>(javaArray());
+ jchar aChar;
+ env->GetCharArrayRegion(charArray, index, 1, &aChar);
+ return jsNumber(aChar);
+ break;
+ }
+
+ case short_type:
+ {
+ jshortArray shortArray = static_cast<jshortArray>(javaArray());
+ jshort aShort;
+ env->GetShortArrayRegion(shortArray, index, 1, &aShort);
+ return jsNumber(aShort);
+ }
+
+ case int_type:
+ {
+ jintArray intArray = static_cast<jintArray>(javaArray());
+ jint anInt;
+ env->GetIntArrayRegion(intArray, index, 1, &anInt);
+ return jsNumber(anInt);
+ }
+
+ case long_type:
+ {
+ jlongArray longArray = static_cast<jlongArray>(javaArray());
+ jlong aLong;
+ env->GetLongArrayRegion(longArray, index, 1, &aLong);
+ return jsNumber(aLong);
+ }
+
+ case float_type:
+ {
+ jfloatArray floatArray = static_cast<jfloatArray>(javaArray());
+ jfloat aFloat;
+ env->GetFloatArrayRegion(floatArray, index, 1, &aFloat);
+ return jsNumber(aFloat);
+ }
+
+ case double_type:
+ {
+ jdoubleArray doubleArray = static_cast<jdoubleArray>(javaArray());
+ jdouble aDouble;
+ env->GetDoubleArrayRegion(doubleArray, index, 1, &aDouble);
+ return jsNumber(aDouble);
+ }
+ default:
+ break;
+ }
+ return jsUndefined();
+}
+
+unsigned int JavaArray::getLength() const
+{
+ return m_length;
+}
+
+#endif // ENABLE(JAVA_BRIDGE)
diff --git a/Source/WebCore/bridge/jni/jsc/JavaArrayJSC.h b/Source/WebCore/bridge/jni/jsc/JavaArrayJSC.h
new file mode 100644
index 0000000..900c728
--- /dev/null
+++ b/Source/WebCore/bridge/jni/jsc/JavaArrayJSC.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2003, 2004, 2005, 2007, 2009, 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:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. 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 APPLE COMPUTER, INC. ``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 APPLE COMPUTER, INC. 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 JavaArrayJSC_h
+#define JavaArrayJSC_h
+
+#if ENABLE(JAVA_BRIDGE)
+
+#include "BridgeJSC.h"
+#include "JNIUtility.h"
+#include "JobjectWrapper.h"
+
+namespace JSC {
+
+namespace Bindings {
+
+class JavaArray : public Array {
+public:
+ JavaArray(jobject array, const char* type, PassRefPtr<RootObject>);
+ virtual ~JavaArray();
+
+ RootObject* rootObject() const;
+
+ virtual void setValueAt(ExecState*, unsigned int index, JSValue) const;
+ virtual JSValue valueAt(ExecState*, unsigned int index) const;
+ virtual unsigned int getLength() const;
+
+ jobject javaArray() const { return m_array->m_instance; }
+
+ static JSValue convertJObjectToArray(ExecState*, jobject, const char* type, PassRefPtr<RootObject>);
+
+private:
+ RefPtr<JobjectWrapper> m_array;
+ unsigned int m_length;
+ const char* m_type;
+};
+
+} // namespace Bindings
+
+} // namespace JSC
+
+#endif // ENABLE(JAVA_BRIDGE)
+
+#endif // JavaArrayJSC_h
diff --git a/Source/WebCore/bridge/jni/jsc/JavaClassJSC.cpp b/Source/WebCore/bridge/jni/jsc/JavaClassJSC.cpp
index 43cdc96..18cd1af 100644
--- a/Source/WebCore/bridge/jni/jsc/JavaClassJSC.cpp
+++ b/Source/WebCore/bridge/jni/jsc/JavaClassJSC.cpp
@@ -30,6 +30,8 @@
#include "JNIUtility.h"
#include "JSDOMWindow.h"
+#include "JavaFieldJSC.h"
+#include "JavaMethod.h"
#include <runtime/Identifier.h>
#include <runtime/JSLock.h>
@@ -63,7 +65,7 @@ JavaClass::JavaClass(jobject anInstance)
JavaField* aField = new JavaField(env, aJField); // deleted in the JavaClass destructor
{
JSLock lock(SilenceAssertionsOnly);
- m_fields.set(((UString)aField->name()).impl(), aField);
+ m_fields.set(aField->name().impl(), aField);
}
env->DeleteLocalRef(aJField);
}
@@ -80,10 +82,10 @@ JavaClass::JavaClass(jobject anInstance)
{
JSLock lock(SilenceAssertionsOnly);
- methodList = m_methods.get(((UString)aMethod->name()).impl());
+ methodList = m_methods.get(aMethod->name().impl());
if (!methodList) {
methodList = new MethodList();
- m_methods.set(((UString)aMethod->name()).impl(), methodList);
+ m_methods.set(aMethod->name().impl(), methodList);
}
}
methodList->append(aMethod);
diff --git a/Source/WebCore/bridge/jni/jsc/JavaClassJSC.h b/Source/WebCore/bridge/jni/jsc/JavaClassJSC.h
index 0527162..48c9cac 100644
--- a/Source/WebCore/bridge/jni/jsc/JavaClassJSC.h
+++ b/Source/WebCore/bridge/jni/jsc/JavaClassJSC.h
@@ -28,7 +28,8 @@
#if ENABLE(JAVA_BRIDGE)
-#include "JNIBridgeJSC.h"
+#include "BridgeJSC.h"
+#include "JNIUtility.h"
#include <wtf/HashMap.h>
namespace JSC {
diff --git a/Source/WebCore/bridge/jni/jsc/JNIBridgeJSC.cpp b/Source/WebCore/bridge/jni/jsc/JavaFieldJSC.cpp
index 3c16d05..d3ba06a 100644
--- a/Source/WebCore/bridge/jni/jsc/JNIBridgeJSC.cpp
+++ b/Source/WebCore/bridge/jni/jsc/JavaFieldJSC.cpp
@@ -25,11 +25,12 @@
*/
#include "config.h"
-#include "JNIBridgeJSC.h"
+#include "JavaFieldJSC.h"
#if ENABLE(JAVA_BRIDGE)
#include "JNIUtilityPrivate.h"
+#include "JavaArrayJSC.h"
#include "Logging.h"
#include "runtime_array.h"
#include "runtime_object.h"
@@ -57,15 +58,7 @@ JavaField::JavaField(JNIEnv* env, jobject aField)
fieldName = env->NewStringUTF("<Unknown>");
m_name = JavaString(env, fieldName);
- m_field = new JObjectWrapper(aField);
-}
-
-JSValue JavaArray::convertJObjectToArray(ExecState* exec, jobject anObject, const char* type, PassRefPtr<RootObject> rootObject)
-{
- if (type[0] != '[')
- return jsUndefined();
-
- return new (exec) RuntimeArray(exec, new JavaArray(anObject, type, rootObject));
+ m_field = new JobjectWrapper(aField);
}
jvalue JavaField::dispatchValueFromInstance(ExecState* exec, const JavaInstance* instance, const char* name, const char* sig, JNIType returnType) const
@@ -150,7 +143,7 @@ JSValue JavaField::valueFromInstance(ExecState* exec, const Instance* i) const
break;
}
- LOG(LiveConnect, "JavaField::valueFromInstance getting %s = %s", UString(name()).utf8().data(), jsresult.toString(exec).ascii().data());
+ LOG(LiveConnect, "JavaField::valueFromInstance getting %s = %s", UString(name().impl()).utf8().data(), jsresult.toString(exec).ascii().data());
return jsresult;
}
@@ -186,7 +179,7 @@ void JavaField::setValueToInstance(ExecState* exec, const Instance* i, JSValue a
const JavaInstance* instance = static_cast<const JavaInstance*>(i);
jvalue javaValue = convertValueToJValue(exec, i->rootObject(), aValue, m_JNIType, type());
- LOG(LiveConnect, "JavaField::setValueToInstance setting value %s to %s", UString(name()).utf8().data(), aValue.toString(exec).ascii().data());
+ LOG(LiveConnect, "JavaField::setValueToInstance setting value %s to %s", UString(name().impl()).utf8().data(), aValue.toString(exec).ascii().data());
switch (m_JNIType) {
case array_type:
@@ -248,198 +241,4 @@ void JavaField::setValueToInstance(ExecState* exec, const Instance* i, JSValue a
}
}
-JavaArray::JavaArray(jobject array, const char* type, PassRefPtr<RootObject> rootObject)
- : Array(rootObject)
-{
- m_array = new JObjectWrapper(array);
- // Java array are fixed length, so we can cache length.
- JNIEnv* env = getJNIEnv();
- m_length = env->GetArrayLength(static_cast<jarray>(m_array->m_instance));
- m_type = strdup(type);
-}
-
-JavaArray::~JavaArray()
-{
- free(const_cast<char*>(m_type));
-}
-
-RootObject* JavaArray::rootObject() const
-{
- return m_rootObject && m_rootObject->isValid() ? m_rootObject.get() : 0;
-}
-
-void JavaArray::setValueAt(ExecState* exec, unsigned index, JSValue aValue) const
-{
- JNIEnv* env = getJNIEnv();
- char* javaClassName = 0;
-
- JNIType arrayType = JNITypeFromPrimitiveType(m_type[1]);
- if (m_type[1] == 'L') {
- // The type of the array will be something like:
- // "[Ljava.lang.string;". This is guaranteed, so no need
- // for extra sanity checks.
- javaClassName = strdup(&m_type[2]);
- javaClassName[strchr(javaClassName, ';')-javaClassName] = 0;
- }
- jvalue aJValue = convertValueToJValue(exec, m_rootObject.get(), aValue, arrayType, javaClassName);
-
- switch (arrayType) {
- case object_type:
- {
- env->SetObjectArrayElement(static_cast<jobjectArray>(javaArray()), index, aJValue.l);
- break;
- }
-
- case boolean_type:
- {
- env->SetBooleanArrayRegion(static_cast<jbooleanArray>(javaArray()), index, 1, &aJValue.z);
- break;
- }
-
- case byte_type:
- {
- env->SetByteArrayRegion(static_cast<jbyteArray>(javaArray()), index, 1, &aJValue.b);
- break;
- }
-
- case char_type:
- {
- env->SetCharArrayRegion(static_cast<jcharArray>(javaArray()), index, 1, &aJValue.c);
- break;
- }
-
- case short_type:
- {
- env->SetShortArrayRegion(static_cast<jshortArray>(javaArray()), index, 1, &aJValue.s);
- break;
- }
-
- case int_type:
- {
- env->SetIntArrayRegion(static_cast<jintArray>(javaArray()), index, 1, &aJValue.i);
- break;
- }
-
- case long_type:
- {
- env->SetLongArrayRegion(static_cast<jlongArray>(javaArray()), index, 1, &aJValue.j);
- }
-
- case float_type:
- {
- env->SetFloatArrayRegion(static_cast<jfloatArray>(javaArray()), index, 1, &aJValue.f);
- break;
- }
-
- case double_type:
- {
- env->SetDoubleArrayRegion(static_cast<jdoubleArray>(javaArray()), index, 1, &aJValue.d);
- break;
- }
- default:
- break;
- }
-
- if (javaClassName)
- free(const_cast<char*>(javaClassName));
-}
-
-
-JSValue JavaArray::valueAt(ExecState* exec, unsigned index) const
-{
- JNIEnv* env = getJNIEnv();
- JNIType arrayType = JNITypeFromPrimitiveType(m_type[1]);
- switch (arrayType) {
- case object_type:
- {
- jobjectArray objectArray = static_cast<jobjectArray>(javaArray());
- jobject anObject;
- anObject = env->GetObjectArrayElement(objectArray, index);
-
- // No object?
- if (!anObject)
- return jsNull();
-
- // Nested array?
- if (m_type[1] == '[')
- return JavaArray::convertJObjectToArray(exec, anObject, m_type + 1, rootObject());
- // or array of other object type?
- return JavaInstance::create(anObject, rootObject())->createRuntimeObject(exec);
- }
-
- case boolean_type:
- {
- jbooleanArray booleanArray = static_cast<jbooleanArray>(javaArray());
- jboolean aBoolean;
- env->GetBooleanArrayRegion(booleanArray, index, 1, &aBoolean);
- return jsBoolean(aBoolean);
- }
-
- case byte_type:
- {
- jbyteArray byteArray = static_cast<jbyteArray>(javaArray());
- jbyte aByte;
- env->GetByteArrayRegion(byteArray, index, 1, &aByte);
- return jsNumber(aByte);
- }
-
- case char_type:
- {
- jcharArray charArray = static_cast<jcharArray>(javaArray());
- jchar aChar;
- env->GetCharArrayRegion(charArray, index, 1, &aChar);
- return jsNumber(aChar);
- break;
- }
-
- case short_type:
- {
- jshortArray shortArray = static_cast<jshortArray>(javaArray());
- jshort aShort;
- env->GetShortArrayRegion(shortArray, index, 1, &aShort);
- return jsNumber(aShort);
- }
-
- case int_type:
- {
- jintArray intArray = static_cast<jintArray>(javaArray());
- jint anInt;
- env->GetIntArrayRegion(intArray, index, 1, &anInt);
- return jsNumber(anInt);
- }
-
- case long_type:
- {
- jlongArray longArray = static_cast<jlongArray>(javaArray());
- jlong aLong;
- env->GetLongArrayRegion(longArray, index, 1, &aLong);
- return jsNumber(aLong);
- }
-
- case float_type:
- {
- jfloatArray floatArray = static_cast<jfloatArray>(javaArray());
- jfloat aFloat;
- env->GetFloatArrayRegion(floatArray, index, 1, &aFloat);
- return jsNumber(aFloat);
- }
-
- case double_type:
- {
- jdoubleArray doubleArray = static_cast<jdoubleArray>(javaArray());
- jdouble aDouble;
- env->GetDoubleArrayRegion(doubleArray, index, 1, &aDouble);
- return jsNumber(aDouble);
- }
- default:
- break;
- }
- return jsUndefined();
-}
-
-unsigned int JavaArray::getLength() const
-{
- return m_length;
-}
-
#endif // ENABLE(JAVA_BRIDGE)
diff --git a/Source/WebCore/bridge/jni/jsc/JNIBridgeJSC.h b/Source/WebCore/bridge/jni/jsc/JavaFieldJSC.h
index 39f64e2..0374b45 100644
--- a/Source/WebCore/bridge/jni/jsc/JNIBridgeJSC.h
+++ b/Source/WebCore/bridge/jni/jsc/JavaFieldJSC.h
@@ -24,14 +24,21 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef JNIBridgeJSC_h
-#define JNIBridgeJSC_h
+#ifndef JavaFieldJSC_h
+#define JavaFieldJSC_h
#if ENABLE(JAVA_BRIDGE)
#include "BridgeJSC.h"
+<<<<<<< HEAD:Source/WebCore/bridge/jni/jsc/JNIBridgeJSC.h
#include "JNIBridge.h"
#include <JavaVM/jni.h>
+=======
+#include "JNIUtility.h"
+#include "JavaMethod.h"
+#include "JavaString.h"
+#include "JobjectWrapper.h"
+>>>>>>> WebKit at r80534:Source/WebCore/bridge/jni/jsc/JavaFieldJSC.h
namespace JSC {
@@ -56,28 +63,7 @@ private:
JavaString m_name;
JavaString m_type;
JNIType m_JNIType;
- RefPtr<JObjectWrapper> m_field;
-};
-
-class JavaArray : public Array {
-public:
- JavaArray(jobject array, const char* type, PassRefPtr<RootObject>);
- virtual ~JavaArray();
-
- RootObject* rootObject() const;
-
- virtual void setValueAt(ExecState*, unsigned int index, JSValue) const;
- virtual JSValue valueAt(ExecState*, unsigned int index) const;
- virtual unsigned int getLength() const;
-
- jobject javaArray() const { return m_array->m_instance; }
-
- static JSValue convertJObjectToArray(ExecState*, jobject, const char* type, PassRefPtr<RootObject>);
-
-private:
- RefPtr<JObjectWrapper> m_array;
- unsigned int m_length;
- const char* m_type;
+ RefPtr<JobjectWrapper> m_field;
};
} // namespace Bindings
@@ -86,4 +72,4 @@ private:
#endif // ENABLE(JAVA_BRIDGE)
-#endif // JNIBridge_h
+#endif // JavaFieldJSC_h
diff --git a/Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp b/Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
index 6332545..9d9a450 100644
--- a/Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
+++ b/Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.cpp
@@ -29,10 +29,13 @@
#if ENABLE(JAVA_BRIDGE)
#include "JavaRuntimeObject.h"
-#include "JNIBridgeJSC.h"
#include "JNIUtility.h"
#include "JNIUtilityPrivate.h"
+#include "JSDOMBinding.h"
+#include "JavaArrayJSC.h"
#include "JavaClassJSC.h"
+#include "JavaMethod.h"
+#include "JavaString.h"
#include "Logging.h"
#include "jni_jsobject.h"
#include "runtime_method.h"
@@ -40,6 +43,7 @@
#include "runtime_root.h"
#include <runtime/ArgList.h>
#include <runtime/Error.h>
+#include <runtime/FunctionPrototype.h>
#include <runtime/JSLock.h>
using namespace JSC::Bindings;
@@ -49,7 +53,7 @@ using namespace WebCore;
JavaInstance::JavaInstance(jobject instance, PassRefPtr<RootObject> rootObject)
: Instance(rootObject)
{
- m_instance = new JObjectWrapper(instance);
+ m_instance = new JobjectWrapper(instance);
m_class = 0;
}
@@ -114,11 +118,17 @@ JSValue JavaInstance::booleanValue() const
class JavaRuntimeMethod : public RuntimeMethod {
public:
JavaRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
- : RuntimeMethod(exec, globalObject, name, list)
+ // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
+ // We need to pass in the right global object for "i".
+ : RuntimeMethod(exec, globalObject, WebCore::deprecatedGetDOMStructure<JavaRuntimeMethod>(exec), name, list)
{
+ ASSERT(inherits(&s_info));
}
- virtual const ClassInfo* classInfo() const { return &s_info; }
+ static PassRefPtr<Structure> createStructure(JSValue prototype)
+ {
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
+ }
static const ClassInfo s_info;
};
@@ -162,13 +172,13 @@ JSValue JavaInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod
}
const JavaMethod* jMethod = static_cast<const JavaMethod*>(method);
- LOG(LiveConnect, "JavaInstance::invokeMethod call %s %s on %p", UString(jMethod->name()).utf8().data(), jMethod->signature(), m_instance->m_instance);
+ LOG(LiveConnect, "JavaInstance::invokeMethod call %s %s on %p", UString(jMethod->name().impl()).utf8().data(), jMethod->signature(), m_instance->m_instance);
Vector<jvalue> jArgs(count);
for (i = 0; i < count; i++) {
- JavaParameter* aParameter = jMethod->parameterAt(i);
- jArgs[i] = convertValueToJValue(exec, m_rootObject.get(), exec->argument(i), aParameter->getJNIType(), aParameter->type());
+ CString javaClassName = jMethod->parameterAt(i).utf8();
+ jArgs[i] = convertValueToJValue(exec, m_rootObject.get(), exec->argument(i), JNITypeFromClassName(javaClassName.data()), javaClassName.data());
LOG(LiveConnect, "JavaInstance::invokeMethod arg[%d] = %s", i, exec->argument(i).toString(exec).ascii().data());
}
@@ -358,27 +368,4 @@ JSValue JavaInstance::valueOf(ExecState* exec) const
return stringValue(exec);
}
-JObjectWrapper::JObjectWrapper(jobject instance)
- : m_refCount(0)
-{
- ASSERT(instance);
-
- // Cache the JNIEnv used to get the global ref for this java instance.
- // It'll be used to delete the reference.
- m_env = getJNIEnv();
-
- m_instance = m_env->NewGlobalRef(instance);
-
- LOG(LiveConnect, "JObjectWrapper ctor new global ref %p for %p", m_instance, instance);
-
- if (!m_instance)
- LOG_ERROR("Could not get GlobalRef for %p", instance);
-}
-
-JObjectWrapper::~JObjectWrapper()
-{
- LOG(LiveConnect, "JObjectWrapper dtor deleting global ref %p", m_instance);
- m_env->DeleteGlobalRef(m_instance);
-}
-
#endif // ENABLE(JAVA_BRIDGE)
diff --git a/Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.h b/Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.h
index 004635d..899788e 100644
--- a/Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.h
+++ b/Source/WebCore/bridge/jni/jsc/JavaInstanceJSC.h
@@ -29,45 +29,19 @@
#if ENABLE(JAVA_BRIDGE)
#include "BridgeJSC.h"
+<<<<<<< HEAD
+=======
+#include "JNIUtility.h"
+#include "JobjectWrapper.h"
+>>>>>>> WebKit at r80534
#include "runtime_root.h"
-#include <JavaVM/jni.h>
-
namespace JSC {
namespace Bindings {
class JavaClass;
-class JObjectWrapper {
-friend class RefPtr<JObjectWrapper>;
-friend class JavaArray;
-friend class JavaField;
-friend class JavaInstance;
-friend class JavaMethod;
-
-public:
- jobject instance() const { return m_instance; }
- void setInstance(jobject instance) { m_instance = instance; }
-
- void ref() { m_refCount++; }
- void deref()
- {
- if (!(--m_refCount))
- delete this;
- }
-
-protected:
- JObjectWrapper(jobject instance);
- ~JObjectWrapper();
-
- jobject m_instance;
-
-private:
- JNIEnv* m_env;
- unsigned int m_refCount;
-};
-
class JavaInstance : public Instance {
public:
static PassRefPtr<JavaInstance> create(jobject instance, PassRefPtr<RootObject> rootObject)
@@ -99,7 +73,7 @@ protected:
virtual void virtualBegin();
virtual void virtualEnd();
- RefPtr<JObjectWrapper> m_instance;
+ RefPtr<JobjectWrapper> m_instance;
mutable JavaClass* m_class;
};
diff --git a/Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.cpp b/Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.cpp
index 6270f9f..077cea9 100644
--- a/Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.cpp
+++ b/Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.cpp
@@ -24,9 +24,11 @@
*/
#include "config.h"
+#include "JavaRuntimeObject.h"
#include "JavaInstanceJSC.h"
-#include "JavaRuntimeObject.h"
+#include "JSDOMBinding.h"
+#include "runtime/ObjectPrototype.h"
namespace JSC {
namespace Bindings {
@@ -34,8 +36,11 @@ namespace Bindings {
const ClassInfo JavaRuntimeObject::s_info = { "JavaRuntimeObject", &RuntimeObject::s_info, 0, 0 };
JavaRuntimeObject::JavaRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<JavaInstance> instance)
- : RuntimeObject(exec, globalObject, instance)
+ // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
+ // We need to pass in the right global object for "i".
+ : RuntimeObject(exec, globalObject, WebCore::deprecatedGetDOMStructure<JavaRuntimeObject>(exec), instance)
{
+ ASSERT(inherits(&s_info));
}
JavaRuntimeObject::~JavaRuntimeObject()
diff --git a/Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.h b/Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.h
index 0e400f4..12a85ae 100644
--- a/Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.h
+++ b/Source/WebCore/bridge/jni/jsc/JavaRuntimeObject.h
@@ -42,8 +42,10 @@ public:
static const ClassInfo s_info;
-private:
- virtual const ClassInfo* classInfo() const { return &s_info; }
+ static PassRefPtr<Structure> createStructure(JSValue prototype)
+ {
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
+ }
};
}
diff --git a/Source/WebCore/bridge/jni/jsc/JavaStringJSC.h b/Source/WebCore/bridge/jni/jsc/JavaStringJSC.h
index cf575b2..3ce7a16 100644
--- a/Source/WebCore/bridge/jni/jsc/JavaStringJSC.h
+++ b/Source/WebCore/bridge/jni/jsc/JavaStringJSC.h
@@ -68,9 +68,8 @@ public:
}
return m_utf8String.data();
}
- const jchar* uchars() const { return (const jchar*)m_impl->characters(); }
int length() const { return m_impl->length(); }
- UString uString() const { return UString(m_impl); }
+ StringImpl* impl() const { return m_impl.get(); }
private:
RefPtr<StringImpl> m_impl;
diff --git a/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp b/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
index f104e65..6bcc574 100644
--- a/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
+++ b/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.cpp
@@ -26,16 +26,24 @@
#include "config.h"
#include "JNIUtilityPrivate.h"
+#if ENABLE(JAVA_BRIDGE)
+
#include "JavaInstanceV8.h"
#include "JavaNPObjectV8.h"
+<<<<<<< HEAD
#include "npruntime_impl.h"
+=======
+#include <wtf/text/CString.h>
+>>>>>>> WebKit at r80534
namespace JSC {
namespace Bindings {
-jvalue convertNPVariantToJValue(NPVariant value, JNIType jniType, const char* javaClassName)
+jvalue convertNPVariantToJValue(NPVariant value, const WTF::String& javaType)
{
+ CString javaClassName = javaType.utf8();
+ JNIType jniType = JNITypeFromClassName(javaClassName.data());
jvalue result;
NPVariantType type = value.type;
@@ -229,7 +237,7 @@ jvalue convertNPVariantToJValue(NPVariant value, JNIType jniType, const char* ja
// Now convert value to a string if the target type is a java.lang.string, and we're not
// converting from a Null.
- if (!result.l && !strcmp(javaClassName, "java.lang.String")) {
+ if (!result.l && !strcmp(javaClassName.data(), "java.lang.String")) {
#ifdef CONVERT_NULL_TO_EMPTY_STRING
if (type == NPVariantType_Null) {
jchar buf[2];
@@ -476,6 +484,8 @@ void convertJValueToNPVariant(jvalue value, JNIType jniType, const char* javaTyp
}
}
-} // end of namespace Bindings
+} // namespace Bindings
+
+} // namespace JSC
-} // end of namespace JSC
+#endif // ENABLE(JAVA_BRIDGE)
diff --git a/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.h b/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.h
index da7a24c..5aa2921 100644
--- a/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.h
+++ b/Source/WebCore/bridge/jni/v8/JNIUtilityPrivate.h
@@ -26,8 +26,11 @@
#ifndef JNIUtilityPrivate_h
#define JNIUtilityPrivate_h
+#if ENABLE(JAVA_BRIDGE)
+
#include "JNIUtility.h"
#include "npruntime.h"
+#include <wtf/text/WTFString.h>
// FIXME: While fully implementing the bindings I noticed some differences between what
// I wrote and seemed intuitive and what JSC does. Need to verify if my intuition is wrong
@@ -39,11 +42,13 @@ namespace JSC {
namespace Bindings {
-jvalue convertNPVariantToJValue(NPVariant, JNIType, const char* javaClassName);
+jvalue convertNPVariantToJValue(NPVariant, const WTF::String& javaType);
void convertJValueToNPVariant(jvalue, JNIType, const char* javaClassName, NPVariant*);
} // namespace Bindings
} // namespace JSC
+#endif // ENABLE(JAVA_BRIDGE)
+
#endif // JNIUtilityPrivate_h
diff --git a/Source/WebCore/bridge/jni/v8/JavaClassV8.cpp b/Source/WebCore/bridge/jni/v8/JavaClassV8.cpp
index 1d381af..18377bd 100644
--- a/Source/WebCore/bridge/jni/v8/JavaClassV8.cpp
+++ b/Source/WebCore/bridge/jni/v8/JavaClassV8.cpp
@@ -26,6 +26,11 @@
#include "config.h"
#include "JavaClassV8.h"
+#if ENABLE(JAVA_BRIDGE)
+
+#include "JavaFieldV8.h"
+#include "JavaMethod.h"
+
using namespace JSC::Bindings;
JavaClass::JavaClass(jobject anInstance)
@@ -101,3 +106,5 @@ JavaField* JavaClass::fieldNamed(const char* name) const
{
return m_fields.get(name);
}
+
+#endif // ENABLE(JAVA_BRIDGE)
diff --git a/Source/WebCore/bridge/jni/v8/JavaClassV8.h b/Source/WebCore/bridge/jni/v8/JavaClassV8.h
index 99137f1..6b03b2d 100644
--- a/Source/WebCore/bridge/jni/v8/JavaClassV8.h
+++ b/Source/WebCore/bridge/jni/v8/JavaClassV8.h
@@ -26,7 +26,9 @@
#ifndef JavaClassV8_h
#define JavaClassV8_h
-#include "JNIBridgeV8.h"
+#if ENABLE(JAVA_BRIDGE)
+
+#include "JNIUtility.h"
#include "PlatformString.h"
#include <wtf/HashMap.h>
#include <wtf/Vector.h>
@@ -36,13 +38,16 @@ namespace JSC {
namespace Bindings {
+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 anInstance);
+ JavaClass(jobject);
~JavaClass();
MethodList methodsNamed(const char* name) const;
@@ -57,4 +62,6 @@ private:
} // namespace JSC
+#endif // ENABLE(JAVA_BRIDGE)
+
#endif // JavaClassV8_h
diff --git a/Source/WebCore/bridge/jni/v8/JNIBridgeV8.cpp b/Source/WebCore/bridge/jni/v8/JavaFieldV8.cpp
index 35775dc..62081eb 100644
--- a/Source/WebCore/bridge/jni/v8/JNIBridgeV8.cpp
+++ b/Source/WebCore/bridge/jni/v8/JavaFieldV8.cpp
@@ -24,7 +24,9 @@
*/
#include "config.h"
-#include "JNIBridgeV8.h"
+#include "JavaFieldV8.h"
+
+#if ENABLE(JAVA_BRIDGE)
using namespace JSC::Bindings;
@@ -40,5 +42,7 @@ JavaField::JavaField(JNIEnv* env, jobject aField)
jstring fieldName = static_cast<jstring>(callJNIMethod<jobject>(aField, "getName", "()Ljava/lang/String;"));
m_name = JavaString(env, fieldName);
- m_field = new JObjectWrapper(aField);
+ m_field = new JobjectWrapper(aField);
}
+
+#endif // ENABLE(JAVA_BRIDGE)
diff --git a/Source/WebCore/bridge/jni/v8/JNIBridgeV8.h b/Source/WebCore/bridge/jni/v8/JavaFieldV8.h
index 46cbd56..caf28bf 100644
--- a/Source/WebCore/bridge/jni/v8/JNIBridgeV8.h
+++ b/Source/WebCore/bridge/jni/v8/JavaFieldV8.h
@@ -23,11 +23,13 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef JNIBridgeV8_h
-#define JNIBridgeV8_h
+#ifndef JavaFieldV8_h
+#define JavaFieldV8_h
-#include "JNIBridge.h" // For JavaString
-#include "JavaInstanceV8.h" // For JObjectWrapper
+#if ENABLE(JAVA_BRIDGE)
+
+#include "JavaString.h"
+#include "JobjectWrapper.h"
namespace JSC {
@@ -46,11 +48,13 @@ private:
JavaString m_name;
JavaString m_type;
JNIType m_JNIType;
- RefPtr<JObjectWrapper> m_field;
+ RefPtr<JobjectWrapper> m_field;
};
} // namespace Bindings
} // namespace JSC
-#endif // JNIBridgeV8_h
+#endif // ENABLE(JAVA_BRIDGE)
+
+#endif // JavaFieldV8_h
diff --git a/Source/WebCore/bridge/jni/v8/JavaInstanceV8.cpp b/Source/WebCore/bridge/jni/v8/JavaInstanceV8.cpp
index 27adca3..dbf53f0 100644
--- a/Source/WebCore/bridge/jni/v8/JavaInstanceV8.cpp
+++ b/Source/WebCore/bridge/jni/v8/JavaInstanceV8.cpp
@@ -27,17 +27,19 @@
#include "config.h"
#include "JavaInstanceV8.h"
-#include "JNIBridge.h"
+#if ENABLE(JAVA_BRIDGE)
+
+#include "JavaMethod.h"
#include "JNIUtilityPrivate.h"
#include "JavaClassV8.h"
-#include <assert.h>
+#include <wtf/text/CString.h>
using namespace JSC::Bindings;
JavaInstance::JavaInstance(jobject instance)
{
- m_instance = new JObjectWrapper(instance);
+ m_instance = new JobjectWrapper(instance);
m_class = 0;
}
@@ -97,10 +99,8 @@ bool JavaInstance::invokeMethod(const char* methodName, const NPVariant* args, i
if (count > 0)
jArgs = static_cast<jvalue*>(malloc(count * sizeof(jvalue)));
- for (int i = 0; i < count; i++) {
- JavaParameter* aParameter = jMethod->parameterAt(i);
- jArgs[i] = convertNPVariantToJValue(args[i], aParameter->getJNIType(), aParameter->type());
- }
+ for (int i = 0; i < count; i++)
+ jArgs[i] = convertNPVariantToJValue(args[i], jMethod->parameterAt(i));
jvalue result;
@@ -152,22 +152,4 @@ bool JavaInstance::invokeMethod(const char* methodName, const NPVariant* args, i
return true;
}
-JObjectWrapper::JObjectWrapper(jobject instance)
- : m_refCount(0)
-{
- assert(instance);
-
- // Cache the JNIEnv used to get the global ref for this java instanace.
- // It'll be used to delete the reference.
- m_env = getJNIEnv();
-
- m_instance = m_env->NewGlobalRef(instance);
-
- if (!m_instance)
- fprintf(stderr, "%s: could not get GlobalRef for %p\n", __PRETTY_FUNCTION__, instance);
-}
-
-JObjectWrapper::~JObjectWrapper()
-{
- m_env->DeleteGlobalRef(m_instance);
-}
+#endif // ENABLE(JAVA_BRIDGE)
diff --git a/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h b/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h
index 4f009a5..8ee3195 100644
--- a/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h
+++ b/Source/WebCore/bridge/jni/v8/JavaInstanceV8.h
@@ -27,9 +27,12 @@
#ifndef JavaInstanceV8_h
#define JavaInstanceV8_h
+#if ENABLE(JAVA_BRIDGE)
+
+#include "JNIUtility.h"
+#include "JobjectWrapper.h"
#include "npruntime.h"
-#include <JavaVM/jni.h>
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
@@ -41,33 +44,6 @@ namespace Bindings {
class JavaClass;
-class JObjectWrapper {
-friend class RefPtr<JObjectWrapper>;
-friend class JavaField;
-friend class JavaInstance;
-
-public:
- jobject instance() const { return m_instance; }
- void setInstance(jobject instance) { m_instance = instance; }
-
- void ref() { m_refCount++; }
- void deref()
- {
- if (!(--m_refCount))
- delete this;
- }
-
-protected:
- JObjectWrapper(jobject);
- ~JObjectWrapper();
-
- jobject m_instance;
-
-private:
- JNIEnv* m_env;
- unsigned int m_refCount;
-};
-
class JavaInstance : public RefCounted<JavaInstance> {
public:
JavaInstance(jobject instance);
@@ -86,7 +62,7 @@ public:
void end() { virtualEnd(); }
protected:
- RefPtr<JObjectWrapper> m_instance;
+ RefPtr<JobjectWrapper> m_instance;
mutable JavaClass* m_class;
virtual void virtualBegin();
@@ -97,4 +73,6 @@ protected:
} // namespace JSC
+#endif // ENABLE(JAVA_BRIDGE)
+
#endif // JavaInstanceV8_h
diff --git a/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp b/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp
index 3bb8e27..da6cf4a 100644
--- a/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp
+++ b/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.cpp
@@ -27,8 +27,11 @@
#include "config.h"
#include "JavaNPObjectV8.h"
+#if ENABLE(JAVA_BRIDGE)
+
#include "JNIUtilityPrivate.h"
#include "JavaClassV8.h"
+#include "JavaFieldV8.h"
#include "JavaInstanceV8.h"
#include "npruntime_impl.h"
@@ -174,3 +177,5 @@ bool JavaNPObjectGetProperty(NPObject* obj, NPIdentifier identifier, NPVariant*
} // namespace Bindings
} // namespace JSC
+
+#endif // ENABLE(JAVA_BRIDGE)
diff --git a/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.h b/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.h
index 31b0ac7..ff3bb5f 100644
--- a/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.h
+++ b/Source/WebCore/bridge/jni/v8/JavaNPObjectV8.h
@@ -26,6 +26,8 @@
#ifndef JavaNPObjectV8_h
#define JavaNPObjectV8_h
+#if ENABLE(JAVA_BRIDGE)
+
#include "npruntime.h"
#include <wtf/RefPtr.h>
@@ -53,4 +55,6 @@ bool JavaNPObjectGetProperty(NPObject*, NPIdentifier name, NPVariant* result);
} // namespace JSC
+#endif // ENABLE(JAVA_BRIDGE)
+
#endif // JavaNPObjectV8_h
diff --git a/Source/WebCore/bridge/jni/v8/JavaStringV8.h b/Source/WebCore/bridge/jni/v8/JavaStringV8.h
index 827d9f5..64db331 100644
--- a/Source/WebCore/bridge/jni/v8/JavaStringV8.h
+++ b/Source/WebCore/bridge/jni/v8/JavaStringV8.h
@@ -27,7 +27,9 @@
#define JavaStringV8_h
#include "JNIUtility.h"
+
#include <wtf/text/CString.h>
+#include <wtf/text/WTFString.h>
namespace JSC {
@@ -38,20 +40,26 @@ class JavaStringImpl {
public:
void init() {}
- void init(JNIEnv* e, jstring s)
+ void init(JNIEnv* env, jstring string)
{
- int size = e->GetStringLength(s);
- const char* cs = getCharactersFromJStringInEnv(e, s);
- m_utf8String = WTF::CString(cs, size);
- releaseCharactersForJStringInEnv(e, s, cs);
+ int size = env->GetStringLength(string);
+ const jchar* jChars = getUCharactersFromJStringInEnv(env, string);
+ m_impl = StringImpl::create(jChars, size);
+ releaseUCharactersForJStringInEnv(env, string, jChars);
}
- const char* utf8() const { return m_utf8String.data(); }
- const jchar* uchars() const { return 0; } // Not implemented
+ const char* utf8() const
+ {
+ if (!m_utf8String.data())
+ m_utf8String = String(m_impl).utf8();
+ return m_utf8String.data();
+ }
int length() const { return m_utf8String.length(); }
+ StringImpl* impl() const { return m_impl.get(); }
private:
- WTF::CString m_utf8String;
+ RefPtr<StringImpl> m_impl;
+ mutable CString m_utf8String;
};
} // namespace Bindings
diff --git a/Source/WebCore/bridge/jsc/BridgeJSC.cpp b/Source/WebCore/bridge/jsc/BridgeJSC.cpp
index 2747c75..9c0adfc 100644
--- a/Source/WebCore/bridge/jsc/BridgeJSC.cpp
+++ b/Source/WebCore/bridge/jsc/BridgeJSC.cpp
@@ -27,9 +27,12 @@
#include "config.h"
#include "BridgeJSC.h"
+#include "JSDOMWindowBase.h"
#include "runtime_object.h"
#include "runtime_root.h"
-#include <runtime/JSLock.h>
+#include "runtime/JSLock.h"
+#include "runtime/ObjectPrototype.h"
+
#if PLATFORM(QT)
#include "qt_instance.h"
@@ -51,6 +54,7 @@ Array::~Array()
Instance::Instance(PassRefPtr<RootObject> rootObject)
: m_rootObject(rootObject)
+ , m_runtimeObject(*WebCore::JSDOMWindowBase::commonJSGlobalData())
{
ASSERT(m_rootObject);
}
@@ -58,7 +62,6 @@ Instance::Instance(PassRefPtr<RootObject> rootObject)
Instance::~Instance()
{
ASSERT(!m_runtimeObject);
- ASSERT(!m_runtimeObject.hasDeadObject());
}
static KJSDidExecuteFunctionPtr s_didExecuteFunction;
@@ -92,28 +95,23 @@ JSObject* Instance::createRuntimeObject(ExecState* exec)
JSLock lock(SilenceAssertionsOnly);
RuntimeObject* newObject = newRuntimeObject(exec);
- m_runtimeObject = newObject;
- m_rootObject->addRuntimeObject(newObject);
+ m_runtimeObject.set(exec->globalData(), newObject, 0);
+ m_rootObject->addRuntimeObject(exec->globalData(), newObject);
return newObject;
}
RuntimeObject* Instance::newRuntimeObject(ExecState* exec)
{
JSLock lock(SilenceAssertionsOnly);
- return new (exec)RuntimeObject(exec, exec->lexicalGlobalObject(), this);
-}
-void Instance::willDestroyRuntimeObject(RuntimeObject* object)
-{
- ASSERT(m_rootObject);
- m_rootObject->removeRuntimeObject(object);
- m_runtimeObject.clear(object);
+ // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
+ // We need to pass in the right global object for "i".
+ return new (exec) RuntimeObject(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeObject>(exec), this);
}
-void Instance::willInvalidateRuntimeObject(RuntimeObject* object)
+void Instance::willInvalidateRuntimeObject()
{
- ASSERT(object);
- m_runtimeObject.clear(object);
+ m_runtimeObject.clear();
}
RootObject* Instance::rootObject() const
diff --git a/Source/WebCore/bridge/jsc/BridgeJSC.h b/Source/WebCore/bridge/jsc/BridgeJSC.h
index bb5a379..c44faf1 100644
--- a/Source/WebCore/bridge/jsc/BridgeJSC.h
+++ b/Source/WebCore/bridge/jsc/BridgeJSC.h
@@ -88,8 +88,7 @@ public:
virtual Class* getClass() const = 0;
JSObject* createRuntimeObject(ExecState*);
- void willInvalidateRuntimeObject(RuntimeObject*);
- void willDestroyRuntimeObject(RuntimeObject*);
+ void willInvalidateRuntimeObject();
// Returns false if the value was not set successfully.
virtual bool setValueOfUndefinedField(ExecState*, const Identifier&, JSValue) { return false; }
diff --git a/Source/WebCore/bridge/npapi.h b/Source/WebCore/bridge/npapi.h
index 48e78c0..b3a7d25 100644
--- a/Source/WebCore/bridge/npapi.h
+++ b/Source/WebCore/bridge/npapi.h
@@ -237,6 +237,11 @@ typedef struct _NPSize
int32_t height;
} NPSize;
+typedef enum {
+ NPFocusNext = 0,
+ NPFocusPrevious = 1
+} NPFocusDirection;
+
/* Return values for NPP_HandleEvent */
#define kNPEventNotHandled 0
#define kNPEventHandled 1
@@ -713,6 +718,12 @@ enum NPEventType {
#define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
+/*
+ * Flags for NPP_ClearSiteData.
+ */
+#define NP_CLEAR_ALL 0
+#define NP_CLEAR_CACHE (1 << 0)
+
#if !defined(__LP64__)
#if defined(XP_MACOSX)
#pragma options align=reset
@@ -778,6 +789,9 @@ enum NPEventType {
#define NPVERS_HAS_PRIVATE_MODE 22
#define NPVERS_MACOSX_HAS_EVENT_MODELS 23
#define NPVERS_HAS_CANCEL_SRC_STREAM 24
+#define NPVERS_HAS_ADVANCED_KEY_HANDLING 25
+#define NPVERS_HAS_URL_REDIRECT_HANDLING 26
+#define NPVERS_HAS_CLEAR_SITE_DATA 27
/*----------------------------------------------------------------------*/
/* Function Prototypes */
@@ -823,6 +837,11 @@ void NP_LOADDS NPP_URLNotify(NPP instance, const char* url,
jref NP_LOADDS NPP_GetJavaClass(void);
NPError NP_LOADDS NPP_GetValue(NPP instance, NPPVariable variable, void *value);
NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, void *value);
+NPBool NP_LOADDS NPP_GotFocus(NPP instance, NPFocusDirection direction);
+void NP_LOADDS NPP_LostFocus(NPP instance);
+void NP_LOADDS NPP_URLRedirectNotify(NPP instance, const char* url, int32_t status, void* notifyData);
+NPError NP_LOADDS NPP_ClearSiteData(const char* site, uint64_t flags, uint64_t maxAge);
+char** NP_LOADDS NPP_GetSitesWithData(void);
/* NPN_* functions are provided by the navigator and called by the plugin. */
void NP_LOADDS NPN_Version(int* plugin_major, int* plugin_minor,
diff --git a/Source/WebCore/bridge/npruntime_internal.h b/Source/WebCore/bridge/npruntime_internal.h
index 550c34c..2d7dc06 100644
--- a/Source/WebCore/bridge/npruntime_internal.h
+++ b/Source/WebCore/bridge/npruntime_internal.h
@@ -50,4 +50,5 @@
#undef NormalState
#undef True
#undef False
+ #undef Success
#endif
diff --git a/Source/WebCore/bridge/nptypes.h b/Source/WebCore/bridge/nptypes.h
index 11e9683..3001288 100644
--- a/Source/WebCore/bridge/nptypes.h
+++ b/Source/WebCore/bridge/nptypes.h
@@ -36,127 +36,25 @@
*
* ***** END LICENSE BLOCK ***** */
-/*
- * Header file for ensuring that C99 types ([u]int32_t and bool) are
- * available.
- */
-
-#if defined(WIN32) || defined(OS2)
- /*
- * Win32 and OS/2 don't know C99, so define [u]int_16/32 here. The bool
- * is predefined tho, both in C and C++.
- */
- typedef short int16_t;
- typedef unsigned short uint16_t;
- typedef int int32_t;
- typedef unsigned int uint32_t;
-#elif defined(_AIX) || defined(__sun) || defined(__osf__) || defined(IRIX) || defined(HPUX)
- /*
- * AIX and SunOS ship a inttypes.h header that defines [u]int32_t,
- * but not bool for C.
- */
- #include <inttypes.h>
-
- #ifndef __cplusplus
- typedef int bool;
- #endif
-#elif defined(bsdi) || defined(FREEBSD) || defined(OPENBSD)
- /*
- * BSD/OS, FreeBSD, and OpenBSD ship sys/types.h that define int32_t and
- * u_int32_t.
- */
- #include <sys/types.h>
-
- /*
- * BSD/OS ships no header that defines uint32_t, nor bool (for C)
- */
- #if defined(bsdi)
- typedef u_int32_t uint32_t;
-
- #if !defined(__cplusplus)
- typedef int bool;
- #endif
- #else
- /*
- * FreeBSD and OpenBSD define uint32_t and bool.
- */
- #include <inttypes.h>
- #include <stdbool.h>
- #endif
-#elif defined(BEOS)
- #include <inttypes.h>
-#else
- /*
- * For those that ship a standard C99 stdint.h header file, include
- * it. Can't do the same for stdbool.h tho, since some systems ship
- * with a stdbool.h file that doesn't compile!
- */
- #include <stdint.h>
-
- #ifndef __cplusplus
- #if !defined(__GNUC__) || (__GNUC__ > 2 || __GNUC_MINOR__ > 95)
- #include <stdbool.h>
- #else
- /*
- * GCC 2.91 can't deal with a typedef for bool, but a #define
- * works.
- */
- #define bool int
- #endif
- #endif
-#endif
-/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is mozilla.org code.
- *
- * The Initial Developer of the Original Code is
- * mozilla.org.
- * Portions created by the Initial Developer are Copyright (C) 2004
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- * Johnny Stenback <jst@mozilla.org> (Original author)
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
+#ifndef nptypes_h_
+#define nptypes_h_
/*
- * Header file for ensuring that C99 types ([u]int32_t and bool) are
- * available.
+ * Header file for ensuring that C99 types ([u]int32_t, [u]int64_t and bool) and
+ * true/false macros are available.
*/
#if defined(WIN32) || defined(OS2)
/*
- * Win32 and OS/2 don't know C99, so define [u]int_16/32 here. The bool
+ * Win32 and OS/2 don't know C99, so define [u]int_16/32/64 here. The bool
* is predefined tho, both in C and C++.
*/
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned int uint32_t;
+ typedef long long int64_t;
+ typedef unsigned long long uint64_t;
#elif defined(_AIX) || defined(__sun) || defined(__osf__) || defined(IRIX) || defined(HPUX)
/*
* AIX and SunOS ship a inttypes.h header that defines [u]int32_t,
@@ -166,6 +64,8 @@
#ifndef __cplusplus
typedef int bool;
+ #define true 1
+ #define false 0
#endif
#elif defined(bsdi) || defined(FREEBSD) || defined(OPENBSD)
/*
@@ -179,9 +79,12 @@
*/
#if defined(bsdi)
typedef u_int32_t uint32_t;
+ typedef u_int64_t uint64_t;
#if !defined(__cplusplus)
typedef int bool;
+ #define true 1
+ #define false 0
#endif
#else
/*
@@ -209,6 +112,10 @@
* works.
*/
#define bool int
+ #define true 1
+ #define false 0
#endif
#endif
#endif
+
+#endif /* nptypes_h_ */
diff --git a/Source/WebCore/bridge/objc/ObjCRuntimeObject.h b/Source/WebCore/bridge/objc/ObjCRuntimeObject.h
index 78550b9..e9fa10d 100644
--- a/Source/WebCore/bridge/objc/ObjCRuntimeObject.h
+++ b/Source/WebCore/bridge/objc/ObjCRuntimeObject.h
@@ -42,8 +42,10 @@ public:
static const ClassInfo s_info;
-private:
- virtual const ClassInfo* classInfo() const { return &s_info; }
+ static PassRefPtr<Structure> createStructure(JSValue prototype)
+ {
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
+ }
};
}
diff --git a/Source/WebCore/bridge/objc/ObjCRuntimeObject.mm b/Source/WebCore/bridge/objc/ObjCRuntimeObject.mm
index d9afdf2..d9d3767 100644
--- a/Source/WebCore/bridge/objc/ObjCRuntimeObject.mm
+++ b/Source/WebCore/bridge/objc/ObjCRuntimeObject.mm
@@ -25,6 +25,8 @@
#import "config.h"
+#import "runtime/ObjectPrototype.h"
+#import "JSDOMBinding.h"
#import "ObjCRuntimeObject.h"
#import "objc_instance.h"
@@ -34,8 +36,11 @@ namespace Bindings {
const ClassInfo ObjCRuntimeObject::s_info = { "ObjCRuntimeObject", &RuntimeObject::s_info, 0, 0 };
ObjCRuntimeObject::ObjCRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<ObjcInstance> instance)
- : RuntimeObject(exec, globalObject, instance)
+ // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
+ // We need to pass in the right global object for "i".
+ : RuntimeObject(exec, globalObject, WebCore::deprecatedGetDOMStructure<ObjCRuntimeObject>(exec), instance)
{
+ ASSERT(inherits(&s_info));
}
ObjCRuntimeObject::~ObjCRuntimeObject()
diff --git a/Source/WebCore/bridge/objc/objc_instance.mm b/Source/WebCore/bridge/objc/objc_instance.mm
index ae9d95d..e0b18f1 100644
--- a/Source/WebCore/bridge/objc/objc_instance.mm
+++ b/Source/WebCore/bridge/objc/objc_instance.mm
@@ -27,11 +27,13 @@
#import "objc_instance.h"
#import "runtime_method.h"
+#import "JSDOMBinding.h"
#import "ObjCRuntimeObject.h"
#import "WebScriptObject.h"
#import <objc/objc-auto.h>
#import <runtime/Error.h>
#import <runtime/JSLock.h>
+#import "runtime/FunctionPrototype.h"
#import <wtf/Assertions.h>
#ifdef NDEBUG
@@ -175,11 +177,17 @@ bool ObjcInstance::supportsInvokeDefaultMethod() const
class ObjCRuntimeMethod : public RuntimeMethod {
public:
ObjCRuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& name, Bindings::MethodList& list)
- : RuntimeMethod(exec, globalObject, name, list)
+ // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
+ // We need to pass in the right global object for "i".
+ : RuntimeMethod(exec, globalObject, WebCore::deprecatedGetDOMStructure<ObjCRuntimeMethod>(exec), name, list)
{
+ ASSERT(inherits(&s_info));
}
- virtual const ClassInfo* classInfo() const { return &s_info; }
+ static PassRefPtr<Structure> createStructure(JSValue prototype)
+ {
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
+ }
static const ClassInfo s_info;
};
diff --git a/Source/WebCore/bridge/objc/objc_runtime.h b/Source/WebCore/bridge/objc/objc_runtime.h
index 450b985..1cee85b 100644
--- a/Source/WebCore/bridge/objc/objc_runtime.h
+++ b/Source/WebCore/bridge/objc/objc_runtime.h
@@ -105,7 +105,7 @@ public:
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
- return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
private:
@@ -119,8 +119,6 @@ private:
virtual bool toBoolean(ExecState*) const;
- virtual const ClassInfo* classInfo() const { return &s_info; }
-
RefPtr<ObjcInstance> _instance;
Identifier _item;
};
diff --git a/Source/WebCore/bridge/objc/objc_runtime.mm b/Source/WebCore/bridge/objc/objc_runtime.mm
index 3c4ba23..52226e6 100644
--- a/Source/WebCore/bridge/objc/objc_runtime.mm
+++ b/Source/WebCore/bridge/objc/objc_runtime.mm
@@ -187,7 +187,7 @@ unsigned int ObjcArray::getLength() const
return [_array.get() count];
}
-const ClassInfo ObjcFallbackObjectImp::s_info = { "ObjcFallbackObject", 0, 0, 0 };
+const ClassInfo ObjcFallbackObjectImp::s_info = { "ObjcFallbackObject", &JSObjectWithGlobalObject::s_info, 0, 0 };
ObjcFallbackObjectImp::ObjcFallbackObjectImp(ExecState* exec, JSGlobalObject* globalObject, ObjcInstance* i, const Identifier& propertyName)
// FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
@@ -195,6 +195,7 @@ ObjcFallbackObjectImp::ObjcFallbackObjectImp(ExecState* exec, JSGlobalObject* gl
, _instance(i)
, _item(propertyName)
{
+ ASSERT(inherits(&s_info));
}
bool ObjcFallbackObjectImp::getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot& slot)
diff --git a/Source/WebCore/bridge/qt/qt_instance.cpp b/Source/WebCore/bridge/qt/qt_instance.cpp
index b4d2117..7af752d 100644
--- a/Source/WebCore/bridge/qt/qt_instance.cpp
+++ b/Source/WebCore/bridge/qt/qt_instance.cpp
@@ -29,6 +29,7 @@
#include "qt_class.h"
#include "qt_runtime.h"
#include "runtime_object.h"
+#include "runtime/FunctionPrototype.h"
#include <qdebug.h>
#include <qhash.h>
@@ -60,14 +61,11 @@ public:
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
- return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
protected:
static const unsigned StructureFlags = RuntimeObject::StructureFlags | OverridesMarkChildren;
-
-private:
- virtual const ClassInfo* classInfo() const { return &s_info; }
};
const ClassInfo QtRuntimeObject::s_info = { "QtRuntimeObject", &RuntimeObject::s_info, 0, 0 };
@@ -244,7 +242,7 @@ JSValue QtInstance::getMethod(ExecState* exec, const Identifier& propertyName)
if (!getClass())
return jsNull();
MethodList methodList = m_class->methodsNamed(propertyName, this);
- return new (exec) RuntimeMethod(exec, exec->lexicalGlobalObject(), propertyName, methodList);
+ return new (exec) RuntimeMethod(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeMethod>(exec), propertyName, methodList);
}
JSValue QtInstance::invokeMethod(ExecState*, RuntimeMethod*)
diff --git a/Source/WebCore/bridge/qt/qt_pixmapruntime.cpp b/Source/WebCore/bridge/qt/qt_pixmapruntime.cpp
index 1ef20c3..534e28e 100644
--- a/Source/WebCore/bridge/qt/qt_pixmapruntime.cpp
+++ b/Source/WebCore/bridge/qt/qt_pixmapruntime.cpp
@@ -34,6 +34,7 @@
#include <runtime_method.h>
#include <runtime_object.h>
#include <runtime_root.h>
+#include "runtime/FunctionPrototype.h"
using namespace WebCore;
namespace JSC {
@@ -151,14 +152,11 @@ public:
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
- return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
protected:
static const unsigned StructureFlags = RuntimeObject::StructureFlags | OverridesMarkChildren;
-
-private:
- virtual const ClassInfo* classInfo() const { return &s_info; }
};
QtPixmapRuntimeObject::QtPixmapRuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<Instance> instance)
@@ -181,7 +179,7 @@ Class* QtPixmapInstance::getClass() const
JSValue QtPixmapInstance::getMethod(ExecState* exec, const Identifier& propertyName)
{
MethodList methodList = getClass()->methodsNamed(propertyName, this);
- return new (exec) RuntimeMethod(exec, exec->lexicalGlobalObject(), propertyName, methodList);
+ return new (exec) RuntimeMethod(exec, exec->lexicalGlobalObject(), WebCore::deprecatedGetDOMStructure<RuntimeMethod>(exec), propertyName, methodList);
}
JSValue QtPixmapInstance::invokeMethod(ExecState* exec, RuntimeMethod* runtimeMethod)
diff --git a/Source/WebCore/bridge/qt/qt_runtime.cpp b/Source/WebCore/bridge/qt/qt_runtime.cpp
index 5507fc9..78821b9 100644
--- a/Source/WebCore/bridge/qt/qt_runtime.cpp
+++ b/Source/WebCore/bridge/qt/qt_runtime.cpp
@@ -166,11 +166,11 @@ static JSRealType valueRealType(ExecState* exec, JSValue val)
JSObject *object = val.toObject(exec);
if (object->inherits(&RuntimeArray::s_info)) // RuntimeArray 'inherits' from Array, but not in C++
return RTArray;
- else if (object->inherits(&JSArray::info))
+ else if (object->inherits(&JSArray::s_info))
return Array;
- else if (object->inherits(&DateInstance::info))
+ else if (object->inherits(&DateInstance::s_info))
return Date;
- else if (object->inherits(&RegExpObject::info))
+ else if (object->inherits(&RegExpObject::s_info))
return RegExp;
else if (object->inherits(&RuntimeObject::s_info))
return QObj;
@@ -227,9 +227,9 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
hint = QMetaType::QRegExp;
break;
case Object:
- if (object->inherits(&NumberObject::info))
+ if (object->inherits(&NumberObject::s_info))
hint = QMetaType::Double;
- else if (object->inherits(&BooleanObject::info))
+ else if (object->inherits(&BooleanObject::s_info))
hint = QMetaType::Bool;
else
hint = QMetaType::QVariantMap;
@@ -263,7 +263,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type
int dist = -1;
switch (hint) {
case QMetaType::Bool:
- if (type == Object && object->inherits(&BooleanObject::info))
+ if (type == Object && object->inherits(&BooleanObject::s_info))
ret = QVariant(asBooleanObject(value)->internalValue().toBoolean(exec));
else
ret = QVariant(value.toBoolean(exec));
@@ -983,7 +983,7 @@ JSValue convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, con
#define QW_D(Class) Class##Data* d = d_func()
#define QW_DS(Class,Instance) Class##Data* d = Instance->d_func()
-const ClassInfo QtRuntimeMethod::s_info = { "QtRuntimeMethod", 0, 0, 0 };
+const ClassInfo QtRuntimeMethod::s_info = { "QtRuntimeMethod", &InternalFunction::s_info, 0, 0 };
QtRuntimeMethod::QtRuntimeMethod(QtRuntimeMethodData* dd, ExecState* exec, const Identifier& ident, PassRefPtr<QtInstance> inst)
: InternalFunction(&exec->globalData(), exec->lexicalGlobalObject(), deprecatedGetDOMStructure<QtRuntimeMethod>(exec), ident)
@@ -1629,7 +1629,7 @@ EncodedJSValue QtRuntimeConnectionMethod::call(ExecState* exec)
// receiver function [from arguments]
// receiver this object [from arguments]
- QtConnectionObject* conn = new QtConnectionObject(d->m_instance, signalIndex, thisObject, funcObject);
+ QtConnectionObject* conn = new QtConnectionObject(exec->globalData(), d->m_instance, signalIndex, thisObject, funcObject);
bool ok = QMetaObject::connect(sender, signalIndex, conn, conn->metaObject()->methodOffset());
if (!ok) {
delete conn;
@@ -1723,12 +1723,12 @@ JSValue QtRuntimeConnectionMethod::lengthGetter(ExecState*, JSValue, const Ident
// ===============
-QtConnectionObject::QtConnectionObject(PassRefPtr<QtInstance> instance, int signalIndex, JSObject* thisObject, JSObject* funcObject)
+QtConnectionObject::QtConnectionObject(JSGlobalData& globalData, PassRefPtr<QtInstance> instance, int signalIndex, JSObject* thisObject, JSObject* funcObject)
: m_instance(instance)
, m_signalIndex(signalIndex)
, m_originalObject(m_instance->getObject())
- , m_thisObject(thisObject)
- , m_funcObject(funcObject)
+ , m_thisObject(globalData, thisObject)
+ , m_funcObject(globalData, funcObject)
{
setParent(m_originalObject);
ASSERT(JSLock::currentThreadIsHoldingLock()); // so our ProtectedPtrs are safe
@@ -1826,27 +1826,25 @@ void QtConnectionObject::execute(void **argv)
}
}
// Stuff in the __qt_sender property, if we can
- ScopeChain oldsc = ScopeChain(NoScopeChain());
+ ScopeChainNode* oldsc = 0;
JSFunction* fimp = 0;
- if (m_funcObject->inherits(&JSFunction::info)) {
+ if (m_funcObject->inherits(&JSFunction::s_info)) {
fimp = static_cast<JSFunction*>(m_funcObject.get());
JSObject* qt_sender = QtInstance::getQtInstance(sender(), ro, QScriptEngine::QtOwnership)->createRuntimeObject(exec);
- JSObject* wrapper = new (exec) JSObject(JSObject::createStructure(jsNull()));
+ JSObject* wrapper = constructEmptyObject(exec, createEmptyObjectStructure(jsNull()));
PutPropertySlot slot;
wrapper->put(exec, Identifier(exec, "__qt_sender__"), qt_sender, slot);
oldsc = fimp->scope();
- ScopeChain sc = oldsc;
- sc.push(wrapper);
- fimp->setScope(sc);
+ fimp->setScope(exec->globalData(), oldsc->push(wrapper));
}
CallData callData;
CallType callType = m_funcObject->getCallData(callData);
- call(exec, m_funcObject, callType, callData, m_thisObject, l);
+ call(exec, m_funcObject.get(), callType, callData, m_thisObject.get(), l);
if (fimp)
- fimp->setScope(oldsc);
+ fimp->setScope(exec->globalData(), oldsc);
}
}
}
@@ -1859,7 +1857,7 @@ void QtConnectionObject::execute(void **argv)
bool QtConnectionObject::match(QObject* sender, int signalIndex, JSObject* thisObject, JSObject *funcObject)
{
if (m_originalObject == sender && m_signalIndex == signalIndex
- && thisObject == (JSObject*)m_thisObject && funcObject == (JSObject*)m_funcObject)
+ && thisObject == (JSObject*)m_thisObject.get() && funcObject == (JSObject*)m_funcObject.get())
return true;
return false;
}
diff --git a/Source/WebCore/bridge/qt/qt_runtime.h b/Source/WebCore/bridge/qt/qt_runtime.h
index c5abca7..b86ccbe 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 "Protect.h"
+#include "Global.h"
#include "runtime_method.h"
#include <qbytearray.h>
@@ -155,7 +155,7 @@ public:
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
- return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
protected:
@@ -212,7 +212,7 @@ private:
class QtConnectionObject: public QObject
{
public:
- QtConnectionObject(PassRefPtr<QtInstance> instance, int signalIndex, JSObject* thisObject, JSObject* funcObject);
+ QtConnectionObject(JSGlobalData&, PassRefPtr<QtInstance> instance, int signalIndex, JSObject* thisObject, JSObject* funcObject);
~QtConnectionObject();
static const QMetaObject staticMetaObject;
@@ -229,8 +229,8 @@ private:
RefPtr<QtInstance> m_instance;
int m_signalIndex;
QObject* m_originalObject; // only used as a key, not dereferenced
- ProtectedPtr<JSObject> m_thisObject;
- ProtectedPtr<JSObject> m_funcObject;
+ Global<JSObject> m_thisObject;
+ Global<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 2d0b7e3..a138660 100644
--- a/Source/WebCore/bridge/runtime_array.cpp
+++ b/Source/WebCore/bridge/runtime_array.cpp
@@ -35,13 +35,14 @@ using namespace WebCore;
namespace JSC {
-const ClassInfo RuntimeArray::s_info = { "RuntimeArray", &JSArray::info, 0, 0 };
+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))
{
+ ASSERT(inherits(&s_info));
setSubclassData(array);
}
diff --git a/Source/WebCore/bridge/runtime_array.h b/Source/WebCore/bridge/runtime_array.h
index f7b67bf..f4c74e2 100644
--- a/Source/WebCore/bridge/runtime_array.h
+++ b/Source/WebCore/bridge/runtime_array.h
@@ -46,8 +46,6 @@ public:
virtual bool deleteProperty(ExecState* exec, const Identifier &propertyName);
virtual bool deleteProperty(ExecState* exec, unsigned propertyName);
- virtual const ClassInfo* classInfo() const { return &s_info; }
-
unsigned getLength() const { return getConcreteArray()->getLength(); }
Bindings::Array* getConcreteArray() const { return static_cast<Bindings::Array*>(subclassData()); }
@@ -59,8 +57,15 @@ public:
return globalObject->arrayPrototype();
}
+ static PassRefPtr<Structure> createStructure(JSValue prototype)
+ {
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
+ }
+
+protected:
+ static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSArray::StructureFlags;
+
private:
- static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObject::StructureFlags;
static JSValue lengthGetter(ExecState*, JSValue, const Identifier&);
static JSValue indexGetter(ExecState*, JSValue, unsigned);
};
diff --git a/Source/WebCore/bridge/runtime_method.cpp b/Source/WebCore/bridge/runtime_method.cpp
index 8a61f2e..4b5ecff 100644
--- a/Source/WebCore/bridge/runtime_method.cpp
+++ b/Source/WebCore/bridge/runtime_method.cpp
@@ -41,15 +41,14 @@ using namespace Bindings;
ASSERT_CLASS_FITS_IN_CELL(RuntimeMethod);
-const ClassInfo RuntimeMethod::s_info = { "RuntimeMethod", &InternalFunction::info, 0, 0 };
+const ClassInfo RuntimeMethod::s_info = { "RuntimeMethod", &InternalFunction::s_info, 0, 0 };
-RuntimeMethod::RuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, const Identifier& ident, Bindings::MethodList& m)
- // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
- // exec-globalData() is also likely wrong.
+RuntimeMethod::RuntimeMethod(ExecState* exec, JSGlobalObject* globalObject, NonNullPassRefPtr<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, deprecatedGetDOMStructure<RuntimeMethod>(exec), ident)
+ : InternalFunction(&exec->globalData(), globalObject, structure, ident)
, _methodList(new MethodList(m))
{
+ ASSERT(inherits(&s_info));
}
JSValue RuntimeMethod::lengthGetter(ExecState*, JSValue slotBase, const Identifier&)
diff --git a/Source/WebCore/bridge/runtime_method.h b/Source/WebCore/bridge/runtime_method.h
index 27bc663..c0c9f16 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*, const Identifier& name, Bindings::MethodList&);
+ RuntimeMethod(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, const Identifier& name, Bindings::MethodList&);
Bindings::MethodList* methods() const { return _methodList.get(); }
static const ClassInfo s_info;
@@ -47,13 +47,13 @@ public:
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
- return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
- virtual const ClassInfo* classInfo() const { return &s_info; }
+protected:
+ static const unsigned StructureFlags = OverridesGetOwnPropertySlot | InternalFunction::StructureFlags;
private:
- static const unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | OverridesMarkChildren | InternalFunction::StructureFlags;
static JSValue lengthGetter(ExecState*, JSValue, const Identifier&);
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
diff --git a/Source/WebCore/bridge/runtime_object.cpp b/Source/WebCore/bridge/runtime_object.cpp
index 368f7b0..de1964a 100644
--- a/Source/WebCore/bridge/runtime_object.cpp
+++ b/Source/WebCore/bridge/runtime_object.cpp
@@ -36,33 +36,24 @@ using namespace WebCore;
namespace JSC {
namespace Bindings {
-const ClassInfo RuntimeObject::s_info = { "RuntimeObject", 0, 0, 0 };
-
-RuntimeObject::RuntimeObject(ExecState* exec, JSGlobalObject* globalObject, PassRefPtr<Instance> instance)
- // FIXME: deprecatedGetDOMStructure uses the prototype off of the wrong global object
- // We need to pass in the right global object for "i".
- : JSObjectWithGlobalObject(globalObject, deprecatedGetDOMStructure<RuntimeObject>(exec))
- , m_instance(instance)
-{
-}
+const ClassInfo RuntimeObject::s_info = { "RuntimeObject", &JSObjectWithGlobalObject::s_info, 0, 0 };
RuntimeObject::RuntimeObject(ExecState*, JSGlobalObject* globalObject, NonNullPassRefPtr<Structure> structure, PassRefPtr<Instance> instance)
: JSObjectWithGlobalObject(globalObject, structure)
, m_instance(instance)
{
+ ASSERT(inherits(&s_info));
}
RuntimeObject::~RuntimeObject()
{
- if (m_instance)
- m_instance->willDestroyRuntimeObject(this);
}
void RuntimeObject::invalidate()
{
ASSERT(m_instance);
if (m_instance)
- m_instance->willInvalidateRuntimeObject(this);
+ m_instance->willInvalidateRuntimeObject();
m_instance = 0;
}
diff --git a/Source/WebCore/bridge/runtime_object.h b/Source/WebCore/bridge/runtime_object.h
index fc9baf1..0decd17 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*, PassRefPtr<Instance>);
+ RuntimeObject(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, PassRefPtr<Instance>);
virtual ~RuntimeObject();
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
@@ -63,16 +63,13 @@ public:
static PassRefPtr<Structure> createStructure(JSValue prototype)
{
- return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount);
+ return Structure::create(prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
protected:
- static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObject::StructureFlags;
- RuntimeObject(ExecState*, JSGlobalObject*, NonNullPassRefPtr<Structure>, PassRefPtr<Instance>);
+ static const unsigned StructureFlags = OverridesGetOwnPropertySlot | OverridesGetPropertyNames | JSObjectWithGlobalObject::StructureFlags;
private:
- virtual const ClassInfo* classInfo() const { return &s_info; }
-
static JSValue fallbackObjectGetter(ExecState*, JSValue, const Identifier&);
static JSValue fieldGetter(ExecState*, JSValue, const Identifier&);
static JSValue methodGetter(ExecState*, JSValue, const Identifier&);
diff --git a/Source/WebCore/bridge/runtime_root.cpp b/Source/WebCore/bridge/runtime_root.cpp
index 5496e55..2796754 100644
--- a/Source/WebCore/bridge/runtime_root.cpp
+++ b/Source/WebCore/bridge/runtime_root.cpp
@@ -83,7 +83,7 @@ PassRefPtr<RootObject> RootObject::create(const void* nativeHandle, JSGlobalObje
RootObject::RootObject(const void* nativeHandle, JSGlobalObject* globalObject)
: m_isValid(true)
, m_nativeHandle(nativeHandle)
- , m_globalObject(globalObject)
+ , m_globalObject(globalObject->globalData(), globalObject)
{
ASSERT(globalObject);
rootObjectSet()->add(this);
@@ -101,10 +101,9 @@ void RootObject::invalidate()
return;
{
- WeakGCMap<RuntimeObject*, RuntimeObject>::iterator end = m_runtimeObjects.uncheckedEnd();
- for (WeakGCMap<RuntimeObject*, RuntimeObject>::iterator it = m_runtimeObjects.uncheckedBegin(); it != end; ++it) {
- if (m_runtimeObjects.isValid(it))
- it->second->invalidate();
+ WeakGCMap<RuntimeObject*, RuntimeObject>::iterator end = m_runtimeObjects.end();
+ for (WeakGCMap<RuntimeObject*, RuntimeObject>::iterator it = m_runtimeObjects.begin(); it != end; ++it) {
+ it.get().second->invalidate();
}
m_runtimeObjects.clear();
@@ -113,7 +112,7 @@ void RootObject::invalidate()
m_isValid = false;
m_nativeHandle = 0;
- m_globalObject = 0;
+ m_globalObject.clear();
{
HashSet<InvalidationCallback*>::iterator end = m_invalidationCallbacks.end();
@@ -167,20 +166,20 @@ const void* RootObject::nativeHandle() const
JSGlobalObject* RootObject::globalObject() const
{
ASSERT(m_isValid);
- return m_globalObject;
+ return m_globalObject.get();
}
void RootObject::updateGlobalObject(JSGlobalObject* globalObject)
{
- m_globalObject = globalObject;
+ m_globalObject.set(globalObject->globalData(), globalObject);
}
-void RootObject::addRuntimeObject(RuntimeObject* object)
+void RootObject::addRuntimeObject(JSGlobalData& globalData, RuntimeObject* object)
{
ASSERT(m_isValid);
ASSERT(!m_runtimeObjects.get(object));
- m_runtimeObjects.set(object, object);
+ m_runtimeObjects.set(globalData, object, object);
}
void RootObject::removeRuntimeObject(RuntimeObject* object)
@@ -188,7 +187,7 @@ void RootObject::removeRuntimeObject(RuntimeObject* object)
if (!m_isValid)
return;
- ASSERT(m_runtimeObjects.uncheckedGet(object));
+ ASSERT(m_runtimeObjects.get(object));
m_runtimeObjects.take(object);
}
diff --git a/Source/WebCore/bridge/runtime_root.h b/Source/WebCore/bridge/runtime_root.h
index dde8a48..feade45 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 <runtime/Protect.h>
+#include <collector/handles/Global.h>
#include <runtime/WeakGCMap.h>
#include <wtf/Forward.h>
@@ -71,7 +71,7 @@ public:
JSGlobalObject* globalObject() const;
void updateGlobalObject(JSGlobalObject*);
- void addRuntimeObject(RuntimeObject*);
+ void addRuntimeObject(JSGlobalData&, RuntimeObject*);
void removeRuntimeObject(RuntimeObject*);
struct InvalidationCallback {
@@ -86,7 +86,7 @@ private:
bool m_isValid;
const void* m_nativeHandle;
- ProtectedPtr<JSGlobalObject> m_globalObject;
+ Global<JSGlobalObject> m_globalObject;
ProtectCountSet m_protectCountSet;
WeakGCMap<RuntimeObject*, RuntimeObject> m_runtimeObjects; // Really need a WeakGCSet, but this will do.
diff --git a/Source/WebCore/bridge/testqtbindings.cpp b/Source/WebCore/bridge/testqtbindings.cpp
index 592415e..20bf88a 100644
--- a/Source/WebCore/bridge/testqtbindings.cpp
+++ b/Source/WebCore/bridge/testqtbindings.cpp
@@ -74,7 +74,7 @@ public slots:
using namespace JSC;
using namespace JSC::Bindings;
-class Global : public JSObject {
+class Global : public JSNonFinalObject {
public:
virtual UString className() const { return "global"; }
};