setPropertyForKey method
void
setPropertyForKey(
- String propertyKey,
- JSValue value, {
- JSPropertyAttributes attributes = JSPropertyAttributes.kJSPropertyAttributeNone,
Sets a property on an object using a JSValueRef as the property key.
This function is the same as performing "objectpropertyKey
= value" from JavaScript.
propertyKey
(JSValueRef) A JSValueRef containing the property key to use when looking up the property.
value
(JSValueRef) A JSValueRef to use as the property's value.
attributes
(JSPropertyAttributes) A logically ORed set of JSPropertyAttributes to give to the property.
exception
(JSValueRef*) A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception.
Implementation
void setPropertyForKey(
String propertyKey,
JSValue value, {
JSPropertyAttributes attributes =
JSPropertyAttributes.kJSPropertyAttributeNone,
}) {
final JSException exception = JSException.create(context);
final JSValue jspropKey = JSValue.makeString(context, propertyKey);
JSObjectSetPropertyForKey(
context.ref,
_ref,
jspropKey.ref,
value.ref,
JSPropertyAttributes.values.indexOf(attributes),
exception.ref,
);
if (exception.shouldThrow) throw exception.error;
}