本文整理汇总了C++中MutableHandleValue::isString方法的典型用法代码示例。如果您正苦于以下问题:C++ MutableHandleValue::isString方法的具体用法?C++ MutableHandleValue::isString怎么用?C++ MutableHandleValue::isString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MutableHandleValue
的用法示例。
在下文中一共展示了MutableHandleValue::isString方法的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 {
MOZ_ASSUME_UNREACHABLE("Self-hosting CloneValue can't clone given value.");
}
return true;
}
示例2: obj
bool
JSCompartment::wrap(JSContext *cx, MutableHandleValue vp, HandleObject existingArg)
{
JS_ASSERT(cx->compartment == this);
JS_ASSERT_IF(existingArg, existingArg->compartment() == cx->compartment);
JS_ASSERT_IF(existingArg, vp.isObject());
JS_ASSERT_IF(existingArg, IsDeadProxyObject(existingArg));
unsigned flags = 0;
JS_CHECK_CHROME_RECURSION(cx, return false);
#ifdef DEBUG
struct AutoDisableProxyCheck {
JSRuntime *runtime;
AutoDisableProxyCheck(JSRuntime *rt) : runtime(rt) {
runtime->gcDisableStrictProxyCheckingCount++;
}
~AutoDisableProxyCheck() { runtime->gcDisableStrictProxyCheckingCount--; }
} adpc(rt);
#endif
/* Only GC things have to be wrapped or copied. */
if (!vp.isMarkable())
return true;
if (vp.isString()) {
RawString str = vp.toString();
/* If the string is already in this compartment, we are done. */
if (str->zone() == zone())
return true;
/* If the string is an atom, we don't have to copy. */
if (str->isAtom()) {
JS_ASSERT(str->zone() == cx->runtime->atomsCompartment->zone());
return true;
}
}
/*
* Wrappers should really be parented to the wrapped parent of the wrapped
* object, but in that case a wrapped global object would have a NULL
* parent without being a proper global object (JSCLASS_IS_GLOBAL). Instead,
* we parent all wrappers to the global object in their home compartment.
* This loses us some transparency, and is generally very cheesy.
*/
HandleObject global = cx->global();
/* Unwrap incoming objects. */
if (vp.isObject()) {
RootedObject obj(cx, &vp.toObject());
if (obj->compartment() == this)
return WrapForSameCompartment(cx, obj, vp);
/* Translate StopIteration singleton. */
if (obj->isStopIteration())
return js_FindClassObject(cx, JSProto_StopIteration, vp);
/* Unwrap the object, but don't unwrap outer windows. */
obj = UnwrapObject(obj, /* stopAtOuter = */ true, &flags);
if (obj->compartment() == this)
return WrapForSameCompartment(cx, obj, vp);
if (cx->runtime->preWrapObjectCallback) {
obj = cx->runtime->preWrapObjectCallback(cx, global, obj, flags);
if (!obj)
return false;
}
if (obj->compartment() == this)
return WrapForSameCompartment(cx, obj, vp);
vp.setObject(*obj);
#ifdef DEBUG
{
JSObject *outer = GetOuterObject(cx, obj);
JS_ASSERT(outer && outer == obj);
}
#endif
}
RootedValue key(cx, vp);
/* If we already have a wrapper for this value, use it. */
if (WrapperMap::Ptr p = crossCompartmentWrappers.lookup(key)) {
vp.set(p->value);
if (vp.isObject()) {
RawObject obj = &vp.toObject();
JS_ASSERT(obj->isCrossCompartmentWrapper());
JS_ASSERT(obj->getParent() == global);
}
return true;
}
if (vp.isString()) {
Rooted<JSLinearString *> str(cx, vp.toString()->ensureLinear(cx));
if (!str)
//.........这里部分代码省略.........