本文整理汇总了C++中MutableHandle::hasGetterObject方法的典型用法代码示例。如果您正苦于以下问题:C++ MutableHandle::hasGetterObject方法的具体用法?C++ MutableHandle::hasGetterObject怎么用?C++ MutableHandle::hasGetterObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MutableHandle
的用法示例。
在下文中一共展示了MutableHandle::hasGetterObject方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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());
}
示例2: v
static bool
WaiveAccessors(JSContext* cx, MutableHandle<PropertyDescriptor> desc)
{
if (desc.hasGetterObject() && desc.getterObject()) {
RootedValue v(cx, JS::ObjectValue(*desc.getterObject()));
if (!WrapperFactory::WaiveXrayAndWrap(cx, &v))
return false;
desc.setGetterObject(&v.toObject());
}
if (desc.hasSetterObject() && desc.setterObject()) {
RootedValue v(cx, JS::ObjectValue(*desc.setterObject()));
if (!WrapperFactory::WaiveXrayAndWrap(cx, &v))
return false;
desc.setSetterObject(&v.toObject());
}
return true;
}
示例3: JS_ReportErrorFlagsAndNumber
bool
DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
MutableHandle<JSPropertyDescriptor> desc, bool* defined)
{
if (desc.hasGetterObject() && desc.setter() == JS_StrictPropertyStub) {
return JS_ReportErrorFlagsAndNumber(cx,
JSREPORT_WARNING | JSREPORT_STRICT |
JSREPORT_STRICT_MODE_ERROR,
js_GetErrorMessage, NULL,
JSMSG_GETTER_ONLY);
}
if (xpc::WrapperFactory::IsXrayWrapper(proxy)) {
return true;
}
JSObject* expando = EnsureExpandoObject(cx, proxy);
if (!expando) {
return false;
}
bool dummy;
return js_DefineOwnProperty(cx, expando, id, desc, &dummy);
}
示例4: 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);
}