本文整理汇总了C++中atomset::Ptr::setTagged方法的典型用法代码示例。如果您正苦于以下问题:C++ Ptr::setTagged方法的具体用法?C++ Ptr::setTagged怎么用?C++ Ptr::setTagged使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类atomset::Ptr
的用法示例。
在下文中一共展示了Ptr::setTagged方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
JSAtom *
js_AtomizeString(JSContext *cx, JSString *str, InternBehavior ib)
{
if (str->isAtom()) {
JSAtom &atom = str->asAtom();
/* N.B. static atoms are effectively always interned. */
if (ib != InternAtom || atom.isStaticAtom())
return &atom;
/* Here we have to check whether the atom is already interned. */
AutoLockAtomsCompartment lock(cx);
AtomSet &atoms = cx->runtime->atomState.atoms;
AtomSet::Ptr p = atoms.lookup(AtomHasher::Lookup(&atom));
JS_ASSERT(p); /* Non-static atom must exist in atom state set. */
JS_ASSERT(p->asPtr() == &atom);
JS_ASSERT(ib == InternAtom);
p->setTagged(bool(ib));
return &atom;
}
if (str->isAtom())
return &str->asAtom();
size_t length = str->length();
const jschar *chars = str->getChars(cx);
if (!chars)
return NULL;
JS_ASSERT(length <= JSString::MAX_LENGTH);
return Atomize(cx, &chars, length, ib);
}
示例2: lookup
JSAtom *
js::AtomizeString(ExclusiveContext *cx, JSString *str,
js::InternBehavior ib /* = js::DoNotInternAtom */)
{
if (str->isAtom()) {
JSAtom &atom = str->asAtom();
/* N.B. static atoms are effectively always interned. */
if (ib != InternAtom || js::StaticStrings::isStatic(&atom))
return &atom;
AtomHasher::Lookup lookup(&atom);
/* Likewise, permanent atoms are always interned. */
AtomSet::Ptr p = cx->permanentAtoms().readonlyThreadsafeLookup(lookup);
if (p)
return &atom;
AutoLockForExclusiveAccess lock(cx);
p = cx->atoms().lookup(lookup);
JS_ASSERT(p); /* Non-static atom must exist in atom state set. */
JS_ASSERT(p->asPtr() == &atom);
JS_ASSERT(ib == InternAtom);
p->setTagged(bool(ib));
return &atom;
}
const jschar *chars = str->getChars(cx);
if (!chars)
return nullptr;
return AtomizeAndCopyChars(cx, chars, str->length(), ib);
}
示例3: lookup
JSAtom *
js::AtomizeString(ExclusiveContext *cx, JSString *str,
js::InternBehavior ib /* = js::DoNotInternAtom */)
{
if (str->isAtom()) {
JSAtom &atom = str->asAtom();
/* N.B. static atoms are effectively always interned. */
if (ib != InternAtom || js::StaticStrings::isStatic(&atom))
return &atom;
AtomHasher::Lookup lookup(&atom);
/* Likewise, permanent atoms are always interned. */
MOZ_ASSERT(cx->isPermanentAtomsInitialized());
AtomSet::Ptr p = cx->permanentAtoms().readonlyThreadsafeLookup(lookup);
if (p)
return &atom;
AutoLockForExclusiveAccess lock(cx);
p = cx->atoms().lookup(lookup);
MOZ_ASSERT(p); /* Non-static atom must exist in atom state set. */
MOZ_ASSERT(p->asPtr() == &atom);
MOZ_ASSERT(ib == InternAtom);
p->setTagged(bool(ib));
return &atom;
}
JSLinearString *linear = str->ensureLinear(cx);
if (!linear)
return nullptr;
JS::AutoCheckCannotGC nogc;
return linear->hasLatin1Chars()
? AtomizeAndCopyChars(cx, linear->latin1Chars(nogc), linear->length(), ib)
: AtomizeAndCopyChars(cx, linear->twoByteChars(nogc), linear->length(), ib);
}