Reviewed by Maciej.
- Change getProperty* to return undefined, rather than NULL, for missing
properties, since that's what the spec says. Also added exception out
parameters to the *Index functions, because they can call through to the
regular functions, which can throw for custom objects.
* API/JSObjectRef.cpp:
(JSObjectGetProperty):
(JSObjectGetPropertyAtIndex):
(JSObjectSetPropertyAtIndex):
* API/JSObjectRef.h:
* API/testapi.c:
(main):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15474 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/JavaScriptCore/API/JSObjectRef.cpp b/JavaScriptCore/API/JSObjectRef.cpp
index 7fc0136..a2619e5 100644
--- a/JavaScriptCore/API/JSObjectRef.cpp
+++ b/JavaScriptCore/API/JSObjectRef.cpp
@@ -148,8 +148,6 @@
UString::Rep* nameRep = toJS(propertyName);
JSValue* jsValue = jsObject->get(exec, Identifier(nameRep));
- if (jsValue->isUndefined())
- jsValue = 0;
if (exec->hadException()) {
if (exception)
*exception = toRef(exec->exception());
@@ -174,20 +172,23 @@
}
}
-JSValueRef JSObjectGetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex)
+JSValueRef JSObjectGetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex, JSValueRef* exception)
{
JSLock lock;
ExecState* exec = toJS(context);
JSObject* jsObject = toJS(object);
JSValue* jsValue = jsObject->get(exec, propertyIndex);
- if (jsValue->isUndefined())
- return 0;
+ if (exec->hadException()) {
+ if (exception)
+ *exception = toRef(exec->exception());
+ exec->clearException();
+ }
return toRef(jsValue);
}
-void JSObjectSetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex, JSValueRef value)
+void JSObjectSetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSValueRef* exception)
{
JSLock lock;
ExecState* exec = toJS(context);
@@ -195,6 +196,11 @@
JSValue* jsValue = toJS(value);
jsObject->put(exec, propertyIndex, jsValue);
+ if (exec->hadException()) {
+ if (exception)
+ *exception = toRef(exec->exception());
+ exec->clearException();
+ }
}
bool JSObjectDeleteProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)