return toRef(jsValue);
}
-bool JSObjectSetProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes)
+void JSObjectSetProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes)
{
JSLock lock;
ExecState* exec = toJS(context);
UString::Rep* nameRep = toJS(propertyName);
JSValue* jsValue = toJS(value);
- Identifier jsNameID = Identifier(nameRep);
- if (jsObject->canPut(exec, jsNameID)) {
- jsObject->put(exec, jsNameID, jsValue, attributes);
- return true;
- } else
- return false;
+ jsObject->put(exec, Identifier(nameRep), jsValue, attributes);
+}
+
+JSValueRef JSObjectGetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex)
+{
+ JSLock lock;
+ ExecState* exec = toJS(context);
+ JSObject* jsObject = toJS(object);
+
+ JSValue* jsValue = jsObject->get(exec, propertyIndex);
+ if (jsValue->isUndefined())
+ return 0;
+ return toRef(jsValue);
+}
+
+
+void JSObjectSetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex, JSValueRef value)
+{
+ JSLock lock;
+ ExecState* exec = toJS(context);
+ JSObject* jsObject = toJS(object);
+ JSValue* jsValue = toJS(value);
+
+ jsObject->put(exec, propertyIndex, jsValue);
}
bool JSObjectDeleteProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
@result true if the object has a property whose name matches propertyName, otherwise false.
*/
bool JSObjectHasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+
/*!
@function
@abstract Gets a property from an object.
@result The property's value if object has the property, otherwise NULL.
*/
JSValueRef JSObjectGetProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+
/*!
@function
@abstract Sets a property on an object.
@param propertyName A JSString containing the property's name.
@param value A JSValue to use as the property's value.
@param attributes A logically ORed set of JSPropertyAttributes to give to the property.
-@result true if the set operation succeeds, otherwise false (for example, if the object already has a property of the given name with the kJSPropertyAttributeReadOnly attribute set).
*/
-bool JSObjectSetProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes);
+void JSObjectSetProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSPropertyAttributes attributes);
+
/*!
@function
@abstract Deletes a property from an object.
*/
bool JSObjectDeleteProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+/*!
+@function
+@abstract Gets a property from an object by numeric index.
+@param context The execution context to use.
+@param object The JSObject whose property you want to get.
+@param propertyIndex The property's name as a number
+@result The property's value if object has the property, otherwise NULL.
+@discussion This is equivalent to getting a property by a string name containing the number, but allows faster access to JS arrays.
+*/
+JSValueRef JSObjectGetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex);
+
+/*!
+@function
+@abstract Sets a property on an object by numeric index.
+@param context The execution context to use.
+@param object The JSObject whose property you want to set.
+@param propertyIndex The property's name as a number
+@param value A JSValue to use as the property's value.
+@param attributes A logically ORed set of JSPropertyAttributes to give to the property.
+@discussion This is equivalent to setting a property by a string name containing the number, but allows faster access to JS arrays.
+*/
+void JSObjectSetPropertyAtIndex(JSContextRef context, JSObjectRef object, unsigned propertyIndex, JSValueRef value, JSPropertyAttributes attributes);
+
/*!
@function
@abstract Gets a pointer to private data from an object.
@discussion JSObjectGetPrivate and JSObjectSetPrivate only work on custom objects created by JSObjectMake, JSObjectMakeFunction, and JSObjectMakeConstructor.
*/
void* JSObjectGetPrivate(JSObjectRef object);
+
/*!
@function
@abstract Sets a pointer to private data on an object.
+2006-07-14 Maciej Stachowiak <mjs@apple.com>
+
+ Reviewed by Geoff.
+
+ - removed bool return value from JSObjectSetProperty, since it is inefficient and
+ also doesn't work quite right
+ - added JSObjectGetPropertyAtIndex and JSObjectSetPropertyAtIndex
+
+ * API/JSObjectRef.cpp:
+ (JSObjectSetProperty): Removed return value and canPut stuff.
+ (JSObjectGetPropertyAtIndex): Added.
+ (JSObjectSetPropertyAtIndex): Added.
+ * API/JSObjectRef.h: Prototyped and documented new functions.
+
2006-07-14 Geoffrey Garen <ggaren@apple.com>
Reviewed by Beth.