本文整理汇总了C++中MutableHandle::value方法的典型用法代码示例。如果您正苦于以下问题:C++ MutableHandle::value方法的具体用法?C++ MutableHandle::value怎么用?C++ MutableHandle::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MutableHandle
的用法示例。
在下文中一共展示了MutableHandle::value方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: value
bool
JSCompartment::wrap(JSContext *cx, MutableHandle<PropDesc> desc)
{
if (desc.isUndefined())
return true;
JSCompartment *comp = cx->compartment();
if (desc.hasValue()) {
RootedValue value(cx, desc.value());
if (!comp->wrap(cx, &value))
return false;
desc.setValue(value);
}
if (desc.hasGet()) {
RootedValue get(cx, desc.getterValue());
if (!comp->wrap(cx, &get))
return false;
desc.setGetter(get);
}
if (desc.hasSet()) {
RootedValue set(cx, desc.setterValue());
if (!comp->wrap(cx, &set))
return false;
desc.setSetter(set);
}
return true;
}
示例2: getOwnPropertyDescriptor
bool
WaiveXrayWrapper::getOwnPropertyDescriptor(JSContext* cx, HandleObject wrapper, HandleId id,
MutableHandle<PropertyDescriptor> desc) const
{
return CrossCompartmentWrapper::getOwnPropertyDescriptor(cx, wrapper, id, desc) &&
WrapperFactory::WaiveXrayAndWrap(cx, desc.value()) && WaiveAccessors(cx, desc);
}
示例3: if
bool
JavaScriptShared::toDescriptor(JSContext* cx, const PPropertyDescriptor& in,
MutableHandle<JSPropertyDescriptor> out)
{
out.setAttributes(in.attrs());
if (!fromVariant(cx, in.value(), out.value()))
return false;
out.object().set(fromObjectOrNullVariant(cx, in.obj()));
if (in.getter().type() == GetterSetter::Tuint64_t && !in.getter().get_uint64_t()) {
out.setGetter(nullptr);
} else if (in.attrs() & JSPROP_GETTER) {
Rooted<JSObject*> getter(cx);
getter = fromObjectVariant(cx, in.getter().get_ObjectVariant());
if (!getter)
return false;
out.setGetter(JS_DATA_TO_FUNC_PTR(JSGetterOp, getter.get()));
} else {
out.setGetter(UnknownPropertyStub);
}
if (in.setter().type() == GetterSetter::Tuint64_t && !in.setter().get_uint64_t()) {
out.setSetter(nullptr);
} else if (in.attrs() & JSPROP_SETTER) {
Rooted<JSObject*> setter(cx);
setter = fromObjectVariant(cx, in.setter().get_ObjectVariant());
if (!setter)
return false;
out.setSetter(JS_DATA_TO_FUNC_PTR(JSSetterOp, setter.get()));
} else {
out.setSetter(UnknownStrictPropertyStub);
}
return true;
}
示例4: Throw
bool
js::SetPropertyIgnoringNamedGetter(JSContext* cx, const BaseProxyHandler* handler,
HandleObject proxy, HandleObject receiver,
HandleId id, MutableHandle<PropertyDescriptor> desc,
bool descIsOwn, bool strict, MutableHandleValue vp)
{
/* The control-flow here differs from ::get() because of the fall-through case below. */
MOZ_ASSERT_IF(descIsOwn, desc.object());
if (desc.object()) {
MOZ_ASSERT(desc.getter() != JS_PropertyStub);
MOZ_ASSERT(desc.setter() != JS_StrictPropertyStub);
// Check for read-only properties.
if (desc.isReadonly()) {
if (strict)
return Throw(cx, id, descIsOwn ? JSMSG_READ_ONLY : JSMSG_CANT_REDEFINE_PROP);
return true;
}
if (desc.hasSetterObject() || desc.setter()) {
if (!CallSetter(cx, receiver, id, desc.setter(), desc.attributes(), strict, vp))
return false;
if (!proxy->is<ProxyObject>() || proxy->as<ProxyObject>().handler() != handler)
return true;
if (desc.isShared())
return true;
}
desc.value().set(vp.get());
if (descIsOwn) {
MOZ_ASSERT(desc.object() == proxy);
return handler->defineProperty(cx, proxy, id, desc);
}
return DefineProperty(cx, receiver, id, desc.value(),
desc.getter(), desc.setter(), desc.attributes());
}
desc.object().set(receiver);
desc.value().set(vp.get());
desc.setAttributes(JSPROP_ENUMERATE);
desc.setGetter(nullptr);
desc.setSetter(nullptr); // Pick up the class getter/setter.
return DefineProperty(cx, receiver, id, desc.value(), nullptr, nullptr, JSPROP_ENUMERATE);
}
示例5: target
bool
DirectProxyHandler::defineProperty(JSContext *cx, HandleObject proxy, HandleId id,
MutableHandle<PropertyDescriptor> desc) const
{
assertEnteredPolicy(cx, proxy, id, SET);
RootedObject target(cx, proxy->as<ProxyObject>().target());
RootedValue v(cx, desc.value());
return CheckDefineProperty(cx, target, id, v, desc.attributes(), desc.getter(), desc.setter()) &&
JS_DefinePropertyById(cx, target, id, v, desc.attributes(), desc.getter(), desc.setter());
}
示例6: wrap
bool
JSCompartment::wrap(JSContext* cx, MutableHandle<PropertyDescriptor> desc)
{
if (!wrap(cx, desc.object()))
return false;
if (desc.hasGetterObject()) {
if (!wrap(cx, desc.getterObject()))
return false;
}
if (desc.hasSetterObject()) {
if (!wrap(cx, desc.setterObject()))
return false;
}
return wrap(cx, desc.value());
}
示例7: if
bool
JavaScriptShared::toDescriptor(JSContext *cx, const PPropertyDescriptor &in,
MutableHandle<JSPropertyDescriptor> out)
{
out.setAttributes(in.attrs());
out.setShortId(in.shortid());
if (!toValue(cx, in.value(), out.value()))
return false;
Rooted<JSObject*> obj(cx);
if (!unwrap(cx, in.objId(), &obj))
return false;
out.object().set(obj);
if (!in.getter()) {
out.setGetter(nullptr);
} else if (in.attrs() & JSPROP_GETTER) {
Rooted<JSObject*> getter(cx);
if (!unwrap(cx, in.getter(), &getter))
return false;
out.setGetter(JS_DATA_TO_FUNC_PTR(JSPropertyOp, getter.get()));
} else {
if (in.getter() == DefaultPropertyOp)
out.setGetter(JS_PropertyStub);
else
out.setGetter(UnknownPropertyStub);
}
if (!in.setter()) {
out.setSetter(nullptr);
} else if (in.attrs() & JSPROP_SETTER) {
Rooted<JSObject*> setter(cx);
if (!unwrap(cx, in.setter(), &setter))
return false;
out.setSetter(JS_DATA_TO_FUNC_PTR(JSStrictPropertyOp, setter.get()));
} else {
if (in.setter() == DefaultPropertyOp)
out.setSetter(JS_StrictPropertyStub);
else if (in.setter() == GetterOnlyPropertyStub)
out.setSetter(js_GetterOnlyPropertyStub);
else
out.setSetter(UnknownStrictPropertyStub);
}
return true;
}
示例8: impl
bool impl(JSContext *cx, HandleObject proxy, HandleId id,
MutableHandle<JSPropertyDescriptor> desc, bool ownOnly) const
{
if (JSID_IS_STRING(id)) {
bool match;
if (!JS_StringEqualsAscii(cx, JSID_TO_STRING(id), "phantom", &match))
return false;
if (match) {
desc.object().set(proxy);
desc.attributesRef() = JSPROP_READONLY | JSPROP_ENUMERATE;
desc.value().setInt32(42);
return true;
}
}
if (ownOnly)
return DirectProxyHandler::getOwnPropertyDescriptor(cx, proxy, id, desc);
return DirectProxyHandler::getPropertyDescriptor(cx, proxy, id, desc);
}
示例9: defineGeneric
bool
js::SetPropertyIgnoringNamedGetter(JSContext *cx, const BaseProxyHandler *handler,
HandleObject proxy, HandleObject receiver,
HandleId id, MutableHandle<PropertyDescriptor> desc,
bool descIsOwn, bool strict, MutableHandleValue vp)
{
/* The control-flow here differs from ::get() because of the fall-through case below. */
if (descIsOwn) {
MOZ_ASSERT(desc.object());
// Check for read-only properties.
if (desc.isReadonly())
return strict ? Throw(cx, id, JSMSG_READ_ONLY) : true;
if (!desc.setter()) {
// Be wary of the odd explicit undefined setter case possible through
// Object.defineProperty.
if (!desc.hasSetterObject())
desc.setSetter(JS_StrictPropertyStub);
} else if (desc.hasSetterObject() || desc.setter() != JS_StrictPropertyStub) {
if (!CallSetter(cx, receiver, id, desc.setter(), desc.attributes(), strict, vp))
return false;
if (!proxy->is<ProxyObject>() || proxy->as<ProxyObject>().handler() != handler)
return true;
if (desc.isShared())
return true;
}
if (!desc.getter()) {
// Same as above for the null setter case.
if (!desc.hasGetterObject())
desc.setGetter(JS_PropertyStub);
}
desc.value().set(vp.get());
return handler->defineProperty(cx, receiver, id, desc);
}
if (desc.object()) {
// Check for read-only properties.
if (desc.isReadonly())
return strict ? Throw(cx, id, JSMSG_CANT_REDEFINE_PROP) : true;
if (!desc.setter()) {
// Be wary of the odd explicit undefined setter case possible through
// Object.defineProperty.
if (!desc.hasSetterObject())
desc.setSetter(JS_StrictPropertyStub);
} else if (desc.hasSetterObject() || desc.setter() != JS_StrictPropertyStub) {
if (!CallSetter(cx, receiver, id, desc.setter(), desc.attributes(), strict, vp))
return false;
if (!proxy->is<ProxyObject>() || proxy->as<ProxyObject>().handler() != handler)
return true;
if (desc.isShared())
return true;
}
if (!desc.getter()) {
// Same as above for the null setter case.
if (!desc.hasGetterObject())
desc.setGetter(JS_PropertyStub);
}
desc.value().set(vp.get());
return JSObject::defineGeneric(cx, receiver, id, desc.value(),
desc.getter(), desc.setter(), desc.attributes());
}
desc.object().set(receiver);
desc.value().set(vp.get());
desc.setAttributes(JSPROP_ENUMERATE);
desc.setGetter(nullptr);
desc.setSetter(nullptr); // Pick up the class getter/setter.
return JSObject::defineGeneric(cx, receiver, id, desc.value(), nullptr, nullptr,
JSPROP_ENUMERATE);
}