本文整理汇总了C++中HandleValue::isPrimitive方法的典型用法代码示例。如果您正苦于以下问题:C++ HandleValue::isPrimitive方法的具体用法?C++ HandleValue::isPrimitive怎么用?C++ HandleValue::isPrimitive使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HandleValue
的用法示例。
在下文中一共展示了HandleValue::isPrimitive方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CallArgsFromVp
static bool
ProtoSetter(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
HandleValue thisv = args.thisv();
if (thisv.isNullOrUndefined()) {
ReportIncompatible(cx, args);
return false;
}
if (thisv.isPrimitive()) {
// Mutating a boxed primitive's [[Prototype]] has no side effects.
args.rval().setUndefined();
return true;
}
if (!cx->runningWithTrustedPrincipals())
++sSetProtoCalled;
Rooted<JSObject*> obj(cx, &args.thisv().toObject());
/* Do nothing if __proto__ isn't being set to an object or null. */
if (args.length() == 0 || !args[0].isObjectOrNull()) {
args.rval().setUndefined();
return true;
}
Rooted<JSObject*> newProto(cx, args[0].toObjectOrNull());
if (!SetPrototype(cx, obj, newProto))
return false;
args.rval().setUndefined();
return true;
}
示例2: obj
static bool
ProtoGetterImpl(JSContext *cx, CallArgs args)
{
JS_ASSERT(TestProtoThis(args.thisv()));
HandleValue thisv = args.thisv();
if (thisv.isPrimitive() && !BoxNonStrictThis(cx, args))
return false;
RootedObject obj(cx, &args.thisv().toObject());
RootedObject proto(cx);
if (!JSObject::getProto(cx, obj, &proto))
return false;
args.rval().setObjectOrNull(proto);
return true;
}
示例3: obj
NS_IMETHODIMP
nsJSIID::HasInstance(nsIXPConnectWrappedNative* wrapper,
JSContext* cx, JSObject * /* unused */,
HandleValue val, bool* bp, bool* _retval)
{
*bp = false;
if (val.isPrimitive())
return NS_OK;
// we have a JSObject
RootedObject obj(cx, &val.toObject());
const nsIID* iid;
mInfo->GetIIDShared(&iid);
return xpc::HasInstance(cx, obj, iid, bp);
}
示例4: obj
static bool
ProtoGetterImpl(JSContext *cx, CallArgs args)
{
JS_ASSERT(TestProtoGetterThis(args.thisv()));
HandleValue thisv = args.thisv();
if (thisv.isPrimitive() && !BoxNonStrictThis(cx, args))
return false;
unsigned dummy;
RootedObject obj(cx, &args.thisv().toObject());
RootedId nid(cx, NameToId(cx->names().proto));
RootedValue v(cx);
if (!CheckAccess(cx, obj, nid, JSACC_PROTO, &v, &dummy))
return false;
args.rval().set(v);
return true;
}
示例5: obj
static bool
ProtoGetter(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
HandleValue thisv = args.thisv();
if (thisv.isNullOrUndefined()) {
ReportIncompatible(cx, args);
return false;
}
if (thisv.isPrimitive() && !BoxNonStrictThis(cx, args))
return false;
RootedObject obj(cx, &args.thisv().toObject());
RootedObject proto(cx);
if (!GetPrototype(cx, obj, &proto))
return false;
args.rval().setObjectOrNull(proto);
return true;
}
示例6: callee
static bool
ProtoSetter(JSContext* cx, unsigned argc, Value* vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
// Do this here, rather than after the this-check so even likely-buggy
// use of the __proto__ setter on unacceptable values, where no subsequent
// use occurs on an acceptable value, will trigger a warning.
RootedObject callee(cx, &args.callee());
if (!GlobalObject::warnOnceAboutPrototypeMutation(cx, callee))
return false;
HandleValue thisv = args.thisv();
if (thisv.isNullOrUndefined()) {
ReportIncompatible(cx, args);
return false;
}
if (thisv.isPrimitive()) {
// Mutating a boxed primitive's [[Prototype]] has no side effects.
args.rval().setUndefined();
return true;
}
if (!cx->runningWithTrustedPrincipals())
++sSetProtoCalled;
Rooted<JSObject*> obj(cx, &args.thisv().toObject());
/* Do nothing if __proto__ isn't being set to an object or null. */
if (args.length() == 0 || !args[0].isObjectOrNull()) {
args.rval().setUndefined();
return true;
}
Rooted<JSObject*> newProto(cx, args[0].toObjectOrNull());
if (!SetPrototype(cx, obj, newProto))
return false;
args.rval().setUndefined();
return true;
}
示例7: nid
static bool
ProtoSetterImpl(JSContext *cx, CallArgs args)
{
JS_ASSERT(TestProtoSetterThis(args.thisv()));
HandleValue thisv = args.thisv();
if (thisv.isPrimitive()) {
JS_ASSERT(!thisv.isNullOrUndefined());
// Mutating a boxed primitive's [[Prototype]] has no side effects.
args.rval().setUndefined();
return true;
}
if (!cx->runningWithTrustedPrincipals())
++sSetProtoCalled;
Rooted<JSObject*> obj(cx, &args.thisv().toObject());
/* ES5 8.6.2 forbids changing [[Prototype]] if not [[Extensible]]. */
bool extensible;
if (!JSObject::isExtensible(cx, obj, &extensible))
return false;
if (!extensible) {
obj->reportNotExtensible(cx);
return false;
}
/*
* Disallow mutating the [[Prototype]] of a proxy that wasn't simply
* wrapping some other object. Also disallow it on ArrayBuffer objects,
* which due to their complicated delegate-object shenanigans can't easily
* have a mutable [[Prototype]].
*/
if (obj->is<ProxyObject>() || obj->is<ArrayBufferObject>()) {
JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_INCOMPATIBLE_PROTO,
"Object", "__proto__ setter",
obj->is<ProxyObject>() ? "Proxy" : "ArrayBuffer");
return false;
}
/* Do nothing if __proto__ isn't being set to an object or null. */
if (args.length() == 0 || !args[0].isObjectOrNull()) {
args.rval().setUndefined();
return true;
}
Rooted<JSObject*> newProto(cx, args[0].toObjectOrNull());
unsigned dummy;
RootedId nid(cx, NameToId(cx->names().proto));
RootedValue v(cx);
if (!CheckAccess(cx, obj, nid, JSAccessMode(JSACC_PROTO | JSACC_WRITE), &v, &dummy))
return false;
if (!SetClassAndProto(cx, obj, obj->getClass(), newProto, true))
return false;
args.rval().setUndefined();
return true;
}