本文整理汇总了C++中JSString::viewWithUnderlyingString方法的典型用法代码示例。如果您正苦于以下问题:C++ JSString::viewWithUnderlyingString方法的具体用法?C++ JSString::viewWithUnderlyingString怎么用?C++ JSString::viewWithUnderlyingString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSString
的用法示例。
在下文中一共展示了JSString::viewWithUnderlyingString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: encode
static EncodedJSValue JSC_HOST_CALL IntlCollatorFuncCompare(ExecState* state)
{
VM& vm = state->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
// 10.3.4 Collator Compare Functions (ECMA-402 2.0)
// 1. Let collator be the this value.
// 2. Assert: Type(collator) is Object and collator has an [[initializedCollator]] internal slot whose value is true.
IntlCollator* collator = jsCast<IntlCollator*>(state->thisValue());
// 3. If x is not provided, let x be undefined.
// 4. If y is not provided, let y be undefined.
// 5. Let X be ToString(x).
JSString* x = state->argument(0).toString(state);
// 6. ReturnIfAbrupt(X).
RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 7. Let Y be ToString(y).
JSString* y = state->argument(1).toString(state);
// 8. ReturnIfAbrupt(Y).
RETURN_IF_EXCEPTION(scope, encodedJSValue());
// 9. Return CompareStrings(collator, X, Y).
auto xViewWithString = x->viewWithUnderlyingString(*state);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
auto yViewWithString = y->viewWithUnderlyingString(*state);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
scope.release();
return JSValue::encode(collator->compareStrings(*state, xViewWithString.view, yViewWithString.view));
}