diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2009-06-15 09:06:43 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-06-15 09:31:31 (GMT) |
commit | c411f16870f112c3407c28c22b617f613a82cff4 (patch) | |
tree | 29a1bcd590c8b31af2aab445bfe8a978dc5bf582 /src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObjectFunctions.h | |
parent | 3d77b56b32a0c53ec0bbfaa07236fedb900ff336 (diff) | |
download | Qt-c411f16870f112c3407c28c22b617f613a82cff4.zip Qt-c411f16870f112c3407c28c22b617f613a82cff4.tar.gz Qt-c411f16870f112c3407c28c22b617f613a82cff4.tar.bz2 |
Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit-4.6-snapshot-15062009 ( 65232bf00dc494ebfd978f998c88f58d18ecce1e )
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObjectFunctions.h')
-rw-r--r-- | src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObjectFunctions.h | 152 |
1 files changed, 113 insertions, 39 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObjectFunctions.h b/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObjectFunctions.h index fdbafbc..987c59f 100644 --- a/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObjectFunctions.h +++ b/src/3rdparty/webkit/JavaScriptCore/API/JSCallbackObjectFunctions.h @@ -40,7 +40,7 @@ namespace JSC { template <class Base> -inline JSCallbackObject<Base>* JSCallbackObject<Base>::asCallbackObject(JSValuePtr value) +inline JSCallbackObject<Base>* JSCallbackObject<Base>::asCallbackObject(JSValue value) { ASSERT(asObject(value)->inherits(&info)); return static_cast<JSCallbackObject*>(asObject(value)); @@ -99,7 +99,7 @@ template <class Base> UString JSCallbackObject<Base>::className() const { UString thisClassName = classRef()->className(); - if (!thisClassName.isNull()) + if (!thisClassName.isEmpty()) return thisClassName; return Base::className(); @@ -125,9 +125,19 @@ bool JSCallbackObject<Base>::getOwnPropertySlot(ExecState* exec, const Identifie } else if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { if (!propertyNameRef) propertyNameRef = OpaqueJSString::create(propertyName.ustring()); - JSLock::DropAllLocks dropAllLocks(exec); - if (JSValueRef value = getProperty(ctx, thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) { - slot.setValue(toJS(value)); + JSValueRef exception = 0; + JSValueRef value; + { + JSLock::DropAllLocks dropAllLocks(exec); + value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception); + } + exec->setException(toJS(exec, exception)); + if (value) { + slot.setValue(toJS(exec, value)); + return true; + } + if (exception) { + slot.setValue(jsUndefined()); return true; } } @@ -157,19 +167,25 @@ bool JSCallbackObject<Base>::getOwnPropertySlot(ExecState* exec, unsigned proper } template <class Base> -void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName, JSValuePtr value, PutPropertySlot& slot) +void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName, JSValue value, PutPropertySlot& slot) { JSContextRef ctx = toRef(exec); JSObjectRef thisRef = toRef(this); RefPtr<OpaqueJSString> propertyNameRef; - JSValueRef valueRef = toRef(value); + JSValueRef valueRef = toRef(exec, value); for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectSetPropertyCallback setProperty = jsClass->setProperty) { if (!propertyNameRef) propertyNameRef = OpaqueJSString::create(propertyName.ustring()); - JSLock::DropAllLocks dropAllLocks(exec); - if (setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, toRef(exec->exceptionSlot()))) + JSValueRef exception = 0; + bool result; + { + JSLock::DropAllLocks dropAllLocks(exec); + result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); + } + exec->setException(toJS(exec, exception)); + if (result || exception) return; } @@ -180,8 +196,14 @@ void JSCallbackObject<Base>::put(ExecState* exec, const Identifier& propertyName if (JSObjectSetPropertyCallback setProperty = entry->setProperty) { if (!propertyNameRef) propertyNameRef = OpaqueJSString::create(propertyName.ustring()); - JSLock::DropAllLocks dropAllLocks(exec); - if (setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, toRef(exec->exceptionSlot()))) + JSValueRef exception = 0; + bool result; + { + JSLock::DropAllLocks dropAllLocks(exec); + result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); + } + exec->setException(toJS(exec, exception)); + if (result || exception) return; } else throwError(exec, ReferenceError, "Attempt to set a property that is not settable."); @@ -212,8 +234,14 @@ bool JSCallbackObject<Base>::deleteProperty(ExecState* exec, const Identifier& p if (JSObjectDeletePropertyCallback deleteProperty = jsClass->deleteProperty) { if (!propertyNameRef) propertyNameRef = OpaqueJSString::create(propertyName.ustring()); - JSLock::DropAllLocks dropAllLocks(exec); - if (deleteProperty(ctx, thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) + JSValueRef exception = 0; + bool result; + { + JSLock::DropAllLocks dropAllLocks(exec); + result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception); + } + exec->setException(toJS(exec, exception)); + if (result || exception) return true; } @@ -266,9 +294,15 @@ JSObject* JSCallbackObject<Base>::construct(ExecState* exec, JSObject* construct int argumentCount = static_cast<int>(args.size()); Vector<JSValueRef, 16> arguments(argumentCount); for (int i = 0; i < argumentCount; i++) - arguments[i] = toRef(args.at(exec, i)); - JSLock::DropAllLocks dropAllLocks(exec); - return toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); + arguments[i] = toRef(exec, args.at(i)); + JSValueRef exception = 0; + JSObject* result; + { + JSLock::DropAllLocks dropAllLocks(exec); + result = toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), &exception)); + } + exec->setException(toJS(exec, exception)); + return result; } } @@ -277,15 +311,21 @@ JSObject* JSCallbackObject<Base>::construct(ExecState* exec, JSObject* construct } template <class Base> -bool JSCallbackObject<Base>::hasInstance(ExecState* exec, JSValuePtr value, JSValuePtr) +bool JSCallbackObject<Base>::hasInstance(ExecState* exec, JSValue value, JSValue) { JSContextRef execRef = toRef(exec); JSObjectRef thisRef = toRef(this); for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectHasInstanceCallback hasInstance = jsClass->hasInstance) { - JSLock::DropAllLocks dropAllLocks(exec); - return hasInstance(execRef, thisRef, toRef(value), toRef(exec->exceptionSlot())); + JSValueRef exception = 0; + bool result; + { + JSLock::DropAllLocks dropAllLocks(exec); + result = hasInstance(execRef, thisRef, toRef(exec, value), &exception); + } + exec->setException(toJS(exec, exception)); + return result; } } return false; @@ -304,25 +344,31 @@ CallType JSCallbackObject<Base>::getCallData(CallData& callData) } template <class Base> -JSValuePtr JSCallbackObject<Base>::call(ExecState* exec, JSObject* functionObject, JSValuePtr thisValue, const ArgList& args) +JSValue JSCallbackObject<Base>::call(ExecState* exec, JSObject* functionObject, JSValue thisValue, const ArgList& args) { JSContextRef execRef = toRef(exec); JSObjectRef functionRef = toRef(functionObject); - JSObjectRef thisObjRef = toRef(thisValue->toThisObject(exec)); + JSObjectRef thisObjRef = toRef(thisValue.toThisObject(exec)); for (JSClassRef jsClass = static_cast<JSCallbackObject<Base>*>(functionObject)->classRef(); jsClass; jsClass = jsClass->parentClass) { if (JSObjectCallAsFunctionCallback callAsFunction = jsClass->callAsFunction) { int argumentCount = static_cast<int>(args.size()); Vector<JSValueRef, 16> arguments(argumentCount); for (int i = 0; i < argumentCount; i++) - arguments[i] = toRef(args.at(exec, i)); - JSLock::DropAllLocks dropAllLocks(exec); - return toJS(callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), toRef(exec->exceptionSlot()))); + arguments[i] = toRef(exec, args.at(i)); + JSValueRef exception = 0; + JSValue result; + { + JSLock::DropAllLocks dropAllLocks(exec); + result = toJS(exec, callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception)); + } + exec->setException(toJS(exec, exception)); + return result; } } ASSERT_NOT_REACHED(); // getCallData should prevent us from reaching here - return noValue(); + return JSValue(); } template <class Base> @@ -376,9 +422,17 @@ double JSCallbackObject<Base>::toNumber(ExecState* exec) const for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { - JSLock::DropAllLocks dropAllLocks(exec); - if (JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, toRef(exec->exceptionSlot()))) - return toJS(value)->getNumber(); + JSValueRef exception = 0; + JSValueRef value; + { + JSLock::DropAllLocks dropAllLocks(exec); + value = convertToType(ctx, thisRef, kJSTypeNumber, &exception); + } + exec->setException(toJS(exec, exception)); + if (value) { + double dValue; + return toJS(exec, value).getNumber(dValue) ? dValue : NaN; + } } return Base::toNumber(exec); @@ -392,13 +446,17 @@ UString JSCallbackObject<Base>::toString(ExecState* exec) const for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { + JSValueRef exception = 0; JSValueRef value; { JSLock::DropAllLocks dropAllLocks(exec); - value = convertToType(ctx, thisRef, kJSTypeString, toRef(exec->exceptionSlot())); + value = convertToType(ctx, thisRef, kJSTypeString, &exception); } + exec->setException(toJS(exec, exception)); if (value) - return toJS(value)->getString(); + return toJS(exec, value).getString(); + if (exception) + return ""; } return Base::toString(exec); @@ -427,7 +485,7 @@ bool JSCallbackObject<Base>::inherits(JSClassRef c) const } template <class Base> -JSValuePtr JSCallbackObject<Base>::staticValueGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValue JSCallbackObject<Base>::staticValueGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSCallbackObject* thisObj = asCallbackObject(slot.slotBase()); @@ -440,16 +498,24 @@ JSValuePtr JSCallbackObject<Base>::staticValueGetter(ExecState* exec, const Iden if (JSObjectGetPropertyCallback getProperty = entry->getProperty) { if (!propertyNameRef) propertyNameRef = OpaqueJSString::create(propertyName.ustring()); - JSLock::DropAllLocks dropAllLocks(exec); - if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) - return toJS(value); + JSValueRef exception = 0; + JSValueRef value; + { + JSLock::DropAllLocks dropAllLocks(exec); + value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception); + } + exec->setException(toJS(exec, exception)); + if (value) + return toJS(exec, value); + if (exception) + return jsUndefined(); } return throwError(exec, ReferenceError, "Static value property defined with NULL getProperty callback."); } template <class Base> -JSValuePtr JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValue JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSCallbackObject* thisObj = asCallbackObject(slot.slotBase()); @@ -474,7 +540,7 @@ JSValuePtr JSCallbackObject<Base>::staticFunctionGetter(ExecState* exec, const I } template <class Base> -JSValuePtr JSCallbackObject<Base>::callbackGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) +JSValue JSCallbackObject<Base>::callbackGetter(ExecState* exec, const Identifier& propertyName, const PropertySlot& slot) { JSCallbackObject* thisObj = asCallbackObject(slot.slotBase()); @@ -485,9 +551,17 @@ JSValuePtr JSCallbackObject<Base>::callbackGetter(ExecState* exec, const Identif if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { if (!propertyNameRef) propertyNameRef = OpaqueJSString::create(propertyName.ustring()); - JSLock::DropAllLocks dropAllLocks(exec); - if (JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), toRef(exec->exceptionSlot()))) - return toJS(value); + JSValueRef exception = 0; + JSValueRef value; + { + JSLock::DropAllLocks dropAllLocks(exec); + value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception); + } + exec->setException(toJS(exec, exception)); + if (value) + return toJS(exec, value); + if (exception) + return jsUndefined(); } return throwError(exec, ReferenceError, "hasProperty callback returned true for a property that doesn't exist."); |