mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:47:35 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -18,7 +18,7 @@ namespace JS {
|
|||
|
||||
JS_DEFINE_ALLOCATOR(RegExpObject);
|
||||
|
||||
Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_string(StringView flags)
|
||||
Result<regex::RegexOptions<ECMAScriptFlags>, ByteString> regex_flags_from_string(StringView flags)
|
||||
{
|
||||
bool d = false, g = false, i = false, m = false, s = false, u = false, y = false, v = false;
|
||||
auto options = RegExpObject::default_flags;
|
||||
|
@ -27,42 +27,42 @@ Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_
|
|||
switch (ch) {
|
||||
case 'd':
|
||||
if (d)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
d = true;
|
||||
break;
|
||||
case 'g':
|
||||
if (g)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
g = true;
|
||||
options |= regex::ECMAScriptFlags::Global;
|
||||
break;
|
||||
case 'i':
|
||||
if (i)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
i = true;
|
||||
options |= regex::ECMAScriptFlags::Insensitive;
|
||||
break;
|
||||
case 'm':
|
||||
if (m)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
m = true;
|
||||
options |= regex::ECMAScriptFlags::Multiline;
|
||||
break;
|
||||
case 's':
|
||||
if (s)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
s = true;
|
||||
options |= regex::ECMAScriptFlags::SingleLine;
|
||||
break;
|
||||
case 'u':
|
||||
if (u)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
u = true;
|
||||
options |= regex::ECMAScriptFlags::Unicode;
|
||||
break;
|
||||
case 'y':
|
||||
if (y)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
y = true;
|
||||
// Now for the more interesting flag, 'sticky' actually unsets 'global', part of which is the default.
|
||||
options.reset_flag(regex::ECMAScriptFlags::Global);
|
||||
|
@ -74,12 +74,12 @@ Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_
|
|||
break;
|
||||
case 'v':
|
||||
if (v)
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectRepeatedFlag.message(), ch);
|
||||
v = true;
|
||||
options |= regex::ECMAScriptFlags::UnicodeSets;
|
||||
break;
|
||||
default:
|
||||
return DeprecatedString::formatted(ErrorType::RegExpObjectBadFlag.message(), ch);
|
||||
return ByteString::formatted(ErrorType::RegExpObjectBadFlag.message(), ch);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,10 +87,10 @@ Result<regex::RegexOptions<ECMAScriptFlags>, DeprecatedString> regex_flags_from_
|
|||
}
|
||||
|
||||
// 22.2.3.4 Static Semantics: ParsePattern ( patternText, u, v ), https://tc39.es/ecma262/#sec-parsepattern
|
||||
ErrorOr<DeprecatedString, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets)
|
||||
ErrorOr<ByteString, ParseRegexPatternError> parse_regex_pattern(StringView pattern, bool unicode, bool unicode_sets)
|
||||
{
|
||||
if (unicode && unicode_sets)
|
||||
return ParseRegexPatternError { DeprecatedString::formatted(ErrorType::RegExpObjectIncompatibleFlags.message(), 'u', 'v') };
|
||||
return ParseRegexPatternError { ByteString::formatted(ErrorType::RegExpObjectIncompatibleFlags.message(), 'u', 'v') };
|
||||
|
||||
auto utf16_pattern_result = AK::utf8_to_utf16(pattern);
|
||||
if (utf16_pattern_result.is_error())
|
||||
|
@ -132,11 +132,11 @@ ErrorOr<DeprecatedString, ParseRegexPatternError> parse_regex_pattern(StringView
|
|||
previous_code_unit_was_backslash = false;
|
||||
}
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
// 22.2.3.4 Static Semantics: ParsePattern ( patternText, u, v ), https://tc39.es/ecma262/#sec-parsepattern
|
||||
ThrowCompletionOr<DeprecatedString> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets)
|
||||
ThrowCompletionOr<ByteString> parse_regex_pattern(VM& vm, StringView pattern, bool unicode, bool unicode_sets)
|
||||
{
|
||||
auto result = parse_regex_pattern(pattern, unicode, unicode_sets);
|
||||
if (result.is_error())
|
||||
|
@ -150,7 +150,7 @@ NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm)
|
|||
return realm.heap().allocate<RegExpObject>(realm, realm.intrinsics().regexp_prototype());
|
||||
}
|
||||
|
||||
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm, Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags)
|
||||
NonnullGCPtr<RegExpObject> RegExpObject::create(Realm& realm, Regex<ECMA262> regex, ByteString pattern, ByteString flags)
|
||||
{
|
||||
return realm.heap().allocate<RegExpObject>(realm, move(regex), move(pattern), move(flags), realm.intrinsics().regexp_prototype());
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ RegExpObject::RegExpObject(Object& prototype)
|
|||
{
|
||||
}
|
||||
|
||||
RegExpObject::RegExpObject(Regex<ECMA262> regex, DeprecatedString pattern, DeprecatedString flags, Object& prototype)
|
||||
RegExpObject::RegExpObject(Regex<ECMA262> regex, ByteString pattern, ByteString flags, Object& prototype)
|
||||
: Object(ConstructWithPrototypeTag::Tag, prototype)
|
||||
, m_pattern(move(pattern))
|
||||
, m_flags(move(flags))
|
||||
|
@ -183,14 +183,14 @@ ThrowCompletionOr<NonnullGCPtr<RegExpObject>> RegExpObject::regexp_initialize(VM
|
|||
// 1. If pattern is undefined, let P be the empty String.
|
||||
// 2. Else, let P be ? ToString(pattern).
|
||||
auto pattern = pattern_value.is_undefined()
|
||||
? DeprecatedString::empty()
|
||||
: TRY(pattern_value.to_deprecated_string(vm));
|
||||
? ByteString::empty()
|
||||
: TRY(pattern_value.to_byte_string(vm));
|
||||
|
||||
// 3. If flags is undefined, let F be the empty String.
|
||||
// 4. Else, let F be ? ToString(flags).
|
||||
auto flags = flags_value.is_undefined()
|
||||
? DeprecatedString::empty()
|
||||
: TRY(flags_value.to_deprecated_string(vm));
|
||||
? ByteString::empty()
|
||||
: TRY(flags_value.to_byte_string(vm));
|
||||
|
||||
// 5. If F contains any code unit other than "d", "g", "i", "m", "s", "u", "v", or "y", or if F contains any code unit more than once, throw a SyntaxError exception.
|
||||
// 6. If F contains "i", let i be true; else let i be false.
|
||||
|
@ -203,7 +203,7 @@ ThrowCompletionOr<NonnullGCPtr<RegExpObject>> RegExpObject::regexp_initialize(VM
|
|||
return vm.throw_completion<SyntaxError>(parsed_flags_or_error.release_error());
|
||||
auto parsed_flags = parsed_flags_or_error.release_value();
|
||||
|
||||
auto parsed_pattern = DeprecatedString::empty();
|
||||
auto parsed_pattern = ByteString::empty();
|
||||
if (!pattern.is_empty()) {
|
||||
bool unicode = parsed_flags.has_flag_set(regex::ECMAScriptFlags::Unicode);
|
||||
bool unicode_sets = parsed_flags.has_flag_set(regex::ECMAScriptFlags::UnicodeSets);
|
||||
|
@ -244,7 +244,7 @@ ThrowCompletionOr<NonnullGCPtr<RegExpObject>> RegExpObject::regexp_initialize(VM
|
|||
}
|
||||
|
||||
// 22.2.6.13.1 EscapeRegExpPattern ( P, F ), https://tc39.es/ecma262/#sec-escaperegexppattern
|
||||
DeprecatedString RegExpObject::escape_regexp_pattern() const
|
||||
ByteString RegExpObject::escape_regexp_pattern() const
|
||||
{
|
||||
// 1. Let S be a String in the form of a Pattern[~UnicodeMode] (Pattern[+UnicodeMode] if F contains "u") equivalent
|
||||
// to P interpreted as UTF-16 encoded Unicode code points (6.1.4), in which certain code points are escaped as
|
||||
|
@ -301,7 +301,7 @@ DeprecatedString RegExpObject::escape_regexp_pattern() const
|
|||
}
|
||||
}
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
// 22.2.3.1 RegExpCreate ( P, F ), https://tc39.es/ecma262/#sec-regexpcreate
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue