diff options
author | Feng Qian <fqian@google.com> | 2009-06-17 12:12:20 -0700 |
---|---|---|
committer | Feng Qian <fqian@google.com> | 2009-06-17 12:12:20 -0700 |
commit | 5f1ab04193ad0130ca8204aadaceae083aca9881 (patch) | |
tree | 5a92cd389e2cfe7fb67197ce14b38469462379f8 /JavaScriptCore/API/JSCallbackObjectFunctions.h | |
parent | 194315e5a908cc8ed67d597010544803eef1ac59 (diff) | |
download | external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.zip external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.tar.gz external_webkit-5f1ab04193ad0130ca8204aadaceae083aca9881.tar.bz2 |
Get WebKit r44544.
Diffstat (limited to 'JavaScriptCore/API/JSCallbackObjectFunctions.h')
-rw-r--r-- | JavaScriptCore/API/JSCallbackObjectFunctions.h | 128 |
1 files changed, 78 insertions, 50 deletions
diff --git a/JavaScriptCore/API/JSCallbackObjectFunctions.h b/JavaScriptCore/API/JSCallbackObjectFunctions.h index d6ae9bd..987c59f 100644 --- a/JavaScriptCore/API/JSCallbackObjectFunctions.h +++ b/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)); @@ -125,12 +125,15 @@ 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); JSValueRef exception = 0; - JSValueRef value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception); - exec->setException(toJS(exception)); + JSValueRef value; + { + JSLock::DropAllLocks dropAllLocks(exec); + value = getProperty(ctx, thisRef, propertyNameRef.get(), &exception); + } + exec->setException(toJS(exec, exception)); if (value) { - slot.setValue(toJS(value)); + slot.setValue(toJS(exec, value)); return true; } if (exception) { @@ -164,21 +167,24 @@ 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); JSValueRef exception = 0; - bool result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); - exec->setException(toJS(exception)); + bool result; + { + JSLock::DropAllLocks dropAllLocks(exec); + result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); + } + exec->setException(toJS(exec, exception)); if (result || exception) return; } @@ -190,10 +196,13 @@ 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); JSValueRef exception = 0; - bool result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); - exec->setException(toJS(exception)); + bool result; + { + JSLock::DropAllLocks dropAllLocks(exec); + result = setProperty(ctx, thisRef, propertyNameRef.get(), valueRef, &exception); + } + exec->setException(toJS(exec, exception)); if (result || exception) return; } else @@ -225,10 +234,13 @@ 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); JSValueRef exception = 0; - bool result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception); - exec->setException(toJS(exception)); + bool result; + { + JSLock::DropAllLocks dropAllLocks(exec); + result = deleteProperty(ctx, thisRef, propertyNameRef.get(), &exception); + } + exec->setException(toJS(exec, exception)); if (result || exception) return true; } @@ -282,11 +294,14 @@ 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); + arguments[i] = toRef(exec, args.at(i)); JSValueRef exception = 0; - JSObject* result = toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), &exception)); - exec->setException(toJS(exception)); + JSObject* result; + { + JSLock::DropAllLocks dropAllLocks(exec); + result = toJS(callAsConstructor(execRef, constructorRef, argumentCount, arguments.data(), &exception)); + } + exec->setException(toJS(exec, exception)); return result; } } @@ -296,17 +311,20 @@ 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); JSValueRef exception = 0; - bool result = hasInstance(execRef, thisRef, toRef(value), &exception); - exec->setException(toJS(exception)); + bool result; + { + JSLock::DropAllLocks dropAllLocks(exec); + result = hasInstance(execRef, thisRef, toRef(exec, value), &exception); + } + exec->setException(toJS(exec, exception)); return result; } } @@ -326,7 +344,7 @@ 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); @@ -337,17 +355,20 @@ JSValuePtr JSCallbackObject<Base>::call(ExecState* exec, JSObject* functionObjec 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); + arguments[i] = toRef(exec, args.at(i)); JSValueRef exception = 0; - JSValuePtr result = toJS(callAsFunction(execRef, functionRef, thisObjRef, argumentCount, arguments.data(), &exception)); - exec->setException(toJS(exception)); + 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> @@ -401,14 +422,16 @@ double JSCallbackObject<Base>::toNumber(ExecState* exec) const for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { - JSLock::DropAllLocks dropAllLocks(exec); - JSValueRef exception = 0; - JSValueRef value = convertToType(ctx, thisRef, kJSTypeNumber, &exception); - exec->setException(toJS(exception)); + JSValueRef value; + { + JSLock::DropAllLocks dropAllLocks(exec); + value = convertToType(ctx, thisRef, kJSTypeNumber, &exception); + } + exec->setException(toJS(exec, exception)); if (value) { double dValue; - return toJS(value).getNumber(dValue) ? dValue : NaN; + return toJS(exec, value).getNumber(dValue) ? dValue : NaN; } } @@ -423,15 +446,15 @@ UString JSCallbackObject<Base>::toString(ExecState* exec) const for (JSClassRef jsClass = classRef(); jsClass; jsClass = jsClass->parentClass) if (JSObjectConvertToTypeCallback convertToType = jsClass->convertToType) { - JSValueRef value; JSValueRef exception = 0; + JSValueRef value; { JSLock::DropAllLocks dropAllLocks(exec); value = convertToType(ctx, thisRef, kJSTypeString, &exception); - exec->setException(toJS(exception)); } + exec->setException(toJS(exec, exception)); if (value) - return toJS(value).getString(); + return toJS(exec, value).getString(); if (exception) return ""; } @@ -462,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()); @@ -475,12 +498,15 @@ JSValuePtr JSCallbackObject<Base>::staticValueGetter(ExecState* exec, const Iden if (JSObjectGetPropertyCallback getProperty = entry->getProperty) { if (!propertyNameRef) propertyNameRef = OpaqueJSString::create(propertyName.ustring()); - JSLock::DropAllLocks dropAllLocks(exec); JSValueRef exception = 0; - JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception); - exec->setException(toJS(exception)); + JSValueRef value; + { + JSLock::DropAllLocks dropAllLocks(exec); + value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception); + } + exec->setException(toJS(exec, exception)); if (value) - return toJS(value); + return toJS(exec, value); if (exception) return jsUndefined(); } @@ -489,7 +515,7 @@ JSValuePtr JSCallbackObject<Base>::staticValueGetter(ExecState* exec, const Iden } 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()); @@ -514,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()); @@ -525,13 +551,15 @@ JSValuePtr JSCallbackObject<Base>::callbackGetter(ExecState* exec, const Identif if (JSObjectGetPropertyCallback getProperty = jsClass->getProperty) { if (!propertyNameRef) propertyNameRef = OpaqueJSString::create(propertyName.ustring()); - JSLock::DropAllLocks dropAllLocks(exec); - JSValueRef exception = 0; - JSValueRef value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception); - exec->setException(toJS(exception)); + JSValueRef value; + { + JSLock::DropAllLocks dropAllLocks(exec); + value = getProperty(toRef(exec), thisRef, propertyNameRef.get(), &exception); + } + exec->setException(toJS(exec, exception)); if (value) - return toJS(value); + return toJS(exec, value); if (exception) return jsUndefined(); } |