mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 14:57:34 +00:00
Everywhere: Rename to_{string => deprecated_string}() where applicable
This will make it easier to support both string types at the same time while we convert code, and tracking down remaining uses. One big exception is Value::to_string() in LibJS, where the name is dictated by the ToString AO.
This commit is contained in:
parent
6e19ab2bbc
commit
57dc179b1f
597 changed files with 1973 additions and 1972 deletions
|
@ -398,7 +398,7 @@ ALWAYS_INLINE ExecutionResult OpCode_SaveRightCaptureGroup::execute(MatchInput c
|
|||
auto view = input.view.substring_view(start_position, length);
|
||||
|
||||
if (input.regex_options & AllFlags::StringCopyMatches) {
|
||||
match = { view.to_string(), input.line, start_position, input.global_offset + start_position }; // create a copy of the original string
|
||||
match = { view.to_deprecated_string(), input.line, start_position, input.global_offset + start_position }; // create a copy of the original string
|
||||
} else {
|
||||
match = { view, input.line, start_position, input.global_offset + start_position }; // take view to original string
|
||||
}
|
||||
|
@ -423,7 +423,7 @@ ALWAYS_INLINE ExecutionResult OpCode_SaveRightNamedCaptureGroup::execute(MatchIn
|
|||
auto view = input.view.substring_view(start_position, length);
|
||||
|
||||
if (input.regex_options & AllFlags::StringCopyMatches) {
|
||||
match = { view.to_string(), name(), input.line, start_position, input.global_offset + start_position }; // create a copy of the original string
|
||||
match = { view.to_deprecated_string(), name(), input.line, start_position, input.global_offset + start_position }; // create a copy of the original string
|
||||
} else {
|
||||
match = { view, name(), input.line, start_position, input.global_offset + start_position }; // take view to original string
|
||||
}
|
||||
|
@ -927,7 +927,7 @@ Vector<CompareTypeAndValuePair> OpCode_Compare::flat_compares() const
|
|||
return result;
|
||||
}
|
||||
|
||||
Vector<DeprecatedString> OpCode_Compare::variable_arguments_to_string(Optional<MatchInput const&> input) const
|
||||
Vector<DeprecatedString> OpCode_Compare::variable_arguments_to_deprecated_string(Optional<MatchInput const&> input) const
|
||||
{
|
||||
Vector<DeprecatedString> result;
|
||||
|
||||
|
@ -952,9 +952,9 @@ Vector<DeprecatedString> OpCode_Compare::variable_arguments_to_string(Optional<M
|
|||
if (is_ascii) {
|
||||
result.empend(DeprecatedString::formatted(
|
||||
" compare against: '{}'",
|
||||
view.substring_view(string_start_offset, string_start_offset > view.length() ? 0 : 1).to_string()));
|
||||
view.substring_view(string_start_offset, string_start_offset > view.length() ? 0 : 1).to_deprecated_string()));
|
||||
} else {
|
||||
auto str = view.substring_view(string_start_offset, string_start_offset > view.length() ? 0 : 1).to_string();
|
||||
auto str = view.substring_view(string_start_offset, string_start_offset > view.length() ? 0 : 1).to_deprecated_string();
|
||||
u8 buf[8] { 0 };
|
||||
__builtin_memcpy(buf, str.characters(), min(str.length(), sizeof(buf)));
|
||||
result.empend(DeprecatedString::formatted(" compare against: {:x},{:x},{:x},{:x},{:x},{:x},{:x},{:x}",
|
||||
|
@ -988,21 +988,21 @@ Vector<DeprecatedString> OpCode_Compare::variable_arguments_to_string(Optional<M
|
|||
if (!view.is_null() && view.length() > state().string_position)
|
||||
result.empend(DeprecatedString::formatted(
|
||||
" compare against: \"{}\"",
|
||||
input.value().view.substring_view(string_start_offset, string_start_offset + length > view.length() ? 0 : length).to_string()));
|
||||
input.value().view.substring_view(string_start_offset, string_start_offset + length > view.length() ? 0 : length).to_deprecated_string()));
|
||||
} else if (compare_type == CharacterCompareType::CharClass) {
|
||||
auto character_class = (CharClass)m_bytecode->at(offset++);
|
||||
result.empend(DeprecatedString::formatted(" ch_class={} [{}]", (size_t)character_class, character_class_name(character_class)));
|
||||
if (!view.is_null() && view.length() > state().string_position)
|
||||
result.empend(DeprecatedString::formatted(
|
||||
" compare against: '{}'",
|
||||
input.value().view.substring_view(string_start_offset, state().string_position > view.length() ? 0 : 1).to_string()));
|
||||
input.value().view.substring_view(string_start_offset, state().string_position > view.length() ? 0 : 1).to_deprecated_string()));
|
||||
} else if (compare_type == CharacterCompareType::CharRange) {
|
||||
auto value = (CharRange)m_bytecode->at(offset++);
|
||||
result.empend(DeprecatedString::formatted(" ch_range={:x}-{:x}", value.from, value.to));
|
||||
if (!view.is_null() && view.length() > state().string_position)
|
||||
result.empend(DeprecatedString::formatted(
|
||||
" compare against: '{}'",
|
||||
input.value().view.substring_view(string_start_offset, state().string_position > view.length() ? 0 : 1).to_string()));
|
||||
input.value().view.substring_view(string_start_offset, state().string_position > view.length() ? 0 : 1).to_deprecated_string()));
|
||||
} else if (compare_type == CharacterCompareType::LookupTable) {
|
||||
auto count = m_bytecode->at(offset++);
|
||||
for (size_t j = 0; j < count; ++j) {
|
||||
|
@ -1012,7 +1012,7 @@ Vector<DeprecatedString> OpCode_Compare::variable_arguments_to_string(Optional<M
|
|||
if (!view.is_null() && view.length() > state().string_position)
|
||||
result.empend(DeprecatedString::formatted(
|
||||
" compare against: '{}'",
|
||||
input.value().view.substring_view(string_start_offset, state().string_position > view.length() ? 0 : 1).to_string()));
|
||||
input.value().view.substring_view(string_start_offset, state().string_position > view.length() ? 0 : 1).to_deprecated_string()));
|
||||
} else if (compare_type == CharacterCompareType::GeneralCategory
|
||||
|| compare_type == CharacterCompareType::Property
|
||||
|| compare_type == CharacterCompareType::Script
|
||||
|
|
|
@ -570,7 +570,7 @@ public:
|
|||
return *m_state;
|
||||
}
|
||||
|
||||
DeprecatedString to_string() const
|
||||
DeprecatedString to_deprecated_string() const
|
||||
{
|
||||
return DeprecatedString::formatted("[{:#02X}] {}", (int)opcode_id(), name(opcode_id()));
|
||||
}
|
||||
|
@ -748,7 +748,7 @@ public:
|
|||
ALWAYS_INLINE size_t arguments_count() const { return argument(0); }
|
||||
ALWAYS_INLINE size_t arguments_size() const { return argument(1); }
|
||||
DeprecatedString arguments_string() const override;
|
||||
Vector<DeprecatedString> variable_arguments_to_string(Optional<MatchInput const&> input = {}) const;
|
||||
Vector<DeprecatedString> variable_arguments_to_deprecated_string(Optional<MatchInput const&> input = {}) const;
|
||||
Vector<CompareTypeAndValuePair> flat_compares() const;
|
||||
static bool matches_character_class(CharClass, u32, bool insensitive);
|
||||
|
||||
|
|
|
@ -61,13 +61,13 @@ public:
|
|||
system.characters(),
|
||||
state.instruction_position,
|
||||
recursion,
|
||||
opcode.to_string().characters(),
|
||||
opcode.to_deprecated_string().characters(),
|
||||
opcode.arguments_string().characters(),
|
||||
DeprecatedString::formatted("ip: {:3}, sp: {:3}", state.instruction_position, state.string_position));
|
||||
if (newline)
|
||||
outln();
|
||||
if (newline && is<OpCode_Compare>(opcode)) {
|
||||
for (auto& line : to<OpCode_Compare>(opcode).variable_arguments_to_string())
|
||||
for (auto& line : to<OpCode_Compare>(opcode).variable_arguments_to_deprecated_string())
|
||||
outln(m_file, "{:15} | {:5} | {:9} | {:35} | {:30} | {:20}", "", "", "", "", line, "");
|
||||
}
|
||||
}
|
||||
|
@ -85,10 +85,10 @@ public:
|
|||
builder.appendff(", next ip: {}", state.instruction_position + opcode.size());
|
||||
}
|
||||
|
||||
outln(m_file, " | {:20}", builder.to_string());
|
||||
outln(m_file, " | {:20}", builder.to_deprecated_string());
|
||||
|
||||
if (is<OpCode_Compare>(opcode)) {
|
||||
for (auto& line : to<OpCode_Compare>(opcode).variable_arguments_to_string(input)) {
|
||||
for (auto& line : to<OpCode_Compare>(opcode).variable_arguments_to_deprecated_string(input)) {
|
||||
outln(m_file, "{:15} | {:5} | {:9} | {:35} | {:30} | {:20}", "", "", "", "", line, "");
|
||||
}
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public:
|
|||
for (size_t i = 0; i < length; ++i) {
|
||||
builder.append('=');
|
||||
}
|
||||
auto str = builder.to_string();
|
||||
auto str = builder.to_deprecated_string();
|
||||
VERIFY(!str.is_empty());
|
||||
|
||||
outln(m_file, "{}", str);
|
||||
|
@ -115,7 +115,7 @@ public:
|
|||
builder.append('-');
|
||||
}
|
||||
builder.append('\n');
|
||||
m_debug_stripline = builder.to_string();
|
||||
m_debug_stripline = builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -381,16 +381,16 @@ public:
|
|||
return view;
|
||||
}
|
||||
|
||||
DeprecatedString to_string() const
|
||||
DeprecatedString to_deprecated_string() const
|
||||
{
|
||||
return m_view.visit(
|
||||
[](StringView view) { return view.to_string(); },
|
||||
[](StringView view) { return view.to_deprecated_string(); },
|
||||
[](Utf16View view) { return view.to_utf8(Utf16View::AllowInvalidCodeUnits::Yes); },
|
||||
[](auto& view) {
|
||||
StringBuilder builder;
|
||||
for (auto it = view.begin(); it != view.end(); ++it)
|
||||
builder.append_code_point(*it);
|
||||
return builder.to_string();
|
||||
return builder.to_deprecated_string();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -434,8 +434,8 @@ public:
|
|||
bool operator==(char const* cstring) const
|
||||
{
|
||||
return m_view.visit(
|
||||
[&](Utf32View) { return to_string() == cstring; },
|
||||
[&](Utf16View) { return to_string() == cstring; },
|
||||
[&](Utf32View) { return to_deprecated_string() == cstring; },
|
||||
[&](Utf16View) { return to_deprecated_string() == cstring; },
|
||||
[&](Utf8View const& view) { return view.as_string() == cstring; },
|
||||
[&](StringView view) { return view == cstring; });
|
||||
}
|
||||
|
@ -443,8 +443,8 @@ public:
|
|||
bool operator==(DeprecatedString const& string) const
|
||||
{
|
||||
return m_view.visit(
|
||||
[&](Utf32View) { return to_string() == string; },
|
||||
[&](Utf16View) { return to_string() == string; },
|
||||
[&](Utf32View) { return to_deprecated_string() == string; },
|
||||
[&](Utf16View) { return to_deprecated_string() == string; },
|
||||
[&](Utf8View const& view) { return view.as_string() == string; },
|
||||
[&](StringView view) { return view == string; });
|
||||
}
|
||||
|
@ -452,8 +452,8 @@ public:
|
|||
bool operator==(StringView string) const
|
||||
{
|
||||
return m_view.visit(
|
||||
[&](Utf32View) { return to_string() == string; },
|
||||
[&](Utf16View) { return to_string() == string; },
|
||||
[&](Utf32View) { return to_deprecated_string() == string; },
|
||||
[&](Utf16View) { return to_deprecated_string() == string; },
|
||||
[&](Utf8View const& view) { return view.as_string() == string; },
|
||||
[&](StringView view) { return view == string; });
|
||||
}
|
||||
|
@ -464,25 +464,25 @@ public:
|
|||
[&](Utf32View view) {
|
||||
return view.length() == other.length() && __builtin_memcmp(view.code_points(), other.code_points(), view.length() * sizeof(u32)) == 0;
|
||||
},
|
||||
[&](Utf16View) { return to_string() == RegexStringView { other }.to_string(); },
|
||||
[&](Utf8View const& view) { return view.as_string() == RegexStringView { other }.to_string(); },
|
||||
[&](StringView view) { return view == RegexStringView { other }.to_string(); });
|
||||
[&](Utf16View) { return to_deprecated_string() == RegexStringView { other }.to_deprecated_string(); },
|
||||
[&](Utf8View const& view) { return view.as_string() == RegexStringView { other }.to_deprecated_string(); },
|
||||
[&](StringView view) { return view == RegexStringView { other }.to_deprecated_string(); });
|
||||
}
|
||||
|
||||
bool operator==(Utf16View const& other) const
|
||||
{
|
||||
return m_view.visit(
|
||||
[&](Utf32View) { return to_string() == RegexStringView { other }.to_string(); },
|
||||
[&](Utf32View) { return to_deprecated_string() == RegexStringView { other }.to_deprecated_string(); },
|
||||
[&](Utf16View const& view) { return view == other; },
|
||||
[&](Utf8View const& view) { return view.as_string() == RegexStringView { other }.to_string(); },
|
||||
[&](StringView view) { return view == RegexStringView { other }.to_string(); });
|
||||
[&](Utf8View const& view) { return view.as_string() == RegexStringView { other }.to_deprecated_string(); },
|
||||
[&](StringView view) { return view == RegexStringView { other }.to_deprecated_string(); });
|
||||
}
|
||||
|
||||
bool operator==(Utf8View const& other) const
|
||||
{
|
||||
return m_view.visit(
|
||||
[&](Utf32View) { return to_string() == other.as_string(); },
|
||||
[&](Utf16View) { return to_string() == other.as_string(); },
|
||||
[&](Utf32View) { return to_deprecated_string() == other.as_string(); },
|
||||
[&](Utf16View) { return to_deprecated_string() == other.as_string(); },
|
||||
[&](Utf8View const& view) { return view.as_string() == other.as_string(); },
|
||||
[&](StringView view) { return other.as_string() == view; });
|
||||
}
|
||||
|
@ -653,7 +653,7 @@ template<>
|
|||
struct AK::Formatter<regex::RegexStringView> : Formatter<StringView> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, regex::RegexStringView value)
|
||||
{
|
||||
auto string = value.to_string();
|
||||
auto string = value.to_deprecated_string();
|
||||
return Formatter<StringView>::format(builder, string);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -169,7 +169,7 @@ RegexResult Matcher<Parser>::match(Vector<RegexStringView> const& views, Optiona
|
|||
|
||||
VERIFY(start_position + state.string_position - start_position <= input.view.length());
|
||||
if (input.regex_options.has_flag_set(AllFlags::StringCopyMatches)) {
|
||||
state.matches.at(input.match_index) = { input.view.substring_view(start_position, state.string_position - start_position).to_string(), input.line, start_position, input.global_offset + start_position };
|
||||
state.matches.at(input.match_index) = { input.view.substring_view(start_position, state.string_position - start_position).to_deprecated_string(), input.line, start_position, input.global_offset + start_position };
|
||||
} else { // let the view point to the original string ...
|
||||
state.matches.at(input.match_index) = { input.view.substring_view(start_position, state.string_position - start_position), input.line, start_position, input.global_offset + start_position };
|
||||
}
|
||||
|
|
|
@ -123,11 +123,11 @@ public:
|
|||
size_t start_offset = 0;
|
||||
RegexResult result = matcher->match(view, regex_options);
|
||||
if (!result.success)
|
||||
return view.to_string();
|
||||
return view.to_deprecated_string();
|
||||
|
||||
for (size_t i = 0; i < result.matches.size(); ++i) {
|
||||
auto& match = result.matches[i];
|
||||
builder.append(view.substring_view(start_offset, match.global_offset - start_offset).to_string());
|
||||
builder.append(view.substring_view(start_offset, match.global_offset - start_offset).to_deprecated_string());
|
||||
start_offset = match.global_offset + match.view.length();
|
||||
GenericLexer lexer(replacement_pattern);
|
||||
while (!lexer.is_eof()) {
|
||||
|
@ -138,7 +138,7 @@ public:
|
|||
}
|
||||
auto number = lexer.consume_while(isdigit);
|
||||
if (auto index = number.to_uint(); index.has_value() && result.n_capture_groups >= index.value()) {
|
||||
builder.append(result.capture_group_matches[i][index.value() - 1].view.to_string());
|
||||
builder.append(result.capture_group_matches[i][index.value() - 1].view.to_deprecated_string());
|
||||
} else {
|
||||
builder.appendff("\\{}", number);
|
||||
}
|
||||
|
@ -148,9 +148,9 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
builder.append(view.substring_view(start_offset, view.length() - start_offset).to_string());
|
||||
builder.append(view.substring_view(start_offset, view.length() - start_offset).to_deprecated_string());
|
||||
|
||||
return builder.to_string();
|
||||
return builder.to_deprecated_string();
|
||||
}
|
||||
|
||||
// FIXME: replace(Vector<RegexStringView> const , ...)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue