summaryrefslogtreecommitdiffstats
path: root/WebCore/bridge
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/bridge')
-rw-r--r--WebCore/bridge/NP_jsobject.cpp71
-rw-r--r--WebCore/bridge/c/c_class.cpp7
-rw-r--r--WebCore/bridge/c/c_class.h1
-rw-r--r--WebCore/bridge/c/c_instance.cpp69
-rw-r--r--WebCore/bridge/c/c_instance.h34
-rw-r--r--WebCore/bridge/c/c_runtime.cpp22
-rw-r--r--WebCore/bridge/c/c_runtime.h9
-rw-r--r--WebCore/bridge/c/c_utility.cpp22
-rw-r--r--WebCore/bridge/c/c_utility.h4
-rw-r--r--WebCore/bridge/jni/jni_class.cpp14
-rw-r--r--WebCore/bridge/jni/jni_class.h4
-rw-r--r--WebCore/bridge/jni/jni_instance.cpp24
-rw-r--r--WebCore/bridge/jni/jni_instance.h14
-rw-r--r--WebCore/bridge/jni/jni_jsobject.h4
-rw-r--r--WebCore/bridge/jni/jni_jsobject.mm42
-rw-r--r--WebCore/bridge/jni/jni_objc.mm2
-rw-r--r--WebCore/bridge/jni/jni_runtime.cpp30
-rw-r--r--WebCore/bridge/jni/jni_runtime.h16
-rw-r--r--WebCore/bridge/jni/jni_utility.cpp60
-rw-r--r--WebCore/bridge/jni/jni_utility.h4
-rw-r--r--WebCore/bridge/npapi.h2
-rw-r--r--WebCore/bridge/npruntime.cpp13
-rw-r--r--WebCore/bridge/objc/WebScriptObject.h2
-rw-r--r--WebCore/bridge/objc/objc_class.h4
-rw-r--r--WebCore/bridge/objc/objc_class.mm9
-rw-r--r--WebCore/bridge/objc/objc_instance.h22
-rw-r--r--WebCore/bridge/objc/objc_instance.mm48
-rw-r--r--WebCore/bridge/objc/objc_runtime.h32
-rw-r--r--WebCore/bridge/objc/objc_runtime.mm76
-rw-r--r--WebCore/bridge/objc/objc_utility.h6
-rw-r--r--WebCore/bridge/objc/objc_utility.mm16
-rw-r--r--WebCore/bridge/qt/qt_class.cpp4
-rw-r--r--WebCore/bridge/qt/qt_class.h2
-rw-r--r--WebCore/bridge/qt/qt_instance.cpp100
-rw-r--r--WebCore/bridge/qt/qt_instance.h23
-rw-r--r--WebCore/bridge/qt/qt_runtime.cpp210
-rw-r--r--WebCore/bridge/qt/qt_runtime.h30
-rw-r--r--WebCore/bridge/runtime.cpp34
-rw-r--r--WebCore/bridge/runtime.h50
-rw-r--r--WebCore/bridge/runtime_array.cpp8
-rw-r--r--WebCore/bridge/runtime_array.h12
-rw-r--r--WebCore/bridge/runtime_method.cpp12
-rw-r--r--WebCore/bridge/runtime_method.h6
-rw-r--r--WebCore/bridge/runtime_object.cpp53
-rw-r--r--WebCore/bridge/runtime_object.h21
-rw-r--r--WebCore/bridge/runtime_root.cpp3
-rw-r--r--WebCore/bridge/runtime_root.h2
-rw-r--r--WebCore/bridge/testbindings.cpp2
-rw-r--r--WebCore/bridge/testbindings.pro2
49 files changed, 621 insertions, 636 deletions
diff --git a/WebCore/bridge/NP_jsobject.cpp b/WebCore/bridge/NP_jsobject.cpp
index 9734862..19b4b60 100644
--- a/WebCore/bridge/NP_jsobject.cpp
+++ b/WebCore/bridge/NP_jsobject.cpp
@@ -35,6 +35,7 @@
#include "c_runtime.h"
#endif // ANDROID_NPN_SETEXCEPTION
#include "c_utility.h"
+#include "c_instance.h"
#include "npruntime_impl.h"
#include "npruntime_priv.h"
#include "runtime_root.h"
@@ -42,9 +43,9 @@
#include <runtime/JSGlobalObject.h>
#include <runtime/JSLock.h>
#include <runtime/PropertyNameArray.h>
-#include <kjs/SourceCode.h>
-#include <kjs/completion.h>
-#include <kjs/interpreter.h>
+#include <parser/SourceCode.h>
+#include <runtime/Completion.h>
+#include <runtime/Completion.h>
using WebCore::String;
using WebCore::StringSourceProvider;
@@ -115,17 +116,18 @@ bool _NPN_InvokeDefault(NPP, NPObject* o, const NPVariant* args, uint32_t argCou
JSLock lock(false);
// Call the function object.
- JSValue* function = obj->imp;
+ JSValuePtr function = obj->imp;
CallData callData;
- CallType callType = function->getCallData(callData);
+ CallType callType = function.getCallData(callData);
if (callType == CallTypeNone)
return false;
ArgList argList;
getListFromVariantArgs(exec, args, argCount, rootObject, argList);
- rootObject->globalObject()->startTimeoutCheck();
- JSValue* resultV = call(exec, function, callType, callData, function, argList);
- rootObject->globalObject()->stopTimeoutCheck();
+ ProtectedPtr<JSGlobalObject> globalObject = rootObject->globalObject();
+ globalObject->startTimeoutCheck();
+ JSValuePtr resultV = call(exec, function, callType, callData, function, argList);
+ globalObject->stopTimeoutCheck();
// Convert and return the result of the function call.
convertValueToNPVariant(exec, resultV, result);
@@ -163,18 +165,19 @@ bool _NPN_Invoke(NPP npp, NPObject* o, NPIdentifier methodName, const NPVariant*
return false;
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock(false);
- JSValue* function = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
+ JSValuePtr function = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
CallData callData;
- CallType callType = function->getCallData(callData);
+ CallType callType = function.getCallData(callData);
if (callType == CallTypeNone)
return false;
// Call the function object.
ArgList argList;
getListFromVariantArgs(exec, args, argCount, rootObject, argList);
- rootObject->globalObject()->startTimeoutCheck();
- JSValue* resultV = call(exec, function, callType, callData, obj->imp, argList);
- rootObject->globalObject()->stopTimeoutCheck();
+ ProtectedPtr<JSGlobalObject> globalObject = rootObject->globalObject();
+ globalObject->startTimeoutCheck();
+ JSValuePtr resultV = call(exec, function, callType, callData, obj->imp, argList);
+ globalObject->stopTimeoutCheck();
// Convert and return the result of the function call.
convertValueToNPVariant(exec, resultV, result);
@@ -199,15 +202,15 @@ bool _NPN_Evaluate(NPP, NPObject* o, NPString* s, NPVariant* variant)
return false;
ExecState* exec = rootObject->globalObject()->globalExec();
-
JSLock lock(false);
String scriptString = convertNPStringToUTF16(s);
- rootObject->globalObject()->startTimeoutCheck();
- Completion completion = Interpreter::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(scriptString));
- rootObject->globalObject()->stopTimeoutCheck();
+ ProtectedPtr<JSGlobalObject> globalObject = rootObject->globalObject();
+ globalObject->startTimeoutCheck();
+ Completion completion = JSC::evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(scriptString));
+ globalObject->stopTimeoutCheck();
ComplType type = completion.complType();
- JSValue* result;
+ JSValuePtr result;
if (type == Normal) {
result = completion.value();
if (!result)
@@ -237,7 +240,7 @@ bool _NPN_GetProperty(NPP, NPObject* o, NPIdentifier propertyName, NPVariant* va
PrivateIdentifier* i = static_cast<PrivateIdentifier*>(propertyName);
JSLock lock(false);
- JSValue* result;
+ JSValuePtr result;
if (i->isString)
result = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
else
@@ -365,9 +368,9 @@ bool _NPN_HasMethod(NPP, NPObject* o, NPIdentifier methodName)
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock(false);
- JSValue* func = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
+ JSValuePtr func = obj->imp->get(exec, identifierFromNPIdentifier(i->value.string));
exec->clearException();
- return !func->isUndefined();
+ return !func.isUndefined();
}
if (o->_class->hasMethod)
@@ -376,16 +379,11 @@ bool _NPN_HasMethod(NPP, NPObject* o, NPIdentifier methodName)
return false;
}
-void _NPN_SetException(NPObject* o, const NPUTF8* message)
+void _NPN_SetException(NPObject*, const NPUTF8* message)
{
- // FIXME:
- // Bug 19888: Implement _NPN_SetException() correctly
- // <https://bugs.webkit.org/show_bug.cgi?id=19888>
-#ifdef ANDROID_NPN_SETEXCEPTION
- if (o->_class == NPScriptObjectClass) {
- JSC::Bindings::SetGlobalException(message);
- }
-#endif // ANDROID_NPN_SETEXCEPTION
+ // Ignorning the NPObject param is consistent with the Mozilla implementation.
+ UString exception(message);
+ CInstance::setGlobalException(exception);
}
bool _NPN_Enumerate(NPP, NPObject* o, NPIdentifier** identifier, uint32_t* count)
@@ -422,7 +420,7 @@ bool _NPN_Enumerate(NPP, NPObject* o, NPIdentifier** identifier, uint32_t* count
return false;
}
-bool _NPN_Construct(NPP npp, NPObject* o, const NPVariant* args, uint32_t argCount, NPVariant* result)
+bool _NPN_Construct(NPP, NPObject* o, const NPVariant* args, uint32_t argCount, NPVariant* result)
{
if (o->_class == NPScriptObjectClass) {
JavaScriptObject* obj = reinterpret_cast<JavaScriptObject*>(o);
@@ -438,17 +436,18 @@ bool _NPN_Construct(NPP npp, NPObject* o, const NPVariant* args, uint32_t argCou
JSLock lock(false);
// Call the constructor object.
- JSValue* constructor = obj->imp;
+ JSValuePtr constructor = obj->imp;
ConstructData constructData;
- ConstructType constructType = constructor->getConstructData(constructData);
+ ConstructType constructType = constructor.getConstructData(constructData);
if (constructType == ConstructTypeNone)
return false;
ArgList argList;
getListFromVariantArgs(exec, args, argCount, rootObject, argList);
- rootObject->globalObject()->startTimeoutCheck();
- JSValue* resultV = construct(exec, constructor, constructType, constructData, argList);
- rootObject->globalObject()->stopTimeoutCheck();
+ ProtectedPtr<JSGlobalObject> globalObject = rootObject->globalObject();
+ globalObject->startTimeoutCheck();
+ JSValuePtr resultV = construct(exec, constructor, constructType, constructData, argList);
+ globalObject->stopTimeoutCheck();
// Convert and return the result.
convertValueToNPVariant(exec, resultV, result);
diff --git a/WebCore/bridge/c/c_class.cpp b/WebCore/bridge/c/c_class.cpp
index 1b72476..7ce9927 100644
--- a/WebCore/bridge/c/c_class.cpp
+++ b/WebCore/bridge/c/c_class.cpp
@@ -32,7 +32,7 @@
#include "c_instance.h"
#include "c_runtime.h"
#include "npruntime_impl.h"
-#include <kjs/identifier.h>
+#include <runtime/Identifier.h>
#include <runtime/JSLock.h>
namespace JSC { namespace Bindings {
@@ -70,11 +70,6 @@ CClass* CClass::classForIsA(NPClass* isa)
return aClass;
}
-const char* CClass::name() const
-{
- return "";
-}
-
MethodList CClass::methodsNamed(const Identifier& identifier, Instance* instance) const
{
MethodList methodList;
diff --git a/WebCore/bridge/c/c_class.h b/WebCore/bridge/c/c_class.h
index 9a08605..7f20af4 100644
--- a/WebCore/bridge/c/c_class.h
+++ b/WebCore/bridge/c/c_class.h
@@ -43,7 +43,6 @@ public:
static CClass* classForIsA(NPClass*);
virtual ~CClass();
- virtual const char* name() const;
virtual MethodList methodsNamed(const Identifier&, Instance*) const;
virtual Field* fieldNamed(const Identifier&, Instance*) const;
diff --git a/WebCore/bridge/c/c_instance.cpp b/WebCore/bridge/c/c_instance.cpp
index 79ae520..3e6f6d6 100644
--- a/WebCore/bridge/c/c_instance.cpp
+++ b/WebCore/bridge/c/c_instance.cpp
@@ -35,17 +35,45 @@
#include "npruntime_impl.h"
#include "runtime_root.h"
#include <runtime/ArgList.h>
-#include <runtime/ExecState.h>
+#include <runtime/Error.h>
+#include <interpreter/CallFrame.h>
#include <runtime/JSLock.h>
#include <runtime/JSNumberCell.h>
#include <runtime/PropertyNameArray.h>
#include <wtf/Assertions.h>
+#include <wtf/StdLibExtras.h>
#include <wtf/StringExtras.h>
#include <wtf/Vector.h>
namespace JSC {
namespace Bindings {
+using JSC::UString;
+
+static JSC::UString& globalExceptionString()
+{
+ DEFINE_STATIC_LOCAL(JSC::UString, exceptionStr, ());
+ return exceptionStr;
+}
+
+void CInstance::setGlobalException(UString exception)
+{
+ globalExceptionString() = exception;
+}
+
+void CInstance::moveGlobalExceptionToExecState(ExecState* exec)
+{
+ if (globalExceptionString().isNull())
+ return;
+
+ {
+ JSLock lock(false);
+ throwError(exec, GeneralError, globalExceptionString());
+ }
+
+ globalExceptionString() = UString();
+}
+
CInstance::CInstance(NPObject* o, PassRefPtr<RootObject> rootObject)
: Instance(rootObject)
{
@@ -70,7 +98,7 @@ bool CInstance::supportsInvokeDefaultMethod() const
return _object->_class->invokeDefault;
}
-JSValue* CInstance::invokeMethod(ExecState* exec, const MethodList& methodList, const ArgList& args)
+JSValuePtr CInstance::invokeMethod(ExecState* exec, const MethodList& methodList, const ArgList& args)
{
// Overloading methods are not allowed by NPObjects. Should only be one
// name match for a particular method.
@@ -78,7 +106,7 @@ JSValue* CInstance::invokeMethod(ExecState* exec, const MethodList& methodList,
CMethod* method = static_cast<CMethod*>(methodList[0]);
- NPIdentifier ident = _NPN_GetStringIdentifier(method->name());
+ NPIdentifier ident = method->identifier();
if (!_object->_class->hasMethod(_object, ident))
return jsUndefined();
@@ -98,13 +126,15 @@ JSValue* CInstance::invokeMethod(ExecState* exec, const MethodList& methodList,
{
JSLock::DropAllLocks dropAllLocks(false);
+ ASSERT(globalExceptionString().isNull());
_object->_class->invoke(_object, ident, cArgs.data(), count, &resultVariant);
+ moveGlobalExceptionToExecState(exec);
}
for (i = 0; i < count; i++)
_NPN_ReleaseVariantValue(&cArgs[i]);
- JSValue* resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get());
+ JSValuePtr resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get());
_NPN_ReleaseVariantValue(&resultVariant);
#ifdef ANDROID_NPN_SETEXCEPTION
MoveGlobalExceptionToExecState(exec);
@@ -113,7 +143,7 @@ JSValue* CInstance::invokeMethod(ExecState* exec, const MethodList& methodList,
}
-JSValue* CInstance::invokeDefaultMethod(ExecState* exec, const ArgList& args)
+JSValuePtr CInstance::invokeDefaultMethod(ExecState* exec, const ArgList& args)
{
if (!_object->_class->invokeDefault)
return jsUndefined();
@@ -133,13 +163,15 @@ JSValue* CInstance::invokeDefaultMethod(ExecState* exec, const ArgList& args)
VOID_TO_NPVARIANT(resultVariant);
{
JSLock::DropAllLocks dropAllLocks(false);
+ ASSERT(globalExceptionString().isNull());
_object->_class->invokeDefault(_object, cArgs.data(), count, &resultVariant);
+ moveGlobalExceptionToExecState(exec);
}
-
+
for (i = 0; i < count; i++)
_NPN_ReleaseVariantValue(&cArgs[i]);
- JSValue* resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get());
+ JSValuePtr resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get());
_NPN_ReleaseVariantValue(&resultVariant);
#ifdef ANDROID_NPN_SETEXCEPTION
MoveGlobalExceptionToExecState(exec);
@@ -152,7 +184,7 @@ bool CInstance::supportsConstruct() const
return _object->_class->construct;
}
-JSValue* CInstance::invokeConstruct(ExecState* exec, const ArgList& args)
+JSValuePtr CInstance::invokeConstruct(ExecState* exec, const ArgList& args)
{
if (!_object->_class->construct)
return jsUndefined();
@@ -169,18 +201,20 @@ JSValue* CInstance::invokeConstruct(ExecState* exec, const ArgList& args)
VOID_TO_NPVARIANT(resultVariant);
{
JSLock::DropAllLocks dropAllLocks(false);
+ ASSERT(globalExceptionString().isNull());
_object->_class->construct(_object, cArgs.data(), count, &resultVariant);
+ moveGlobalExceptionToExecState(exec);
}
-
+
for (i = 0; i < count; i++)
_NPN_ReleaseVariantValue(&cArgs[i]);
- JSValue* resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get());
+ JSValuePtr resultValue = convertNPVariantToValue(exec, &resultVariant, _rootObject.get());
_NPN_ReleaseVariantValue(&resultVariant);
return resultValue;
}
-JSValue* CInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
+JSValuePtr CInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
{
if (hint == PreferString)
return stringValue(exec);
@@ -189,26 +223,26 @@ JSValue* CInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) c
return valueOf(exec);
}
-JSValue* CInstance::stringValue(ExecState* exec) const
+JSValuePtr CInstance::stringValue(ExecState* exec) const
{
char buf[1024];
snprintf(buf, sizeof(buf), "NPObject %p, NPClass %p", _object, _object->_class);
return jsString(exec, buf);
}
-JSValue* CInstance::numberValue(ExecState* exec) const
+JSValuePtr CInstance::numberValue(ExecState* exec) const
{
// FIXME: Implement something sensible.
return jsNumber(exec, 0);
}
-JSValue* CInstance::booleanValue() const
+JSValuePtr CInstance::booleanValue() const
{
// FIXME: Implement something sensible.
return jsBoolean(false);
}
-JSValue* CInstance::valueOf(ExecState* exec) const
+JSValuePtr CInstance::valueOf(ExecState* exec) const
{
return stringValue(exec);
}
@@ -223,7 +257,10 @@ void CInstance::getPropertyNames(ExecState* exec, PropertyNameArray& nameArray)
{
JSLock::DropAllLocks dropAllLocks(false);
- if (!_object->_class->enumerate(_object, &identifiers, &count))
+ ASSERT(globalExceptionString().isNull());
+ bool ok = _object->_class->enumerate(_object, &identifiers, &count);
+ moveGlobalExceptionToExecState(exec);
+ if (!ok)
return;
}
diff --git a/WebCore/bridge/c/c_instance.h b/WebCore/bridge/c/c_instance.h
index 6cc4b8d..ed107e9 100644
--- a/WebCore/bridge/c/c_instance.h
+++ b/WebCore/bridge/c/c_instance.h
@@ -36,6 +36,8 @@ typedef struct NPObject NPObject;
namespace JSC {
+class UString;
+
namespace Bindings {
class CClass;
@@ -46,33 +48,35 @@ public:
{
return adoptRef(new CInstance(object, rootObject));
}
+
+ static void setGlobalException(JSC::UString exception);
+
~CInstance ();
-
+
virtual Class *getClass() const;
- virtual JSValue* valueOf(ExecState*) const;
- virtual JSValue* defaultValue(ExecState*, PreferredPrimitiveType) const;
-
- virtual JSValue* invokeMethod(ExecState*, const MethodList&, const ArgList&);
+ virtual JSValuePtr valueOf(ExecState*) const;
+ virtual JSValuePtr defaultValue(ExecState*, PreferredPrimitiveType) const;
+
+ virtual JSValuePtr invokeMethod(ExecState*, const MethodList&, const ArgList&);
virtual bool supportsInvokeDefaultMethod() const;
- virtual JSValue* invokeDefaultMethod(ExecState*, const ArgList&);
-
+ virtual JSValuePtr invokeDefaultMethod(ExecState*, const ArgList&);
+
virtual bool supportsConstruct() const;
- virtual JSValue* invokeConstruct(ExecState*, const ArgList&);
+ virtual JSValuePtr invokeConstruct(ExecState*, const ArgList&);
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
- JSValue* stringValue(ExecState*) const;
- JSValue* numberValue(ExecState*) const;
- JSValue* booleanValue() const;
-
- NPObject *getObject() const { return _object; }
+ JSValuePtr stringValue(ExecState*) const;
+ JSValuePtr numberValue(ExecState*) const;
+ JSValuePtr booleanValue() const;
- virtual BindingLanguage getBindingLanguage() const { return CLanguage; }
+ NPObject *getObject() const { return _object; }
private:
+ static void moveGlobalExceptionToExecState(ExecState* exec);
CInstance(NPObject*, PassRefPtr<RootObject>);
-
+
mutable CClass *_class;
NPObject *_object;
};
diff --git a/WebCore/bridge/c/c_runtime.cpp b/WebCore/bridge/c/c_runtime.cpp
index 7cf5dc9..56220ee 100644
--- a/WebCore/bridge/c/c_runtime.cpp
+++ b/WebCore/bridge/c/c_runtime.cpp
@@ -73,23 +73,7 @@ void MoveGlobalExceptionToExecState(ExecState* exec)
}
#endif // ANDROID_NPN_SETEXCEPTION
-// ---------------------- CMethod ----------------------
-
-const char* CMethod::name() const
-{
- PrivateIdentifier *i = (PrivateIdentifier *)_methodIdentifier;
- return i->isString ? i->value.string : 0;
-}
-
-// ---------------------- CField ----------------------
-
-const char* CField::name() const
-{
- PrivateIdentifier *i = (PrivateIdentifier *)_fieldIdentifier;
- return i->isString ? i->value.string : 0;
-}
-
-JSValue* CField::valueFromInstance(ExecState* exec, const Instance* inst) const
+JSValuePtr CField::valueFromInstance(ExecState* exec, const Instance* inst) const
{
const CInstance* instance = static_cast<const CInstance*>(inst);
NPObject* obj = instance->getObject();
@@ -109,7 +93,7 @@ JSValue* CField::valueFromInstance(ExecState* exec, const Instance* inst) const
MoveGlobalExceptionToExecState(exec);
#endif // ANDROID_NPN_SETEXCEPTION
if (result) {
- JSValue* result = convertNPVariantToValue(exec, &property, instance->rootObject());
+ JSValuePtr result = convertNPVariantToValue(exec, &property, instance->rootObject());
_NPN_ReleaseVariantValue(&property);
return result;
}
@@ -117,7 +101,7 @@ JSValue* CField::valueFromInstance(ExecState* exec, const Instance* inst) const
return jsUndefined();
}
-void CField::setValueToInstance(ExecState *exec, const Instance *inst, JSValue* aValue) const
+void CField::setValueToInstance(ExecState *exec, const Instance *inst, JSValuePtr aValue) const
{
const CInstance* instance = static_cast<const CInstance*>(inst);
NPObject* obj = instance->getObject();
diff --git a/WebCore/bridge/c/c_runtime.h b/WebCore/bridge/c/c_runtime.h
index 998e6d4..12e3b2e 100644
--- a/WebCore/bridge/c/c_runtime.h
+++ b/WebCore/bridge/c/c_runtime.h
@@ -38,9 +38,10 @@ class CField : public Field {
public:
CField(NPIdentifier ident) : _fieldIdentifier(ident) { }
- virtual JSValue* valueFromInstance(ExecState*, const Instance*) const;
- virtual void setValueToInstance(ExecState*, const Instance*, JSValue*) const;
- virtual const char* name() const;
+ virtual JSValuePtr valueFromInstance(ExecState*, const Instance*) const;
+ virtual void setValueToInstance(ExecState*, const Instance*, JSValuePtr) const;
+
+ NPIdentifier identifier() const { return _fieldIdentifier; }
private:
NPIdentifier _fieldIdentifier;
@@ -52,7 +53,7 @@ class CMethod : public Method
public:
CMethod(NPIdentifier ident) : _methodIdentifier(ident) { }
- virtual const char* name() const;
+ NPIdentifier identifier() const { return _methodIdentifier; }
virtual int numParameters() const { return 0; }
private:
diff --git a/WebCore/bridge/c/c_utility.cpp b/WebCore/bridge/c/c_utility.cpp
index dced048..1f5ff6c 100644
--- a/WebCore/bridge/c/c_utility.cpp
+++ b/WebCore/bridge/c/c_utility.cpp
@@ -66,24 +66,24 @@ static String convertUTF8ToUTF16WithLatin1Fallback(const NPUTF8* UTF8Chars, int
}
// Variant value must be released with NPReleaseVariantValue()
-void convertValueToNPVariant(ExecState* exec, JSValue* value, NPVariant* result)
+void convertValueToNPVariant(ExecState* exec, JSValuePtr value, NPVariant* result)
{
JSLock lock(false);
VOID_TO_NPVARIANT(*result);
- if (value->isString()) {
- UString ustring = value->toString(exec);
+ if (value.isString()) {
+ UString ustring = value.toString(exec);
CString cstring = ustring.UTF8String();
NPString string = { (const NPUTF8*)cstring.c_str(), static_cast<uint32_t>(cstring.size()) };
NPN_InitializeVariantWithStringCopy(result, &string);
- } else if (value->isNumber()) {
- DOUBLE_TO_NPVARIANT(value->toNumber(exec), *result);
- } else if (value->isBoolean()) {
- BOOLEAN_TO_NPVARIANT(value->toBoolean(exec), *result);
- } else if (value->isNull()) {
+ } else if (value.isNumber()) {
+ DOUBLE_TO_NPVARIANT(value.toNumber(exec), *result);
+ } else if (value.isBoolean()) {
+ BOOLEAN_TO_NPVARIANT(value.toBoolean(exec), *result);
+ } else if (value.isNull()) {
NULL_TO_NPVARIANT(*result);
- } else if (value->isObject()) {
+ } else if (value.isObject()) {
JSObject* object = asObject(value);
if (object->classInfo() == &RuntimeObjectImp::s_info) {
RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(object);
@@ -105,7 +105,7 @@ void convertValueToNPVariant(ExecState* exec, JSValue* value, NPVariant* result)
}
}
-JSValue* convertNPVariantToValue(ExecState* exec, const NPVariant* variant, RootObject* rootObject)
+JSValuePtr convertNPVariantToValue(ExecState* exec, const NPVariant* variant, RootObject* rootObject)
{
JSLock lock(false);
@@ -131,7 +131,7 @@ JSValue* convertNPVariantToValue(ExecState* exec, const NPVariant* variant, Root
return ((JavaScriptObject*)obj)->imp;
// Wrap NPObject in a CInstance.
- return Instance::createRuntimeObject(exec, CInstance::create(obj, rootObject));
+ return CInstance::create(obj, rootObject)->createRuntimeObject(exec);
}
return jsUndefined();
diff --git a/WebCore/bridge/c/c_utility.h b/WebCore/bridge/c/c_utility.h
index 1e0dd22..2efc66c 100644
--- a/WebCore/bridge/c/c_utility.h
+++ b/WebCore/bridge/c/c_utility.h
@@ -57,8 +57,8 @@ enum NP_ValueType {
};
WebCore::String convertNPStringToUTF16(const NPString *string);
-void convertValueToNPVariant(ExecState*, JSValue*, NPVariant* result);
-JSValue* convertNPVariantToValue(ExecState*, const NPVariant*, RootObject*);
+void convertValueToNPVariant(ExecState*, JSValuePtr, NPVariant* result);
+JSValuePtr convertNPVariantToValue(ExecState*, const NPVariant*, RootObject*);
Identifier identifierFromNPIdentifier(const NPUTF8* name);
struct PrivateIdentifier {
diff --git a/WebCore/bridge/jni/jni_class.cpp b/WebCore/bridge/jni/jni_class.cpp
index 4140524..87750aa 100644
--- a/WebCore/bridge/jni/jni_class.cpp
+++ b/WebCore/bridge/jni/jni_class.cpp
@@ -29,7 +29,7 @@
#if ENABLE(MAC_JAVA_BRIDGE)
#include "JSDOMWindow.h"
-#include <kjs/identifier.h>
+#include <runtime/Identifier.h>
#include <runtime/JSLock.h>
#include "jni_utility.h"
#include "jni_runtime.h"
@@ -53,17 +53,15 @@ JavaClass::JavaClass(jobject anInstance)
int i;
JNIEnv *env = getJNIEnv();
- JSGlobalData* globalData = WebCore::JSDOMWindow::commonJSGlobalData();
-
// Get the fields
jarray fields = (jarray)callJNIMethod<jobject>(aClass, "getFields", "()[Ljava/lang/reflect/Field;");
int numFields = env->GetArrayLength(fields);
for (i = 0; i < numFields; i++) {
jobject aJField = env->GetObjectArrayElement((jobjectArray)fields, i);
- Field *aField = new JavaField(env, aJField); // deleted in the JavaClass destructor
+ JavaField *aField = new JavaField(env, aJField); // deleted in the JavaClass destructor
{
JSLock lock(false);
- _fields.set(Identifier(globalData, UString(aField->name())).ustring().rep(), aField);
+ _fields.set(aField->name(), aField);
}
env->DeleteLocalRef(aJField);
}
@@ -73,15 +71,15 @@ JavaClass::JavaClass(jobject anInstance)
int numMethods = env->GetArrayLength(methods);
for (i = 0; i < numMethods; i++) {
jobject aJMethod = env->GetObjectArrayElement((jobjectArray)methods, i);
- Method *aMethod = new JavaMethod(env, aJMethod); // deleted in the JavaClass destructor
+ JavaMethod *aMethod = new JavaMethod(env, aJMethod); // deleted in the JavaClass destructor
MethodList* methodList;
{
JSLock lock(false);
- methodList = _methods.get(Identifier(globalData, UString(aMethod->name())).ustring().rep());
+ methodList = _methods.get(aMethod->name());
if (!methodList) {
methodList = new MethodList();
- _methods.set(Identifier(globalData, UString(aMethod->name())).ustring().rep(), methodList);
+ _methods.set(aMethod->name(), methodList);
}
}
methodList->append(aMethod);
diff --git a/WebCore/bridge/jni/jni_class.h b/WebCore/bridge/jni/jni_class.h
index 75cfd89..890b4d3 100644
--- a/WebCore/bridge/jni/jni_class.h
+++ b/WebCore/bridge/jni/jni_class.h
@@ -40,8 +40,6 @@ public:
JavaClass (jobject anInstance);
~JavaClass ();
- virtual const char *name() const { return _name; };
-
virtual MethodList methodsNamed(const Identifier&, Instance* instance) const;
virtual Field *fieldNamed(const Identifier&, Instance* instance) const;
@@ -50,8 +48,6 @@ public:
bool isStringClass() const;
private:
- JavaClass (); // prevent default construction
-
const char *_name;
FieldMap _fields;
MethodListMap _methods;
diff --git a/WebCore/bridge/jni/jni_instance.cpp b/WebCore/bridge/jni/jni_instance.cpp
index 6b23900..5a819a6 100644
--- a/WebCore/bridge/jni/jni_instance.cpp
+++ b/WebCore/bridge/jni/jni_instance.cpp
@@ -84,7 +84,7 @@ Class *JavaInstance::getClass() const
return _class;
}
-JSValue* JavaInstance::stringValue(ExecState* exec) const
+JSValuePtr JavaInstance::stringValue(ExecState* exec) const
{
JSLock lock(false);
@@ -96,23 +96,23 @@ JSValue* JavaInstance::stringValue(ExecState* exec) const
return jsString(exec, u);
}
-JSValue* JavaInstance::numberValue(ExecState* exec) const
+JSValuePtr JavaInstance::numberValue(ExecState* exec) const
{
jdouble doubleValue = callJNIMethod<jdouble>(_instance->_instance, "doubleValue", "()D");
return jsNumber(exec, doubleValue);
}
-JSValue* JavaInstance::booleanValue() const
+JSValuePtr JavaInstance::booleanValue() const
{
jboolean booleanValue = callJNIMethod<jboolean>(_instance->_instance, "booleanValue", "()Z");
return jsBoolean(booleanValue);
}
-JSValue* JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const ArgList &args)
+JSValuePtr JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodList, const ArgList &args)
{
int i, count = args.size();
jvalue *jArgs;
- JSValue* resultValue;
+ JSValuePtr resultValue;
Method *method = 0;
size_t numMethods = methodList.size();
@@ -135,7 +135,7 @@ JSValue* JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodLi
}
const JavaMethod *jMethod = static_cast<const JavaMethod*>(method);
- JS_LOG ("call %s %s on %p\n", method->name(), jMethod->signature(), _instance->_instance);
+ JS_LOG ("call %s %s on %p\n", UString(jMethod->name()).UTF8String().c_str(), jMethod->signature(), _instance->_instance);
if (count > 0) {
jArgs = (jvalue *)malloc (count * sizeof(jvalue));
@@ -146,7 +146,7 @@ JSValue* JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodLi
for (i = 0; i < count; i++) {
JavaParameter* aParameter = jMethod->parameterAt(i);
jArgs[i] = convertValueToJValue(exec, args.at(exec, i), aParameter->getJNIType(), aParameter->type());
- JS_LOG("arg[%d] = %s\n", i, args.at(exec, i)->toString(exec).ascii());
+ JS_LOG("arg[%d] = %s\n", i, args.at(exec, i).toString(exec).ascii());
}
jvalue result;
@@ -161,11 +161,11 @@ JSValue* JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodLi
bool handled = false;
if (rootObject->nativeHandle()) {
jobject obj = _instance->_instance;
- JSValue* exceptionDescription = noValue();
+ JSValuePtr exceptionDescription = noValue();
const char *callingURL = 0; // FIXME, need to propagate calling URL to Java
handled = dispatchJNICall(exec, rootObject->nativeHandle(), obj, jMethod->isStatic(), jMethod->JNIReturnType(), jMethod->methodID(obj), jArgs, result, callingURL, exceptionDescription);
if (exceptionDescription) {
- throwError(exec, GeneralError, exceptionDescription->toString(exec));
+ throwError(exec, GeneralError, exceptionDescription.toString(exec));
free (jArgs);
return jsUndefined();
}
@@ -226,7 +226,7 @@ JSValue* JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodLi
resultValue = JavaArray::convertJObjectToArray(exec, result.l, arrayType, rootObject);
}
else {
- resultValue = Instance::createRuntimeObject(exec, JavaInstance::create(result.l, rootObject));
+ resultValue = JavaInstance::create(result.l, rootObject)->createRuntimeObject(exec);
}
}
else {
@@ -287,7 +287,7 @@ JSValue* JavaInstance::invokeMethod (ExecState *exec, const MethodList &methodLi
return resultValue;
}
-JSValue* JavaInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
+JSValuePtr JavaInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
{
if (hint == PreferString)
return stringValue(exec);
@@ -303,7 +303,7 @@ JSValue* JavaInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint
return valueOf(exec);
}
-JSValue* JavaInstance::valueOf(ExecState* exec) const
+JSValuePtr JavaInstance::valueOf(ExecState* exec) const
{
return stringValue(exec);
}
diff --git a/WebCore/bridge/jni/jni_instance.h b/WebCore/bridge/jni/jni_instance.h
index 7104865..c2e0d9d 100644
--- a/WebCore/bridge/jni/jni_instance.h
+++ b/WebCore/bridge/jni/jni_instance.h
@@ -77,18 +77,16 @@ public:
virtual Class *getClass() const;
- virtual JSValue* valueOf(ExecState*) const;
- virtual JSValue* defaultValue(ExecState*, PreferredPrimitiveType) const;
+ virtual JSValuePtr valueOf(ExecState*) const;
+ virtual JSValuePtr defaultValue(ExecState*, PreferredPrimitiveType) const;
- virtual JSValue* invokeMethod(ExecState* exec, const MethodList& method, const ArgList& args);
+ virtual JSValuePtr invokeMethod(ExecState* exec, const MethodList& method, const ArgList& args);
jobject javaInstance() const { return _instance->_instance; }
- JSValue* stringValue(ExecState*) const;
- JSValue* numberValue(ExecState*) const;
- JSValue* booleanValue() const;
-
- virtual BindingLanguage getBindingLanguage() const { return JavaLanguage; }
+ JSValuePtr stringValue(ExecState*) const;
+ JSValuePtr numberValue(ExecState*) const;
+ JSValuePtr booleanValue() const;
protected:
virtual void virtualBegin();
diff --git a/WebCore/bridge/jni/jni_jsobject.h b/WebCore/bridge/jni/jni_jsobject.h
index 812317d..4125565 100644
--- a/WebCore/bridge/jni/jni_jsobject.h
+++ b/WebCore/bridge/jni/jni_jsobject.h
@@ -90,8 +90,8 @@ public:
static jvalue invoke(JSObjectCallContext*);
- jobject convertValueToJObject(JSValue*) const;
- JSValue* convertJObjectToValue(ExecState*, jobject) const;
+ jobject convertValueToJObject(JSValuePtr) const;
+ JSValuePtr convertJObjectToValue(ExecState*, jobject) const;
void getListFromJArray(ExecState*, jobjectArray, ArgList&) const;
RootObject* rootObject() const;
diff --git a/WebCore/bridge/jni/jni_jsobject.mm b/WebCore/bridge/jni/jni_jsobject.mm
index 042d1ed..301d672 100644
--- a/WebCore/bridge/jni/jni_jsobject.mm
+++ b/WebCore/bridge/jni/jni_jsobject.mm
@@ -35,13 +35,13 @@
#include "ScriptController.h"
#include "runtime_object.h"
#include "runtime_root.h"
-#include <runtime/ExecState.h>
+#include <interpreter/CallFrame.h>
#include <runtime/JSGlobalObject.h>
#include <runtime/JSLock.h>
-#include <kjs/completion.h>
-#include <kjs/interpreter.h>
+#include <runtime/Completion.h>
+#include <runtime/Completion.h>
#include <wtf/Assertions.h>
-#include <kjs/SourceProvider.h>
+#include <parser/SourceProvider.h>
using WebCore::Frame;
@@ -293,9 +293,9 @@ jobject JavaJSObject::call(jstring methodName, jobjectArray args) const
JSLock lock(false);
Identifier identifier(exec, JavaString(methodName));
- JSValue* function = _imp->get(exec, identifier);
+ JSValuePtr function = _imp->get(exec, identifier);
CallData callData;
- CallType callType = function->getCallData(callData);
+ CallType callType = function.getCallData(callData);
if (callType == CallTypeNone)
return 0;
@@ -303,7 +303,7 @@ jobject JavaJSObject::call(jstring methodName, jobjectArray args) const
ArgList argList;
getListFromJArray(exec, args, argList);
rootObject->globalObject()->startTimeoutCheck();
- JSValue* result = JSC::call(exec, function, callType, callData, _imp, argList);
+ JSValuePtr result = JSC::call(exec, function, callType, callData, _imp, argList);
rootObject->globalObject()->stopTimeoutCheck();
return convertValueToJObject(result);
@@ -313,7 +313,7 @@ jobject JavaJSObject::eval(jstring script) const
{
JS_LOG ("script = %s\n", JavaString(script).UTF8String());
- JSValue* result;
+ JSValuePtr result;
JSLock lock(false);
@@ -322,7 +322,7 @@ jobject JavaJSObject::eval(jstring script) const
return 0;
rootObject->globalObject()->startTimeoutCheck();
- Completion completion = Interpreter::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(JavaString(script)));
+ Completion completion = JSC::evaluate(rootObject->globalObject()->globalExec(), rootObject->globalObject()->globalScopeChain(), makeSource(JavaString(script)));
rootObject->globalObject()->stopTimeoutCheck();
ComplType type = completion.complType();
@@ -347,7 +347,7 @@ jobject JavaJSObject::getMember(jstring memberName) const
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock(false);
- JSValue* result = _imp->get(exec, Identifier(exec, JavaString(memberName)));
+ JSValuePtr result = _imp->get(exec, Identifier(exec, JavaString(memberName)));
return convertValueToJObject(result);
}
@@ -397,7 +397,7 @@ jobject JavaJSObject::getSlot(jint index) const
ExecState* exec = rootObject->globalObject()->globalExec();
JSLock lock(false);
- JSValue* result = _imp->get(exec, index);
+ JSValuePtr result = _imp->get(exec, index);
return convertValueToJObject(result);
}
@@ -485,7 +485,7 @@ jlong JavaJSObject::createNative(jlong nativeHandle)
return nativeHandle;
}
-jobject JavaJSObject::convertValueToJObject(JSValue* value) const
+jobject JavaJSObject::convertValueToJObject(JSValuePtr value) const
{
JSLock lock(false);
@@ -505,28 +505,28 @@ jobject JavaJSObject::convertValueToJObject(JSValue* value) const
// Java instance -> Java instance
// Everything else -> JavaJSObject
- if (value->isNumber()) {
+ if (value.isNumber()) {
jclass JSObjectClass = env->FindClass ("java/lang/Double");
jmethodID constructorID = env->GetMethodID (JSObjectClass, "<init>", "(D)V");
if (constructorID != NULL) {
- result = env->NewObject (JSObjectClass, constructorID, (jdouble)value->toNumber(exec));
+ result = env->NewObject (JSObjectClass, constructorID, (jdouble)value.toNumber(exec));
}
- } else if (value->isString()) {
- UString stringValue = value->toString(exec);
+ } else if (value.isString()) {
+ UString stringValue = value.toString(exec);
JNIEnv *env = getJNIEnv();
result = env->NewString ((const jchar *)stringValue.data(), stringValue.size());
- } else if (value->isBoolean()) {
+ } else if (value.isBoolean()) {
jclass JSObjectClass = env->FindClass ("java/lang/Boolean");
jmethodID constructorID = env->GetMethodID (JSObjectClass, "<init>", "(Z)V");
if (constructorID != NULL) {
- result = env->NewObject (JSObjectClass, constructorID, (jboolean)value->toBoolean(exec));
+ result = env->NewObject (JSObjectClass, constructorID, (jboolean)value.toBoolean(exec));
}
}
else {
// Create a JavaJSObject.
jlong nativeHandle;
- if (value->isObject()) {
+ if (value.isObject()) {
JSObject* imp = asObject(value);
// We either have a wrapper around a Java instance or a JavaScript
@@ -571,7 +571,7 @@ jobject JavaJSObject::convertValueToJObject(JSValue* value) const
return result;
}
-JSValue* JavaJSObject::convertJObjectToValue(ExecState* exec, jobject theObject) const
+JSValuePtr JavaJSObject::convertJObjectToValue(ExecState* exec, jobject theObject) const
{
// Instances of netscape.javascript.JSObject get converted back to
// JavaScript objects. All other objects are wrapped. It's not
@@ -602,7 +602,7 @@ JSValue* JavaJSObject::convertJObjectToValue(ExecState* exec, jobject theObject)
JSLock lock(false);
- return JSC::Bindings::Instance::createRuntimeObject(exec, JavaInstance::create(theObject, _rootObject));
+ return JavaInstance::create(theObject, _rootObject)->createRuntimeObject(exec);
}
void JavaJSObject::getListFromJArray(ExecState* exec, jobjectArray jArray, ArgList& list) const
diff --git a/WebCore/bridge/jni/jni_objc.mm b/WebCore/bridge/jni/jni_objc.mm
index 45ee9f5..232d9e9 100644
--- a/WebCore/bridge/jni/jni_objc.mm
+++ b/WebCore/bridge/jni/jni_objc.mm
@@ -45,7 +45,7 @@ using namespace JSC::Bindings;
exceptionDescription:(NSString **)exceptionString;
@end
-bool JSC::Bindings::dispatchJNICall(ExecState* exec, const void* targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue* args, jvalue &result, const char*, JSValue*& exceptionDescription)
+bool JSC::Bindings::dispatchJNICall(ExecState* exec, const void* targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue* args, jvalue &result, const char*, JSValuePtr& exceptionDescription)
{
id view = (id)targetAppletView;
diff --git a/WebCore/bridge/jni/jni_runtime.cpp b/WebCore/bridge/jni/jni_runtime.cpp
index 3a9b950..932e56c 100644
--- a/WebCore/bridge/jni/jni_runtime.cpp
+++ b/WebCore/bridge/jni/jni_runtime.cpp
@@ -70,7 +70,7 @@ JavaField::JavaField (JNIEnv *env, jobject aField)
_field = new JObjectWrapper(aField);
}
-JSValue* JavaArray::convertJObjectToArray(ExecState* exec, jobject anObject, const char* type, PassRefPtr<RootObject> rootObject)
+JSValuePtr JavaArray::convertJObjectToArray(ExecState* exec, jobject anObject, const char* type, PassRefPtr<RootObject> rootObject)
{
if (type[0] != '[')
return jsUndefined();
@@ -93,24 +93,24 @@ jvalue JavaField::dispatchValueFromInstance(ExecState *exec, const JavaInstance
{
RootObject* rootObject = instance->rootObject();
if (rootObject && rootObject->nativeHandle()) {
- JSValue* exceptionDescription = noValue();
+ JSValuePtr exceptionDescription = noValue();
jvalue args[1];
args[0].l = jinstance;
dispatchJNICall(exec, rootObject->nativeHandle(), fieldJInstance, false, returnType, mid, args, result, 0, exceptionDescription);
if (exceptionDescription)
- throwError(exec, GeneralError, exceptionDescription->toString(exec));
+ throwError(exec, GeneralError, exceptionDescription.toString(exec));
}
}
}
return result;
}
-JSValue* JavaField::valueFromInstance(ExecState* exec, const Instance* i) const
+JSValuePtr JavaField::valueFromInstance(ExecState* exec, const Instance* i) const
{
const JavaInstance *instance = static_cast<const JavaInstance *>(i);
- JSValue* jsresult = jsUndefined();
+ JSValuePtr jsresult = jsUndefined();
switch (_JNIType) {
case array_type:
@@ -123,7 +123,7 @@ JSValue* JavaField::valueFromInstance(ExecState* exec, const Instance* i) const
jsresult = JavaArray::convertJObjectToArray(exec, anObject, arrayType, instance->rootObject());
}
else if (anObject != 0){
- jsresult = Instance::createRuntimeObject(exec, JavaInstance::create(anObject, instance->rootObject()));
+ jsresult = JavaInstance::create(anObject, instance->rootObject())->createRuntimeObject(exec);
}
}
break;
@@ -157,7 +157,7 @@ JSValue* JavaField::valueFromInstance(ExecState* exec, const Instance* i) const
break;
}
- JS_LOG ("getting %s = %s\n", name(), jsresult->toString(exec).ascii());
+ JS_LOG ("getting %s = %s\n", UString(name()).UTF8String().c_str(), jsresult.toString(exec).ascii());
return jsresult;
}
@@ -175,7 +175,7 @@ void JavaField::dispatchSetValueToInstance(ExecState *exec, const JavaInstance *
{
RootObject* rootObject = instance->rootObject();
if (rootObject && rootObject->nativeHandle()) {
- JSValue* exceptionDescription = noValue();
+ JSValuePtr exceptionDescription = noValue();
jvalue args[2];
jvalue result;
@@ -183,18 +183,18 @@ void JavaField::dispatchSetValueToInstance(ExecState *exec, const JavaInstance *
args[1] = javaValue;
dispatchJNICall(exec, rootObject->nativeHandle(), fieldJInstance, false, void_type, mid, args, result, 0, exceptionDescription);
if (exceptionDescription)
- throwError(exec, GeneralError, exceptionDescription->toString(exec));
+ throwError(exec, GeneralError, exceptionDescription.toString(exec));
}
}
}
}
-void JavaField::setValueToInstance(ExecState* exec, const Instance* i, JSValue* aValue) const
+void JavaField::setValueToInstance(ExecState* exec, const Instance* i, JSValuePtr aValue) const
{
const JavaInstance *instance = static_cast<const JavaInstance *>(i);
jvalue javaValue = convertValueToJValue (exec, aValue, _JNIType, type());
- JS_LOG ("setting value %s to %s\n", name(), aValue->toString(exec).ascii());
+ JS_LOG ("setting value %s to %s\n", UString(name()).UTF8String().c_str(), aValue.toString(exec).ascii());
switch (_JNIType) {
case array_type:
@@ -359,7 +359,7 @@ JNIType JavaMethod::JNIReturnType() const
jmethodID JavaMethod::methodID (jobject obj) const
{
if (_methodID == 0) {
- _methodID = getMethodID (obj, name(), signature());
+ _methodID = getMethodID (obj, _name.UTF8String(), signature());
}
return _methodID;
}
@@ -386,7 +386,7 @@ RootObject* JavaArray::rootObject() const
return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0;
}
-void JavaArray::setValueAt(ExecState* exec, unsigned index, JSValue* aValue) const
+void JavaArray::setValueAt(ExecState* exec, unsigned index, JSValuePtr aValue) const
{
JNIEnv *env = getJNIEnv();
char *javaClassName = 0;
@@ -454,7 +454,7 @@ void JavaArray::setValueAt(ExecState* exec, unsigned index, JSValue* aValue) con
}
-JSValue* JavaArray::valueAt(ExecState* exec, unsigned index) const
+JSValuePtr JavaArray::valueAt(ExecState* exec, unsigned index) const
{
JNIEnv *env = getJNIEnv();
JNIType arrayType = JNITypeFromPrimitiveType(_type[1]);
@@ -474,7 +474,7 @@ JSValue* JavaArray::valueAt(ExecState* exec, unsigned index) const
return JavaArray::convertJObjectToArray(exec, anObject, _type+1, rootObject());
}
// or array of other object type?
- return Instance::createRuntimeObject(exec, JavaInstance::create(anObject, rootObject()));
+ return JavaInstance::create(anObject, rootObject())->createRuntimeObject(exec);
}
case boolean_type: {
diff --git a/WebCore/bridge/jni/jni_runtime.h b/WebCore/bridge/jni/jni_runtime.h
index 67bc06e..3697f2b 100644
--- a/WebCore/bridge/jni/jni_runtime.h
+++ b/WebCore/bridge/jni/jni_runtime.h
@@ -56,7 +56,7 @@ public:
const jchar *uc = getUCharactersFromJStringInEnv (e, s);
{
JSLock lock(false);
- _rep = UString((UChar *)uc,_size).rep();
+ _rep = UString(reinterpret_cast<const UChar*>(uc), _size).rep();
}
releaseUCharactersForJStringInEnv (e, s, uc);
}
@@ -112,10 +112,10 @@ class JavaField : public Field
public:
JavaField (JNIEnv *env, jobject aField);
- virtual JSValue* valueFromInstance(ExecState *exec, const Instance *instance) const;
- virtual void setValueToInstance(ExecState *exec, const Instance *instance, JSValue* aValue) const;
+ virtual JSValuePtr valueFromInstance(ExecState *exec, const Instance *instance) const;
+ virtual void setValueToInstance(ExecState *exec, const Instance *instance, JSValuePtr aValue) const;
- virtual const char *name() const { return _name.UTF8String(); }
+ UString::Rep* name() const { return ((UString)_name).rep(); }
virtual RuntimeType type() const { return _type.UTF8String(); }
JNIType getJNIType() const { return _JNIType; }
@@ -137,7 +137,7 @@ public:
JavaMethod(JNIEnv* env, jobject aMethod);
~JavaMethod();
- virtual const char *name() const { return _name.UTF8String(); };
+ UString::Rep* name() const { return ((UString)_name).rep(); }
RuntimeType returnType() const { return _returnType.UTF8String(); };
JavaParameter* parameterAt(int i) const { return &_parameters[i]; };
int numParameters() const { return _numParameters; };
@@ -168,13 +168,13 @@ public:
RootObject* rootObject() const;
- virtual void setValueAt(ExecState *exec, unsigned int index, JSValue* aValue) const;
- virtual JSValue* valueAt(ExecState *exec, unsigned int index) const;
+ virtual void setValueAt(ExecState *exec, unsigned int index, JSValuePtr aValue) const;
+ virtual JSValuePtr valueAt(ExecState *exec, unsigned int index) const;
virtual unsigned int getLength() const;
jobject javaArray() const { return _array->_instance; }
- static JSValue* convertJObjectToArray (ExecState* exec, jobject anObject, const char* type, PassRefPtr<RootObject>);
+ static JSValuePtr convertJObjectToArray (ExecState* exec, jobject anObject, const char* type, PassRefPtr<RootObject>);
private:
RefPtr<JObjectWrapper> _array;
diff --git a/WebCore/bridge/jni/jni_utility.cpp b/WebCore/bridge/jni/jni_utility.cpp
index 0fe7174..5dc4722 100644
--- a/WebCore/bridge/jni/jni_utility.cpp
+++ b/WebCore/bridge/jni/jni_utility.cpp
@@ -365,8 +365,8 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
env->FindClass("java/lang/String"),
env->NewStringUTF(""));
for(unsigned i = 0; i < length; i++) {
- JSValue* item = jsArray->get(exec, i);
- UString stringValue = item->toString(exec);
+ JSValuePtr item = jsArray->get(exec, i);
+ UString stringValue = item.toString(exec);
env->SetObjectArrayElement(jarray,i,
env->functions->NewString(env, (const jchar *)stringValue.data(), stringValue.size()));
}
@@ -377,8 +377,8 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
case boolean_type: {
jarray = (jobjectArray)env->NewBooleanArray(length);
for(unsigned i = 0; i < length; i++) {
- JSValue* item = jsArray->get(exec, i);
- jboolean value = (jboolean)item->toNumber(exec);
+ JSValuePtr item = jsArray->get(exec, i);
+ jboolean value = (jboolean)item.toNumber(exec);
env->SetBooleanArrayRegion((jbooleanArray)jarray, (jsize)i, (jsize)1, &value);
}
break;
@@ -387,8 +387,8 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
case byte_type: {
jarray = (jobjectArray)env->NewByteArray(length);
for(unsigned i = 0; i < length; i++) {
- JSValue* item = jsArray->get(exec, i);
- jbyte value = (jbyte)item->toNumber(exec);
+ JSValuePtr item = jsArray->get(exec, i);
+ jbyte value = (jbyte)item.toNumber(exec);
env->SetByteArrayRegion((jbyteArray)jarray, (jsize)i, (jsize)1, &value);
}
break;
@@ -397,8 +397,8 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
case char_type: {
jarray = (jobjectArray)env->NewCharArray(length);
for(unsigned i = 0; i < length; i++) {
- JSValue* item = jsArray->get(exec, i);
- UString stringValue = item->toString(exec);
+ JSValuePtr item = jsArray->get(exec, i);
+ UString stringValue = item.toString(exec);
jchar value = 0;
if (stringValue.size() > 0)
value = ((const jchar*)stringValue.data())[0];
@@ -410,8 +410,8 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
case short_type: {
jarray = (jobjectArray)env->NewShortArray(length);
for(unsigned i = 0; i < length; i++) {
- JSValue* item = jsArray->get(exec, i);
- jshort value = (jshort)item->toNumber(exec);
+ JSValuePtr item = jsArray->get(exec, i);
+ jshort value = (jshort)item.toNumber(exec);
env->SetShortArrayRegion((jshortArray)jarray, (jsize)i, (jsize)1, &value);
}
break;
@@ -420,8 +420,8 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
case int_type: {
jarray = (jobjectArray)env->NewIntArray(length);
for(unsigned i = 0; i < length; i++) {
- JSValue* item = jsArray->get(exec, i);
- jint value = (jint)item->toNumber(exec);
+ JSValuePtr item = jsArray->get(exec, i);
+ jint value = (jint)item.toNumber(exec);
env->SetIntArrayRegion((jintArray)jarray, (jsize)i, (jsize)1, &value);
}
break;
@@ -430,8 +430,8 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
case long_type: {
jarray = (jobjectArray)env->NewLongArray(length);
for(unsigned i = 0; i < length; i++) {
- JSValue* item = jsArray->get(exec, i);
- jlong value = (jlong)item->toNumber(exec);
+ JSValuePtr item = jsArray->get(exec, i);
+ jlong value = (jlong)item.toNumber(exec);
env->SetLongArrayRegion((jlongArray)jarray, (jsize)i, (jsize)1, &value);
}
break;
@@ -440,8 +440,8 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
case float_type: {
jarray = (jobjectArray)env->NewFloatArray(length);
for(unsigned i = 0; i < length; i++) {
- JSValue* item = jsArray->get(exec, i);
- jfloat value = (jfloat)item->toNumber(exec);
+ JSValuePtr item = jsArray->get(exec, i);
+ jfloat value = (jfloat)item.toNumber(exec);
env->SetFloatArrayRegion((jfloatArray)jarray, (jsize)i, (jsize)1, &value);
}
break;
@@ -450,8 +450,8 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
case double_type: {
jarray = (jobjectArray)env->NewDoubleArray(length);
for(unsigned i = 0; i < length; i++) {
- JSValue* item = jsArray->get(exec, i);
- jdouble value = (jdouble)item->toNumber(exec);
+ JSValuePtr item = jsArray->get(exec, i);
+ jdouble value = (jdouble)item.toNumber(exec);
env->SetDoubleArrayRegion((jdoubleArray)jarray, (jsize)i, (jsize)1, &value);
}
break;
@@ -468,7 +468,7 @@ static jobject convertArrayInstanceToJavaArray(ExecState* exec, JSArray* jsArray
}
-jvalue convertValueToJValue(ExecState* exec, JSValue* value, JNIType _JNIType, const char* javaClassName)
+jvalue convertValueToJValue(ExecState* exec, JSValuePtr value, JNIType _JNIType, const char* javaClassName)
{
JSLock lock(false);
@@ -480,7 +480,7 @@ jvalue convertValueToJValue(ExecState* exec, JSValue* value, JNIType _JNIType, c
result.l = (jobject)0;
// First see if we have a Java instance.
- if (value->isObject()){
+ if (value.isObject()){
JSObject* objectImp = asObject(value);
if (objectImp->classInfo() == &RuntimeObjectImp::s_info) {
RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(objectImp);
@@ -512,10 +512,10 @@ jvalue convertValueToJValue(ExecState* exec, JSValue* value, JNIType _JNIType, c
}
else
#else
- if (!value->isNull())
+ if (!value.isNull())
#endif
{
- UString stringValue = value->toString(exec);
+ UString stringValue = value.toString(exec);
JNIEnv *env = getJNIEnv();
jobject javaString = env->functions->NewString (env, (const jchar *)stringValue.data(), stringValue.size());
result.l = javaString;
@@ -526,42 +526,42 @@ jvalue convertValueToJValue(ExecState* exec, JSValue* value, JNIType _JNIType, c
break;
case boolean_type: {
- result.z = (jboolean)value->toNumber(exec);
+ result.z = (jboolean)value.toNumber(exec);
}
break;
case byte_type: {
- result.b = (jbyte)value->toNumber(exec);
+ result.b = (jbyte)value.toNumber(exec);
}
break;
case char_type: {
- result.c = (jchar)value->toNumber(exec);
+ result.c = (jchar)value.toNumber(exec);
}
break;
case short_type: {
- result.s = (jshort)value->toNumber(exec);
+ result.s = (jshort)value.toNumber(exec);
}
break;
case int_type: {
- result.i = (jint)value->toNumber(exec);
+ result.i = (jint)value.toNumber(exec);
}
break;
case long_type: {
- result.j = (jlong)value->toNumber(exec);
+ result.j = (jlong)value.toNumber(exec);
}
break;
case float_type: {
- result.f = (jfloat)value->toNumber(exec);
+ result.f = (jfloat)value.toNumber(exec);
}
break;
case double_type: {
- result.d = (jdouble)value->toNumber(exec);
+ result.d = (jdouble)value.toNumber(exec);
}
break;
diff --git a/WebCore/bridge/jni/jni_utility.h b/WebCore/bridge/jni/jni_utility.h
index b30c654..a08cc5d 100644
--- a/WebCore/bridge/jni/jni_utility.h
+++ b/WebCore/bridge/jni/jni_utility.h
@@ -72,7 +72,7 @@ JNIType JNITypeFromClassName(const char *name);
JNIType JNITypeFromPrimitiveType(char type);
const char *signatureFromPrimitiveType(JNIType type);
-jvalue convertValueToJValue(ExecState*, JSValue*, JNIType, const char* javaClassName);
+jvalue convertValueToJValue(ExecState*, JSValuePtr, JNIType, const char* javaClassName);
jvalue getJNIField(jobject obj, JNIType type, const char *name, const char *signature);
@@ -277,7 +277,7 @@ T callJNIStaticMethod(jclass cls, const char* methodName, const char* methodSign
return result;
}
-bool dispatchJNICall(ExecState*, const void* targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue* args, jvalue& result, const char* callingURL, JSValue*& exceptionDescription);
+bool dispatchJNICall(ExecState*, const void* targetAppletView, jobject obj, bool isStatic, JNIType returnType, jmethodID methodID, jvalue* args, jvalue& result, const char* callingURL, JSValuePtr& exceptionDescription);
} // namespace Bindings
diff --git a/WebCore/bridge/npapi.h b/WebCore/bridge/npapi.h
index 84d266b..e098fe0 100644
--- a/WebCore/bridge/npapi.h
+++ b/WebCore/bridge/npapi.h
@@ -429,7 +429,7 @@ typedef enum {
#endif
NPDrawingModelCoreGraphics = 1,
NPDrawingModelOpenGL = 2,
- NPDrawingModelCoreAnimation
+ NPDrawingModelCoreAnimation = 3
} NPDrawingModel;
/*
diff --git a/WebCore/bridge/npruntime.cpp b/WebCore/bridge/npruntime.cpp
index bef3676..bb31c6e 100644
--- a/WebCore/bridge/npruntime.cpp
+++ b/WebCore/bridge/npruntime.cpp
@@ -32,7 +32,7 @@
#include "npruntime_priv.h"
#include "c_utility.h"
-#include <kjs/identifier.h>
+#include <runtime/Identifier.h>
#include <runtime/JSLock.h>
#include <wtf/Assertions.h>
#include <wtf/HashMap.h>
@@ -71,6 +71,8 @@ NPIdentifier _NPN_GetStringIdentifier(const NPUTF8* name)
identifier = getStringIdentifierMap()->get(identifierFromNPIdentifier(name).ustring().rep());
if (identifier == 0) {
identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier));
+ if (!identifier)
+ CRASH();
// We never release identifier names, so this dictionary will grow, as will
// the memory for the identifier name strings.
identifier->isString = true;
@@ -104,6 +106,8 @@ NPIdentifier _NPN_GetIntIdentifier(int32_t intid)
identifier = negativeOneAndZeroIdentifiers[intid + 1];
if (!identifier) {
identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier));
+ if (!identifier)
+ CRASH();
identifier->isString = false;
identifier->value.number = intid;
@@ -113,6 +117,8 @@ NPIdentifier _NPN_GetIntIdentifier(int32_t intid)
identifier = getIntIdentifierMap()->get(intid);
if (!identifier) {
identifier = (PrivateIdentifier*)malloc(sizeof(PrivateIdentifier));
+ if (!identifier)
+ CRASH();
// We never release identifier names, so this dictionary will grow.
identifier->isString = false;
identifier->value.number = intid;
@@ -151,6 +157,8 @@ void NPN_InitializeVariantWithStringCopy(NPVariant* variant, const NPString* val
variant->type = NPVariantType_String;
variant->value.stringValue.UTF8Length = value->UTF8Length;
variant->value.stringValue.UTF8Characters = (NPUTF8 *)malloc(sizeof(NPUTF8) * value->UTF8Length);
+ if (!variant->value.stringValue.UTF8Characters)
+ CRASH();
memcpy((void*)variant->value.stringValue.UTF8Characters, value->UTF8Characters, sizeof(NPUTF8) * value->UTF8Length);
}
@@ -180,7 +188,8 @@ NPObject *_NPN_CreateObject(NPP npp, NPClass* aClass)
obj = aClass->allocate(npp, aClass);
else
obj = (NPObject*)malloc(sizeof(NPObject));
-
+ if (!obj)
+ CRASH();
obj->_class = aClass;
obj->referenceCount = 1;
diff --git a/WebCore/bridge/objc/WebScriptObject.h b/WebCore/bridge/objc/WebScriptObject.h
index 357d42a..7942635 100644
--- a/WebCore/bridge/objc/WebScriptObject.h
+++ b/WebCore/bridge/objc/WebScriptObject.h
@@ -34,7 +34,7 @@
+ (NSString *)webScriptNameForKey:(const char *)name;
+ (BOOL)isKeyExcludedFromWebScript:(const char *)name;
-+ (id)_convertValueToObjcValue:(JSC::JSValue*)value originRootObject:(JSC::Bindings::RootObject*)originRootObject rootObject:(JSC::Bindings::RootObject*)rootObject;
++ (id)_convertValueToObjcValue:(JSC::JSValuePtr)value originRootObject:(JSC::Bindings::RootObject*)originRootObject rootObject:(JSC::Bindings::RootObject*)rootObject;
- _initWithJSObject:(JSC::JSObject*)imp originRootObject:(PassRefPtr<JSC::Bindings::RootObject>)originRootObject rootObject:(PassRefPtr<JSC::Bindings::RootObject>)rootObject;
- (JSC::JSObject *)_imp;
@end
diff --git a/WebCore/bridge/objc/objc_class.h b/WebCore/bridge/objc/objc_class.h
index d96c604..3735680 100644
--- a/WebCore/bridge/objc/objc_class.h
+++ b/WebCore/bridge/objc/objc_class.h
@@ -40,12 +40,10 @@ public:
// Return the cached ObjC of the specified name.
static ObjcClass *classForIsA(ClassStructPtr);
- virtual const char *name() const;
-
virtual MethodList methodsNamed(const Identifier&, Instance *instance) const;
virtual Field *fieldNamed(const Identifier&, Instance *instance) const;
- virtual JSValue* fallbackObject(ExecState *exec, Instance *instance, const Identifier &propertyName);
+ virtual JSValuePtr fallbackObject(ExecState *exec, Instance *instance, const Identifier &propertyName);
ClassStructPtr isa() { return _isa; }
diff --git a/WebCore/bridge/objc/objc_class.mm b/WebCore/bridge/objc/objc_class.mm
index 79991c2..e3bde0a 100644
--- a/WebCore/bridge/objc/objc_class.mm
+++ b/WebCore/bridge/objc/objc_class.mm
@@ -73,11 +73,6 @@ ObjcClass* ObjcClass::classForIsA(ClassStructPtr isa)
return aClass;
}
-const char* ObjcClass::name() const
-{
- return object_getClassName(_isa);
-}
-
MethodList ObjcClass::methodsNamed(const Identifier& identifier, Instance*) const
{
MethodList methodList;
@@ -133,7 +128,7 @@ MethodList ObjcClass::methodsNamed(const Identifier& identifier, Instance*) cons
mappedName = [thisClass webScriptNameForSelector:objcMethodSelector];
if ((mappedName && [mappedName isEqual:(NSString*)methodName.get()]) || strcmp(objcMethodSelectorName, buffer) == 0) {
- Method* aMethod = new ObjcMethod(thisClass, objcMethodSelectorName); // deleted when the dictionary is destroyed
+ Method* aMethod = new ObjcMethod(thisClass, objcMethodSelector); // deleted when the dictionary is destroyed
CFDictionaryAddValue(_methods.get(), methodName.get(), aMethod);
methodList.append(aMethod);
break;
@@ -244,7 +239,7 @@ Field* ObjcClass::fieldNamed(const Identifier& identifier, Instance* instance) c
return aField;
}
-JSValue* ObjcClass::fallbackObject(ExecState* exec, Instance* instance, const Identifier &propertyName)
+JSValuePtr ObjcClass::fallbackObject(ExecState* exec, Instance* instance, const Identifier &propertyName)
{
ObjcInstance* objcInstance = static_cast<ObjcInstance*>(instance);
id targetObject = objcInstance->getObject();
diff --git a/WebCore/bridge/objc/objc_instance.h b/WebCore/bridge/objc/objc_instance.h
index dc7a362..1b7e184 100644
--- a/WebCore/bridge/objc/objc_instance.h
+++ b/WebCore/bridge/objc/objc_instance.h
@@ -48,25 +48,21 @@ public:
virtual Class *getClass() const;
- virtual JSValue* valueOf(ExecState*) const;
- virtual JSValue* defaultValue(ExecState*, PreferredPrimitiveType) const;
+ virtual JSValuePtr valueOf(ExecState*) const;
+ virtual JSValuePtr defaultValue(ExecState*, PreferredPrimitiveType) const;
- virtual JSValue* invokeMethod(ExecState*, const MethodList&, const ArgList&);
+ virtual JSValuePtr invokeMethod(ExecState*, const MethodList&, const ArgList&);
virtual bool supportsInvokeDefaultMethod() const;
- virtual JSValue* invokeDefaultMethod(ExecState*, const ArgList&);
+ virtual JSValuePtr invokeDefaultMethod(ExecState*, const ArgList&);
- virtual bool supportsSetValueOfUndefinedField();
- virtual void setValueOfUndefinedField(ExecState*, const Identifier&, JSValue*);
-
- virtual JSValue* getValueOfUndefinedField(ExecState*, const Identifier& property) const;
+ JSValuePtr getValueOfUndefinedField(ExecState*, const Identifier&) const;
+ virtual bool setValueOfUndefinedField(ExecState*, const Identifier&, JSValuePtr);
ObjectStructPtr getObject() const { return _instance.get(); }
- JSValue* stringValue(ExecState*) const;
- JSValue* numberValue(ExecState*) const;
- JSValue* booleanValue() const;
-
- virtual BindingLanguage getBindingLanguage() const { return ObjectiveCLanguage; }
+ JSValuePtr stringValue(ExecState*) const;
+ JSValuePtr numberValue(ExecState*) const;
+ JSValuePtr booleanValue() const;
protected:
virtual void virtualBegin();
diff --git a/WebCore/bridge/objc/objc_instance.mm b/WebCore/bridge/objc/objc_instance.mm
index 6a714b9..54af18c 100644
--- a/WebCore/bridge/objc/objc_instance.mm
+++ b/WebCore/bridge/objc/objc_instance.mm
@@ -124,9 +124,9 @@ bool ObjcInstance::supportsInvokeDefaultMethod() const
return [_instance.get() respondsToSelector:@selector(invokeDefaultMethodWithArguments:)];
}
-JSValue* ObjcInstance::invokeMethod(ExecState* exec, const MethodList &methodList, const ArgList &args)
+JSValuePtr ObjcInstance::invokeMethod(ExecState* exec, const MethodList &methodList, const ArgList &args)
{
- JSValue* result = jsUndefined();
+ JSValuePtr result = jsUndefined();
JSLock::DropAllLocks dropAllLocks(false); // Can't put this inside the @try scope because it unwinds incorrectly.
@@ -141,11 +141,7 @@ JSValue* ObjcInstance::invokeMethod(ExecState* exec, const MethodList &methodLis
method = static_cast<ObjcMethod*>(methodList[0]);
NSMethodSignature* signature = method->getMethodSignature();
NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:signature];
-#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
- [invocation setSelector:sel_registerName(method->name())];
-#else
- [invocation setSelector:(SEL)method->name()];
-#endif
+ [invocation setSelector:method->selector()];
[invocation setTarget:_instance.get()];
if (method->isFallbackMethod()) {
@@ -246,12 +242,12 @@ JSValue* ObjcInstance::invokeMethod(ExecState* exec, const MethodList &methodLis
// Work around problem in some versions of GCC where result gets marked volatile and
// it can't handle copying from a volatile to non-volatile.
- return const_cast<JSValue*&>(result);
+ return const_cast<JSValuePtr&>(result);
}
-JSValue* ObjcInstance::invokeDefaultMethod(ExecState* exec, const ArgList &args)
+JSValuePtr ObjcInstance::invokeDefaultMethod(ExecState* exec, const ArgList &args)
{
- JSValue* result = jsUndefined();
+ JSValuePtr result = jsUndefined();
JSLock::DropAllLocks dropAllLocks(false); // Can't put this inside the @try scope because it unwinds incorrectly.
setGlobalException(nil);
@@ -297,20 +293,14 @@ JSValue* ObjcInstance::invokeDefaultMethod(ExecState* exec, const ArgList &args)
// Work around problem in some versions of GCC where result gets marked volatile and
// it can't handle copying from a volatile to non-volatile.
- return const_cast<JSValue*&>(result);
+ return const_cast<JSValuePtr&>(result);
}
-bool ObjcInstance::supportsSetValueOfUndefinedField()
-{
- id targetObject = getObject();
- if ([targetObject respondsToSelector:@selector(setValue:forUndefinedKey:)])
- return true;
- return false;
-}
-
-void ObjcInstance::setValueOfUndefinedField(ExecState* exec, const Identifier &property, JSValue* aValue)
+bool ObjcInstance::setValueOfUndefinedField(ExecState* exec, const Identifier& property, JSValuePtr aValue)
{
id targetObject = getObject();
+ if (![targetObject respondsToSelector:@selector(setValue:forUndefinedKey:)])
+ return false;
JSLock::DropAllLocks dropAllLocks(false); // Can't put this inside the @try scope because it unwinds incorrectly.
@@ -330,11 +320,13 @@ void ObjcInstance::setValueOfUndefinedField(ExecState* exec, const Identifier &p
moveGlobalExceptionToExecState(exec);
}
+
+ return true;
}
-JSValue* ObjcInstance::getValueOfUndefinedField(ExecState* exec, const Identifier& property) const
+JSValuePtr ObjcInstance::getValueOfUndefinedField(ExecState* exec, const Identifier& property) const
{
- JSValue* result = jsUndefined();
+ JSValuePtr result = jsUndefined();
id targetObject = getObject();
@@ -358,10 +350,10 @@ JSValue* ObjcInstance::getValueOfUndefinedField(ExecState* exec, const Identifie
// Work around problem in some versions of GCC where result gets marked volatile and
// it can't handle copying from a volatile to non-volatile.
- return const_cast<JSValue*&>(result);
+ return const_cast<JSValuePtr&>(result);
}
-JSValue* ObjcInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
+JSValuePtr ObjcInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
{
if (hint == PreferString)
return stringValue(exec);
@@ -374,24 +366,24 @@ JSValue* ObjcInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint
return valueOf(exec);
}
-JSValue* ObjcInstance::stringValue(ExecState* exec) const
+JSValuePtr ObjcInstance::stringValue(ExecState* exec) const
{
return convertNSStringToString(exec, [getObject() description]);
}
-JSValue* ObjcInstance::numberValue(ExecState* exec) const
+JSValuePtr ObjcInstance::numberValue(ExecState* exec) const
{
// FIXME: Implement something sensible
return jsNumber(exec, 0);
}
-JSValue* ObjcInstance::booleanValue() const
+JSValuePtr ObjcInstance::booleanValue() const
{
// FIXME: Implement something sensible
return jsBoolean(false);
}
-JSValue* ObjcInstance::valueOf(ExecState* exec) const
+JSValuePtr ObjcInstance::valueOf(ExecState* exec) const
{
return stringValue(exec);
}
diff --git a/WebCore/bridge/objc/objc_runtime.h b/WebCore/bridge/objc/objc_runtime.h
index 5f0d8e2..5ed6d2a 100644
--- a/WebCore/bridge/objc/objc_runtime.h
+++ b/WebCore/bridge/objc/objc_runtime.h
@@ -44,11 +44,9 @@ public:
ObjcField(IvarStructPtr);
ObjcField(CFStringRef name);
- virtual JSValue* valueFromInstance(ExecState*, const Instance*) const;
- virtual void setValueToInstance(ExecState*, const Instance*, JSValue*) const;
-
- virtual const char *name() const;
-
+ virtual JSValuePtr valueFromInstance(ExecState*, const Instance*) const;
+ virtual void setValueToInstance(ExecState*, const Instance*, JSValuePtr) const;
+
private:
IvarStructPtr _ivar;
RetainPtr<CFStringRef> _name;
@@ -57,21 +55,21 @@ private:
class ObjcMethod : public Method {
public:
ObjcMethod() : _objcClass(0), _selector(0), _javaScriptName(0) {}
- ObjcMethod(ClassStructPtr aClass, const char *_selector);
-
- virtual const char *name() const;
+ ObjcMethod(ClassStructPtr aClass, SEL _selector);
virtual int numParameters() const;
NSMethodSignature *getMethodSignature() const;
- bool isFallbackMethod() const { return strcmp(_selector, "invokeUndefinedMethodFromWebScript:withArguments:") == 0; }
+ bool isFallbackMethod() const { return _selector == @selector(invokeUndefinedMethodFromWebScript:withArguments:); }
void setJavaScriptName(CFStringRef n) { _javaScriptName = n; }
CFStringRef javaScriptName() const { return _javaScriptName.get(); }
+ SEL selector() const { return _selector; }
+
private:
ClassStructPtr _objcClass;
- const char *_selector;
+ SEL _selector;
RetainPtr<CFStringRef> _javaScriptName;
};
@@ -79,13 +77,13 @@ class ObjcArray : public Array {
public:
ObjcArray(ObjectStructPtr, PassRefPtr<RootObject>);
- virtual void setValueAt(ExecState *exec, unsigned int index, JSValue* aValue) const;
- virtual JSValue* valueAt(ExecState *exec, unsigned int index) const;
+ virtual void setValueAt(ExecState *exec, unsigned int index, JSValuePtr aValue) const;
+ virtual JSValuePtr valueAt(ExecState *exec, unsigned int index) const;
virtual unsigned int getLength() const;
ObjectStructPtr getObjcArray() const { return _array.get(); }
- static JSValue* convertObjcArrayToArray(ExecState *exec, ObjectStructPtr anObject);
+ static JSValuePtr convertObjcArrayToArray(ExecState *exec, ObjectStructPtr anObject);
private:
RetainPtr<ObjectStructPtr> _array;
@@ -104,17 +102,17 @@ public:
return exec->lexicalGlobalObject()->objectPrototype();
}
- static PassRefPtr<StructureID> createStructureID(JSValue* prototype)
+ static PassRefPtr<Structure> createStructure(JSValuePtr prototype)
{
- return StructureID::create(prototype, TypeInfo(ObjectType));
+ return Structure::create(prototype, TypeInfo(ObjectType));
}
private:
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
- virtual void put(ExecState*, const Identifier& propertyName, JSValue*, PutPropertySlot&);
+ virtual void put(ExecState*, const Identifier& propertyName, JSValuePtr, PutPropertySlot&);
virtual CallType getCallData(CallData&);
virtual bool deleteProperty(ExecState*, const Identifier& propertyName);
- virtual JSValue* defaultValue(ExecState*, PreferredPrimitiveType) const;
+ virtual JSValuePtr defaultValue(ExecState*, PreferredPrimitiveType) const;
virtual bool toBoolean(ExecState*) const;
diff --git a/WebCore/bridge/objc/objc_runtime.mm b/WebCore/bridge/objc/objc_runtime.mm
index e6729a8..61ec6ed 100644
--- a/WebCore/bridge/objc/objc_runtime.mm
+++ b/WebCore/bridge/objc/objc_runtime.mm
@@ -56,16 +56,10 @@ ClassStructPtr webUndefinedClass()
// ---------------------- ObjcMethod ----------------------
-ObjcMethod::ObjcMethod(ClassStructPtr aClass, const char* name)
+ObjcMethod::ObjcMethod(ClassStructPtr aClass, SEL selector)
+ : _objcClass(aClass)
+ , _selector(selector)
{
- _objcClass = aClass;
- _selector = name; // Assume ObjC runtime keeps these around forever.
- _javaScriptName = 0;
-}
-
-const char* ObjcMethod::name() const
-{
- return _selector;
}
int ObjcMethod::numParameters() const
@@ -75,50 +69,37 @@ int ObjcMethod::numParameters() const
NSMethodSignature* ObjcMethod::getMethodSignature() const
{
-#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
- return [_objcClass instanceMethodSignatureForSelector:sel_registerName(_selector)];
-#else
- return [_objcClass instanceMethodSignatureForSelector:(SEL)_selector];
-#endif
+ return [_objcClass instanceMethodSignatureForSelector:_selector];
}
// ---------------------- ObjcField ----------------------
ObjcField::ObjcField(Ivar ivar)
+ : _ivar(ivar)
+#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
+ , _name(AdoptCF, CFStringCreateWithCString(0, ivar_getName(_ivar), kCFStringEncodingASCII))
+#else
+ , _name(AdoptCF, CFStringCreateWithCString(0, _ivar->ivar_name, kCFStringEncodingASCII))
+#endif
{
- _ivar = ivar; // Assume ObjectiveC runtime will keep this alive forever
- _name = 0;
-}
-
-ObjcField::ObjcField(CFStringRef name)
-{
- _ivar = 0;
- _name = (CFStringRef)CFRetain(name);
}
-const char* ObjcField::name() const
+ObjcField::ObjcField(CFStringRef name)
+ : _ivar(0)
+ , _name(name)
{
-#if defined(OBJC_API_VERSION) && OBJC_API_VERSION >= 2
- if (_ivar)
- return ivar_getName(_ivar);
-#else
- if (_ivar)
- return _ivar->ivar_name;
-#endif
- return [(NSString*)_name.get() UTF8String];
}
-JSValue* ObjcField::valueFromInstance(ExecState* exec, const Instance* instance) const
+JSValuePtr ObjcField::valueFromInstance(ExecState* exec, const Instance* instance) const
{
- JSValue* result = jsUndefined();
+ JSValuePtr result = jsUndefined();
id targetObject = (static_cast<const ObjcInstance*>(instance))->getObject();
JSLock::DropAllLocks dropAllLocks(false); // Can't put this inside the @try scope because it unwinds incorrectly.
@try {
- NSString* key = [NSString stringWithCString:name() encoding:NSASCIIStringEncoding];
- if (id objcValue = [targetObject valueForKey:key])
+ if (id objcValue = [targetObject valueForKey:(NSString *)_name.get()])
result = convertObjcValueToValue(exec, &objcValue, ObjcObjectType, instance->rootObject());
} @catch(NSException* localException) {
JSLock::lock(false);
@@ -128,10 +109,10 @@ JSValue* ObjcField::valueFromInstance(ExecState* exec, const Instance* instance)
// Work around problem in some versions of GCC where result gets marked volatile and
// it can't handle copying from a volatile to non-volatile.
- return const_cast<JSValue*&>(result);
+ return const_cast<JSValuePtr&>(result);
}
-static id convertValueToObjcObject(ExecState* exec, JSValue* value)
+static id convertValueToObjcObject(ExecState* exec, JSValuePtr value)
{
RefPtr<RootObject> rootObject = findRootObject(exec->dynamicGlobalObject());
if (!rootObject)
@@ -139,7 +120,7 @@ static id convertValueToObjcObject(ExecState* exec, JSValue* value)
return [webScriptObjectClass() _convertValueToObjcValue:value originRootObject:rootObject.get() rootObject:rootObject.get()];
}
-void ObjcField::setValueToInstance(ExecState* exec, const Instance* instance, JSValue* aValue) const
+void ObjcField::setValueToInstance(ExecState* exec, const Instance* instance, JSValuePtr aValue) const
{
id targetObject = (static_cast<const ObjcInstance*>(instance))->getObject();
id value = convertValueToObjcObject(exec, aValue);
@@ -147,8 +128,7 @@ void ObjcField::setValueToInstance(ExecState* exec, const Instance* instance, JS
JSLock::DropAllLocks dropAllLocks(false); // Can't put this inside the @try scope because it unwinds incorrectly.
@try {
- NSString* key = [NSString stringWithCString:name() encoding:NSASCIIStringEncoding];
- [targetObject setValue:value forKey:key];
+ [targetObject setValue:value forKey:(NSString *)_name.get()];
} @catch(NSException* localException) {
JSLock::lock(false);
throwError(exec, GeneralError, [localException reason]);
@@ -164,7 +144,7 @@ ObjcArray::ObjcArray(ObjectStructPtr a, PassRefPtr<RootObject> rootObject)
{
}
-void ObjcArray::setValueAt(ExecState* exec, unsigned int index, JSValue* aValue) const
+void ObjcArray::setValueAt(ExecState* exec, unsigned int index, JSValuePtr aValue) const
{
if (![_array.get() respondsToSelector:@selector(insertObject:atIndex:)]) {
throwError(exec, TypeError, "Array is not mutable.");
@@ -187,7 +167,7 @@ void ObjcArray::setValueAt(ExecState* exec, unsigned int index, JSValue* aValue)
}
}
-JSValue* ObjcArray::valueAt(ExecState* exec, unsigned int index) const
+JSValuePtr ObjcArray::valueAt(ExecState* exec, unsigned int index) const
{
if (index > [_array.get() count])
return throwError(exec, RangeError, "Index exceeds array size.");
@@ -222,16 +202,16 @@ bool ObjcFallbackObjectImp::getOwnPropertySlot(ExecState*, const Identifier&, Pr
return true;
}
-void ObjcFallbackObjectImp::put(ExecState*, const Identifier&, JSValue*, PutPropertySlot&)
+void ObjcFallbackObjectImp::put(ExecState*, const Identifier&, JSValuePtr, PutPropertySlot&)
{
}
-static JSValue* callObjCFallbackObject(ExecState* exec, JSObject* function, JSValue* thisValue, const ArgList& args)
+static JSValuePtr callObjCFallbackObject(ExecState* exec, JSObject* function, JSValuePtr thisValue, const ArgList& args)
{
- if (!thisValue->isObject(&RuntimeObjectImp::s_info))
+ if (!thisValue.isObject(&RuntimeObjectImp::s_info))
return throwError(exec, TypeError);
- JSValue* result = jsUndefined();
+ JSValuePtr result = jsUndefined();
RuntimeObjectImp* imp = static_cast<RuntimeObjectImp*>(asObject(thisValue));
Instance* instance = imp->getInternalInstance();
@@ -246,7 +226,7 @@ static JSValue* callObjCFallbackObject(ExecState* exec, JSObject* function, JSVa
if ([targetObject respondsToSelector:@selector(invokeUndefinedMethodFromWebScript:withArguments:)]){
ObjcClass* objcClass = static_cast<ObjcClass*>(instance->getClass());
- OwnPtr<ObjcMethod> fallbackMethod(new ObjcMethod(objcClass->isa(), sel_getName(@selector(invokeUndefinedMethodFromWebScript:withArguments:))));
+ OwnPtr<ObjcMethod> fallbackMethod(new ObjcMethod(objcClass->isa(), @selector(invokeUndefinedMethodFromWebScript:withArguments:)));
const Identifier& nameIdentifier = static_cast<ObjcFallbackObjectImp*>(function)->propertyName();
RetainPtr<CFStringRef> name(AdoptCF, CFStringCreateWithCharacters(0, nameIdentifier.data(), nameIdentifier.size()));
fallbackMethod->setJavaScriptName(name.get());
@@ -274,7 +254,7 @@ bool ObjcFallbackObjectImp::deleteProperty(ExecState*, const Identifier&)
return false;
}
-JSValue* ObjcFallbackObjectImp::defaultValue(ExecState* exec, PreferredPrimitiveType) const
+JSValuePtr ObjcFallbackObjectImp::defaultValue(ExecState* exec, PreferredPrimitiveType) const
{
return _instance->getValueOfUndefinedField(exec, _item);
}
diff --git a/WebCore/bridge/objc/objc_utility.h b/WebCore/bridge/objc/objc_utility.h
index 304b0a2..35787ea 100644
--- a/WebCore/bridge/objc/objc_utility.h
+++ b/WebCore/bridge/objc/objc_utility.h
@@ -73,9 +73,9 @@ typedef enum {
class RootObject;
-ObjcValue convertValueToObjcValue(ExecState*, JSValue*, ObjcValueType);
-JSValue* convertNSStringToString(ExecState* exec, NSString *nsstring);
-JSValue* convertObjcValueToValue(ExecState*, void* buffer, ObjcValueType, RootObject*);
+ObjcValue convertValueToObjcValue(ExecState*, JSValuePtr, ObjcValueType);
+JSValuePtr convertNSStringToString(ExecState* exec, NSString *nsstring);
+JSValuePtr convertObjcValueToValue(ExecState*, void* buffer, ObjcValueType, RootObject*);
ObjcValueType objcValueTypeForType(const char *type);
bool convertJSMethodNameToObjc(const char *JSName, char *buffer, size_t bufferSize);
diff --git a/WebCore/bridge/objc/objc_utility.mm b/WebCore/bridge/objc/objc_utility.mm
index daab4fe..dbf8c56 100644
--- a/WebCore/bridge/objc/objc_utility.mm
+++ b/WebCore/bridge/objc/objc_utility.mm
@@ -126,13 +126,13 @@ bool convertJSMethodNameToObjc(const char *JSName, char *buffer, size_t bufferSi
[], other exception
*/
-ObjcValue convertValueToObjcValue(ExecState* exec, JSValue* value, ObjcValueType type)
+ObjcValue convertValueToObjcValue(ExecState* exec, JSValuePtr value, ObjcValueType type)
{
ObjcValue result;
double d = 0;
- if (value->isNumber() || value->isString() || value->isBoolean())
- d = value->toNumber(exec);
+ if (value.isNumber() || value.isString() || value.isBoolean())
+ d = value.toNumber(exec);
switch (type) {
case ObjcObjectType: {
@@ -142,7 +142,7 @@ ObjcValue convertValueToObjcValue(ExecState* exec, JSValue* value, ObjcValueType
RootObject* originRootObject = findRootObject(originGlobalObject);
JSGlobalObject* globalObject = 0;
- if (value->isObject() && asObject(value)->isGlobalObject())
+ if (value.isObject() && asObject(value)->isGlobalObject())
globalObject = static_cast<JSGlobalObject*>(asObject(value));
if (!globalObject)
@@ -194,7 +194,7 @@ ObjcValue convertValueToObjcValue(ExecState* exec, JSValue* value, ObjcValueType
return result;
}
-JSValue* convertNSStringToString(ExecState* exec, NSString *nsstring)
+JSValuePtr convertNSStringToString(ExecState* exec, NSString *nsstring)
{
JSLock lock(false);
@@ -203,7 +203,7 @@ JSValue* convertNSStringToString(ExecState* exec, NSString *nsstring)
chars = (unichar *)malloc(sizeof(unichar)*length);
[nsstring getCharacters:chars];
UString u((const UChar*)chars, length);
- JSValue* aValue = jsString(exec, u);
+ JSValuePtr aValue = jsString(exec, u);
free((void *)chars);
return aValue;
}
@@ -226,7 +226,7 @@ JSValue* convertNSStringToString(ExecState* exec, NSString *nsstring)
id object wrapper
other should not happen
*/
-JSValue* convertObjcValueToValue(ExecState* exec, void* buffer, ObjcValueType type, RootObject* rootObject)
+JSValuePtr convertObjcValueToValue(ExecState* exec, void* buffer, ObjcValueType type, RootObject* rootObject)
{
JSLock lock(false);
@@ -253,7 +253,7 @@ JSValue* convertObjcValueToValue(ExecState* exec, void* buffer, ObjcValueType ty
return jsNull();
if (obj == 0)
return jsUndefined();
- return Instance::createRuntimeObject(exec, ObjcInstance::create(obj, rootObject));
+ return ObjcInstance::create(obj, rootObject)->createRuntimeObject(exec);
}
case ObjcCharType:
return jsNumber(exec, *(char*)buffer);
diff --git a/WebCore/bridge/qt/qt_class.cpp b/WebCore/bridge/qt/qt_class.cpp
index 3fe3f89..3aa218c 100644
--- a/WebCore/bridge/qt/qt_class.cpp
+++ b/WebCore/bridge/qt/qt_class.cpp
@@ -18,7 +18,7 @@
*/
#include "config.h"
-#include "identifier.h"
+#include "Identifier.h"
#include "qt_class.h"
#include "qt_instance.h"
@@ -66,7 +66,7 @@ const char* QtClass::name() const
// and not get wrapped in RuntimeMethod). Also, use this for methods,
// so we can cache the object and return the same object for the same
// identifier.
-JSValue* QtClass::fallbackObject(ExecState* exec, Instance* inst, const Identifier& identifier)
+JSValuePtr QtClass::fallbackObject(ExecState* exec, Instance* inst, const Identifier& identifier)
{
QtInstance* qtinst = static_cast<QtInstance*>(inst);
diff --git a/WebCore/bridge/qt/qt_class.h b/WebCore/bridge/qt/qt_class.h
index 449648d..c83bb0f 100644
--- a/WebCore/bridge/qt/qt_class.h
+++ b/WebCore/bridge/qt/qt_class.h
@@ -45,7 +45,7 @@ public:
virtual MethodList methodsNamed(const Identifier&, Instance*) const;
virtual Field* fieldNamed(const Identifier&, Instance*) const;
- virtual JSValue* fallbackObject(ExecState*, Instance*, const Identifier&);
+ virtual JSValuePtr fallbackObject(ExecState*, Instance*, const Identifier&);
private:
QtClass(const QtClass&); // prohibit copying
diff --git a/WebCore/bridge/qt/qt_instance.cpp b/WebCore/bridge/qt/qt_instance.cpp
index c15dbe3..0848463 100644
--- a/WebCore/bridge/qt/qt_instance.cpp
+++ b/WebCore/bridge/qt/qt_instance.cpp
@@ -49,22 +49,30 @@ static InstanceJSObjectMap cachedObjects;
// Derived RuntimeObject
class QtRuntimeObjectImp : public RuntimeObjectImp {
- public:
- QtRuntimeObjectImp(ExecState*, PassRefPtr<Instance>);
- ~QtRuntimeObjectImp();
- virtual void invalidate();
-
- virtual void mark() {
- QtInstance* instance = static_cast<QtInstance*>(getInternalInstance());
- if (instance)
- instance->mark();
- RuntimeObjectImp::mark();
- }
+public:
+ QtRuntimeObjectImp(ExecState*, PassRefPtr<Instance>);
+ ~QtRuntimeObjectImp();
+ virtual void invalidate();
+
+ static const ClassInfo s_info;
+
+ virtual void mark()
+ {
+ QtInstance* instance = static_cast<QtInstance*>(getInternalInstance());
+ if (instance)
+ instance->mark();
+ RuntimeObjectImp::mark();
+ }
- protected:
- void removeFromCache();
+protected:
+ void removeFromCache();
+
+private:
+ virtual const ClassInfo* classInfo() const { return &s_info; }
};
+const ClassInfo QtRuntimeObjectImp::s_info = { "QtRuntimeObject", &RuntimeObjectImp::s_info, 0, 0 };
+
QtRuntimeObjectImp::QtRuntimeObjectImp(ExecState* exec, PassRefPtr<Instance> instance)
: RuntimeObjectImp(exec, WebCore::getDOMStructure<QtRuntimeObjectImp>(exec), instance)
{
@@ -130,17 +138,23 @@ PassRefPtr<QtInstance> QtInstance::getQtInstance(QObject* o, PassRefPtr<RootObje
return ret.release();
}
-RuntimeObjectImp* QtInstance::getRuntimeObject(ExecState* exec, PassRefPtr<QtInstance> instance)
+bool QtInstance::getOwnPropertySlot(JSObject* object, ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
{
- JSLock lock(false);
- QtInstance* qtInstance = instance.get();
- RuntimeObjectImp* ret = static_cast<RuntimeObjectImp*>(cachedObjects.value(qtInstance));
- if (!ret) {
- ret = new (exec) QtRuntimeObjectImp(exec, instance);
- cachedObjects.insert(qtInstance, ret);
- ret = static_cast<RuntimeObjectImp*>(cachedObjects.value(qtInstance));
- }
- return ret;
+ return object->JSObject::getOwnPropertySlot(exec, propertyName, slot);
+}
+
+void QtInstance::put(JSObject* object, ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot)
+{
+ object->JSObject::put(exec, propertyName, value, slot);
+}
+
+QtInstance* QtInstance::getInstance(JSObject* object)
+{
+ if (!object)
+ return 0;
+ if (!object->inherits(&QtRuntimeObjectImp::s_info))
+ return 0;
+ return static_cast<QtInstance*>(static_cast<RuntimeObjectImp*>(object)->getInternalInstance());
}
Class* QtInstance::getClass() const
@@ -150,6 +164,18 @@ Class* QtInstance::getClass() const
return m_class;
}
+RuntimeObjectImp* QtInstance::createRuntimeObject(ExecState* exec)
+{
+ JSLock lock(false);
+ RuntimeObjectImp* ret = static_cast<RuntimeObjectImp*>(cachedObjects.value(this));
+ if (!ret) {
+ ret = new (exec) QtRuntimeObjectImp(exec, this);
+ cachedObjects.insert(this, ret);
+ ret = static_cast<RuntimeObjectImp*>(cachedObjects.value(this));
+ }
+ return ret;
+}
+
void QtInstance::mark()
{
if (m_defaultMethod)
@@ -158,9 +184,9 @@ void QtInstance::mark()
if (val && !val->marked())
val->mark();
}
- foreach(JSValue* val, m_children.values()) {
- if (val && !val->marked())
- val->mark();
+ foreach(JSValuePtr val, m_children.values()) {
+ if (val && !val.marked())
+ val.mark();
}
}
@@ -206,14 +232,14 @@ void QtInstance::getPropertyNames(ExecState* exec, PropertyNameArray& array)
}
}
-JSValue* QtInstance::invokeMethod(ExecState*, const MethodList&, const ArgList&)
+JSValuePtr QtInstance::invokeMethod(ExecState*, const MethodList&, const ArgList&)
{
// Implemented via fallbackMethod & QtRuntimeMetaMethod::callAsFunction
return jsUndefined();
}
-JSValue* QtInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
+JSValuePtr QtInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
{
if (hint == PreferString)
return stringValue(exec);
@@ -222,7 +248,7 @@ JSValue* QtInstance::defaultValue(ExecState* exec, PreferredPrimitiveType hint)
return valueOf(exec);
}
-JSValue* QtInstance::stringValue(ExecState* exec) const
+JSValuePtr QtInstance::stringValue(ExecState* exec) const
{
// Hmm.. see if there is a toString defined
QByteArray buf;
@@ -266,25 +292,25 @@ JSValue* QtInstance::stringValue(ExecState* exec) const
return jsString(exec, buf.constData());
}
-JSValue* QtInstance::numberValue(ExecState* exec) const
+JSValuePtr QtInstance::numberValue(ExecState* exec) const
{
return jsNumber(exec, 0);
}
-JSValue* QtInstance::booleanValue() const
+JSValuePtr QtInstance::booleanValue() const
{
// ECMA 9.2
return jsBoolean(true);
}
-JSValue* QtInstance::valueOf(ExecState* exec) const
+JSValuePtr QtInstance::valueOf(ExecState* exec) const
{
return stringValue(exec);
}
// In qt_runtime.cpp
-JSValue* convertQVariantToValue(ExecState*, PassRefPtr<RootObject> root, const QVariant& variant);
-QVariant convertValueToQVariant(ExecState*, JSValue*, QMetaType::Type hint, int *distance);
+JSValuePtr convertQVariantToValue(ExecState*, PassRefPtr<RootObject> root, const QVariant& variant);
+QVariant convertValueToQVariant(ExecState*, JSValuePtr, QMetaType::Type hint, int *distance);
const char* QtField::name() const
{
@@ -297,7 +323,7 @@ const char* QtField::name() const
return ""; // deleted child object
}
-JSValue* QtField::valueFromInstance(ExecState* exec, const Instance* inst) const
+JSValuePtr QtField::valueFromInstance(ExecState* exec, const Instance* inst) const
{
const QtInstance* instance = static_cast<const QtInstance*>(inst);
QObject* obj = instance->getObject();
@@ -314,7 +340,7 @@ JSValue* QtField::valueFromInstance(ExecState* exec, const Instance* inst) const
else if (m_type == DynamicProperty)
val = obj->property(m_dynamicProperty);
- JSValue* ret = convertQVariantToValue(exec, inst->rootObject(), val);
+ JSValuePtr ret = convertQVariantToValue(exec, inst->rootObject(), val);
// Need to save children so we can mark them
if (m_type == ChildObject)
@@ -327,7 +353,7 @@ JSValue* QtField::valueFromInstance(ExecState* exec, const Instance* inst) const
}
}
-void QtField::setValueToInstance(ExecState* exec, const Instance* inst, JSValue* aValue) const
+void QtField::setValueToInstance(ExecState* exec, const Instance* inst, JSValuePtr aValue) const
{
if (m_type == ChildObject) // QtScript doesn't allow setting to a named child
return;
diff --git a/WebCore/bridge/qt/qt_instance.h b/WebCore/bridge/qt/qt_instance.h
index d70e362..4cfaff8 100644
--- a/WebCore/bridge/qt/qt_instance.h
+++ b/WebCore/bridge/qt/qt_instance.h
@@ -39,29 +39,32 @@ public:
~QtInstance();
virtual Class* getClass() const;
+ virtual RuntimeObjectImp* createRuntimeObject(ExecState*);
virtual void begin();
virtual void end();
- virtual JSValue* valueOf(ExecState*) const;
- virtual JSValue* defaultValue(ExecState*, PreferredPrimitiveType) const;
+ virtual JSValuePtr valueOf(ExecState*) const;
+ virtual JSValuePtr defaultValue(ExecState*, PreferredPrimitiveType) const;
virtual void mark(); // This isn't inherited
- virtual JSValue* invokeMethod(ExecState*, const MethodList&, const ArgList&);
+ virtual JSValuePtr invokeMethod(ExecState*, const MethodList&, const ArgList&);
virtual void getPropertyNames(ExecState*, PropertyNameArray&);
- virtual BindingLanguage getBindingLanguage() const { return QtLanguage; }
-
- JSValue* stringValue(ExecState* exec) const;
- JSValue* numberValue(ExecState* exec) const;
- JSValue* booleanValue() const;
+ JSValuePtr stringValue(ExecState* exec) const;
+ JSValuePtr numberValue(ExecState* exec) const;
+ JSValuePtr booleanValue() const;
QObject* getObject() const { return m_object; }
static PassRefPtr<QtInstance> getQtInstance(QObject*, PassRefPtr<RootObject>);
- static RuntimeObjectImp* getRuntimeObject(ExecState* exec, PassRefPtr<QtInstance>);
+
+ virtual bool getOwnPropertySlot(JSObject*, ExecState*, const Identifier&, PropertySlot&);
+ virtual void put(JSObject*, ExecState*, const Identifier&, JSValuePtr, PutPropertySlot&);
+
+ static QtInstance* getInstance(JSObject*);
private:
static PassRefPtr<QtInstance> create(QObject *instance, PassRefPtr<RootObject> rootObject)
@@ -77,7 +80,7 @@ private:
QObject* m_hashkey;
mutable QHash<QByteArray, JSObject*> m_methods;
mutable QHash<QString, QtField*> m_fields;
- mutable QSet<JSValue*> m_children;
+ mutable QSet<JSValuePtr> m_children;
mutable QtRuntimeMetaMethod* m_defaultMethod;
};
diff --git a/WebCore/bridge/qt/qt_runtime.cpp b/WebCore/bridge/qt/qt_runtime.cpp
index d9a2c59..282de42 100644
--- a/WebCore/bridge/qt/qt_runtime.cpp
+++ b/WebCore/bridge/qt/qt_runtime.cpp
@@ -46,6 +46,7 @@
#include <runtime.h>
#include <runtime_array.h>
#include <runtime_object.h>
+#include "BooleanObject.h"
// QtScript has these
Q_DECLARE_METATYPE(QObjectList);
@@ -109,18 +110,18 @@ QDebug operator<<(QDebug dbg, const JSRealType &c)
}
#endif
-static JSRealType valueRealType(ExecState* exec, JSValue* val)
+static JSRealType valueRealType(ExecState* exec, JSValuePtr val)
{
- if (val->isNumber())
+ if (val.isNumber())
return Number;
- else if (val->isString())
+ else if (val.isString())
return String;
- else if (val->isBoolean())
+ else if (val.isBoolean())
return Boolean;
- else if (val->isNull())
+ else if (val.isNull())
return Null;
- else if (val->isObject()) {
- JSObject *object = val->toObject(exec);
+ else if (val.isObject()) {
+ 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))
@@ -137,11 +138,11 @@ static JSRealType valueRealType(ExecState* exec, JSValue* val)
return String; // I don't know.
}
-QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type hint, int *distance, HashSet<JSObject*>* visitedObjects)
+QVariant convertValueToQVariant(ExecState* exec, JSValuePtr value, QMetaType::Type hint, int *distance, HashSet<JSObject*>* visitedObjects)
{
JSObject* object = 0;
- if (value->isObject()) {
- object = value->toObject(exec);
+ if (value.isObject()) {
+ object = value.toObject(exec);
if (visitedObjects->contains(object))
return QVariant();
@@ -149,7 +150,10 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
}
// check magic pointer values before dereferencing value
- if (value == jsNaN(exec) || value == jsUndefined()) {
+ if (value == jsNaN(exec)
+ || (value == jsUndefined()
+ && hint != QMetaType::QString
+ && hint != (QMetaType::Type) qMetaTypeId<QVariant>())) {
if (distance)
*distance = -1;
return QVariant();
@@ -176,7 +180,12 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
hint = QMetaType::QRegExp;
break;
case Object:
- hint = QMetaType::QVariantMap;
+ if (object->inherits(&NumberObject::info))
+ hint = QMetaType::Double;
+ else if (object->inherits(&BooleanObject::info))
+ hint = QMetaType::Bool;
+ else
+ hint = QMetaType::QVariantMap;
break;
case QObj:
hint = QMetaType::QObjectStar;
@@ -192,7 +201,9 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
if (value == jsNull()
&& hint != QMetaType::QObjectStar
- && hint != QMetaType::VoidStar) {
+ && hint != QMetaType::VoidStar
+ && hint != QMetaType::QString
+ && hint != (QMetaType::Type) qMetaTypeId<QVariant>()) {
if (distance)
*distance = -1;
return QVariant();
@@ -202,7 +213,10 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
int dist = -1;
switch (hint) {
case QMetaType::Bool:
- ret = QVariant(value->toBoolean(exec));
+ if (type == Object && object->inherits(&BooleanObject::info))
+ ret = QVariant(asBooleanObject(value)->internalValue().toBoolean(exec));
+ else
+ ret = QVariant(value.toBoolean(exec));
if (type == Boolean)
dist = 0;
else
@@ -219,7 +233,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
case QMetaType::UShort:
case QMetaType::Float:
case QMetaType::Double:
- ret = QVariant(value->toNumber(exec));
+ ret = QVariant(value.toNumber(exec));
ret.convert((QVariant::Type)hint);
if (type == Number) {
switch (hint) {
@@ -257,13 +271,13 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
case QMetaType::QChar:
if (type == Number || type == Boolean) {
- ret = QVariant(QChar((ushort)value->toNumber(exec)));
+ ret = QVariant(QChar((ushort)value.toNumber(exec)));
if (type == Boolean)
dist = 3;
else
dist = 6;
} else {
- UString str = value->toString(exec);
+ UString str = value.toString(exec);
ret = QVariant(QChar(str.size() ? *(const ushort*)str.rep()->data() : 0));
if (type == String)
dist = 3;
@@ -273,12 +287,18 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
break;
case QMetaType::QString: {
- UString ustring = value->toString(exec);
- ret = QVariant(QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()));
- if (type == String)
- dist = 0;
- else
- dist = 10;
+ if (value.isUndefinedOrNull()) {
+ if (distance)
+ *distance = 1;
+ return QString();
+ } else {
+ UString ustring = value.toString(exec);
+ ret = QVariant(QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()));
+ if (type == String)
+ dist = 0;
+ else
+ dist = 10;
+ }
break;
}
@@ -293,7 +313,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
int objdist = 0;
while(it != properties.end()) {
if (object->propertyIsEnumerable(exec, *it)) {
- JSValue* val = object->get(exec, *it);
+ JSValuePtr val = object->get(exec, *it);
QVariant v = convertValueToQVariant(exec, val, QMetaType::Void, &objdist, visitedObjects);
if (objdist >= 0) {
UString ustring = (*it).ustring();
@@ -317,7 +337,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
int objdist = 0;
qConvDebug() << "converting a " << len << " length Array";
for (int i = 0; i < len; ++i) {
- JSValue* val = rtarray->getConcreteArray()->valueAt(exec, i);
+ JSValuePtr val = rtarray->getConcreteArray()->valueAt(exec, i);
result.append(convertValueToQVariant(exec, val, QMetaType::Void, &objdist, visitedObjects));
if (objdist == -1) {
qConvDebug() << "Failed converting element at index " << i;
@@ -336,7 +356,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
int objdist = 0;
qConvDebug() << "converting a " << len << " length Array";
for (int i = 0; i < len; ++i) {
- JSValue* val = array->get(exec, i);
+ JSValuePtr val = array->get(exec, i);
result.append(convertValueToQVariant(exec, val, QMetaType::Void, &objdist, visitedObjects));
if (objdist == -1) {
qConvDebug() << "Failed converting element at index " << i;
@@ -370,8 +390,8 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
QStringList result;
int len = rtarray->getLength();
for (int i = 0; i < len; ++i) {
- JSValue* val = rtarray->getConcreteArray()->valueAt(exec, i);
- UString ustring = val->toString(exec);
+ JSValuePtr val = rtarray->getConcreteArray()->valueAt(exec, i);
+ UString ustring = val.toString(exec);
QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size());
result.append(qstring);
@@ -384,8 +404,8 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
QStringList result;
int len = array->length();
for (int i = 0; i < len; ++i) {
- JSValue* val = array->get(exec, i);
- UString ustring = val->toString(exec);
+ JSValuePtr val = array->get(exec, i);
+ UString ustring = val.toString(exec);
QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size());
result.append(qstring);
@@ -394,7 +414,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
ret = QVariant(result);
} else {
// Make a single length array
- UString ustring = value->toString(exec);
+ UString ustring = value.toString(exec);
QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size());
QStringList result;
result.append(qstring);
@@ -405,7 +425,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
}
case QMetaType::QByteArray: {
- UString ustring = value->toString(exec);
+ UString ustring = value.toString(exec);
ret = QVariant(QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size()).toLatin1());
if (type == String)
dist = 5;
@@ -432,7 +452,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
dist = 2;
}
} else if (type == Number) {
- double b = value->toNumber(exec);
+ double b = value.toNumber(exec);
GregorianDateTime gdt;
msToGregorianDateTime(b, true, gdt);
if (hint == QMetaType::QDateTime) {
@@ -446,7 +466,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
dist = 10;
}
} else if (type == String) {
- UString ustring = value->toString(exec);
+ UString ustring = value.toString(exec);
QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size());
if (hint == QMetaType::QDateTime) {
@@ -495,7 +515,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
RegExpObject *re = static_cast<RegExpObject*>(object);
*/
// Attempt to convert.. a bit risky
- UString ustring = value->toString(exec);
+ UString ustring = value.toString(exec);
QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size());
// this is of the form '/xxxxxx/i'
@@ -515,7 +535,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
qConvDebug() << "couldn't parse a JS regexp";
}
} else if (type == String) {
- UString ustring = value->toString(exec);
+ UString ustring = value.toString(exec);
QString qstring = QString::fromUtf16((const ushort*)ustring.rep()->data(),ustring.size());
QRegExp re(qstring);
@@ -528,7 +548,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
case QMetaType::QObjectStar:
if (type == QObj) {
- QtInstance* qtinst = static_cast<QtInstance*>(Instance::getInstance(object, Instance::QtLanguage));
+ QtInstance* qtinst = QtInstance::getInstance(object);
if (qtinst) {
if (qtinst->getObject()) {
qConvDebug() << "found instance, with object:" << (void*) qtinst->getObject();
@@ -552,7 +572,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
case QMetaType::VoidStar:
if (type == QObj) {
- QtInstance* qtinst = static_cast<QtInstance*>(Instance::getInstance(object, Instance::QtLanguage));
+ QtInstance* qtinst = QtInstance::getInstance(object);
if (qtinst) {
if (qtinst->getObject()) {
qConvDebug() << "found instance, with object:" << (void*) qtinst->getObject();
@@ -571,7 +591,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
} else if (type == Number) {
// I don't think that converting a double to a pointer is a wise
// move. Except maybe 0.
- qConvDebug() << "got number for void * - not converting, seems unsafe:" << value->toNumber(exec);
+ qConvDebug() << "got number for void * - not converting, seems unsafe:" << value.toNumber(exec);
} else {
qConvDebug() << "void* - unhandled type" << type;
}
@@ -587,7 +607,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
QObjectList result;
int len = rtarray->getLength();
for (int i = 0; i < len; ++i) {
- JSValue* val = rtarray->getConcreteArray()->valueAt(exec, i);
+ JSValuePtr val = rtarray->getConcreteArray()->valueAt(exec, i);
int itemdist = -1;
QVariant item = convertValueToQVariant(exec, val, QMetaType::QObjectStar, &itemdist, visitedObjects);
if (itemdist >= 0)
@@ -601,12 +621,12 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
ret = QVariant::fromValue(result);
}
} else if (type == Array) {
- JSObject* object = value->toObject(exec);
+ JSObject* object = value.toObject(exec);
JSArray* array = static_cast<JSArray *>(object);
QObjectList result;
int len = array->length();
for (int i = 0; i < len; ++i) {
- JSValue* val = array->get(exec, i);
+ JSValuePtr val = array->get(exec, i);
int itemdist = -1;
QVariant item = convertValueToQVariant(exec, val, QMetaType::QObjectStar, &itemdist, visitedObjects);
if (itemdist >= 0)
@@ -638,7 +658,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
QList<int> result;
int len = rtarray->getLength();
for (int i = 0; i < len; ++i) {
- JSValue* val = rtarray->getConcreteArray()->valueAt(exec, i);
+ JSValuePtr val = rtarray->getConcreteArray()->valueAt(exec, i);
int itemdist = -1;
QVariant item = convertValueToQVariant(exec, val, QMetaType::Int, &itemdist, visitedObjects);
if (itemdist >= 0)
@@ -657,7 +677,7 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
QList<int> result;
int len = array->length();
for (int i = 0; i < len; ++i) {
- JSValue* val = array->get(exec, i);
+ JSValuePtr val = array->get(exec, i);
int itemdist = -1;
QVariant item = convertValueToQVariant(exec, val, QMetaType::Int, &itemdist, visitedObjects);
if (itemdist >= 0)
@@ -683,9 +703,20 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
}
break;
} else if (hint == (QMetaType::Type) qMetaTypeId<QVariant>()) {
- // Well.. we can do anything... just recurse with the autodetect flag
- ret = convertValueToQVariant(exec, value, QMetaType::Void, distance, visitedObjects);
- dist = 10;
+ if (value.isUndefinedOrNull()) {
+ if (distance)
+ *distance = 1;
+ return QVariant();
+ } else {
+ if (type == Object) {
+ // Since we haven't really visited this object yet, we remove it
+ visitedObjects->remove(object);
+ }
+
+ // And then recurse with the autodetect flag
+ ret = convertValueToQVariant(exec, value, QMetaType::Void, distance, visitedObjects);
+ dist = 10;
+ }
break;
}
@@ -701,13 +732,13 @@ QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type
return ret;
}
-QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type hint, int *distance)
+QVariant convertValueToQVariant(ExecState* exec, JSValuePtr value, QMetaType::Type hint, int *distance)
{
HashSet<JSObject*> visitedObjects;
return convertValueToQVariant(exec, value, hint, distance, &visitedObjects);
}
-JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, const QVariant& variant)
+JSValuePtr convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, const QVariant& variant)
{
// Variants with QObject * can be isNull but not a null pointer
// An empty QString variant is also null
@@ -798,7 +829,7 @@ JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, co
if (type == QMetaType::QObjectStar || type == QMetaType::QWidgetStar) {
QObject* obj = variant.value<QObject*>();
- return Instance::createRuntimeObject(exec, QtInstance::getQtInstance(obj, root));
+ return QtInstance::getQtInstance(obj, root)->createRuntimeObject(exec);
}
if (type == QMetaType::QVariantMap) {
@@ -808,7 +839,7 @@ JSValue* convertQVariantToValue(ExecState* exec, PassRefPtr<RootObject> root, co
QVariantMap::const_iterator i = map.constBegin();
while (i != map.constEnd()) {
QString s = i.key();
- JSValue* val = convertQVariantToValue(exec, root, i.value());
+ JSValuePtr val = convertQVariantToValue(exec, root, i.value());
if (val) {
PutPropertySlot slot;
ret->put(exec, Identifier(exec, (const UChar *)s.constData(), s.length()), val, slot);
@@ -1110,6 +1141,7 @@ static int findMethodIndex(ExecState* exec,
}
}
+ // If the native method requires more arguments than what was passed from JavaScript
if (jsArgs.size() < (types.count() - 1)) {
qMatchDebug() << "Match:too few args for" << method.signature();
tooFewArgs.append(index);
@@ -1134,7 +1166,7 @@ static int findMethodIndex(ExecState* exec,
bool converted = true;
int matchDistance = 0;
for (int i = 0; converted && i < types.count() - 1; ++i) {
- JSValue* arg = i < jsArgs.size() ? jsArgs.at(exec, i) : jsUndefined();
+ JSValuePtr arg = i < jsArgs.size() ? jsArgs.at(exec, i) : jsUndefined();
int argdistance = -1;
QVariant v = convertValueToQVariant(exec, arg, types.at(i+1).typeId(), &argdistance);
@@ -1156,17 +1188,17 @@ static int findMethodIndex(ExecState* exec,
chosenIndex = index;
break;
} else {
- QtMethodMatchData metaArgs(matchDistance, index, types, args);
+ QtMethodMatchData currentMatch(matchDistance, index, types, args);
if (candidates.isEmpty()) {
- candidates.append(metaArgs);
+ candidates.append(currentMatch);
} else {
- QtMethodMatchData otherArgs = candidates.at(0);
- if ((args.count() > otherArgs.args.count())
- || ((args.count() == otherArgs.args.count())
- && (matchDistance <= otherArgs.matchDistance))) {
- candidates.prepend(metaArgs);
+ QtMethodMatchData bestMatchSoFar = candidates.at(0);
+ if ((args.count() > bestMatchSoFar.args.count())
+ || ((args.count() == bestMatchSoFar.args.count())
+ && (matchDistance <= bestMatchSoFar.matchDistance))) {
+ candidates.prepend(currentMatch);
} else {
- candidates.append(metaArgs);
+ candidates.append(currentMatch);
}
}
}
@@ -1213,23 +1245,27 @@ static int findMethodIndex(ExecState* exec,
}
if (chosenIndex == -1 && candidates.count() > 0) {
- QtMethodMatchData metaArgs = candidates.at(0);
+ QtMethodMatchData bestMatch = candidates.at(0);
if ((candidates.size() > 1)
- && (metaArgs.args.count() == candidates.at(1).args.count())
- && (metaArgs.matchDistance == candidates.at(1).matchDistance)) {
+ && (bestMatch.args.count() == candidates.at(1).args.count())
+ && (bestMatch.matchDistance == candidates.at(1).matchDistance)) {
// ambiguous call
QString message = QString::fromLatin1("ambiguous call of overloaded function %0(); candidates were\n")
.arg(QLatin1String(signature));
for (int i = 0; i < candidates.size(); ++i) {
- if (i > 0)
- message += QLatin1String("\n");
- QMetaMethod mtd = meta->method(candidates.at(i).index);
- message += QString::fromLatin1(" %0").arg(QString::fromLatin1(mtd.signature()));
+ // Only candidate for overload if argument count and match distance is same as best match
+ if (candidates.at(i).args.count() == bestMatch.args.count()
+ || candidates.at(i).matchDistance == bestMatch.matchDistance) {
+ if (i > 0)
+ message += QLatin1String("\n");
+ QMetaMethod mtd = meta->method(candidates.at(i).index);
+ message += QString::fromLatin1(" %0").arg(QString::fromLatin1(mtd.signature()));
+ }
}
*pError = throwError(exec, TypeError, message.toLatin1().constData());
} else {
- chosenIndex = metaArgs.index;
- args = metaArgs.args;
+ chosenIndex = bestMatch.index;
+ args = bestMatch.args;
}
}
@@ -1282,7 +1318,7 @@ void QtRuntimeMetaMethod::mark()
d->m_disconnect->mark();
}
-JSValue* QtRuntimeMetaMethod::call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args)
+JSValuePtr QtRuntimeMetaMethod::call(ExecState* exec, JSObject* functionObject, JSValuePtr thisValue, const ArgList& args)
{
QtRuntimeMetaMethodData* d = static_cast<QtRuntimeMetaMethod *>(functionObject)->d_func();
@@ -1340,13 +1376,13 @@ bool QtRuntimeMetaMethod::getOwnPropertySlot(ExecState* exec, const Identifier&
return QtRuntimeMethod::getOwnPropertySlot(exec, propertyName, slot);
}
-JSValue* QtRuntimeMetaMethod::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot&)
+JSValuePtr QtRuntimeMetaMethod::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot&)
{
// QtScript always returns 0
return jsNumber(exec, 0);
}
-JSValue* QtRuntimeMetaMethod::connectGetter(ExecState* exec, const Identifier& ident, const PropertySlot& slot)
+JSValuePtr QtRuntimeMetaMethod::connectGetter(ExecState* exec, const Identifier& ident, const PropertySlot& slot)
{
QtRuntimeMetaMethod* thisObj = static_cast<QtRuntimeMetaMethod*>(asObject(slot.slotBase()));
QW_DS(QtRuntimeMetaMethod, thisObj);
@@ -1356,7 +1392,7 @@ JSValue* QtRuntimeMetaMethod::connectGetter(ExecState* exec, const Identifier& i
return d->m_connect;
}
-JSValue* QtRuntimeMetaMethod::disconnectGetter(ExecState* exec, const Identifier& ident, const PropertySlot& slot)
+JSValuePtr QtRuntimeMetaMethod::disconnectGetter(ExecState* exec, const Identifier& ident, const PropertySlot& slot)
{
QtRuntimeMetaMethod* thisObj = static_cast<QtRuntimeMetaMethod*>(asObject(slot.slotBase()));
QW_DS(QtRuntimeMetaMethod, thisObj);
@@ -1380,7 +1416,7 @@ QtRuntimeConnectionMethod::QtRuntimeConnectionMethod(ExecState* exec, const Iden
d->m_isConnect = isConnect;
}
-JSValue* QtRuntimeConnectionMethod::call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args)
+JSValuePtr QtRuntimeConnectionMethod::call(ExecState* exec, JSObject* functionObject, JSValuePtr thisValue, const ArgList& args)
{
QtRuntimeConnectionMethodData* d = static_cast<QtRuntimeConnectionMethod *>(functionObject)->d_func();
@@ -1403,7 +1439,7 @@ JSValue* QtRuntimeConnectionMethod::call(ExecState* exec, JSObject* functionObje
if (signalIndex != -1) {
if (args.size() == 1) {
- funcObject = args.at(exec, 0)->toObject(exec);
+ funcObject = args.at(exec, 0).toObject(exec);
CallData callData;
if (funcObject->getCallData(callData) == CallTypeNone) {
if (d->m_isConnect)
@@ -1412,24 +1448,24 @@ JSValue* QtRuntimeConnectionMethod::call(ExecState* exec, JSObject* functionObje
return throwError(exec, TypeError, "QtMetaMethod.disconnect: target is not a function");
}
} else if (args.size() >= 2) {
- if (args.at(exec, 0)->isObject()) {
- thisObject = args.at(exec, 0)->toObject(exec);
+ if (args.at(exec, 0).isObject()) {
+ thisObject = args.at(exec, 0).toObject(exec);
// Get the actual function to call
- JSObject *asObj = args.at(exec, 1)->toObject(exec);
+ JSObject *asObj = args.at(exec, 1).toObject(exec);
CallData callData;
if (asObj->getCallData(callData) != CallTypeNone) {
// Function version
funcObject = asObj;
} else {
// Convert it to a string
- UString funcName = args.at(exec, 1)->toString(exec);
+ UString funcName = args.at(exec, 1).toString(exec);
Identifier funcIdent(exec, funcName);
// ### DropAllLocks
// This is resolved at this point in QtScript
- JSValue* val = thisObject->get(exec, funcIdent);
- JSObject* asFuncObj = val->toObject(exec);
+ JSValuePtr val = thisObject->get(exec, funcIdent);
+ JSObject* asFuncObj = val.toObject(exec);
if (asFuncObj->getCallData(callData) != CallTypeNone) {
funcObject = asFuncObj;
@@ -1526,7 +1562,7 @@ bool QtRuntimeConnectionMethod::getOwnPropertySlot(ExecState* exec, const Identi
return QtRuntimeMethod::getOwnPropertySlot(exec, propertyName, slot);
}
-JSValue* QtRuntimeConnectionMethod::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot&)
+JSValuePtr QtRuntimeConnectionMethod::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot&)
{
// we have one formal argument, and one optional
return jsNumber(exec, 1);
@@ -1626,7 +1662,7 @@ void QtConnectionObject::execute(void **argv)
// Build the argument list (up to the formal argument length of the slot)
ArgList l;
// ### DropAllLocks?
- int funcArgC = m_funcObject->get(exec, exec->propertyNames().length)->toInt32(exec);
+ int funcArgC = m_funcObject->get(exec, exec->propertyNames().length).toInt32(exec);
int argTotal = qMax(funcArgC, argc);
for(int i=0; i < argTotal; i++) {
if (i < argc) {
@@ -1642,8 +1678,8 @@ void QtConnectionObject::execute(void **argv)
if (m_funcObject->inherits(&JSFunction::info)) {
JSFunction* fimp = static_cast<JSFunction*>(m_funcObject.get());
- JSObject* qt_sender = Instance::createRuntimeObject(exec, QtInstance::getQtInstance(sender(), ro));
- JSObject* wrapper = new (exec) JSObject(JSObject::createStructureID(jsNull()));
+ JSObject* qt_sender = QtInstance::getQtInstance(sender(), ro)->createRuntimeObject(exec);
+ JSObject* wrapper = new (exec) JSObject(JSObject::createStructure(jsNull()));
PutPropertySlot slot;
wrapper->put(exec, Identifier(exec, "__qt_sender__"), qt_sender, slot);
ScopeChain oldsc = fimp->scope();
@@ -1692,7 +1728,7 @@ template <typename T> RootObject* QtArray<T>::rootObject() const
return _rootObject && _rootObject->isValid() ? _rootObject.get() : 0;
}
-template <typename T> void QtArray<T>::setValueAt(ExecState* exec, unsigned index, JSValue* aValue) const
+template <typename T> void QtArray<T>::setValueAt(ExecState* exec, unsigned index, JSValuePtr aValue) const
{
// QtScript sets the value, but doesn't forward it to the original source
// (e.g. if you do 'object.intList[5] = 6', the object is not updated, but the
@@ -1706,7 +1742,7 @@ template <typename T> void QtArray<T>::setValueAt(ExecState* exec, unsigned inde
}
-template <typename T> JSValue* QtArray<T>::valueAt(ExecState *exec, unsigned int index) const
+template <typename T> JSValuePtr QtArray<T>::valueAt(ExecState *exec, unsigned int index) const
{
if (index < m_length) {
T val = m_list.at(index);
diff --git a/WebCore/bridge/qt/qt_runtime.h b/WebCore/bridge/qt/qt_runtime.h
index 80248a2..7912a2b 100644
--- a/WebCore/bridge/qt/qt_runtime.h
+++ b/WebCore/bridge/qt/qt_runtime.h
@@ -20,10 +20,10 @@
#ifndef BINDINGS_QT_RUNTIME_H_
#define BINDINGS_QT_RUNTIME_H_
-#include "completion.h"
+#include "Completion.h"
+#include "Protect.h"
#include "runtime.h"
#include "runtime_method.h"
-#include "protect.h"
#include <qbytearray.h>
#include <qmetaobject.h>
@@ -56,8 +56,8 @@ public:
: m_type(ChildObject), m_childObject(child)
{}
- virtual JSValue* valueFromInstance(ExecState*, const Instance*) const;
- virtual void setValueToInstance(ExecState*, const Instance*, JSValue*) const;
+ virtual JSValuePtr valueFromInstance(ExecState*, const Instance*) const;
+ virtual void setValueToInstance(ExecState*, const Instance*, JSValuePtr) const;
virtual const char* name() const;
QtFieldType fieldType() const {return m_type;}
private:
@@ -98,8 +98,8 @@ public:
RootObject* rootObject() const;
- virtual void setValueAt(ExecState*, unsigned index, JSValue*) const;
- virtual JSValue* valueAt(ExecState*, unsigned index) const;
+ virtual void setValueAt(ExecState*, unsigned index, JSValuePtr) const;
+ virtual JSValuePtr valueAt(ExecState*, unsigned index) const;
virtual unsigned int getLength() const {return m_length;}
private:
@@ -149,9 +149,9 @@ public:
return exec->lexicalGlobalObject()->functionPrototype();
}
- static PassRefPtr<StructureID> createStructureID(JSValue* prototype)
+ static PassRefPtr<Structure> createStructure(JSValuePtr prototype)
{
- return StructureID::create(prototype, TypeInfo(ObjectType));
+ return Structure::create(prototype, TypeInfo(ObjectType));
}
protected:
@@ -174,10 +174,10 @@ protected:
private:
virtual CallType getCallData(CallData&);
- static JSValue* call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args);
- static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
- static JSValue* connectGetter(ExecState*, const Identifier&, const PropertySlot&);
- static JSValue* disconnectGetter(ExecState*, const Identifier&, const PropertySlot&);
+ static JSValuePtr call(ExecState* exec, JSObject* functionObject, JSValuePtr thisValue, const ArgList& args);
+ static JSValuePtr lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
+ static JSValuePtr connectGetter(ExecState*, const Identifier&, const PropertySlot&);
+ static JSValuePtr disconnectGetter(ExecState*, const Identifier&, const PropertySlot&);
};
class QtConnectionObject;
@@ -193,8 +193,8 @@ protected:
private:
virtual CallType getCallData(CallData&);
- static JSValue* call(ExecState* exec, JSObject* functionObject, JSValue* thisValue, const ArgList& args);
- static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
+ static JSValuePtr call(ExecState* exec, JSObject* functionObject, JSValuePtr thisValue, const ArgList& args);
+ static JSValuePtr lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
static QMultiMap<QObject *, QtConnectionObject *> connections;
friend class QtConnectionObject;
};
@@ -223,7 +223,7 @@ private:
ProtectedPtr<JSObject> m_funcObject;
};
-QVariant convertValueToQVariant(ExecState* exec, JSValue* value, QMetaType::Type hint, int *distance);
+QVariant convertValueToQVariant(ExecState* exec, JSValuePtr value, QMetaType::Type hint, int *distance);
} // namespace Bindings
} // namespace JSC
diff --git a/WebCore/bridge/runtime.cpp b/WebCore/bridge/runtime.cpp
index 3ca53ab..d6b6962 100644
--- a/WebCore/bridge/runtime.cpp
+++ b/WebCore/bridge/runtime.cpp
@@ -78,39 +78,11 @@ void Instance::end()
virtualEnd();
}
-JSValue* Instance::getValueOfField(ExecState* exec, const Field* aField) const
+RuntimeObjectImp* Instance::createRuntimeObject(ExecState* exec)
{
- return aField->valueFromInstance(exec, this);
-}
-
-void Instance::setValueOfField(ExecState* exec, const Field* aField, JSValue* aValue) const
-{
- aField->setValueToInstance(exec, this, aValue);
-}
-
-RuntimeObjectImp* Instance::createRuntimeObject(ExecState* exec, PassRefPtr<Instance> instance)
-{
-#if PLATFORM(QT)
- if (instance->getBindingLanguage() == QtLanguage)
- return QtInstance::getRuntimeObject(exec, static_cast<QtInstance*>(instance.get()));
-#endif
JSLock lock(false);
-
- return new (exec) RuntimeObjectImp(exec, instance);
-}
-
-Instance* Instance::getInstance(JSObject* object, BindingLanguage language)
-{
- if (!object)
- return 0;
- if (!object->inherits(&RuntimeObjectImp::s_info))
- return 0;
- Instance* instance = static_cast<RuntimeObjectImp*>(object)->getInternalInstance();
- if (!instance)
- return 0;
- if (instance->getBindingLanguage() != language)
- return 0;
- return instance;
+
+ return new (exec) RuntimeObjectImp(exec, this);
}
RootObject* Instance::rootObject() const
diff --git a/WebCore/bridge/runtime.h b/WebCore/bridge/runtime.h
index 3c39121..8adfbe1 100644
--- a/WebCore/bridge/runtime.h
+++ b/WebCore/bridge/runtime.h
@@ -49,16 +49,14 @@ typedef Vector<Method*> MethodList;
class Field {
public:
- virtual const char* name() const = 0;
- virtual JSValue* valueFromInstance(ExecState*, const Instance*) const = 0;
- virtual void setValueToInstance(ExecState*, const Instance*, JSValue*) const = 0;
+ virtual JSValuePtr valueFromInstance(ExecState*, const Instance*) const = 0;
+ virtual void setValueToInstance(ExecState*, const Instance*, JSValuePtr) const = 0;
virtual ~Field() { }
};
class Method : Noncopyable {
public:
- virtual const char *name() const = 0;
virtual int numParameters() const = 0;
virtual ~Method() { }
@@ -66,10 +64,9 @@ public:
class Class : Noncopyable {
public:
- virtual const char* name() const = 0;
virtual MethodList methodsNamed(const Identifier&, Instance*) const = 0;
virtual Field* fieldNamed(const Identifier&, Instance*) const = 0;
- virtual JSValue* fallbackObject(ExecState*, Instance*, const Identifier&) { return jsUndefined(); }
+ virtual JSValuePtr fallbackObject(ExecState*, Instance*, const Identifier&) { return jsUndefined(); }
virtual ~Class() { }
};
@@ -78,27 +75,11 @@ typedef void (*KJSDidExecuteFunctionPtr)(ExecState*, JSObject* rootObject);
class Instance : public RefCounted<Instance> {
public:
- typedef enum {
-#if ENABLE(MAC_JAVA_BRIDGE)
- JavaLanguage,
-#endif
-#if PLATFORM(MAC)
- ObjectiveCLanguage,
-#endif
- CLanguage
-#if PLATFORM(QT)
- , QtLanguage
-#endif
- } BindingLanguage;
-
Instance(PassRefPtr<RootObject>);
static void setDidExecuteFunction(KJSDidExecuteFunctionPtr func);
static KJSDidExecuteFunctionPtr didExecuteFunction();
- static RuntimeObjectImp* createRuntimeObject(ExecState*, PassRefPtr<Instance>);
- static Instance* getInstance(JSObject*, BindingLanguage);
-
// These functions are called before and after the main entry points into
// the native implementations. They can be used to establish and cleanup
// any needed state.
@@ -106,32 +87,31 @@ public:
void end();
virtual Class *getClass() const = 0;
+ virtual RuntimeObjectImp* createRuntimeObject(ExecState*);
- virtual JSValue* getValueOfField(ExecState*, const Field*) const;
- virtual JSValue* getValueOfUndefinedField(ExecState*, const Identifier&) const { return jsUndefined(); }
- virtual void setValueOfField(ExecState*, const Field*, JSValue*) const;
- virtual bool supportsSetValueOfUndefinedField() { return false; }
- virtual void setValueOfUndefinedField(ExecState*, const Identifier&, JSValue*) {}
+ // Returns false if the value was not set successfully.
+ virtual bool setValueOfUndefinedField(ExecState*, const Identifier&, JSValuePtr) { return false; }
- virtual JSValue* invokeMethod(ExecState*, const MethodList&, const ArgList& args) = 0;
+ virtual JSValuePtr invokeMethod(ExecState*, const MethodList&, const ArgList& args) = 0;
virtual bool supportsInvokeDefaultMethod() const { return false; }
- virtual JSValue* invokeDefaultMethod(ExecState*, const ArgList&) { return jsUndefined(); }
+ virtual JSValuePtr invokeDefaultMethod(ExecState*, const ArgList&) { return jsUndefined(); }
virtual bool supportsConstruct() const { return false; }
- virtual JSValue* invokeConstruct(ExecState*, const ArgList&) { return 0; }
+ virtual JSValuePtr invokeConstruct(ExecState*, const ArgList&) { return noValue(); }
virtual void getPropertyNames(ExecState*, PropertyNameArray&) { }
- virtual JSValue* defaultValue(ExecState*, PreferredPrimitiveType) const = 0;
+ virtual JSValuePtr defaultValue(ExecState*, PreferredPrimitiveType) const = 0;
- virtual JSValue* valueOf(ExecState* exec) const { return jsString(exec, getClass()->name()); }
+ virtual JSValuePtr valueOf(ExecState* exec) const = 0;
RootObject* rootObject() const;
virtual ~Instance();
- virtual BindingLanguage getBindingLanguage() const = 0;
+ virtual bool getOwnPropertySlot(JSObject*, ExecState*, const Identifier&, PropertySlot&) { return false; }
+ virtual void put(JSObject*, ExecState*, const Identifier&, JSValuePtr, PutPropertySlot&) { }
protected:
virtual void virtualBegin() { }
@@ -145,8 +125,8 @@ public:
Array(PassRefPtr<RootObject>);
virtual ~Array();
- virtual void setValueAt(ExecState *, unsigned index, JSValue*) const = 0;
- virtual JSValue* valueAt(ExecState *, unsigned index) const = 0;
+ virtual void setValueAt(ExecState *, unsigned index, JSValuePtr) const = 0;
+ virtual JSValuePtr valueAt(ExecState *, unsigned index) const = 0;
virtual unsigned int getLength() const = 0;
protected:
diff --git a/WebCore/bridge/runtime_array.cpp b/WebCore/bridge/runtime_array.cpp
index c3912a9..1979432 100644
--- a/WebCore/bridge/runtime_array.cpp
+++ b/WebCore/bridge/runtime_array.cpp
@@ -42,13 +42,13 @@ RuntimeArray::RuntimeArray(ExecState* exec, Bindings::Array* a)
{
}
-JSValue* RuntimeArray::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
+JSValuePtr RuntimeArray::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
RuntimeArray* thisObj = static_cast<RuntimeArray*>(asObject(slot.slotBase()));
return jsNumber(exec, thisObj->getLength());
}
-JSValue* RuntimeArray::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
+JSValuePtr RuntimeArray::indexGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
RuntimeArray* thisObj = static_cast<RuntimeArray*>(asObject(slot.slotBase()));
return thisObj->getConcreteArray()->valueAt(exec, slot.index());
@@ -83,7 +83,7 @@ bool RuntimeArray::getOwnPropertySlot(ExecState *exec, unsigned index, PropertyS
return JSObject::getOwnPropertySlot(exec, index, slot);
}
-void RuntimeArray::put(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot& slot)
+void RuntimeArray::put(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot)
{
if (propertyName == exec->propertyNames().length) {
throwError(exec, RangeError);
@@ -100,7 +100,7 @@ void RuntimeArray::put(ExecState* exec, const Identifier& propertyName, JSValue*
JSObject::put(exec, propertyName, value, slot);
}
-void RuntimeArray::put(ExecState* exec, unsigned index, JSValue* value)
+void RuntimeArray::put(ExecState* exec, unsigned index, JSValuePtr value)
{
if (index >= getLength()) {
throwError(exec, RangeError);
diff --git a/WebCore/bridge/runtime_array.h b/WebCore/bridge/runtime_array.h
index 22ad5f3..1ea47a4 100644
--- a/WebCore/bridge/runtime_array.h
+++ b/WebCore/bridge/runtime_array.h
@@ -37,8 +37,8 @@ public:
virtual bool getOwnPropertySlot(ExecState *, const Identifier&, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState *, unsigned, PropertySlot&);
- virtual void put(ExecState*, const Identifier& propertyName, JSValue*, PutPropertySlot&);
- virtual void put(ExecState*, unsigned propertyName, JSValue*);
+ virtual void put(ExecState*, const Identifier& propertyName, JSValuePtr, PutPropertySlot&);
+ virtual void put(ExecState*, unsigned propertyName, JSValuePtr);
virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
@@ -56,14 +56,14 @@ public:
return exec->lexicalGlobalObject()->arrayPrototype();
}
- static PassRefPtr<StructureID> createStructureID(JSValue* prototype)
+ static PassRefPtr<Structure> createStructure(JSValuePtr prototype)
{
- return StructureID::create(prototype, TypeInfo(ObjectType));
+ return Structure::create(prototype, TypeInfo(ObjectType));
}
private:
- static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
- static JSValue* indexGetter(ExecState*, const Identifier&, const PropertySlot&);
+ static JSValuePtr lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
+ static JSValuePtr indexGetter(ExecState*, const Identifier&, const PropertySlot&);
OwnPtr<Bindings::Array> _array;
};
diff --git a/WebCore/bridge/runtime_method.cpp b/WebCore/bridge/runtime_method.cpp
index b855081..eb0fae4 100644
--- a/WebCore/bridge/runtime_method.cpp
+++ b/WebCore/bridge/runtime_method.cpp
@@ -47,7 +47,7 @@ RuntimeMethod::RuntimeMethod(ExecState* exec, const Identifier& ident, Bindings:
{
}
-JSValue* RuntimeMethod::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
+JSValuePtr RuntimeMethod::lengthGetter(ExecState* exec, const Identifier&, const PropertySlot& slot)
{
RuntimeMethod* thisObj = static_cast<RuntimeMethod*>(asObject(slot.slotBase()));
@@ -70,7 +70,7 @@ bool RuntimeMethod::getOwnPropertySlot(ExecState* exec, const Identifier& proper
return InternalFunction::getOwnPropertySlot(exec, propertyName, slot);
}
-static JSValue* callRuntimeMethod(ExecState* exec, JSObject* function, JSValue* thisValue, const ArgList& args)
+static JSValuePtr callRuntimeMethod(ExecState* exec, JSObject* function, JSValuePtr thisValue, const ArgList& args)
{
RuntimeMethod* method = static_cast<RuntimeMethod*>(function);
@@ -79,13 +79,13 @@ static JSValue* callRuntimeMethod(ExecState* exec, JSObject* function, JSValue*
RuntimeObjectImp* imp;
- if (thisValue->isObject(&RuntimeObjectImp::s_info)) {
+ if (thisValue.isObject(&RuntimeObjectImp::s_info)) {
imp = static_cast<RuntimeObjectImp*>(asObject(thisValue));
} else {
// If thisObj is the DOM object for a plugin, get the corresponding
// runtime object from the DOM object.
- JSValue* value = thisValue->get(exec, Identifier(exec, "__apple_runtime_object"));
- if (value->isObject(&RuntimeObjectImp::s_info))
+ JSValuePtr value = thisValue.get(exec, Identifier(exec, "__apple_runtime_object"));
+ if (value.isObject(&RuntimeObjectImp::s_info))
imp = static_cast<RuntimeObjectImp*>(asObject(value));
else
return throwError(exec, TypeError);
@@ -96,7 +96,7 @@ static JSValue* callRuntimeMethod(ExecState* exec, JSObject* function, JSValue*
return RuntimeObjectImp::throwInvalidAccessError(exec);
instance->begin();
- JSValue* result = instance->invokeMethod(exec, *method->methods(), args);
+ JSValuePtr result = instance->invokeMethod(exec, *method->methods(), args);
instance->end();
return result;
}
diff --git a/WebCore/bridge/runtime_method.h b/WebCore/bridge/runtime_method.h
index adc68f6..bb983f9 100644
--- a/WebCore/bridge/runtime_method.h
+++ b/WebCore/bridge/runtime_method.h
@@ -45,13 +45,13 @@ public:
return exec->lexicalGlobalObject()->functionPrototype();
}
- static PassRefPtr<StructureID> createStructureID(JSValue* prototype)
+ static PassRefPtr<Structure> createStructure(JSValuePtr prototype)
{
- return StructureID::create(prototype, TypeInfo(ObjectType, ImplementsHasInstance));
+ return Structure::create(prototype, TypeInfo(ObjectType, ImplementsHasInstance));
}
private:
- static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
+ static JSValuePtr lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual CallType getCallData(CallData&);
diff --git a/WebCore/bridge/runtime_object.cpp b/WebCore/bridge/runtime_object.cpp
index 5bde348..88aa560 100644
--- a/WebCore/bridge/runtime_object.cpp
+++ b/WebCore/bridge/runtime_object.cpp
@@ -47,7 +47,7 @@ RuntimeObjectImp::RuntimeObjectImp(ExecState* exec, PassRefPtr<Instance> i)
instance->rootObject()->addRuntimeObject(this);
}
-RuntimeObjectImp::RuntimeObjectImp(ExecState* exec, PassRefPtr<StructureID> structure, PassRefPtr<Instance> i)
+RuntimeObjectImp::RuntimeObjectImp(ExecState*, PassRefPtr<Structure> structure, PassRefPtr<Instance> i)
: JSObject(structure)
, instance(i)
{
@@ -66,7 +66,7 @@ void RuntimeObjectImp::invalidate()
instance = 0;
}
-JSValue* RuntimeObjectImp::fallbackObjectGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValuePtr RuntimeObjectImp::fallbackObjectGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
RuntimeObjectImp* thisObj = static_cast<RuntimeObjectImp*>(asObject(slot.slotBase()));
RefPtr<Instance> instance = thisObj->instance;
@@ -77,14 +77,14 @@ JSValue* RuntimeObjectImp::fallbackObjectGetter(ExecState* exec, const Identifie
instance->begin();
Class *aClass = instance->getClass();
- JSValue* result = aClass->fallbackObject(exec, instance.get(), propertyName);
+ JSValuePtr result = aClass->fallbackObject(exec, instance.get(), propertyName);
instance->end();
return result;
}
-JSValue* RuntimeObjectImp::fieldGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValuePtr RuntimeObjectImp::fieldGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
RuntimeObjectImp* thisObj = static_cast<RuntimeObjectImp*>(asObject(slot.slotBase()));
RefPtr<Instance> instance = thisObj->instance;
@@ -96,14 +96,14 @@ JSValue* RuntimeObjectImp::fieldGetter(ExecState* exec, const Identifier& proper
Class *aClass = instance->getClass();
Field* aField = aClass->fieldNamed(propertyName, instance.get());
- JSValue* result = instance->getValueOfField(exec, aField);
+ JSValuePtr result = aField->valueFromInstance(exec, instance.get());
instance->end();
return result;
}
-JSValue* RuntimeObjectImp::methodGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
+JSValuePtr RuntimeObjectImp::methodGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot)
{
RuntimeObjectImp* thisObj = static_cast<RuntimeObjectImp*>(asObject(slot.slotBase()));
RefPtr<Instance> instance = thisObj->instance;
@@ -115,7 +115,7 @@ JSValue* RuntimeObjectImp::methodGetter(ExecState* exec, const Identifier& prope
Class *aClass = instance->getClass();
MethodList methodList = aClass->methodsNamed(propertyName, instance.get());
- JSValue* result = new (exec) RuntimeMethod(exec, propertyName, methodList);
+ JSValuePtr result = new (exec) RuntimeMethod(exec, propertyName, methodList);
instance->end();
@@ -153,7 +153,7 @@ bool RuntimeObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& pro
}
// Try a fallback object.
- if (!aClass->fallbackObject(exec, instance.get(), propertyName)->isUndefined()) {
+ if (!aClass->fallbackObject(exec, instance.get(), propertyName).isUndefined()) {
slot.setCustom(this, fallbackObjectGetter);
instance->end();
return true;
@@ -161,18 +161,11 @@ bool RuntimeObjectImp::getOwnPropertySlot(ExecState *exec, const Identifier& pro
}
instance->end();
-#if PLATFORM(QT)
- // For Qt instances we call the baseclass implementation to allow
- // runtime objects to have custom properties or a prototype
- if (instance->getBindingLanguage() == Instance::QtLanguage)
- return JSObject::getOwnPropertySlot(exec, propertyName, slot);
-#endif
- // For other platforms and/or binding languages we don't allow
- // runtime properties/prototypes
- return false;
+
+ return instance->getOwnPropertySlot(this, exec, propertyName, slot);
}
-void RuntimeObjectImp::put(ExecState* exec, const Identifier& propertyName, JSValue* value, PutPropertySlot& slot)
+void RuntimeObjectImp::put(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot)
{
if (!instance) {
throwInvalidAccessError(exec);
@@ -185,13 +178,9 @@ void RuntimeObjectImp::put(ExecState* exec, const Identifier& propertyName, JSVa
// Set the value of the property.
Field *aField = instance->getClass()->fieldNamed(propertyName, instance.get());
if (aField)
- instance->setValueOfField(exec, aField, value);
- else if (instance->supportsSetValueOfUndefinedField())
- instance->setValueOfUndefinedField(exec, propertyName, value);
-#if PLATFORM(QT)
- else if (instance->getBindingLanguage() == Instance::QtLanguage)
- JSObject::put(exec, propertyName, value, slot);
-#endif
+ aField->setValueToInstance(exec, instance.get(), value);
+ else if (!instance->setValueOfUndefinedField(exec, propertyName, value))
+ instance->put(this, exec, propertyName, value, slot);
instance->end();
}
@@ -202,23 +191,23 @@ bool RuntimeObjectImp::deleteProperty(ExecState*, const Identifier&)
return false;
}
-JSValue* RuntimeObjectImp::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
+JSValuePtr RuntimeObjectImp::defaultValue(ExecState* exec, PreferredPrimitiveType hint) const
{
if (!instance)
return throwInvalidAccessError(exec);
RefPtr<Instance> protector(instance);
instance->begin();
- JSValue* result = instance->defaultValue(exec, hint);
+ JSValuePtr result = instance->defaultValue(exec, hint);
instance->end();
return result;
}
-static JSValue* callRuntimeObject(ExecState* exec, JSObject* function, JSValue*, const ArgList& args)
+static JSValuePtr callRuntimeObject(ExecState* exec, JSObject* function, JSValuePtr, const ArgList& args)
{
RefPtr<Instance> instance(static_cast<RuntimeObjectImp*>(function)->getInternalInstance());
instance->begin();
- JSValue* result = instance->invokeDefaultMethod(exec, args);
+ JSValuePtr result = instance->invokeDefaultMethod(exec, args);
instance->end();
return result;
}
@@ -231,15 +220,15 @@ CallType RuntimeObjectImp::getCallData(CallData& callData)
return CallTypeHost;
}
-JSObject* callRuntimeConstructor(ExecState* exec, JSObject* constructor, const ArgList& args)
+static JSObject* callRuntimeConstructor(ExecState* exec, JSObject* constructor, const ArgList& args)
{
RefPtr<Instance> instance(static_cast<RuntimeObjectImp*>(constructor)->getInternalInstance());
instance->begin();
- JSValue* result = instance->invokeConstruct(exec, args);
+ JSValuePtr result = instance->invokeConstruct(exec, args);
instance->end();
ASSERT(result);
- return result->isObject() ? static_cast<JSObject*>(result) : constructor;
+ return result.isObject() ? static_cast<JSObject*>(result.asCell()) : constructor;
}
ConstructType RuntimeObjectImp::getConstructData(ConstructData& constructData)
diff --git a/WebCore/bridge/runtime_object.h b/WebCore/bridge/runtime_object.h
index 7e11273..b8788c9 100644
--- a/WebCore/bridge/runtime_object.h
+++ b/WebCore/bridge/runtime_object.h
@@ -33,12 +33,14 @@ namespace JSC {
class RuntimeObjectImp : public JSObject {
public:
+ RuntimeObjectImp(ExecState*, PassRefPtr<Bindings::Instance>);
+
virtual ~RuntimeObjectImp();
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
- virtual void put(ExecState*, const Identifier& propertyName, JSValue*, PutPropertySlot&);
+ virtual void put(ExecState*, const Identifier& propertyName, JSValuePtr, PutPropertySlot&);
virtual bool deleteProperty(ExecState* , const Identifier& propertyName);
- virtual JSValue* defaultValue(ExecState*, PreferredPrimitiveType) const;
+ virtual JSValuePtr defaultValue(ExecState*, PreferredPrimitiveType) const;
virtual CallType getCallData(CallData&);
virtual ConstructType getConstructData(ConstructData&);
@@ -56,23 +58,20 @@ public:
return exec->lexicalGlobalObject()->objectPrototype();
}
- static PassRefPtr<StructureID> createStructureID(JSValue* prototype)
+ static PassRefPtr<Structure> createStructure(JSValuePtr prototype)
{
- return StructureID::create(prototype, TypeInfo(ObjectType));
+ return Structure::create(prototype, TypeInfo(ObjectType));
}
protected:
- RuntimeObjectImp(ExecState*, PassRefPtr<StructureID>, PassRefPtr<Bindings::Instance>);
+ RuntimeObjectImp(ExecState*, PassRefPtr<Structure>, PassRefPtr<Bindings::Instance>);
private:
- friend class Bindings::Instance;
- RuntimeObjectImp(ExecState*, PassRefPtr<Bindings::Instance>);
-
virtual const ClassInfo* classInfo() const { return &s_info; }
- static JSValue* fallbackObjectGetter(ExecState*, const Identifier&, const PropertySlot&);
- static JSValue* fieldGetter(ExecState*, const Identifier&, const PropertySlot&);
- static JSValue* methodGetter(ExecState*, const Identifier&, const PropertySlot&);
+ static JSValuePtr fallbackObjectGetter(ExecState*, const Identifier&, const PropertySlot&);
+ static JSValuePtr fieldGetter(ExecState*, const Identifier&, const PropertySlot&);
+ static JSValuePtr methodGetter(ExecState*, const Identifier&, const PropertySlot&);
RefPtr<Bindings::Instance> instance;
};
diff --git a/WebCore/bridge/runtime_root.cpp b/WebCore/bridge/runtime_root.cpp
index 027d0c9..8e00fd5 100644
--- a/WebCore/bridge/runtime_root.cpp
+++ b/WebCore/bridge/runtime_root.cpp
@@ -30,6 +30,7 @@
#include <runtime/JSGlobalObject.h>
#include <wtf/HashCountedSet.h>
#include <wtf/HashSet.h>
+#include <wtf/StdLibExtras.h>
namespace JSC { namespace Bindings {
@@ -42,7 +43,7 @@ typedef HashSet<RootObject*> RootObjectSet;
static RootObjectSet* rootObjectSet()
{
- static RootObjectSet staticRootObjectSet;
+ DEFINE_STATIC_LOCAL(RootObjectSet, staticRootObjectSet, ());
return &staticRootObjectSet;
}
diff --git a/WebCore/bridge/runtime_root.h b/WebCore/bridge/runtime_root.h
index a86096d..0d6fdbd 100644
--- a/WebCore/bridge/runtime_root.h
+++ b/WebCore/bridge/runtime_root.h
@@ -29,7 +29,7 @@
#if PLATFORM(MAC)
#include "jni_jsobject.h"
#endif
-#include <kjs/protect.h>
+#include <runtime/Protect.h>
#include <wtf/HashSet.h>
#include <wtf/Noncopyable.h>
diff --git a/WebCore/bridge/testbindings.cpp b/WebCore/bridge/testbindings.cpp
index fa61e2f..e4bbc7e 100644
--- a/WebCore/bridge/testbindings.cpp
+++ b/WebCore/bridge/testbindings.cpp
@@ -1,6 +1,6 @@
/*
- * This file is part of the KDE libraries
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
diff --git a/WebCore/bridge/testbindings.pro b/WebCore/bridge/testbindings.pro
index e6e0b9d..1beee44 100644
--- a/WebCore/bridge/testbindings.pro
+++ b/WebCore/bridge/testbindings.pro
@@ -1,7 +1,7 @@
QT -= gui
include(../../WebKit.pri)
-INCLUDEPATH += .. ../kjs .
+INCLUDEPATH += .. ../ .
qt-port:INCLUDEPATH += bindings/qt
SOURCES += testqtbindings.cpp