本文整理汇总了C++中PropertyDescriptor::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertyDescriptor::setValue方法的具体用法?C++ PropertyDescriptor::setValue怎么用?C++ PropertyDescriptor::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyDescriptor
的用法示例。
在下文中一共展示了PropertyDescriptor::setValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toPropertyDescriptor
// ES5 8.10.5 ToPropertyDescriptor
static bool toPropertyDescriptor(ExecState* exec, JSValue in, PropertyDescriptor& desc)
{
if (!in.isObject()) {
throwError(exec, createTypeError(exec, ASCIILiteral("Property description must be an object.")));
return false;
}
JSObject* description = asObject(in);
PropertySlot enumerableSlot(description);
if (description->getPropertySlot(exec, exec->propertyNames().enumerable, enumerableSlot)) {
desc.setEnumerable(enumerableSlot.getValue(exec, exec->propertyNames().enumerable).toBoolean(exec));
if (exec->hadException())
return false;
}
PropertySlot configurableSlot(description);
if (description->getPropertySlot(exec, exec->propertyNames().configurable, configurableSlot)) {
desc.setConfigurable(configurableSlot.getValue(exec, exec->propertyNames().configurable).toBoolean(exec));
if (exec->hadException())
return false;
}
JSValue value;
PropertySlot valueSlot(description);
if (description->getPropertySlot(exec, exec->propertyNames().value, valueSlot)) {
desc.setValue(valueSlot.getValue(exec, exec->propertyNames().value));
if (exec->hadException())
return false;
}
PropertySlot writableSlot(description);
if (description->getPropertySlot(exec, exec->propertyNames().writable, writableSlot)) {
desc.setWritable(writableSlot.getValue(exec, exec->propertyNames().writable).toBoolean(exec));
if (exec->hadException())
return false;
}
PropertySlot getSlot(description);
if (description->getPropertySlot(exec, exec->propertyNames().get, getSlot)) {
JSValue get = getSlot.getValue(exec, exec->propertyNames().get);
if (exec->hadException())
return false;
if (!get.isUndefined()) {
CallData callData;
if (getCallData(get, callData) == CallTypeNone) {
throwError(exec, createTypeError(exec, ASCIILiteral("Getter must be a function.")));
return false;
}
}
desc.setGetter(get);
}
PropertySlot setSlot(description);
if (description->getPropertySlot(exec, exec->propertyNames().set, setSlot)) {
JSValue set = setSlot.getValue(exec, exec->propertyNames().set);
if (exec->hadException())
return false;
if (!set.isUndefined()) {
CallData callData;
if (getCallData(set, callData) == CallTypeNone) {
throwError(exec, createTypeError(exec, ASCIILiteral("Setter must be a function.")));
return false;
}
}
desc.setSetter(set);
}
if (!desc.isAccessorDescriptor())
return true;
if (desc.value()) {
throwError(exec, createTypeError(exec, ASCIILiteral("Invalid property. 'value' present on property with getter or setter.")));
return false;
}
if (desc.writablePresent()) {
throwError(exec, createTypeError(exec, ASCIILiteral("Invalid property. 'writable' present on property with getter or setter.")));
return false;
}
return true;
}