本文整理汇总了C++中JavascriptString::GetItem方法的典型用法代码示例。如果您正苦于以下问题:C++ JavascriptString::GetItem方法的具体用法?C++ JavascriptString::GetItem怎么用?C++ JavascriptString::GetItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JavascriptString
的用法示例。
在下文中一共展示了JavascriptString::GetItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EntryNext
Var JavascriptStringIterator::EntryNext(RecyclableObject* function, CallInfo callInfo, ...)
{
PROBE_STACK(function->GetScriptContext(), Js::Constants::MinStackDefault);
ARGUMENTS(args, callInfo);
ScriptContext* scriptContext = function->GetScriptContext();
JavascriptLibrary* library = scriptContext->GetLibrary();
Assert(!(callInfo.Flags & CallFlags_New));
Var thisObj = args[0];
if (!JavascriptStringIterator::Is(thisObj))
{
JavascriptError::ThrowTypeError(scriptContext, JSERR_This_NeedStringIterator, L"String Iterator.prototype.next");
}
JavascriptStringIterator* iterator = JavascriptStringIterator::FromVar(thisObj);
JavascriptString* string = iterator->m_string;
if (string == nullptr)
{
return library->CreateIteratorResultObjectUndefinedTrue();
}
charcount_t length = string->GetLength();
charcount_t index = iterator->m_nextIndex;
if (index >= length)
{
// Nulling out the m_string field is important so that the iterator
// does not keep the string alive after iteration is completed.
iterator->m_string = nullptr;
return library->CreateIteratorResultObjectUndefinedTrue();
}
wchar_t chFirst = string->GetItem(index);
Var result;
if (index + 1 == string->GetLength() ||
!NumberUtilities::IsSurrogateLowerPart(chFirst) ||
!NumberUtilities::IsSurrogateUpperPart(string->GetItem(index + 1)))
{
result = scriptContext->GetLibrary()->GetCharStringCache().GetStringForChar(chFirst);
iterator->m_nextIndex += 1;
}
else
{
result = JavascriptString::SubstringCore(string, index, 2, scriptContext);
iterator->m_nextIndex += 2;
}
return library->CreateIteratorResultObjectValueFalse(result);
}