本文整理汇总了C++中ObjectOpResult::ok方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectOpResult::ok方法的具体用法?C++ ObjectOpResult::ok怎么用?C++ ObjectOpResult::ok使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectOpResult
的用法示例。
在下文中一共展示了ObjectOpResult::ok方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: v
// ES 2017 draft 9.4.4.2
/* static */ bool
MappedArgumentsObject::obj_defineProperty(JSContext* cx, HandleObject obj, HandleId id,
Handle<PropertyDescriptor> desc, ObjectOpResult& result)
{
// Step 1.
Rooted<MappedArgumentsObject*> argsobj(cx, &obj->as<MappedArgumentsObject>());
// Steps 2-3.
bool isMapped = false;
if (JSID_IS_INT(id)) {
unsigned arg = unsigned(JSID_TO_INT(id));
isMapped = arg < argsobj->initialLength() && !argsobj->isElementDeleted(arg);
}
// Step 4.
Rooted<PropertyDescriptor> newArgDesc(cx, desc);
// Step 5.
if (!desc.isAccessorDescriptor() && isMapped) {
// Step 5.a.
if (desc.hasWritable() && !desc.writable()) {
if (!desc.hasValue()) {
RootedValue v(cx, argsobj->element(JSID_TO_INT(id)));
newArgDesc.setValue(v);
}
newArgDesc.setGetter(nullptr);
newArgDesc.setSetter(nullptr);
} else {
// In this case the live mapping is supposed to keep working,
// we have to pass along the Getter/Setter otherwise they are
// overwritten.
newArgDesc.setGetter(MappedArgGetter);
newArgDesc.setSetter(MappedArgSetter);
newArgDesc.value().setUndefined();
newArgDesc.attributesRef() |= JSPROP_IGNORE_VALUE;
}
}
// Step 6. NativeDefineProperty will lookup [[Value]] for us.
if (!NativeDefineProperty(cx, obj.as<NativeObject>(), id, newArgDesc, result))
return false;
// Step 7.
if (!result.ok())
return true;
// Step 8.
if (isMapped) {
unsigned arg = unsigned(JSID_TO_INT(id));
if (desc.isAccessorDescriptor()) {
if (!argsobj->markElementDeleted(cx, arg))
return false;
} else {
if (desc.hasValue()) {
RootedFunction callee(cx, &argsobj->callee());
RootedScript script(cx, JSFunction::getOrCreateScript(cx, callee));
if (!script)
return false;
argsobj->setElement(cx, arg, desc.value());
if (arg < script->functionNonDelazifying()->nargs())
TypeScript::SetArgument(cx, script, arg, desc.value());
}
if (desc.hasWritable() && !desc.writable()) {
if (!argsobj->markElementDeleted(cx, arg))
return false;
}
}
}
// Step 9.
return result.succeed();
}