summaryrefslogtreecommitdiff
path: root/Source/WebCore/bridge/runtime_object.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/bridge/runtime_object.cpp')
-rw-r--r--Source/WebCore/bridge/runtime_object.cpp99
1 files changed, 61 insertions, 38 deletions
diff --git a/Source/WebCore/bridge/runtime_object.cpp b/Source/WebCore/bridge/runtime_object.cpp
index 32524f49a..ebdcbf00c 100644
--- a/Source/WebCore/bridge/runtime_object.cpp
+++ b/Source/WebCore/bridge/runtime_object.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003, 2008, 2009 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2008-2009, 2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -10,10 +10,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -35,18 +35,18 @@ using namespace WebCore;
namespace JSC {
namespace Bindings {
-const ClassInfo RuntimeObject::s_info = { "RuntimeObject", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(RuntimeObject) };
+WEBCORE_EXPORT const ClassInfo RuntimeObject::s_info = { "RuntimeObject", &Base::s_info, 0, CREATE_METHOD_TABLE(RuntimeObject) };
-RuntimeObject::RuntimeObject(VM& vm, Structure* structure, PassRefPtr<Instance> instance)
+RuntimeObject::RuntimeObject(VM& vm, Structure* structure, RefPtr<Instance>&& instance)
: JSDestructibleObject(vm, structure)
- , m_instance(instance)
+ , m_instance(WTFMove(instance))
{
}
void RuntimeObject::finishCreation(VM& vm)
{
Base::finishCreation(vm);
- ASSERT(inherits(info()));
+ ASSERT(inherits(vm, info()));
}
void RuntimeObject::destroy(JSCell* cell)
@@ -59,16 +59,19 @@ void RuntimeObject::invalidate()
ASSERT(m_instance);
if (m_instance)
m_instance->willInvalidateRuntimeObject();
- m_instance = 0;
+ m_instance = nullptr;
}
-EncodedJSValue RuntimeObject::fallbackObjectGetter(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue, PropertyName propertyName)
+EncodedJSValue RuntimeObject::fallbackObjectGetter(ExecState* exec, EncodedJSValue thisValue, PropertyName propertyName)
{
- RuntimeObject* thisObj = jsCast<RuntimeObject*>(JSValue::decode(slotBase));
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ RuntimeObject* thisObj = jsCast<RuntimeObject*>(JSValue::decode(thisValue));
RefPtr<Instance> instance = thisObj->m_instance;
if (!instance)
- return JSValue::encode(throwInvalidAccessError(exec));
+ return JSValue::encode(throwInvalidAccessError(exec, scope));
instance->begin();
@@ -80,13 +83,16 @@ EncodedJSValue RuntimeObject::fallbackObjectGetter(ExecState* exec, EncodedJSVal
return JSValue::encode(result);
}
-EncodedJSValue RuntimeObject::fieldGetter(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue, PropertyName propertyName)
+EncodedJSValue RuntimeObject::fieldGetter(ExecState* exec, EncodedJSValue thisValue, PropertyName propertyName)
{
- RuntimeObject* thisObj = jsCast<RuntimeObject*>(JSValue::decode(slotBase));
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ RuntimeObject* thisObj = jsCast<RuntimeObject*>(JSValue::decode(thisValue));
RefPtr<Instance> instance = thisObj->m_instance;
if (!instance)
- return JSValue::encode(throwInvalidAccessError(exec));
+ return JSValue::encode(throwInvalidAccessError(exec, scope));
instance->begin();
@@ -99,13 +105,16 @@ EncodedJSValue RuntimeObject::fieldGetter(ExecState* exec, EncodedJSValue slotBa
return JSValue::encode(result);
}
-EncodedJSValue RuntimeObject::methodGetter(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue, PropertyName propertyName)
+EncodedJSValue RuntimeObject::methodGetter(ExecState* exec, EncodedJSValue thisValue, PropertyName propertyName)
{
- RuntimeObject* thisObj = jsCast<RuntimeObject*>(JSValue::decode(slotBase));
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
+ RuntimeObject* thisObj = jsCast<RuntimeObject*>(JSValue::decode(thisValue));
RefPtr<Instance> instance = thisObj->m_instance;
if (!instance)
- return JSValue::encode(throwInvalidAccessError(exec));
+ return JSValue::encode(throwInvalidAccessError(exec, scope));
instance->begin();
@@ -118,9 +127,12 @@ EncodedJSValue RuntimeObject::methodGetter(ExecState* exec, EncodedJSValue slotB
bool RuntimeObject::getOwnPropertySlot(JSObject* object, ExecState *exec, PropertyName propertyName, PropertySlot& slot)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
RuntimeObject* thisObject = jsCast<RuntimeObject*>(object);
if (!thisObject->m_instance) {
- throwInvalidAccessError(exec);
+ throwInvalidAccessError(exec, scope);
return false;
}
@@ -161,25 +173,30 @@ bool RuntimeObject::getOwnPropertySlot(JSObject* object, ExecState *exec, Proper
return instance->getOwnPropertySlot(thisObject, exec, propertyName, slot);
}
-void RuntimeObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
+bool RuntimeObject::put(JSCell* cell, ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot& slot)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
RuntimeObject* thisObject = jsCast<RuntimeObject*>(cell);
if (!thisObject->m_instance) {
- throwInvalidAccessError(exec);
- return;
+ throwInvalidAccessError(exec, scope);
+ return false;
}
RefPtr<Instance> instance = thisObject->m_instance;
instance->begin();
// Set the value of the property.
+ bool result = false;
Field *aField = instance->getClass()->fieldNamed(propertyName, instance.get());
if (aField)
- aField->setValueToInstance(exec, instance.get(), value);
+ result = aField->setValueToInstance(exec, instance.get(), value);
else if (!instance->setValueOfUndefinedField(exec, propertyName, value))
- instance->put(thisObject, exec, propertyName, value, slot);
+ result = instance->put(thisObject, exec, propertyName, value, slot);
instance->end();
+ return result;
}
bool RuntimeObject::deleteProperty(JSCell*, ExecState*, PropertyName)
@@ -190,9 +207,12 @@ bool RuntimeObject::deleteProperty(JSCell*, ExecState*, PropertyName)
JSValue RuntimeObject::defaultValue(const JSObject* object, ExecState* exec, PreferredPrimitiveType hint)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
const RuntimeObject* thisObject = jsCast<const RuntimeObject*>(object);
if (!thisObject->m_instance)
- return throwInvalidAccessError(exec);
+ return throwInvalidAccessError(exec, scope);
RefPtr<Instance> instance = thisObject->m_instance;
@@ -204,8 +224,8 @@ JSValue RuntimeObject::defaultValue(const JSObject* object, ExecState* exec, Pre
static EncodedJSValue JSC_HOST_CALL callRuntimeObject(ExecState* exec)
{
- ASSERT(exec->callee()->inherits(RuntimeObject::info()));
- RefPtr<Instance> instance(static_cast<RuntimeObject*>(exec->callee())->getInternalInstance());
+ ASSERT(exec->jsCallee()->inherits(exec->vm(), RuntimeObject::info()));
+ RefPtr<Instance> instance(static_cast<RuntimeObject*>(exec->jsCallee())->getInternalInstance());
instance->begin();
JSValue result = instance->invokeDefaultMethod(exec);
instance->end();
@@ -216,21 +236,21 @@ CallType RuntimeObject::getCallData(JSCell* cell, CallData& callData)
{
RuntimeObject* thisObject = jsCast<RuntimeObject*>(cell);
if (!thisObject->m_instance)
- return CallTypeNone;
+ return CallType::None;
RefPtr<Instance> instance = thisObject->m_instance;
if (!instance->supportsInvokeDefaultMethod())
- return CallTypeNone;
+ return CallType::None;
callData.native.function = callRuntimeObject;
- return CallTypeHost;
+ return CallType::Host;
}
static EncodedJSValue JSC_HOST_CALL callRuntimeConstructor(ExecState* exec)
{
- JSObject* constructor = exec->callee();
- ASSERT(constructor->inherits(RuntimeObject::info()));
- RefPtr<Instance> instance(static_cast<RuntimeObject*>(exec->callee())->getInternalInstance());
+ JSObject* constructor = exec->jsCallee();
+ ASSERT(constructor->inherits(exec->vm(), RuntimeObject::info()));
+ RefPtr<Instance> instance(static_cast<RuntimeObject*>(exec->jsCallee())->getInternalInstance());
instance->begin();
ArgList args(exec);
JSValue result = instance->invokeConstruct(exec, args);
@@ -244,21 +264,24 @@ ConstructType RuntimeObject::getConstructData(JSCell* cell, ConstructData& const
{
RuntimeObject* thisObject = jsCast<RuntimeObject*>(cell);
if (!thisObject->m_instance)
- return ConstructTypeNone;
+ return ConstructType::None;
RefPtr<Instance> instance = thisObject->m_instance;
if (!instance->supportsConstruct())
- return ConstructTypeNone;
+ return ConstructType::None;
constructData.native.function = callRuntimeConstructor;
- return ConstructTypeHost;
+ return ConstructType::Host;
}
void RuntimeObject::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode)
{
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+
RuntimeObject* thisObject = jsCast<RuntimeObject*>(object);
if (!thisObject->m_instance) {
- throwInvalidAccessError(exec);
+ throwInvalidAccessError(exec, scope);
return;
}
@@ -269,9 +292,9 @@ void RuntimeObject::getOwnPropertyNames(JSObject* object, ExecState* exec, Prope
instance->end();
}
-JSObject* RuntimeObject::throwInvalidAccessError(ExecState* exec)
+JSObject* RuntimeObject::throwInvalidAccessError(ExecState* exec, ThrowScope& scope)
{
- return exec->vm().throwException(exec, createReferenceError(exec, "Trying to access object from destroyed plug-in."));
+ return throwException(exec, scope, createReferenceError(exec, "Trying to access object from destroyed plug-in."));
}
}