本文整理汇总了C++中JSFlatString::morphAtomizedStringIntoPermanentAtom方法的典型用法代码示例。如果您正苦于以下问题:C++ JSFlatString::morphAtomizedStringIntoPermanentAtom方法的具体用法?C++ JSFlatString::morphAtomizedStringIntoPermanentAtom怎么用?C++ JSFlatString::morphAtomizedStringIntoPermanentAtom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSFlatString
的用法示例。
在下文中一共展示了JSFlatString::morphAtomizedStringIntoPermanentAtom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lock
bool
StaticStrings::init(JSContext* cx)
{
AutoLockForExclusiveAccess lock(cx);
AutoCompartment ac(cx, cx->runtime()->atomsCompartment());
static_assert(UNIT_STATIC_LIMIT - 1 <= JSString::MAX_LATIN1_CHAR,
"Unit strings must fit in Latin1Char.");
for (uint32_t i = 0; i < UNIT_STATIC_LIMIT; i++) {
Latin1Char buffer[] = { Latin1Char(i), '\0' };
JSFlatString* s = NewStringCopyN<NoGC>(cx, buffer, 1);
if (!s)
return false;
unitStaticTable[i] = s->morphAtomizedStringIntoPermanentAtom();
}
for (uint32_t i = 0; i < NUM_SMALL_CHARS * NUM_SMALL_CHARS; i++) {
Latin1Char buffer[] = { FROM_SMALL_CHAR(i >> 6), FROM_SMALL_CHAR(i & 0x3F), '\0' };
JSFlatString* s = NewStringCopyN<NoGC>(cx, buffer, 2);
if (!s)
return false;
length2StaticTable[i] = s->morphAtomizedStringIntoPermanentAtom();
}
for (uint32_t i = 0; i < INT_STATIC_LIMIT; i++) {
if (i < 10) {
intStaticTable[i] = unitStaticTable[i + '0'];
} else if (i < 100) {
size_t index = ((size_t)TO_SMALL_CHAR((i / 10) + '0') << 6) +
TO_SMALL_CHAR((i % 10) + '0');
intStaticTable[i] = length2StaticTable[index];
} else {
Latin1Char buffer[] = { Latin1Char('0' + (i / 100)),
Latin1Char('0' + ((i / 10) % 10)),
Latin1Char('0' + (i % 10)),
'\0' };
JSFlatString* s = NewStringCopyN<NoGC>(cx, buffer, 3);
if (!s)
return false;
intStaticTable[i] = s->morphAtomizedStringIntoPermanentAtom();
}
}
return true;
}