本文整理汇总了C++中MutableHandleValue::isNumber方法的典型用法代码示例。如果您正苦于以下问题:C++ MutableHandleValue::isNumber方法的具体用法?C++ MutableHandleValue::isNumber怎么用?C++ MutableHandleValue::isNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MutableHandleValue
的用法示例。
在下文中一共展示了MutableHandleValue::isNumber方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: obj
static bool
CloneValue(JSContext *cx, MutableHandleValue vp, CloneMemory &clonedObjects)
{
if (vp.isObject()) {
RootedObject obj(cx, &vp.toObject());
RootedObject clone(cx, CloneObject(cx, obj, clonedObjects));
if (!clone)
return false;
vp.setObject(*clone);
} else if (vp.isBoolean() || vp.isNumber() || vp.isNullOrUndefined()) {
// Nothing to do here: these are represented inline in the value
} else if (vp.isString()) {
Rooted<JSStableString*> str(cx, vp.toString()->ensureStable(cx));
if (!str)
return false;
RootedString clone(cx, js_NewStringCopyN<CanGC>(cx, str->chars().get(), str->length()));
if (!clone)
return false;
vp.setString(clone);
} else {
if (JSString *valSrc = JS_ValueToSource(cx, vp))
printf("Error: Can't yet clone value: %s\n", JS_EncodeString(cx, valSrc));
return false;
}
return true;
}
示例2: obj
static bool
CloneValue(JSContext *cx, MutableHandleValue vp, CloneMemory &clonedObjects)
{
if (vp.isObject()) {
RootedObject obj(cx, &vp.toObject());
RootedObject clone(cx, CloneObject(cx, obj, clonedObjects));
if (!clone)
return false;
vp.setObject(*clone);
} else if (vp.isBoolean() || vp.isNumber() || vp.isNullOrUndefined()) {
// Nothing to do here: these are represented inline in the value
} else if (vp.isString()) {
Rooted<JSStableString*> str(cx, vp.toString()->ensureStable(cx));
if (!str)
return false;
RootedString clone(cx, js_NewStringCopyN<CanGC>(cx, str->chars().get(), str->length()));
if (!clone)
return false;
vp.setString(clone);
} else {
MOZ_ASSUME_UNREACHABLE("Self-hosting CloneValue can't clone given value.");
}
return true;
}