MCPcopy Create free account
hub / github.com/NativeScript/android / valid_name_code_point

Function valid_name_code_point

test-app/runtime/src/main/cpp/ada/ada.cpp:10412–10438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10410}
10411
10412bool valid_name_code_point(char32_t code_point, bool first) {
10413 // https://tc39.es/ecma262/#prod-IdentifierStart
10414 // Fast paths:
10415 if (first &&
10416 (code_point == '$' || code_point == '_' || is_ascii_letter(code_point))) {
10417 return true;
10418 }
10419 if (!first && (code_point == '$' || is_ascii_letter_or_digit(code_point))) {
10420 return true;
10421 }
10422 // Slow path...
10423 if (code_point == 0xffffffff) {
10424 return false; // minimal error handling
10425 }
10426 if (first) {
10427 auto iter = std::lower_bound(
10428 std::begin(ada::idna::id_start), std::end(ada::idna::id_start),
10429 code_point,
10430 [](const uint32_t* range, uint32_t cp) { return range[1] < cp; });
10431 return iter != std::end(id_start) && code_point >= (*iter)[0];
10432 } else {
10433 auto iter = std::lower_bound(
10434 std::begin(id_continue), std::end(id_continue), code_point,
10435 [](const uint32_t* range, uint32_t cp) { return range[1] < cp; });
10436 return iter != std::end(id_start) && code_point >= (*iter)[0];
10437 }
10438}
10439} // namespace ada::idna
10440/* end file src/identifier.cpp */
10441/* end file src/idna.cpp */

Callers 2

tokenizeFunction · 0.85
generate_pattern_stringFunction · 0.85

Calls 4

is_ascii_letterFunction · 0.85
is_ascii_letter_or_digitFunction · 0.85
beginFunction · 0.50
endFunction · 0.50

Tested by

no test coverage detected