本文整理汇总了C++中ObjectOpResult类的典型用法代码示例。如果您正苦于以下问题:C++ ObjectOpResult类的具体用法?C++ ObjectOpResult怎么用?C++ ObjectOpResult使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectOpResult类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: UnmappedArgSetter
static bool
UnmappedArgSetter(JSContext* cx, HandleObject obj, HandleId id, MutableHandleValue vp,
ObjectOpResult& result)
{
if (!obj->is<UnmappedArgumentsObject>())
return result.succeed();
Handle<UnmappedArgumentsObject*> argsobj = obj.as<UnmappedArgumentsObject>();
Rooted<PropertyDescriptor> desc(cx);
if (!GetOwnPropertyDescriptor(cx, argsobj, id, &desc))
return false;
MOZ_ASSERT(desc.object());
unsigned attrs = desc.attributes();
MOZ_ASSERT(!(attrs & JSPROP_READONLY));
attrs &= (JSPROP_ENUMERATE | JSPROP_PERMANENT); /* only valid attributes */
if (JSID_IS_INT(id)) {
unsigned arg = unsigned(JSID_TO_INT(id));
if (arg < argsobj->initialLength()) {
argsobj->setElement(cx, arg, vp);
return result.succeed();
}
} else {
MOZ_ASSERT(JSID_IS_ATOM(id, cx->names().length));
}
/*
* For simplicity we use delete/define to replace the property with a
* simple data property. Note that we rely on ArgumentsObject::obj_delProperty
* to clear the corresponding reserved slot so the GC can collect its value.
*/
ObjectOpResult ignored;
return NativeDeleteProperty(cx, argsobj, id, ignored) &&
NativeDefineProperty(cx, argsobj, id, vp, nullptr, nullptr, attrs, result);
}
示例2: handler
// ES8 rev 0c1bd3004329336774cbc90de727cd0cf5f11e93 9.5.10 Proxy.[[Delete]](P)
bool
ScriptedProxyHandler::delete_(JSContext* cx, HandleObject proxy, HandleId id,
ObjectOpResult& result) const
{
// Steps 2-4.
RootedObject handler(cx, ScriptedProxyHandler::handlerObject(proxy));
if (!handler) {
JS_ReportErrorNumberASCII(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
return false;
}
// Step 5.
RootedObject target(cx, proxy->as<ProxyObject>().target());
MOZ_ASSERT(target);
// Step 6.
RootedValue trap(cx);
if (!GetProxyTrap(cx, handler, cx->names().deleteProperty, &trap))
return false;
// Step 7.
if (trap.isUndefined())
return DeleteProperty(cx, target, id, result);
// Step 8.
bool booleanTrapResult;
{
RootedValue value(cx);
if (!IdToStringOrSymbol(cx, id, &value))
return false;
RootedValue targetVal(cx, ObjectValue(*target));
RootedValue trapResult(cx);
if (!Call(cx, trap, handler, targetVal, value, &trapResult))
return false;
booleanTrapResult = ToBoolean(trapResult);
}
// Step 9.
if (!booleanTrapResult)
return result.fail(JSMSG_PROXY_DELETE_RETURNED_FALSE);
// Step 10.
Rooted<PropertyDescriptor> desc(cx);
if (!GetOwnPropertyDescriptor(cx, target, id, &desc))
return false;
// Step 12.
if (desc.object() && !desc.configurable()) {
RootedValue v(cx, IdToValue(id));
ReportValueError(cx, JSMSG_CANT_DELETE, JSDVG_IGNORE_STACK, v, nullptr);
return false;
}
// Steps 11,13.
return result.succeed();
}
示例3: handler
// ES6 draft rev 32 (2 Feb 2014) 9.5.10 Proxy.[[Delete]](P)
bool
ScriptedDirectProxyHandler::delete_(JSContext* cx, HandleObject proxy, HandleId id,
ObjectOpResult& result) const
{
// step 2
RootedObject handler(cx, GetDirectProxyHandlerObject(proxy));
// step 3
if (!handler) {
JS_ReportErrorNumber(cx, GetErrorMessage, nullptr, JSMSG_PROXY_REVOKED);
return false;
}
// steps 4-5
RootedObject target(cx, proxy->as<ProxyObject>().target());
// steps 6-7
RootedValue trap(cx);
if (!GetProperty(cx, handler, handler, cx->names().deleteProperty, &trap))
return false;
// step 8
if (trap.isUndefined())
return DeleteProperty(cx, target, id, result);
// steps 9-10
RootedValue value(cx);
if (!IdToStringOrSymbol(cx, id, &value))
return false;
Value argv[] = {
ObjectValue(*target),
value
};
RootedValue trapResult(cx);
if (!Invoke(cx, ObjectValue(*handler), trap, ArrayLength(argv), argv, &trapResult))
return false;
// step 11
if (!ToBoolean(trapResult))
return result.fail(JSMSG_PROXY_DELETE_RETURNED_FALSE);
// steps 12-13
Rooted<PropertyDescriptor> desc(cx);
if (!GetOwnPropertyDescriptor(cx, target, id, &desc))
return false;
// step 14-15
if (desc.object() && !desc.configurable()) {
RootedValue v(cx, IdToValue(id));
ReportValueError(cx, JSMSG_CANT_DELETE, JSDVG_IGNORE_STACK, v, nullptr);
return false;
}
// step 16
return result.succeed();
}
示例4: ns
bool
ModuleNamespaceObject::ProxyHandler::delete_(JSContext* cx, HandleObject proxy, HandleId id,
ObjectOpResult& result) const
{
Rooted<ModuleNamespaceObject*> ns(cx, &proxy->as<ModuleNamespaceObject>());
if (ns->bindings().has(id))
return result.failReadOnly();
return result.succeed();
}
示例5: XPC_WN_MaybeResolvingSetPropertyStub
bool
XPC_WN_MaybeResolvingSetPropertyStub(JSContext* cx, HandleObject obj, HandleId id,
MutableHandleValue vp, ObjectOpResult& result)
{
result.succeed();
return XPC_WN_MaybeResolvingPropertyStub(cx, obj, id, vp);
}
示例6:
bool
OpaqueCrossCompartmentWrapper::defineProperty(JSContext* cx, HandleObject wrapper, HandleId id,
Handle<JSPropertyDescriptor> desc,
ObjectOpResult& result) const
{
return result.succeed();
}
示例7:
bool
ModuleNamespaceObject::ProxyHandler::preventExtensions(JSContext* cx, HandleObject proxy,
ObjectOpResult& result) const
{
result.succeed();
return true;
}
示例8: MappedArgSetter
static bool
MappedArgSetter(JSContext* cx, HandleObject obj, HandleId id, MutableHandleValue vp,
ObjectOpResult& result)
{
if (!obj->is<MappedArgumentsObject>())
return result.succeed();
Handle<MappedArgumentsObject*> argsobj = obj.as<MappedArgumentsObject>();
Rooted<PropertyDescriptor> desc(cx);
if (!GetOwnPropertyDescriptor(cx, argsobj, id, &desc))
return false;
MOZ_ASSERT(desc.object());
unsigned attrs = desc.attributes();
MOZ_ASSERT(!(attrs & JSPROP_READONLY));
attrs &= (JSPROP_ENUMERATE | JSPROP_PERMANENT); /* only valid attributes */
RootedFunction callee(cx, &argsobj->callee());
RootedScript script(cx, callee->getOrCreateScript(cx));
if (!script)
return false;
if (JSID_IS_INT(id)) {
unsigned arg = unsigned(JSID_TO_INT(id));
if (arg < argsobj->initialLength() && !argsobj->isElementDeleted(arg)) {
argsobj->setElement(cx, arg, vp);
if (arg < script->functionNonDelazifying()->nargs())
TypeScript::SetArgument(cx, script, arg, vp);
return result.succeed();
}
} else {
MOZ_ASSERT(JSID_IS_ATOM(id, cx->names().length) || JSID_IS_ATOM(id, cx->names().callee));
}
/*
* For simplicity we use delete/define to replace the property with a
* simple data property. Note that we rely on ArgumentsObject::obj_delProperty
* to clear the corresponding reserved slot so the GC can collect its value.
* Note also that we must define the property instead of setting it in case
* the user has changed the prototype to an object that has a setter for
* this id.
*/
ObjectOpResult ignored;
return NativeDeleteProperty(cx, argsobj, id, ignored) &&
NativeDefineProperty(cx, argsobj, id, vp, nullptr, nullptr, attrs, result);
}
示例9:
bool
SecurityWrapper<Base>::preventExtensions(JSContext *cx, HandleObject wrapper,
ObjectOpResult &result) const
{
// Just like BaseProxyHandler, SecurityWrappers claim by default to always
// be extensible, so as not to leak information about the state of the
// underlying wrapped thing.
return result.fail(JSMSG_CANT_CHANGE_EXTENSIBILITY);
}
示例10: object
bool
RObjectState::recover(JSContext* cx, SnapshotIterator& iter) const
{
RootedObject object(cx, &iter.read().toObject());
RootedValue val(cx);
if (object->is<UnboxedPlainObject>()) {
const UnboxedLayout& layout = object->as<UnboxedPlainObject>().layout();
RootedId id(cx);
RootedValue receiver(cx, ObjectValue(*object));
const UnboxedLayout::PropertyVector& properties = layout.properties();
for (size_t i = 0; i < properties.length(); i++) {
val = iter.read();
// This is the default placeholder value of MObjectState, when no
// properties are defined yet.
if (val.isUndefined())
continue;
id = NameToId(properties[i].name);
ObjectOpResult result;
// SetProperty can only fail due to OOM.
if (!SetProperty(cx, object, id, val, receiver, result))
return false;
if (!result)
return result.reportError(cx, object, id);
}
} else {
RootedNativeObject nativeObject(cx, &object->as<NativeObject>());
MOZ_ASSERT(nativeObject->slotSpan() == numSlots());
for (size_t i = 0; i < numSlots(); i++) {
val = iter.read();
nativeObject->setSlot(i, val);
}
}
val.setObject(*object);
iter.storeInstructionResult(val);
return true;
}
示例11: env_setProperty
static bool
env_setProperty(JSContext* cx, HandleObject obj, HandleId id, MutableHandleValue vp,
ObjectOpResult& result)
{
/* XXX porting may be easy, but these don't seem to supply setenv by default */
#if !defined SOLARIS
JSString* valstr;
JS::Rooted<JSString*> idstr(cx);
int rv;
RootedValue idval(cx);
if (!JS_IdToValue(cx, id, &idval))
return false;
idstr = ToString(cx, idval);
valstr = ToString(cx, vp);
if (!idstr || !valstr)
return false;
JSAutoByteString name(cx, idstr);
if (!name)
return false;
JSAutoByteString value(cx, valstr);
if (!value)
return false;
#if defined XP_WIN || defined HPUX || defined OSF1 || defined SCO
{
char* waste = JS_smprintf("%s=%s", name.ptr(), value.ptr());
if (!waste) {
JS_ReportOutOfMemory(cx);
return false;
}
rv = putenv(waste);
#ifdef XP_WIN
/*
* HPUX9 at least still has the bad old non-copying putenv.
*
* Per mail from <[email protected]>, OSF1 also has a putenv
* that will crash if you pass it an auto char array (so it must place
* its argument directly in the char* environ[] array).
*/
free(waste);
#endif
}
#else
rv = setenv(name.ptr(), value.ptr(), 1);
#endif
if (rv < 0) {
JS_ReportError(cx, "can't set envariable %s to %s", name.ptr(), value.ptr());
return false;
}
vp.setString(valstr);
#endif /* !defined SOLARIS */
return result.succeed();
}
示例12: XPC_WN_MaybeResolvingDeletePropertyStub
bool
XPC_WN_MaybeResolvingDeletePropertyStub(JSContext* cx, HandleObject obj, HandleId id,
ObjectOpResult& result)
{
XPCCallContext ccx(cx, obj);
XPCWrappedNative* wrapper = ccx.GetWrapper();
THROW_AND_RETURN_IF_BAD_WRAPPER(cx, wrapper);
if (ccx.GetResolvingWrapper() == wrapper) {
return result.succeed();
}
return Throw(NS_ERROR_XPC_CANT_MODIFY_PROP_ON_WN, cx);
}
示例13: SetProperty
bool
SetProperty(JSContext* cx, HandleObject obj, HandlePropertyName name, HandleValue value,
bool strict, jsbytecode* pc)
{
RootedId id(cx, NameToId(name));
JSOp op = JSOp(*pc);
if (op == JSOP_SETALIASEDVAR) {
// Aliased var assigns ignore readonly attributes on the property, as
// required for initializing 'const' closure variables.
Shape* shape = obj->as<NativeObject>().lookup(cx, name);
MOZ_ASSERT(shape && shape->hasSlot());
obj->as<NativeObject>().setSlotWithType(cx, shape, value);
return true;
}
RootedValue receiver(cx, ObjectValue(*obj));
ObjectOpResult result;
if (MOZ_LIKELY(!obj->getOps()->setProperty)) {
if (!NativeSetProperty(
cx, obj.as<NativeObject>(), id, value, receiver,
(op == JSOP_SETNAME || op == JSOP_STRICTSETNAME ||
op == JSOP_SETGNAME || op == JSOP_STRICTSETGNAME)
? Unqualified
: Qualified,
result))
{
return false;
}
} else {
if (!SetProperty(cx, obj, id, value, receiver, result))
return false;
}
return result.checkStrictErrorOrWarning(cx, obj, id, strict);
}
示例14: unsigned
/* static */ bool
ArgumentsObject::obj_delProperty(JSContext* cx, HandleObject obj, HandleId id,
ObjectOpResult& result)
{
ArgumentsObject& argsobj = obj->as<ArgumentsObject>();
if (JSID_IS_INT(id)) {
unsigned arg = unsigned(JSID_TO_INT(id));
if (arg < argsobj.initialLength() && !argsobj.isElementDeleted(arg)) {
if (!argsobj.markElementDeleted(cx, arg))
return false;
}
} else if (JSID_IS_ATOM(id, cx->names().length)) {
argsobj.markLengthOverridden();
} else if (JSID_IS_ATOM(id, cx->names().callee)) {
argsobj.as<MappedArgumentsObject>().markCalleeOverridden();
} else if (JSID_IS_SYMBOL(id) && JSID_TO_SYMBOL(id) == cx->wellKnownSymbols().iterator) {
argsobj.markIteratorOverridden();
}
return result.succeed();
}
示例15: SetPropertyIgnoringNamedGetter
bool
DOMProxyHandler::set(JSContext *cx, Handle<JSObject*> proxy, Handle<jsid> id,
Handle<JS::Value> v, Handle<JS::Value> receiver,
ObjectOpResult &result) const
{
MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
"Should not have a XrayWrapper here");
bool done;
if (!setCustom(cx, proxy, id, v, &done)) {
return false;
}
if (done) {
return result.succeed();
}
// Make sure to ignore our named properties when checking for own
// property descriptors for a set.
JS::Rooted<PropertyDescriptor> ownDesc(cx);
if (!getOwnPropDescriptor(cx, proxy, id, /* ignoreNamedProps = */ true,
&ownDesc)) {
return false;
}
return js::SetPropertyIgnoringNamedGetter(cx, proxy, id, v, receiver, ownDesc, result);
}