summaryrefslogtreecommitdiff
path: root/Meta/Lagom
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-12-04 18:02:33 +0000
committerAndreas Kling <kling@serenityos.org>2022-12-06 08:54:33 +0100
commit6e19ab2bbce0b113b628e6f8e9b5c0640053933e (patch)
tree372d21b2f5dcff112f5d0089559c6af5798680d4 /Meta/Lagom
parentf74251606d74b504a1379ebb893fdb5529054ea5 (diff)
downloadserenity-6e19ab2bbce0b113b628e6f8e9b5c0640053933e.zip
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
Diffstat (limited to 'Meta/Lagom')
-rw-r--r--Meta/Lagom/Fuzzers/FuzzCyrillicDecoder.cpp2
-rw-r--r--Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp2
-rw-r--r--Meta/Lagom/Fuzzers/FuzzHebrewDecoder.cpp2
-rw-r--r--Meta/Lagom/Fuzzers/FuzzLatin1Decoder.cpp2
-rw-r--r--Meta/Lagom/Fuzzers/FuzzLatin2Decoder.cpp2
-rw-r--r--Meta/Lagom/Fuzzers/FuzzQuotedPrintableParser.cpp2
-rw-r--r--Meta/Lagom/Fuzzers/FuzzUTF16BEDecoder.cpp2
-rw-r--r--Meta/Lagom/Fuzzers/FuzzilliJs.cpp2
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp64
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibEDID/GeneratePnpIDs.cpp22
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp80
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp132
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp58
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp62
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp22
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp50
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp32
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp96
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h70
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp160
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp4
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp4
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp32
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/LibWeb/GeneratorUtil.h8
-rw-r--r--Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp24
-rw-r--r--Meta/Lagom/Tools/ConfigureComponents/main.cpp46
-rw-r--r--Meta/Lagom/Tools/IPCMagicLinter/main.cpp8
-rw-r--r--Meta/Lagom/Wasm/js_repl.cpp8
28 files changed, 499 insertions, 499 deletions
diff --git a/Meta/Lagom/Fuzzers/FuzzCyrillicDecoder.cpp b/Meta/Lagom/Fuzzers/FuzzCyrillicDecoder.cpp
index e5160bde57..8bbd7cc83c 100644
--- a/Meta/Lagom/Fuzzers/FuzzCyrillicDecoder.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzCyrillicDecoder.cpp
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <AK/String.h>
+#include <AK/DeprecatedString.h>
#include <LibTextCodec/Decoder.h>
#include <stddef.h>
#include <stdint.h>
diff --git a/Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp b/Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp
index f066f445ae..f72354e19c 100644
--- a/Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzGIFLoader.cpp
@@ -5,8 +5,8 @@
*/
#include <AK/Debug.h>
+#include <AK/DeprecatedString.h>
#include <AK/Format.h>
-#include <AK/String.h>
#include <LibGfx/GIFLoader.h>
#include <stddef.h>
#include <stdint.h>
diff --git a/Meta/Lagom/Fuzzers/FuzzHebrewDecoder.cpp b/Meta/Lagom/Fuzzers/FuzzHebrewDecoder.cpp
index 162dfd6a7c..98e123df48 100644
--- a/Meta/Lagom/Fuzzers/FuzzHebrewDecoder.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzHebrewDecoder.cpp
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <AK/String.h>
+#include <AK/DeprecatedString.h>
#include <LibTextCodec/Decoder.h>
#include <stddef.h>
#include <stdint.h>
diff --git a/Meta/Lagom/Fuzzers/FuzzLatin1Decoder.cpp b/Meta/Lagom/Fuzzers/FuzzLatin1Decoder.cpp
index fefe5d341d..97733bbc7a 100644
--- a/Meta/Lagom/Fuzzers/FuzzLatin1Decoder.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzLatin1Decoder.cpp
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <AK/String.h>
+#include <AK/DeprecatedString.h>
#include <LibTextCodec/Decoder.h>
#include <stddef.h>
#include <stdint.h>
diff --git a/Meta/Lagom/Fuzzers/FuzzLatin2Decoder.cpp b/Meta/Lagom/Fuzzers/FuzzLatin2Decoder.cpp
index 5bdf6c7af0..3ff3e14ceb 100644
--- a/Meta/Lagom/Fuzzers/FuzzLatin2Decoder.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzLatin2Decoder.cpp
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <AK/String.h>
+#include <AK/DeprecatedString.h>
#include <LibTextCodec/Decoder.h>
#include <stddef.h>
#include <stdint.h>
diff --git a/Meta/Lagom/Fuzzers/FuzzQuotedPrintableParser.cpp b/Meta/Lagom/Fuzzers/FuzzQuotedPrintableParser.cpp
index ad85fcb9de..c1bf58c372 100644
--- a/Meta/Lagom/Fuzzers/FuzzQuotedPrintableParser.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzQuotedPrintableParser.cpp
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <AK/String.h>
+#include <AK/DeprecatedString.h>
#include <AK/StringView.h>
#include <LibIMAP/QuotedPrintable.h>
diff --git a/Meta/Lagom/Fuzzers/FuzzUTF16BEDecoder.cpp b/Meta/Lagom/Fuzzers/FuzzUTF16BEDecoder.cpp
index d1e3cf43d5..f054e793d5 100644
--- a/Meta/Lagom/Fuzzers/FuzzUTF16BEDecoder.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzUTF16BEDecoder.cpp
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include <AK/String.h>
+#include <AK/DeprecatedString.h>
#include <LibTextCodec/Decoder.h>
#include <stddef.h>
#include <stdint.h>
diff --git a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp
index f55840bcac..423484ad82 100644
--- a/Meta/Lagom/Fuzzers/FuzzilliJs.cpp
+++ b/Meta/Lagom/Fuzzers/FuzzilliJs.cpp
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <AK/DeprecatedString.h>
#include <AK/Function.h>
-#include <AK/String.h>
#include <AK/StringView.h>
#include <LibJS/Forward.h>
#include <LibJS/Interpreter.h>
diff --git a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp
index 9eebb2f916..32fb7b5c70 100644
--- a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp
@@ -16,12 +16,12 @@
#include <stdio.h>
struct Parameter {
- Vector<String> attributes;
- String type;
- String name;
+ Vector<DeprecatedString> attributes;
+ DeprecatedString type;
+ DeprecatedString name;
};
-static String pascal_case(String const& identifier)
+static DeprecatedString pascal_case(DeprecatedString const& identifier)
{
StringBuilder builder;
bool was_new_word = true;
@@ -40,12 +40,12 @@ static String pascal_case(String const& identifier)
}
struct Message {
- String name;
+ DeprecatedString name;
bool is_synchronous { false };
Vector<Parameter> inputs;
Vector<Parameter> outputs;
- String response_name() const
+ DeprecatedString response_name() const
{
StringBuilder builder;
builder.append(pascal_case(name));
@@ -55,18 +55,18 @@ struct Message {
};
struct Endpoint {
- Vector<String> includes;
- String name;
+ Vector<DeprecatedString> includes;
+ DeprecatedString name;
u32 magic;
Vector<Message> messages;
};
-static bool is_primitive_type(String const& type)
+static bool is_primitive_type(DeprecatedString const& type)
{
return type.is_one_of("u8", "i8", "u16", "i16", "u32", "i32", "u64", "i64", "bool", "double", "float", "int", "unsigned", "unsigned int");
}
-static String message_name(String const& endpoint, String const& message, bool is_response)
+static DeprecatedString message_name(DeprecatedString const& endpoint, DeprecatedString const& message, bool is_response)
{
StringBuilder builder;
builder.append("Messages::"sv);
@@ -121,7 +121,7 @@ Vector<Endpoint> parse(ByteBuffer const& file_contents)
consume_whitespace();
}
}
- // FIXME: This is not entirely correct. Types can have spaces, for example `HashMap<int, String>`.
+ // FIXME: This is not entirely correct. Types can have spaces, for example `HashMap<int, DeprecatedString>`.
// Maybe we should use LibCpp::Parser for parsing types.
parameter.type = lexer.consume_until([](char ch) { return isspace(ch); });
VERIFY(!lexer.is_eof());
@@ -191,7 +191,7 @@ Vector<Endpoint> parse(ByteBuffer const& file_contents)
};
auto parse_include = [&] {
- String include;
+ DeprecatedString include;
consume_whitespace();
include = lexer.consume_while([](char ch) { return ch != '\n'; });
consume_whitespace();
@@ -217,7 +217,7 @@ Vector<Endpoint> parse(ByteBuffer const& file_contents)
lexer.consume_specific("endpoint");
consume_whitespace();
endpoints.last().name = lexer.consume_while([](char ch) { return !isspace(ch); });
- endpoints.last().magic = Traits<String>::hash(endpoints.last().name);
+ endpoints.last().magic = Traits<DeprecatedString>::hash(endpoints.last().name);
consume_whitespace();
assert_specific('{');
parse_messages();
@@ -231,22 +231,22 @@ Vector<Endpoint> parse(ByteBuffer const& file_contents)
return endpoints;
}
-HashMap<String, int> build_message_ids_for_endpoint(SourceGenerator generator, Endpoint const& endpoint)
+HashMap<DeprecatedString, int> build_message_ids_for_endpoint(SourceGenerator generator, Endpoint const& endpoint)
{
- HashMap<String, int> message_ids;
+ HashMap<DeprecatedString, int> message_ids;
generator.appendln("\nenum class MessageID : i32 {");
for (auto const& message : endpoint.messages) {
message_ids.set(message.name, message_ids.size() + 1);
generator.set("message.pascal_name", pascal_case(message.name));
- generator.set("message.id", String::number(message_ids.size()));
+ generator.set("message.id", DeprecatedString::number(message_ids.size()));
generator.appendln(" @message.pascal_name@ = @message.id@,");
if (message.is_synchronous) {
message_ids.set(message.response_name(), message_ids.size() + 1);
generator.set("message.pascal_name", pascal_case(message.response_name()));
- generator.set("message.id", String::number(message_ids.size()));
+ generator.set("message.id", DeprecatedString::number(message_ids.size()));
generator.appendln(" @message.pascal_name@ = @message.id@,");
}
@@ -255,7 +255,7 @@ HashMap<String, int> build_message_ids_for_endpoint(SourceGenerator generator, E
return message_ids;
}
-String constructor_for_message(String const& name, Vector<Parameter> const& parameters)
+DeprecatedString constructor_for_message(DeprecatedString const& name, Vector<Parameter> const& parameters)
{
StringBuilder builder;
builder.append(name);
@@ -282,7 +282,7 @@ String constructor_for_message(String const& name, Vector<Parameter> const& para
return builder.to_string();
}
-void do_message(SourceGenerator message_generator, String const& name, Vector<Parameter> const& parameters, String const& response_type = {})
+void do_message(SourceGenerator message_generator, DeprecatedString const& name, Vector<Parameter> const& parameters, DeprecatedString const& response_type = {})
{
auto pascal_name = pascal_case(name);
message_generator.set("message.name", name);
@@ -418,17 +418,17 @@ private:
void do_message_for_proxy(SourceGenerator message_generator, Endpoint const& endpoint, Message const& message)
{
- auto do_implement_proxy = [&](String const& name, Vector<Parameter> const& parameters, bool is_synchronous, bool is_try) {
- String return_type = "void";
+ auto do_implement_proxy = [&](DeprecatedString const& name, Vector<Parameter> const& parameters, bool is_synchronous, bool is_try) {
+ DeprecatedString return_type = "void";
if (is_synchronous) {
if (message.outputs.size() == 1)
return_type = message.outputs[0].type;
else if (!message.outputs.is_empty())
return_type = message_name(endpoint.name, message.name, true);
}
- String inner_return_type = return_type;
+ DeprecatedString inner_return_type = return_type;
if (is_try)
- return_type = String::formatted("IPC::IPCErrorOr<{}>", return_type);
+ return_type = DeprecatedString::formatted("IPC::IPCErrorOr<{}>", return_type);
message_generator.set("message.name", message.name);
message_generator.set("message.pascal_name", pascal_case(message.name));
@@ -527,14 +527,14 @@ void do_message_for_proxy(SourceGenerator message_generator, Endpoint const& end
void build_endpoint(SourceGenerator generator, Endpoint const& endpoint)
{
generator.set("endpoint.name", endpoint.name);
- generator.set("endpoint.magic", String::number(endpoint.magic));
+ generator.set("endpoint.magic", DeprecatedString::number(endpoint.magic));
generator.appendln("\nnamespace Messages::@endpoint.name@ {");
- HashMap<String, int> message_ids = build_message_ids_for_endpoint(generator.fork(), endpoint);
+ HashMap<DeprecatedString, int> message_ids = build_message_ids_for_endpoint(generator.fork(), endpoint);
for (auto const& message : endpoint.messages) {
- String response_name;
+ DeprecatedString response_name;
if (message.is_synchronous) {
response_name = message.response_name();
do_message(generator.fork(), response_name, message.outputs);
@@ -614,7 +614,7 @@ public:
switch (message_id) {)~~~");
for (auto const& message : endpoint.messages) {
- auto do_decode_message = [&](String const& name) {
+ auto do_decode_message = [&](DeprecatedString const& name) {
auto message_generator = generator.fork();
message_generator.set("message.name", name);
@@ -661,13 +661,13 @@ public:
virtual ~@endpoint.name@Stub() override { }
virtual u32 magic() const override { return @endpoint.magic@; }
- virtual String name() const override { return "@endpoint.name@"; }
+ virtual DeprecatedString name() const override { return "@endpoint.name@"; }
virtual OwnPtr<IPC::MessageBuffer> handle(const IPC::Message& message) override
{
switch (message.message_id()) {)~~~");
for (auto const& message : endpoint.messages) {
- auto do_handle_message = [&](String const& name, Vector<Parameter> const& parameters, bool returns_something) {
+ auto do_handle_message = [&](DeprecatedString const& name, Vector<Parameter> const& parameters, bool returns_something) {
auto message_generator = generator.fork();
StringBuilder argument_generator;
@@ -721,8 +721,8 @@ public:
for (auto const& message : endpoint.messages) {
auto message_generator = generator.fork();
- auto do_handle_message_decl = [&](String const& name, Vector<Parameter> const& parameters, bool is_response) {
- String return_type = "void";
+ auto do_handle_message_decl = [&](DeprecatedString const& name, Vector<Parameter> const& parameters, bool is_response) {
+ DeprecatedString return_type = "void";
if (message.is_synchronous && !message.outputs.is_empty() && !is_response)
return_type = message_name(endpoint.name, message.name, true);
message_generator.set("message.complex_return_type", return_type);
@@ -731,7 +731,7 @@ public:
message_generator.appendln(R"~~~(
virtual @message.complex_return_type@ @handler_name@()~~~");
- auto make_argument_type = [](String const& type) {
+ auto make_argument_type = [](DeprecatedString const& type) {
StringBuilder builder;
bool const_ref = !is_primitive_type(type);
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibEDID/GeneratePnpIDs.cpp b/Meta/Lagom/Tools/CodeGenerators/LibEDID/GeneratePnpIDs.cpp
index aab3df4ecd..d48b13dffe 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibEDID/GeneratePnpIDs.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibEDID/GeneratePnpIDs.cpp
@@ -23,11 +23,11 @@ struct ApprovalDate {
};
struct PnpIdData {
- String manufacturer_name;
+ DeprecatedString manufacturer_name;
ApprovalDate approval_date;
};
-static ErrorOr<String> decode_html_entities(StringView const& str)
+static ErrorOr<DeprecatedString> decode_html_entities(StringView const& str)
{
static constexpr struct {
StringView entity_name;
@@ -116,12 +116,12 @@ static ErrorOr<ApprovalDate> parse_approval_date(StringView const& str)
return ApprovalDate { .year = year.value(), .month = month.value(), .day = day.value() };
}
-static ErrorOr<HashMap<String, PnpIdData>> parse_pnp_ids_database(Core::Stream::File& pnp_ids_file)
+static ErrorOr<HashMap<DeprecatedString, PnpIdData>> parse_pnp_ids_database(Core::Stream::File& pnp_ids_file)
{
auto pnp_ids_file_bytes = TRY(pnp_ids_file.read_all());
StringView pnp_ids_file_contents(pnp_ids_file_bytes);
- HashMap<String, PnpIdData> pnp_id_data;
+ HashMap<DeprecatedString, PnpIdData> pnp_id_data;
for (size_t row_content_offset = 0;;) {
static auto const row_start_tag = "<tr class=\""sv;
@@ -142,7 +142,7 @@ static ErrorOr<HashMap<String, PnpIdData>> parse_pnp_ids_database(Core::Stream::
return Error::from_string_literal("Invalid row start tag");
auto row_string = pnp_ids_file_contents.substring_view(row_start_tag_end.value() + 1, row_end.value() - row_start_tag_end.value() - 1);
- Vector<String, (size_t)PnpIdColumns::ColumnCount> columns;
+ Vector<DeprecatedString, (size_t)PnpIdColumns::ColumnCount> columns;
for (size_t column_row_offset = 0;;) {
static auto const column_start_tag = "<td>"sv;
auto column_start = row_string.find(column_start_tag, column_row_offset);
@@ -181,12 +181,12 @@ static ErrorOr<HashMap<String, PnpIdData>> parse_pnp_ids_database(Core::Stream::
return pnp_id_data;
}
-static ErrorOr<void> generate_header(Core::Stream::File& file, HashMap<String, PnpIdData> const& pnp_ids)
+static ErrorOr<void> generate_header(Core::Stream::File& file, HashMap<DeprecatedString, PnpIdData> const& pnp_ids)
{
StringBuilder builder;
SourceGenerator generator { builder };
- generator.set("pnp_id_count", String::formatted("{}", pnp_ids.size()));
+ generator.set("pnp_id_count", DeprecatedString::formatted("{}", pnp_ids.size()));
generator.append(R"~~~(
#pragma once
@@ -215,7 +215,7 @@ namespace PnpIDs {
return {};
}
-static ErrorOr<void> generate_source(Core::Stream::File& file, HashMap<String, PnpIdData> const& pnp_ids)
+static ErrorOr<void> generate_source(Core::Stream::File& file, HashMap<DeprecatedString, PnpIdData> const& pnp_ids)
{
StringBuilder builder;
SourceGenerator generator { builder };
@@ -231,9 +231,9 @@ static constexpr PnpIDData s_pnp_ids[] = {
for (auto& pnp_id_data : pnp_ids) {
generator.set("manufacturer_id", pnp_id_data.key);
generator.set("manufacturer_name", pnp_id_data.value.manufacturer_name);
- generator.set("approval_year", String::formatted("{}", pnp_id_data.value.approval_date.year));
- generator.set("approval_month", String::formatted("{}", pnp_id_data.value.approval_date.month));
- generator.set("approval_day", String::formatted("{}", pnp_id_data.value.approval_date.day));
+ generator.set("approval_year", DeprecatedString::formatted("{}", pnp_id_data.value.approval_date.year));
+ generator.set("approval_month", DeprecatedString::formatted("{}", pnp_id_data.value.approval_date.month));
+ generator.set("approval_day", DeprecatedString::formatted("{}", pnp_id_data.value.approval_date.day));
generator.append(R"~~~(
{ "@manufacturer_id@"sv, "@manufacturer_name@"sv, { @approval_year@, @approval_month@, @approval_day@ } },
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp
index 34083106cb..df8f5257c5 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateDateTimeFormatData.cpp
@@ -7,6 +7,7 @@
#include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common.
#include <AK/AllOf.h>
#include <AK/CharacterTypes.h>
+#include <AK/DeprecatedString.h>
#include <AK/Find.h>
#include <AK/Format.h>
#include <AK/GenericLexer.h>
@@ -17,7 +18,6 @@
#include <AK/JsonValue.h>
#include <AK/LexicalPath.h>
#include <AK/SourceGenerator.h>
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/Traits.h>
#include <AK/Utf8View.h>
@@ -487,7 +487,7 @@ struct AK::Formatter<Locale::HourCycle> : Formatter<FormatString> {
};
struct LocaleData {
- HashMap<String, size_t> calendars;
+ HashMap<DeprecatedString, size_t> calendars;
size_t time_zones { 0 };
size_t time_zone_formats { 0 };
@@ -513,27 +513,27 @@ struct CLDR {
UniqueStorage<DayPeriodList> unique_day_period_lists;
UniqueStorage<HourCycleList> unique_hour_cycle_lists;
- HashMap<String, LocaleData> locales;
+ HashMap<DeprecatedString, LocaleData> locales;
- HashMap<String, size_t> hour_cycles;
- Vector<String> hour_cycle_regions;
+ HashMap<DeprecatedString, size_t> hour_cycles;
+ Vector<DeprecatedString> hour_cycle_regions;
- HashMap<String, u8> minimum_days;
- Vector<String> minimum_days_regions;
+ HashMap<DeprecatedString, u8> minimum_days;
+ Vector<DeprecatedString> minimum_days_regions;
- HashMap<String, Locale::Weekday> first_day;
- Vector<String> first_day_regions;
+ HashMap<DeprecatedString, Locale::Weekday> first_day;
+ Vector<DeprecatedString> first_day_regions;
- HashMap<String, Locale::Weekday> weekend_start;
- Vector<String> weekend_start_regions;
+ HashMap<DeprecatedString, Locale::Weekday> weekend_start;
+ Vector<DeprecatedString> weekend_start_regions;
- HashMap<String, Locale::Weekday> weekend_end;
- Vector<String> weekend_end_regions;
+ HashMap<DeprecatedString, Locale::Weekday> weekend_end;
+ Vector<DeprecatedString> weekend_end_regions;
- HashMap<String, Vector<TimeZone::TimeZone>> meta_zones;
- Vector<String> time_zones { "UTC"sv };
+ HashMap<DeprecatedString, Vector<TimeZone::TimeZone>> meta_zones;
+ Vector<DeprecatedString> time_zones { "UTC"sv };
- Vector<String> calendars;
+ Vector<DeprecatedString> calendars;
};
static Optional<Locale::DayPeriod> day_period_from_string(StringView day_period)
@@ -563,7 +563,7 @@ static Optional<Locale::DayPeriod> day_period_from_string(StringView day_period)
return {};
}
-static ErrorOr<void> parse_hour_cycles(String core_path, CLDR& cldr)
+static ErrorOr<void> parse_hour_cycles(DeprecatedString core_path, CLDR& cldr)
{
// https://unicode.org/reports/tr35/tr35-dates.html#Time_Data
LexicalPath time_data_path(move(core_path));
@@ -607,7 +607,7 @@ static ErrorOr<void> parse_hour_cycles(String core_path, CLDR& cldr)
return {};
}
-static ErrorOr<void> parse_week_data(String core_path, CLDR& cldr)
+static ErrorOr<void> parse_week_data(DeprecatedString core_path, CLDR& cldr)
{
// https://unicode.org/reports/tr35/tr35-dates.html#Week_Data
LexicalPath week_data_path(move(core_path));
@@ -672,7 +672,7 @@ static ErrorOr<void> parse_week_data(String core_path, CLDR& cldr)
return {};
}
-static ErrorOr<void> parse_meta_zones(String core_path, CLDR& cldr)
+static ErrorOr<void> parse_meta_zones(DeprecatedString core_path, CLDR& cldr)
{
// https://unicode.org/reports/tr35/tr35-dates.html#Metazones
LexicalPath meta_zone_path(move(core_path));
@@ -714,7 +714,7 @@ static constexpr auto is_char(char ch)
// "{hour}:{minute} {ampm}" becomes "{hour}:{minute}" (remove the space before {ampm})
// "{ampm} {hour}" becomes "{hour}" (remove the space after {ampm})
// "{hour}:{minute} {ampm} {timeZoneName}" becomes "{hour}:{minute} {timeZoneName}" (remove one of the spaces around {ampm})
-static String remove_period_from_pattern(String pattern)
+static DeprecatedString remove_period_from_pattern(DeprecatedString pattern)
{
auto is_surrounding_space = [&](auto code_point_iterator) {
if (code_point_iterator.done())
@@ -751,15 +751,15 @@ static String remove_period_from_pattern(String pattern)
after_removal = it;
if (is_surrounding_space(before_removal) && !is_opening(after_removal)) {
- pattern = String::formatted("{}{}",
+ pattern = DeprecatedString::formatted("{}{}",
pattern.substring_view(0, *index - before_removal.underlying_code_point_length_in_bytes()),
pattern.substring_view(*index + remove.length()));
} else if (is_surrounding_space(after_removal) && !is_closing(before_removal)) {
- pattern = String::formatted("{}{}",
+ pattern = DeprecatedString::formatted("{}{}",
pattern.substring_view(0, *index),
pattern.substring_view(*index + remove.length() + after_removal.underlying_code_point_length_in_bytes()));
} else {
- pattern = String::formatted("{}{}",
+ pattern = DeprecatedString::formatted("{}{}",
pattern.substring_view(0, *index),
pattern.substring_view(*index + remove.length()));
}
@@ -768,7 +768,7 @@ static String remove_period_from_pattern(String pattern)
return pattern;
}
-static Optional<CalendarPattern> parse_date_time_pattern_raw(String pattern, String skeleton, CLDR& cldr)
+static Optional<CalendarPattern> parse_date_time_pattern_raw(DeprecatedString pattern, DeprecatedString skeleton, CLDR& cldr)
{
// https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
using Locale::CalendarPatternStyle;
@@ -987,7 +987,7 @@ static Optional<CalendarPattern> parse_date_time_pattern_raw(String pattern, Str
return format;
}
-static Optional<size_t> parse_date_time_pattern(String pattern, String skeleton, CLDR& cldr)
+static Optional<size_t> parse_date_time_pattern(DeprecatedString pattern, DeprecatedString skeleton, CLDR& cldr)
{
auto format = parse_date_time_pattern_raw(move(pattern), move(skeleton), cldr);
if (!format.has_value())
@@ -1377,7 +1377,7 @@ static void parse_calendar_symbols(Calendar& calendar, JsonObject const& calenda
calendar.symbols = cldr.unique_calendar_symbols_lists.ensure(move(symbols_list));
}
-static ErrorOr<void> parse_calendars(String locale_calendars_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_calendars(DeprecatedString locale_calendars_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath calendars_path(move(locale_calendars_path));
if (!calendars_path.basename().starts_with("ca-"sv))
@@ -1394,7 +1394,7 @@ static ErrorOr<void> parse_calendars(String locale_calendars_path, CLDR& cldr, L
auto format = patterns_object.get(name);
auto skeleton = skeletons_object.get(name);
- auto format_index = parse_date_time_pattern(format.as_string(), skeleton.as_string_or(String::empty()), cldr).value();
+ auto format_index = parse_date_time_pattern(format.as_string(), skeleton.as_string_or(DeprecatedString::empty()), cldr).value();
if (patterns)
patterns->append(cldr.unique_patterns.get(format_index));
@@ -1468,7 +1468,7 @@ static ErrorOr<void> parse_calendars(String locale_calendars_path, CLDR& cldr, L
return {};
}
-static ErrorOr<void> parse_time_zone_names(String locale_time_zone_names_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_time_zone_names(DeprecatedString locale_time_zone_names_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath time_zone_names_path(move(locale_time_zone_names_path));
time_zone_names_path = time_zone_names_path.append("timeZoneNames.json"sv);
@@ -1577,7 +1577,7 @@ static ErrorOr<void> parse_time_zone_names(String locale_time_zone_names_path, C
return {};
}
-static ErrorOr<void> parse_day_periods(String core_path, CLDR& cldr)
+static ErrorOr<void> parse_day_periods(DeprecatedString core_path, CLDR& cldr)
{
// https://unicode.org/reports/tr35/tr35-dates.html#Day_Period_Rule_Sets
LexicalPath day_periods_path(move(core_path));
@@ -1633,7 +1633,7 @@ static ErrorOr<void> parse_day_periods(String core_path, CLDR& cldr)
return {};
}
-static ErrorOr<void> parse_all_locales(String core_path, String dates_path, CLDR& cldr)
+static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedString dates_path, CLDR& cldr)
{
TRY(parse_hour_cycles(core_path, cldr));
TRY(parse_week_data(core_path, cldr));
@@ -1641,7 +1641,7 @@ static ErrorOr<void> parse_all_locales(String core_path, String dates_path, CLDR
auto dates_iterator = TRY(path_to_dir_iterator(move(dates_path)));
- auto remove_variants_from_path = [&](String path) -> ErrorOr<String> {
+ auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr<DeprecatedString> {
auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path)));
StringBuilder builder;
@@ -1673,15 +1673,15 @@ static ErrorOr<void> parse_all_locales(String core_path, String dates_path, CLDR
return {};
}
-static String format_identifier(StringView owner, String identifier)
+static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier)
{
identifier = identifier.replace("-"sv, "_"sv, ReplaceMode::All);
identifier = identifier.replace("/"sv, "_"sv, ReplaceMode::All);
if (all_of(identifier, is_ascii_digit))
- return String::formatted("{}_{}", owner[0], identifier);
+ return DeprecatedString::formatted("{}_{}", owner[0], identifier);
if (is_ascii_lower_alpha(identifier[0]))
- return String::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
+ return DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
return identifier;
}
@@ -1937,9 +1937,9 @@ struct DayPeriodData {
cldr.unique_day_period_lists.generate(generator, cldr.unique_day_periods.type_that_fits(), "s_day_period_lists"sv);
cldr.unique_hour_cycle_lists.generate(generator, cldr.unique_hour_cycle_lists.type_that_fits(), "s_hour_cycle_lists"sv);
- auto append_calendars = [&](String name, auto const& calendars) {
+ auto append_calendars = [&](DeprecatedString name, auto const& calendars) {
generator.set("name", name);
- generator.set("size", String::number(calendars.size()));
+ generator.set("size", DeprecatedString::number(calendars.size()));
generator.append(R"~~~(
static constexpr Array<@calendar_index_type@, @size@> @name@ { {)~~~");
@@ -1949,7 +1949,7 @@ static constexpr Array<@calendar_index_type@, @size@> @name@ { {)~~~");
auto calendar = calendars.find(calendar_key)->value;
generator.append(first ? " "sv : ", "sv);
- generator.append(String::number(calendar));
+ generator.append(DeprecatedString::number(calendar));
first = false;
}
@@ -1959,7 +1959,7 @@ static constexpr Array<@calendar_index_type@, @size@> @name@ { {)~~~");
auto append_mapping = [&](auto const& keys, auto const& map, auto type, auto name, auto mapping_getter) {
generator.set("type", type);
generator.set("name", name);
- generator.set("size", String::number(keys.size()));
+ generator.set("size", DeprecatedString::number(keys.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> @name@ { {)~~~");
@@ -1970,7 +1970,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~");
auto mapping = mapping_getter(value);
generator.append(first ? " "sv : ", "sv);
- generator.append(String::number(mapping));
+ generator.append(DeprecatedString::number(mapping));
first = false;
}
@@ -1992,7 +1992,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~");
generator.append("\n");
auto append_from_string = [&](StringView enum_title, StringView enum_snake, auto const& values, Vector<Alias> const& aliases = {}) {
- HashValueMap<String> hashes;
+ HashValueMap<DeprecatedString> hashes;
hashes.ensure_capacity(values.size());
for (auto const& value : values)
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp
index 7b338d30fb..7e83227d6c 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateLocaleData.cpp
@@ -7,6 +7,7 @@
#include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common.
#include <AK/AllOf.h>
#include <AK/CharacterTypes.h>
+#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/HashMap.h>
#include <AK/JsonObject.h>
@@ -15,21 +16,20 @@
#include <AK/LexicalPath.h>
#include <AK/QuickSort.h>
#include <AK/SourceGenerator.h>
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DirIterator.h>
#include <LibCore/File.h>
#include <LibCore/Stream.h>
-static String format_identifier(StringView owner, String identifier)
+static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier)
{
identifier = identifier.replace("-"sv, "_"sv, ReplaceMode::All);
if (all_of(identifier, is_ascii_digit))
- return String::formatted("{}_{}", owner[0], identifier);
+ return DeprecatedString::formatted("{}_{}", owner[0], identifier);
if (is_ascii_lower_alpha(identifier[0]))
- return String::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
+ return DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
return identifier;
}
@@ -153,9 +153,9 @@ using KeywordList = Vector<size_t>;
using ListPatternList = Vector<size_t>;
struct LocaleData {
- String language;
- Optional<String> territory;
- Optional<String> variant;
+ DeprecatedString language;
+ Optional<DeprecatedString> territory;
+ Optional<DeprecatedString> variant;
size_t display_patterns { 0 };
size_t languages { 0 };
size_t territories { 0 };
@@ -195,15 +195,15 @@ struct CLDR {
UniqueStorage<ListPatternList> unique_list_pattern_lists;
UniqueStorage<TextLayout> unique_text_layouts;
- HashMap<String, LocaleData> locales;
+ HashMap<DeprecatedString, LocaleData> locales;
Vector<Alias> locale_aliases;
- Vector<String> languages;
- Vector<String> territories;
- Vector<String> scripts;
- Vector<String> variants;
- Vector<String> currencies;
- Vector<String> date_fields;
+ Vector<DeprecatedString> languages;
+ Vector<DeprecatedString> territories;
+ Vector<DeprecatedString> scripts;
+ Vector<DeprecatedString> variants;
+ Vector<DeprecatedString> currencies;
+ Vector<DeprecatedString> date_fields;
Vector<Alias> date_field_aliases {
// ECMA-402 and the CLDR refer to some date fields with different names. Defining these aliases
// means we can remain agnostic about the naming differences elsewhere.
@@ -212,17 +212,17 @@ struct CLDR {
{ "zone"sv, "timeZoneName"sv },
};
- HashMap<String, Vector<String>> keywords;
- HashMap<String, Vector<Alias>> keyword_aliases;
- HashMap<String, String> keyword_names;
-
- Vector<String> list_pattern_types;
- Vector<String> character_orders;
- HashMap<String, size_t> language_aliases;
- HashMap<String, size_t> territory_aliases;
- HashMap<String, size_t> script_aliases;
- HashMap<String, size_t> variant_aliases;
- HashMap<String, size_t> subdivision_aliases;
+ HashMap<DeprecatedString, Vector<DeprecatedString>> keywords;
+ HashMap<DeprecatedString, Vector<Alias>> keyword_aliases;
+ HashMap<DeprecatedString, DeprecatedString> keyword_names;
+
+ Vector<DeprecatedString> list_pattern_types;
+ Vector<DeprecatedString> character_orders;
+ HashMap<DeprecatedString, size_t> language_aliases;
+ HashMap<DeprecatedString, size_t> territory_aliases;
+ HashMap<DeprecatedString, size_t> script_aliases;
+ HashMap<DeprecatedString, size_t> variant_aliases;
+ HashMap<DeprecatedString, size_t> subdivision_aliases;
Vector<LanguageMapping> complex_mappings;
Vector<LanguageMapping> likely_subtags;
size_t max_variant_size { 0 };
@@ -245,7 +245,7 @@ static ErrorOr<LanguageMapping> parse_language_mapping(CLDR& cldr, StringView ke
return LanguageMapping { move(parsed_key), move(parsed_alias) };
}
-static ErrorOr<void> parse_core_aliases(String core_supplemental_path, CLDR& cldr)
+static ErrorOr<void> parse_core_aliases(DeprecatedString core_supplemental_path, CLDR& cldr)
{
LexicalPath core_aliases_path(move(core_supplemental_path));
core_aliases_path = core_aliases_path.append("aliases.json"sv);
@@ -279,7 +279,7 @@ static ErrorOr<void> parse_core_aliases(String core_supplemental_path, CLDR& cld
return {};
}
-static ErrorOr<void> parse_likely_subtags(String core_supplemental_path, CLDR& cldr)
+static ErrorOr<void> parse_likely_subtags(DeprecatedString core_supplemental_path, CLDR& cldr)
{
LexicalPath likely_subtags_path(move(core_supplemental_path));
likely_subtags_path = likely_subtags_path.append("likelySubtags.json"sv);
@@ -298,7 +298,7 @@ static ErrorOr<void> parse_likely_subtags(String core_supplemental_path, CLDR& c
return {};
}
-static ErrorOr<void> parse_identity(String locale_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_identity(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath languages_path(move(locale_path)); // Note: Every JSON file defines identity data, so we can use any of them.
languages_path = languages_path.append("languages.json"sv);
@@ -335,7 +335,7 @@ static ErrorOr<void> parse_identity(String locale_path, CLDR& cldr, LocaleData&
return {};
}
-static ErrorOr<void> parse_locale_display_patterns(String locale_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_locale_display_patterns(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath locale_display_names_path(move(locale_path));
locale_display_names_path = locale_display_names_path.append("localeDisplayNames.json"sv);
@@ -356,7 +356,7 @@ static ErrorOr<void> parse_locale_display_patterns(String locale_path, CLDR& cld
return {};
}
-static ErrorOr<void> preprocess_languages(String locale_path, CLDR& cldr)
+static ErrorOr<void> preprocess_languages(DeprecatedString locale_path, CLDR& cldr)
{
LexicalPath languages_path(move(locale_path));
languages_path = languages_path.append("languages.json"sv);
@@ -375,7 +375,7 @@ static ErrorOr<void> preprocess_languages(String locale_path, CLDR& cldr)
return {};
}
-static ErrorOr<void> parse_unicode_extension_keywords(String bcp47_path, CLDR& cldr)
+static ErrorOr<void> parse_unicode_extension_keywords(DeprecatedString bcp47_path, CLDR& cldr)
{
constexpr auto desired_keywords = Array { "ca"sv, "co"sv, "hc"sv, "kf"sv, "kn"sv, "nu"sv };
auto keywords = TRY(read_json_file(bcp47_path));
@@ -426,7 +426,7 @@ static ErrorOr<void> parse_unicode_extension_keywords(String bcp47_path, CLDR& c
return {};
}
-static Optional<String> find_keyword_alias(StringView key, StringView calendar, CLDR& cldr)
+static Optional<DeprecatedString> find_keyword_alias(StringView key, StringView calendar, CLDR& cldr)
{
auto it = cldr.keyword_aliases.find(key);
if (it == cldr.keyword_aliases.end())
@@ -439,7 +439,7 @@ static Optional<String> find_keyword_alias(StringView key, StringView calendar,
return alias->name;
}
-static ErrorOr<void> parse_locale_languages(String locale_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_locale_languages(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath languages_path(move(locale_path));
languages_path = languages_path.append("languages.json"sv);
@@ -465,7 +465,7 @@ static ErrorOr<void> parse_locale_languages(String locale_path, CLDR& cldr, Loca
return {};
}
-static ErrorOr<void> parse_locale_territories(String locale_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_locale_territories(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath territories_path(move(locale_path));
territories_path = territories_path.append("territories.json"sv);
@@ -488,7 +488,7 @@ static ErrorOr<void> parse_locale_territories(String locale_path, CLDR& cldr, Lo
return {};
}
-static ErrorOr<void> parse_locale_scripts(String locale_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_locale_scripts(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath scripts_path(move(locale_path));
scripts_path = scripts_path.append("scripts.json"sv);
@@ -511,7 +511,7 @@ static ErrorOr<void> parse_locale_scripts(String locale_path, CLDR& cldr, Locale
return {};
}
-static ErrorOr<void> parse_locale_list_patterns(String misc_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_locale_list_patterns(DeprecatedString misc_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath list_patterns_path(move(misc_path));
list_patterns_path = list_patterns_path.append("listPatterns.json"sv);
@@ -562,7 +562,7 @@ static ErrorOr<void> parse_locale_list_patterns(String misc_path, CLDR& cldr, Lo
return {};
}
-static ErrorOr<void> parse_locale_layout(String misc_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_locale_layout(DeprecatedString misc_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath layout_path(move(misc_path));
layout_path = layout_path.append("layout.json"sv);
@@ -594,7 +594,7 @@ static ErrorOr<void> parse_locale_layout(String misc_path, CLDR& cldr, LocaleDat
return {};
}
-static ErrorOr<void> parse_locale_currencies(String numbers_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_locale_currencies(DeprecatedString numbers_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath currencies_path(move(numbers_path));
currencies_path = currencies_path.append("currencies.json"sv);
@@ -642,7 +642,7 @@ static ErrorOr<void> parse_locale_currencies(String numbers_path, CLDR& cldr, Lo
return {};
}
-static ErrorOr<void> parse_locale_calendars(String locale_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_locale_calendars(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath locale_display_names_path(move(locale_path));
locale_display_names_path = locale_display_names_path.append("localeDisplayNames.json"sv);
@@ -673,7 +673,7 @@ static ErrorOr<void> parse_locale_calendars(String locale_path, CLDR& cldr, Loca
return {};
}
-static ErrorOr<void> parse_locale_date_fields(String dates_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_locale_date_fields(DeprecatedString dates_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath date_fields_path(move(dates_path));
date_fields_path = date_fields_path.append("dateFields.json"sv);
@@ -714,8 +714,8 @@ static ErrorOr<void> parse_locale_date_fields(String dates_path, CLDR& cldr, Loc
return;
auto const& long_name = value.as_object().get("displayName"sv);
- auto const& short_name = fields_object.as_object().get(String::formatted("{}-short", key)).as_object().get("displayName"sv);
- auto const& narrow_name = fields_object.as_object().get(String::formatted("{}-narrow", key)).as_object().get("displayName"sv);
+ auto const& short_name = fields_object.as_object().get(DeprecatedString::formatted("{}-short", key)).as_object().get("displayName"sv);
+ auto const& narrow_name = fields_object.as_object().get(DeprecatedString::formatted("{}-narrow", key)).as_object().get("displayName"sv);
auto index = cldr.date_fields.find_first_index(key).value();
long_date_fields[index] = cldr.unique_strings.ensure(long_name.as_string());
@@ -729,7 +729,7 @@ static ErrorOr<void> parse_locale_date_fields(String dates_path, CLDR& cldr, Loc
return {};
}
-static ErrorOr<void> parse_number_system_keywords(String locale_numbers_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_number_system_keywords(DeprecatedString locale_numbers_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath numbers_path(move(locale_numbers_path));
numbers_path = numbers_path.append("numbers.json"sv);
@@ -743,7 +743,7 @@ static ErrorOr<void> parse_number_system_keywords(String locale_numbers_path, CL
KeywordList keywords {};
- auto append_numbering_system = [&](String system_name) {
+ auto append_numbering_system = [&](DeprecatedString system_name) {
if (auto system_alias = find_keyword_alias("nu"sv, system_name, cldr); system_alias.has_value())
system_name = system_alias.release_value();
@@ -768,7 +768,7 @@ static ErrorOr<void> parse_number_system_keywords(String locale_numbers_path, CL
return {};
}
-static ErrorOr<void> parse_calendar_keywords(String locale_dates_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_calendar_keywords(DeprecatedString locale_dates_path, CLDR& cldr, LocaleData& locale)
{
auto calendars_iterator = TRY(path_to_dir_iterator(locale_dates_path, {}));
KeywordList keywords {};
@@ -833,7 +833,7 @@ static void fill_in_collation_keywords(CLDR& cldr, LocaleData& locale)
locale.collation_numeric_keywords = kn_index;
}
-static ErrorOr<void> parse_default_content_locales(String core_path, CLDR& cldr)
+static ErrorOr<void> parse_default_content_locales(DeprecatedString core_path, CLDR& cldr)
{
LexicalPath default_content_path(move(core_path));
default_content_path = default_content_path.append("defaultContent.json"sv);
@@ -882,7 +882,7 @@ static ErrorOr<void> define_aliases_without_scripts(CLDR& cldr)
if ((parsed_locale.language == 0) || (parsed_locale.script == 0) || (parsed_locale.region == 0))
return {};
- auto locale_without_script = String::formatted("{}-{}",
+ auto locale_without_script = DeprecatedString::formatted("{}-{}",
cldr.unique_strings.get(parsed_locale.language),
cldr.unique_strings.get(parsed_locale.region));
@@ -907,7 +907,7 @@ static ErrorOr<void> define_aliases_without_scripts(CLDR& cldr)
return {};
}
-static ErrorOr<void> parse_all_locales(String bcp47_path, String core_path, String locale_names_path, String misc_path, String numbers_path, String dates_path, CLDR& cldr)
+static ErrorOr<void> parse_all_locales(DeprecatedString bcp47_path, DeprecatedString core_path, DeprecatedString locale_names_path, DeprecatedString misc_path, DeprecatedString numbers_path, DeprecatedString dates_path, CLDR& cldr)
{
auto bcp47_iterator = TRY(path_to_dir_iterator(move(bcp47_path), "bcp47"sv));
auto identity_iterator = TRY(path_to_dir_iterator(locale_names_path));
@@ -924,7 +924,7 @@ static ErrorOr<void> parse_all_locales(String bcp47_path, String core_path, Stri
TRY(parse_core_aliases(core_supplemental_path.string(), cldr));
TRY(parse_likely_subtags(core_supplemental_path.string(), cldr));
- auto remove_variants_from_path = [&](String path) -> ErrorOr<String> {
+ auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr<DeprecatedString> {
auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path)));
StringBuilder builder;
@@ -1034,7 +1034,7 @@ namespace Locale {
for (auto& keyword : cldr.keywords) {
auto const& keyword_name = cldr.keyword_names.find(keyword.key)->value;
- auto enum_name = String::formatted("Keyword{}", format_identifier({}, keyword_name));
+ auto enum_name = DeprecatedString::formatted("Keyword{}", format_identifier({}, keyword_name));
if (auto aliases = cldr.keyword_aliases.find(keyword.key); aliases != cldr.keyword_aliases.end())
generate_enum(generator, format_identifier, enum_name, {}, keyword.value, aliases->value);
@@ -1057,9 +1057,9 @@ static ErrorOr<void> generate_unicode_locale_implementation(Core::Stream::Buffer
StringBuilder builder;
SourceGenerator generator { builder };
generator.set("string_index_type"sv, string_index_type);
- generator.set("locales_size"sv, String::number(cldr.locales.size()));
- generator.set("territories_size", String::number(cldr.territories.size()));
- generator.set("variants_size", String::number(cldr.max_variant_size));
+ generator.set("locales_size"sv, DeprecatedString::number(cldr.locales.size()));
+ generator.set("territories_size", DeprecatedString::number(cldr.territories.size()));
+ generator.set("variants_size", DeprecatedString::number(cldr.max_variant_size));
generator.append(R"~~~(
#include <AK/Array.h>
@@ -1162,7 +1162,7 @@ Span<StringView const> get_available_keyword_values(StringView key)
cldr.unique_text_layouts.generate(generator, "TextLayout"sv, "s_text_layouts"sv, 30);
auto append_index = [&](auto index) {
- generator.append(String::formatted(", {}", index));
+ generator.append(DeprecatedString::formatted(", {}", index));
};
auto append_list_and_size = [&](auto const& list) {
@@ -1175,16 +1175,16 @@ Span<StringView const> get_available_keyword_values(StringView key)
generator.append(", {");
for (auto const& item : list) {
generator.append(first ? " "sv : ", "sv);
- generator.append(String::number(item));
+ generator.append(DeprecatedString::number(item));
first = false;
}
- generator.append(String::formatted(" }}, {}", list.size()));
+ generator.append(DeprecatedString::formatted(" }}, {}", list.size()));
};
auto append_mapping = [&](auto const& keys, auto const& map, auto type, auto name, auto mapping_getter) {
generator.set("type", type);
generator.set("name", name);
- generator.set("size", String::number(keys.size()));
+ generator.set("size", DeprecatedString::number(keys.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> @name@ { {)~~~");
@@ -1195,7 +1195,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~");
auto mapping = mapping_getter(value);
generator.append(first ? " "sv : ", "sv);
- generator.append(String::number(mapping));
+ generator.append(DeprecatedString::number(mapping));
first = false;
}
@@ -1243,7 +1243,7 @@ struct CanonicalLanguageID {
return language_id;
}
- bool matches_variants(Vector<String> const& other_variants) const {
+ bool matches_variants(Vector<DeprecatedString> const& other_variants) const {
if (variants_size == 0)
return true;
if (other_variants.size() != variants_size)
@@ -1272,7 +1272,7 @@ struct LanguageMapping {
)~~~");
auto append_complex_mapping = [&](StringView name, auto& mappings) {
- generator.set("size", String::number(mappings.size()));
+ generator.set("size", DeprecatedString::number(mappings.size()));
generator.set("name"sv, name);
generator.append(R"~~~(
@@ -1292,14 +1292,14 @@ static constexpr Array<LanguageMapping, @size@> s_@name@ { {
});
for (auto const& mapping : mappings) {
- generator.set("language"sv, String::number(mapping.key.language));
+ generator.set("language"sv, DeprecatedString::number(mapping.key.language));
generator.append(" { { @language@");
append_index(mapping.key.script);
append_index(mapping.key.region);
append_list_and_size(mapping.key.variants);
- generator.set("language"sv, String::number(mapping.alias.language));
+ generator.set("language"sv, DeprecatedString::number(mapping.alias.language));
generator.append(" }, { @language@");
append_index(mapping.alias.script);
@@ -1439,7 +1439,7 @@ Optional<StringView> get_locale_@enum_snake@_mapping(StringView locale, StringVi
};
auto append_from_string = [&](StringView enum_title, StringView enum_snake, auto const& values, Vector<Alias> const& aliases = {}) {
- HashValueMap<String> hashes;
+ HashValueMap<DeprecatedString> hashes;
hashes.ensure_capacity(values.size());
for (auto const& value : values)
@@ -1493,8 +1493,8 @@ Optional<StringView> get_locale_@enum_snake@_mapping(StringView locale, StringVi
for (auto const& keyword : cldr.keywords) {
auto const& keyword_name = cldr.keyword_names.find(keyword.key)->value;
- auto enum_name = String::formatted("Keyword{}", format_identifier({}, keyword_name));
- auto enum_snake = String::formatted("keyword_{}", keyword.key);
+ auto enum_name = DeprecatedString::formatted("Keyword{}", format_identifier({}, keyword_name));
+ auto enum_snake = DeprecatedString::formatted("keyword_{}", keyword.key);
if (auto aliases = cldr.keyword_aliases.find(keyword.key); aliases != cldr.keyword_aliases.end())
append_from_string(enum_name, enum_snake, keyword.value, aliases->value);
@@ -1728,7 +1728,7 @@ Optional<LanguageID> add_likely_subtags(LanguageID const& language_id)
return maximized;
}
-Optional<String> resolve_most_likely_territory(LanguageID const& language_id)
+Optional<DeprecatedString> resolve_most_likely_territory(LanguageID const& language_id)
{
if (auto const* likely_subtag = resolve_likely_subtag(language_id); likely_subtag != nullptr)
return decode_string(likely_subtag->alias.region);
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp
index 351c861bc9..9bd837d7eb 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateNumberFormatData.cpp
@@ -8,6 +8,7 @@
#include <AK/AllOf.h>
#include <AK/Array.h>
#include <AK/CharacterTypes.h>
+#include <AK/DeprecatedString.h>
#include <AK/Find.h>
#include <AK/Format.h>
#include <AK/HashFunctions.h>
@@ -18,7 +19,6 @@
#include <AK/LexicalPath.h>
#include <AK/QuickSort.h>
#include <AK/SourceGenerator.h>
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/Traits.h>
#include <AK/Utf8View.h>
@@ -220,7 +220,7 @@ struct AK::Traits<Unit> : public GenericTraits<Unit> {
struct LocaleData {
Vector<size_t> number_systems;
- HashMap<String, size_t> units {};
+ HashMap<DeprecatedString, size_t> units {};
u8 minimum_grouping_digits { 0 };
};
@@ -232,14 +232,14 @@ struct CLDR {
UniqueStorage<NumberSystem> unique_systems;
UniqueStorage<Unit> unique_units;
- HashMap<String, Array<u32, 10>> number_system_digits;
- Vector<String> number_systems;
+ HashMap<DeprecatedString, Array<u32, 10>> number_system_digits;
+ Vector<DeprecatedString> number_systems;
- HashMap<String, LocaleData> locales;
+ HashMap<DeprecatedString, LocaleData> locales;
size_t max_identifier_count { 0 };
};
-static ErrorOr<void> parse_number_system_digits(String core_supplemental_path, CLDR& cldr)
+static ErrorOr<void> parse_number_system_digits(DeprecatedString core_supplemental_path, CLDR& cldr)
{
LexicalPath number_systems_path(move(core_supplemental_path));
number_systems_path = number_systems_path.append("numberingSystems.json"sv);
@@ -271,7 +271,7 @@ static ErrorOr<void> parse_number_system_digits(String core_supplemental_path, C
return {};
}
-static String parse_identifiers(String pattern, StringView replacement, CLDR& cldr, NumberFormat& format)
+static DeprecatedString parse_identifiers(DeprecatedString pattern, StringView replacement, CLDR& cldr, NumberFormat& format)
{
static constexpr Utf8View whitespace { "\u0020\u00a0\u200f"sv };
@@ -317,7 +317,7 @@ static String parse_identifiers(String pattern, StringView replacement, CLDR& cl
cldr.max_identifier_count = max(cldr.max_identifier_count, format.identifier_indices.size());
}
- pattern = String::formatted("{}{{{}:{}}}{}",
+ pattern = DeprecatedString::formatted("{}{{{}:{}}}{}",
*start_index > 0 ? pattern.substring_view(0, *start_index) : ""sv,
replacement,
replacement_index,
@@ -325,13 +325,13 @@ static String parse_identifiers(String pattern, StringView replacement, CLDR& cl
}
}
-static void parse_number_pattern(Vector<String> patterns, CLDR& cldr, NumberFormatType type, NumberFormat& format, NumberSystem* number_system_for_groupings = nullptr)
+static void parse_number_pattern(Vector<DeprecatedString> patterns, CLDR& cldr, NumberFormatType type, NumberFormat& format, NumberSystem* number_system_for_groupings = nullptr)
{
// https://unicode.org/reports/tr35/tr35-numbers.html#Number_Format_Patterns
// https://cldr.unicode.org/translation/number-currency-formats/number-and-currency-patterns
VERIFY((patterns.size() == 1) || (patterns.size() == 2));
- auto replace_patterns = [&](String pattern) {
+ auto replace_patterns = [&](DeprecatedString pattern) {
static HashMap<StringView, StringView> replacements = {
{ "{0}"sv, "{number}"sv },
{ "{1}"sv, "{currency}"sv },
@@ -345,7 +345,7 @@ static void parse_number_pattern(Vector<String> patterns, CLDR& cldr, NumberForm
for (auto const& replacement : replacements)
pattern = pattern.replace(replacement.key, replacement.value, ReplaceMode::All);
- if (auto start_number_index = pattern.find_any_of("#0"sv, String::SearchDirection::Forward); start_number_index.has_value()) {
+ if (auto start_number_index = pattern.find_any_of("#0"sv, DeprecatedString::SearchDirection::Forward); start_number_index.has_value()) {
auto end_number_index = *start_number_index + 1;
for (; end_number_index < pattern.length(); ++end_number_index) {
@@ -372,7 +372,7 @@ static void parse_number_pattern(Vector<String> patterns, CLDR& cldr, NumberForm
}
}
- pattern = String::formatted("{}{{number}}{}",
+ pattern = DeprecatedString::formatted("{}{{number}}{}",
*start_number_index > 0 ? pattern.substring_view(0, *start_number_index) : ""sv,
pattern.substring_view(end_number_index));
@@ -389,19 +389,19 @@ static void parse_number_pattern(Vector<String> patterns, CLDR& cldr, NumberForm
};
auto zero_format = replace_patterns(move(patterns[0]));
- format.positive_format_index = cldr.unique_strings.ensure(String::formatted("{{plusSign}}{}", zero_format));
+ format.positive_format_index = cldr.unique_strings.ensure(DeprecatedString::formatted("{{plusSign}}{}", zero_format));
if (patterns.size() == 2) {
auto negative_format = replace_patterns(move(patterns[1]));
format.negative_format_index = cldr.unique_strings.ensure(move(negative_format));
} else {
- format.negative_format_index = cldr.unique_strings.ensure(String::formatted("{{minusSign}}{}", zero_format));
+ format.negative_format_index = cldr.unique_strings.ensure(DeprecatedString::formatted("{{minusSign}}{}", zero_format));
}
format.zero_format_index = cldr.unique_strings.ensure(move(zero_format));
}
-static void parse_number_pattern(Vector<String> patterns, CLDR& cldr, NumberFormatType type, size_t& format_index, NumberSystem* number_system_for_groupings = nullptr)
+static void parse_number_pattern(Vector<DeprecatedString> patterns, CLDR& cldr, NumberFormatType type, size_t& format_index, NumberSystem* number_system_for_groupings = nullptr)
{
NumberFormat format {};
parse_number_pattern(move(patterns), cldr, type, format, number_system_for_groupings);
@@ -409,7 +409,7 @@ static void parse_number_pattern(Vector<String> patterns, CLDR& cldr, NumberForm
format_index = cldr.unique_formats.ensure(move(format));
}
-static ErrorOr<void> parse_number_systems(String locale_numbers_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_number_systems(DeprecatedString locale_numbers_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath numbers_path(move(locale_numbers_path));
numbers_path = numbers_path.append("numbers.json"sv);
@@ -522,7 +522,7 @@ static ErrorOr<void> parse_number_systems(String locale_numbers_path, CLDR& cldr
// The range separator does not appear in the symbols list, we have to extract it from
// the range pattern.
- auto misc_patterns_key = String::formatted("{}{}", misc_patterns_prefix, system);
+ auto misc_patterns_key = DeprecatedString::formatted("{}{}", misc_patterns_prefix, system);
auto misc_patterns = locale_numbers_object.as_object().get(misc_patterns_key);
auto range_separator = misc_patterns.as_object().get("range"sv).as_string();
@@ -594,7 +594,7 @@ static ErrorOr<void> parse_number_systems(String locale_numbers_path, CLDR& cldr
return {};
}
-static ErrorOr<void> parse_units(String locale_units_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_units(DeprecatedString locale_units_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath units_path(move(locale_units_path));
units_path = units_path.append("units.json"sv);
@@ -607,7 +607,7 @@ static ErrorOr<void> parse_units(String locale_units_path, CLDR& cldr, LocaleDat
auto const& short_object = locale_units_object.as_object().get("short"sv);
auto const& narrow_object = locale_units_object.as_object().get("narrow"sv);
- HashMap<String, Unit> units;
+ HashMap<DeprecatedString, Unit> units;
auto ensure_unit = [&](auto const& unit) -> Unit& {
return units.ensure(unit, [&]() {
@@ -697,7 +697,7 @@ static ErrorOr<void> parse_units(String locale_units_path, CLDR& cldr, LocaleDat
return {};
}
-static ErrorOr<void> parse_all_locales(String core_path, String numbers_path, String units_path, CLDR& cldr)
+static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedString numbers_path, DeprecatedString units_path, CLDR& cldr)
{
auto numbers_iterator = TRY(path_to_dir_iterator(move(numbers_path)));
auto units_iterator = TRY(path_to_dir_iterator(move(units_path)));
@@ -708,7 +708,7 @@ static ErrorOr<void> parse_all_locales(String core_path, String numbers_path, St
TRY(parse_number_system_digits(core_supplemental_path.string(), cldr));
- auto remove_variants_from_path = [&](String path) -> ErrorOr<String> {
+ auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr<DeprecatedString> {
auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path)));
StringBuilder builder;
@@ -740,7 +740,7 @@ static ErrorOr<void> parse_all_locales(String core_path, String numbers_path, St
return {};
}
-static String format_identifier(StringView, String identifier)
+static DeprecatedString format_identifier(StringView, DeprecatedString identifier)
{
return identifier.to_titlecase();
}
@@ -776,7 +776,7 @@ static ErrorOr<void> generate_unicode_locale_implementation(Core::Stream::Buffer
generator.set("number_format_index_type"sv, cldr.unique_formats.type_that_fits());
generator.set("number_format_list_index_type"sv, cldr.unique_format_lists.type_that_fits());
generator.set("numeric_symbol_list_index_type"sv, cldr.unique_symbols.type_that_fits());
- generator.set("identifier_count", String::number(cldr.max_identifier_count));
+ generator.set("identifier_count", DeprecatedString::number(cldr.max_identifier_count));
generator.append(R"~~~(
#include <AK/Array.h>
@@ -860,22 +860,22 @@ struct Unit {
auto locales = cldr.locales.keys();
quick_sort(locales);
- generator.set("size", String::number(locales.size()));
+ generator.set("size", DeprecatedString::number(locales.size()));
generator.append(R"~~~(
static constexpr Array<u8, @size@> s_minimum_grouping_digits { { )~~~");
bool first = true;
for (auto const& locale : locales) {
generator.append(first ? " "sv : ", "sv);
- generator.append(String::number(cldr.locales.find(locale)->value.minimum_grouping_digits));
+ generator.append(DeprecatedString::number(cldr.locales.find(locale)->value.minimum_grouping_digits));
first = false;
}
generator.append(" } };\n");
- auto append_map = [&](String name, auto type, auto const& map) {
+ auto append_map = [&](DeprecatedString name, auto type, auto const& map) {
generator.set("name", name);
generator.set("type", type);
- generator.set("size", String::number(map.size()));
+ generator.set("size", DeprecatedString::number(map.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> @name@ { {)~~~");
@@ -884,9 +884,9 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~");
for (auto const& item : map) {
generator.append(first ? " "sv : ", "sv);
if constexpr (requires { item.value; })
- generator.append(String::number(item.value));
+ generator.append(DeprecatedString::number(item.value));
else
- generator.append(String::number(item));
+ generator.append(DeprecatedString::number(item));
first = false;
}
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp
index 5053862c70..40c4d843dc 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GeneratePluralRulesData.cpp
@@ -5,13 +5,13 @@
*/
#include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common.
+#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/JsonObject.h>
#include <AK/JsonParser.h>
#include <AK/JsonValue.h>
#include <AK/LexicalPath.h>
#include <AK/SourceGenerator.h>
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/Variant.h>
#include <LibCore/ArgsParser.h>
@@ -19,14 +19,14 @@
#include <LibCore/Stream.h>
#include <LibLocale/PluralRules.h>
-static String format_identifier(StringView owner, String identifier)
+static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier)
{
identifier = identifier.replace("-"sv, "_"sv, ReplaceMode::All);
if (all_of(identifier, is_ascii_digit))
- return String::formatted("{}_{}", owner[0], identifier);
+ return DeprecatedString::formatted("{}_{}", owner[0], identifier);
if (is_ascii_lower_alpha(identifier[0]))
- return String::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
+ return DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
return identifier;
}
@@ -39,20 +39,20 @@ struct Relation {
Inequality,
};
- String const& modulus_variable_name() const
+ DeprecatedString const& modulus_variable_name() const
{
VERIFY(modulus.has_value());
if (!cached_modulus_variable_name.has_value())
- cached_modulus_variable_name = String::formatted("mod_{}_{}", symbol, *modulus);
+ cached_modulus_variable_name = DeprecatedString::formatted("mod_{}_{}", symbol, *modulus);
return *cached_modulus_variable_name;
}
- String const& exponential_variable_name() const
+ DeprecatedString const& exponential_variable_name() const
{
if (!cached_exponential_variable_name.has_value())
- cached_exponential_variable_name = String::formatted("exp_{}", symbol);
+ cached_exponential_variable_name = DeprecatedString::formatted("exp_{}", symbol);
return *cached_exponential_variable_name;
}
@@ -65,25 +65,25 @@ struct Relation {
else if (symbol == 'e' || symbol == 'c')
generator.append(exponential_variable_name());
else
- generator.append(String::formatted("ops.{}", Locale::PluralOperands::symbol_to_variable_name(symbol)));
+ generator.append(DeprecatedString::formatted("ops.{}", Locale::PluralOperands::symbol_to_variable_name(symbol)));
};
auto append_value = [&](u32 value) {
append_variable_name();
generator.append(" == "sv);
- generator.append(String::number(value));
+ generator.append(DeprecatedString::number(value));
};
auto append_range = [&](auto const& range) {
// This check avoids generating "0 <= unsigned_value", which is always true.
if (range[0] != 0 || Locale::PluralOperands::symbol_requires_floating_point_modulus(symbol)) {
- generator.append(String::formatted("{} <= ", range[0]));
+ generator.append(DeprecatedString::formatted("{} <= ", range[0]));
append_variable_name();
generator.append(" && "sv);
}
append_variable_name();
- generator.append(String::formatted(" <= {}", range[1]));
+ generator.append(DeprecatedString::formatted(" <= {}", range[1]));
};
if (type == Type::Inequality)
@@ -106,7 +106,7 @@ struct Relation {
generator.append(")"sv);
}
- void generate_precomputed_variables(SourceGenerator& generator, HashTable<String>& generated_variables) const
+ void generate_precomputed_variables(SourceGenerator& generator, HashTable<DeprecatedString>& generated_variables) const
{
// FIXME: How do we handle the exponential symbols? They seem unused by ECMA-402.
if (symbol == 'e' || symbol == 'c') {
@@ -128,7 +128,7 @@ struct Relation {
generated_variables.set(variable);
generator.set("variable"sv, move(variable));
generator.set("operand"sv, Locale::PluralOperands::symbol_to_variable_name(symbol));
- generator.set("modulus"sv, String::number(*modulus));
+ generator.set("modulus"sv, DeprecatedString::number(*modulus));
if (Locale::PluralOperands::symbol_requires_floating_point_modulus(symbol)) {
generator.append(R"~~~(
@@ -145,8 +145,8 @@ struct Relation {
Vector<Comparator> comparators;
private:
- mutable Optional<String> cached_modulus_variable_name;
- mutable Optional<String> cached_exponential_variable_name;
+ mutable Optional<DeprecatedString> cached_modulus_variable_name;
+ mutable Optional<DeprecatedString> cached_exponential_variable_name;
};
struct Condition {
@@ -171,7 +171,7 @@ struct Condition {
}
}
- void generate_precomputed_variables(SourceGenerator& generator, HashTable<String>& generated_variables) const
+ void generate_precomputed_variables(SourceGenerator& generator, HashTable<DeprecatedString>& generated_variables) const
{
for (auto const& conjunctions : relations) {
for (auto const& relation : conjunctions)
@@ -183,18 +183,18 @@ struct Condition {
};
struct Range {
- String start;
- String end;
- String category;
+ DeprecatedString start;
+ DeprecatedString end;
+ DeprecatedString category;
};
-using Conditions = HashMap<String, Condition>;
+using Conditions = HashMap<DeprecatedString, Condition>;
using Ranges = Vector<Range>;
struct LocaleData {
- static String generated_method_name(StringView form, StringView locale)
+ static DeprecatedString generated_method_name(StringView form, StringView locale)
{
- return String::formatted("{}_plurality_{}", form, format_identifier({}, locale));
+ return DeprecatedString::formatted("{}_plurality_{}", form, format_identifier({}, locale));
}
Conditions& rules_for_form(StringView form)
@@ -214,7 +214,7 @@ struct LocaleData {
struct CLDR {
UniqueStringStorage unique_strings;
- HashMap<String, LocaleData> locales;
+ HashMap<DeprecatedString, LocaleData> locales;
};
static Relation parse_relation(StringView relation)
@@ -322,7 +322,7 @@ static void parse_condition(StringView category, StringView rule, Conditions& ru
});
}
-static ErrorOr<void> parse_plural_rules(String core_supplemental_path, StringView file_name, CLDR& cldr)
+static ErrorOr<void> parse_plural_rules(DeprecatedString core_supplemental_path, StringView file_name, CLDR& cldr)
{
static constexpr auto form_prefix = "plurals-type-"sv;
static constexpr auto rule_prefix = "pluralRule-count-"sv;
@@ -357,7 +357,7 @@ static ErrorOr<void> parse_plural_rules(String core_supplemental_path, StringVie
}
// https://unicode.org/reports/tr35/tr35-numbers.html#Plural_Ranges
-static ErrorOr<void> parse_plural_ranges(String core_supplemental_path, CLDR& cldr)
+static ErrorOr<void> parse_plural_ranges(DeprecatedString core_supplemental_path, CLDR& cldr)
{
static constexpr auto start_segment = "-start-"sv;
static constexpr auto end_segment = "-end-"sv;
@@ -393,7 +393,7 @@ static ErrorOr<void> parse_plural_ranges(String core_supplemental_path, CLDR& cl
return {};
}
-static ErrorOr<void> parse_all_locales(String core_path, String locale_names_path, CLDR& cldr)
+static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedString locale_names_path, CLDR& cldr)
{
auto identity_iterator = TRY(path_to_dir_iterator(move(locale_names_path)));
@@ -401,7 +401,7 @@ static ErrorOr<void> parse_all_locales(String core_path, String locale_names_pat
core_supplemental_path = core_supplemental_path.append("supplemental"sv);
VERIFY(Core::File::is_directory(core_supplemental_path.string()));
- auto remove_variants_from_path = [&](String path) -> ErrorOr<String> {
+ auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr<DeprecatedString> {
auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path)));
StringBuilder builder;
@@ -486,7 +486,7 @@ static PluralCategory default_range(PluralCategory, PluralCategory end)
return;
generator.set("method"sv, LocaleData::generated_method_name(form, locale));
- HashTable<String> generated_variables;
+ HashTable<DeprecatedString> generated_variables;
generator.append(R"~~~(
static PluralCategory @method@([[maybe_unused]] PluralOperands ops)
@@ -541,7 +541,7 @@ static PluralCategory @method@(PluralCategory start, PluralCategory end)
generator.set("type"sv, type);
generator.set("form"sv, form);
generator.set("default"sv, default_);
- generator.set("size"sv, String::number(locales.size()));
+ generator.set("size"sv, DeprecatedString::number(locales.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> s_@form@_functions { {)~~~");
@@ -566,7 +566,7 @@ static constexpr Array<@type@, @size@> s_@form@_functions { {)~~~");
auto append_categories = [&](auto const& name, auto const& rules) {
generator.set("name", name);
- generator.set("size", String::number(rules.size() + 1));
+ generator.set("size", DeprecatedString::number(rules.size() + 1));
generator.append(R"~~~(
static constexpr Array<PluralCategory, @size@> @name@ { { PluralCategory::Other)~~~");
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp
index b1bf7bdc05..8673f3fe1d 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibLocale/GenerateRelativeTimeFormatData.cpp
@@ -5,6 +5,7 @@
*/
#include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common.
+#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/HashMap.h>
#include <AK/JsonObject.h>
@@ -12,7 +13,6 @@
#include <AK/JsonValue.h>
#include <AK/LexicalPath.h>
#include <AK/SourceGenerator.h>
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DirIterator.h>
@@ -40,9 +40,9 @@ struct RelativeTimeFormat {
&& (pattern == other.pattern);
}
- String time_unit;
- String style;
- String plurality;
+ DeprecatedString time_unit;
+ DeprecatedString style;
+ DeprecatedString plurality;
size_t tense_or_number { 0 };
size_t pattern { 0 };
};
@@ -74,10 +74,10 @@ struct CLDR {
UniqueStringStorage unique_strings;
UniqueStorage<RelativeTimeFormat> unique_formats;
- HashMap<String, LocaleData> locales;
+ HashMap<DeprecatedString, LocaleData> locales;
};
-static ErrorOr<void> parse_date_fields(String locale_dates_path, CLDR& cldr, LocaleData& locale)
+static ErrorOr<void> parse_date_fields(DeprecatedString locale_dates_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath date_fields_path(move(locale_dates_path));
date_fields_path = date_fields_path.append("dateFields.json"sv);
@@ -136,11 +136,11 @@ static ErrorOr<void> parse_date_fields(String locale_dates_path, CLDR& cldr, Loc
return {};
}
-static ErrorOr<void> parse_all_locales(String dates_path, CLDR& cldr)
+static ErrorOr<void> parse_all_locales(DeprecatedString dates_path, CLDR& cldr)
{
auto dates_iterator = TRY(path_to_dir_iterator(move(dates_path)));
- auto remove_variants_from_path = [&](String path) -> ErrorOr<String> {
+ auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr<DeprecatedString> {
auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path)));
StringBuilder builder;
@@ -227,9 +227,9 @@ struct RelativeTimeFormatImpl {
cldr.unique_formats.generate(generator, "RelativeTimeFormatImpl"sv, "s_relative_time_formats"sv, 10);
- auto append_list = [&](String name, auto const& list) {
+ auto append_list = [&](DeprecatedString name, auto const& list) {
generator.set("name", name);
- generator.set("size", String::number(list.size()));
+ generator.set("size", DeprecatedString::number(list.size()));
generator.append(R"~~~(
static constexpr Array<@relative_time_format_index_type@, @size@> @name@ { {)~~~");
@@ -237,7 +237,7 @@ static constexpr Array<@relative_time_format_index_type@, @size@> @name@ { {)~~~
bool first = true;
for (auto index : list) {
generator.append(first ? " "sv : ", "sv);
- generator.append(String::number(index));
+ generator.append(DeprecatedString::number(index));
first = false;
}
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp
index aa331c37dc..4ae9ab8f07 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp
@@ -6,10 +6,10 @@
#include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common.
#include <AK/DateConstants.h>
+#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/HashMap.h>
#include <AK/SourceGenerator.h>
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
@@ -36,7 +36,7 @@ struct TimeZoneOffset {
i64 offset { 0 };
Optional<DateTime> until;
- Optional<String> dst_rule;
+ Optional<DeprecatedString> dst_rule;
Optional<i32> dst_rule_index;
i64 dst_offset { 0 };
@@ -56,17 +56,17 @@ struct DaylightSavingsOffset {
struct TimeZoneData {
UniqueStringStorage unique_strings;
- HashMap<String, Vector<TimeZoneOffset>> time_zones;
- Vector<String> time_zone_names;
+ HashMap<DeprecatedString, Vector<TimeZoneOffset>> time_zones;
+ Vector<DeprecatedString> time_zone_names;
Vector<Alias> time_zone_aliases;
- HashMap<String, Vector<DaylightSavingsOffset>> dst_offsets;
- Vector<String> dst_offset_names;
+ HashMap<DeprecatedString, Vector<DaylightSavingsOffset>> dst_offsets;
+ Vector<DeprecatedString> dst_offset_names;
- HashMap<String, TimeZone::Location> time_zone_coordinates;
+ HashMap<DeprecatedString, TimeZone::Location> time_zone_coordinates;
- HashMap<String, Vector<size_t>> time_zone_regions;
- Vector<String> time_zone_region_names;
+ HashMap<DeprecatedString, Vector<size_t>> time_zone_regions;
+ Vector<DeprecatedString> time_zone_region_names;
};
}
@@ -110,10 +110,10 @@ struct AK::Formatter<DaylightSavingsOffset> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, DaylightSavingsOffset const& dst_offset)
{
auto format_time = [&](auto year) {
- return String::formatted("AK::Time::from_timestamp({}, 1, 1, 0, 0, 0, 0)", year);
+ return DeprecatedString::formatted("AK::Time::from_timestamp({}, 1, 1, 0, 0, 0, 0)", year);
};
- static String max_year_as_time("max_year_as_time"sv);
+ static DeprecatedString max_year_as_time("max_year_as_time"sv);
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {}, {} }}"sv,
@@ -422,7 +422,7 @@ static void set_dst_rule_indices(TimeZoneData& time_zone_data)
}
}
-static String format_identifier(StringView owner, String identifier)
+static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier)
{
constexpr auto gmt_time_zones = Array { "Etc/GMT"sv, "GMT"sv };
@@ -431,9 +431,9 @@ static String format_identifier(StringView owner, String identifier)
auto offset = identifier.substring_view(gmt_time_zone.length());
if (offset.starts_with('+'))
- identifier = String::formatted("{}_Ahead_{}", gmt_time_zone, offset.substring_view(1));
+ identifier = DeprecatedString::formatted("{}_Ahead_{}", gmt_time_zone, offset.substring_view(1));
else if (offset.starts_with('-'))
- identifier = String::formatted("{}_Behind_{}", gmt_time_zone, offset.substring_view(1));
+ identifier = DeprecatedString::formatted("{}_Behind_{}", gmt_time_zone, offset.substring_view(1));
}
}
@@ -441,9 +441,9 @@ static String format_identifier(StringView owner, String identifier)
identifier = identifier.replace("/"sv, "_"sv, ReplaceMode::All);
if (all_of(identifier, is_ascii_digit))
- return String::formatted("{}_{}", owner[0], identifier);
+ return DeprecatedString::formatted("{}_{}", owner[0], identifier);
if (is_ascii_lower_alpha(identifier[0]))
- return String::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
+ return DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
return identifier;
}
@@ -551,14 +551,14 @@ struct DaylightSavingsOffset {
auto append_offsets = [&](auto const& name, auto type, auto const& offsets) {
generator.set("name", name);
generator.set("type", type);
- generator.set("size", String::number(offsets.size()));
+ generator.set("size", DeprecatedString::number(offsets.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> @name@ { {
)~~~");
for (auto const& offset : offsets)
- generator.append(String::formatted(" {},\n", offset));
+ generator.append(DeprecatedString::formatted(" {},\n", offset));
generator.append("} };\n");
};
@@ -580,7 +580,7 @@ static constexpr Array<@type@, @size@> @name@ { {
auto const& time_zones = time_zone_data.time_zone_regions.find(value)->value;
generator.set("name", name);
- generator.set("size", String::number(time_zones.size()));
+ generator.set("size", DeprecatedString::number(time_zones.size()));
generator.append(R"~~~(
static constexpr Array<@string_index_type@, @size@> @name@ { {)~~~");
@@ -588,14 +588,14 @@ static constexpr Array<@string_index_type@, @size@> @name@ { {)~~~");
bool first = true;
for (auto const& time_zone : time_zones) {
generator.append(first ? " "sv : ", "sv);
- generator.append(String::number(time_zone));
+ generator.append(DeprecatedString::number(time_zone));
first = false;
}
generator.append(" } };");
});
- generator.set("size", String::number(time_zone_data.time_zone_names.size()));
+ generator.set("size", DeprecatedString::number(time_zone_data.time_zone_names.size()));
generator.append(R"~~~(
static constexpr Array<Location, @size@> s_time_zone_locations { {
)~~~");
@@ -603,12 +603,12 @@ static constexpr Array<Location, @size@> s_time_zone_locations { {
for (auto const& time_zone : time_zone_data.time_zone_names) {
auto location = time_zone_data.time_zone_coordinates.get(time_zone).value_or({});
- generator.append(String::formatted(" {},\n", location));
+ generator.append(DeprecatedString::formatted(" {},\n", location));
}
generator.append("} };\n");
auto append_string_conversions = [&](StringView enum_title, StringView enum_snake, auto const& values, Vector<Alias> const& aliases = {}) {
- HashValueMap<String> hashes;
+ HashValueMap<DeprecatedString> hashes;
hashes.ensure_capacity(values.size());
auto hash = [](auto const& value) {
@@ -731,10 +731,10 @@ Optional<Array<NamedOffset, 2>> get_named_time_zone_offsets(TimeZone time_zone,
auto const& time_zone_offset = find_time_zone_offset(time_zone, time);
Array<NamedOffset, 2> named_offsets;
- auto format_name = [](auto format, auto offset) -> String {
+ auto format_name = [](auto format, auto offset) -> DeprecatedString {
if (offset == 0)
return decode_string(format).replace("{}"sv, ""sv, ReplaceMode::FirstOnly);
- return String::formatted(decode_string(format), decode_string(offset));
+ return DeprecatedString::formatted(decode_string(format), decode_string(offset));
};
auto set_named_offset = [&](auto& named_offset, auto dst_offset, auto in_dst, auto format, auto offset) {
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp
index 485deac41b..a8f356f686 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateEmojiData.cpp
@@ -6,8 +6,8 @@
#include "GeneratorUtil.h"
#include <AK/AnyOf.h>
+#include <AK/DeprecatedString.h>
#include <AK/SourceGenerator.h>
-#include <AK/String.h>
#include <AK/StringUtils.h>
#include <AK/Types.h>
#include <LibCore/ArgsParser.h>
@@ -17,13 +17,13 @@
struct Emoji {
size_t name { 0 };
- Optional<String> image_path;
+ Optional<DeprecatedString> image_path;
Unicode::EmojiGroup group;
- String subgroup;
+ DeprecatedString subgroup;
u32 display_order { 0 };
Vector<u32> code_points;
- String encoded_code_points;
- String status;
+ DeprecatedString encoded_code_points;
+ DeprecatedString status;
size_t code_point_array_index { 0 };
};
@@ -44,7 +44,7 @@ static void set_image_path_for_emoji(StringView emoji_resource_path, Emoji& emoj
builder.appendff("U+{:X}", code_point);
}
- auto path = String::formatted("{}/{}.png", emoji_resource_path, builder.build());
+ auto path = DeprecatedString::formatted("{}/{}.png", emoji_resource_path, builder.build());
if (Core::Stream::File::exists(path))
emoji.image_path = move(path);
}
@@ -57,7 +57,7 @@ static ErrorOr<void> parse_emoji_test_data(Core::Stream::BufferedFile& file, Emo
Array<u8, 1024> buffer;
Unicode::EmojiGroup group;
- String subgroup;
+ DeprecatedString subgroup;
u32 display_order { 0 };
while (TRY(file.can_read_line())) {
@@ -178,7 +178,7 @@ static ErrorOr<void> generate_emoji_data_implementation(Core::Stream::BufferedFi
SourceGenerator generator { builder };
generator.set("string_index_type"sv, emoji_data.unique_strings.type_that_fits());
- generator.set("emojis_size"sv, String::number(emoji_data.emojis.size()));
+ generator.set("emojis_size"sv, DeprecatedString::number(emoji_data.emojis.size()));
generator.append(R"~~~(
#include <AK/Array.h>
@@ -198,7 +198,7 @@ namespace Unicode {
for (auto const& emoji : emoji_data.emojis) {
total_code_point_count += emoji.code_points.size();
}
- generator.set("total_code_point_count", String::number(total_code_point_count));
+ generator.set("total_code_point_count", DeprecatedString::number(total_code_point_count));
generator.append(R"~~~(
static constexpr Array<u32, @total_code_point_count@> s_emoji_code_points { {)~~~");
@@ -207,7 +207,7 @@ static constexpr Array<u32, @total_code_point_count@> s_emoji_code_points { {)~~
for (auto const& emoji : emoji_data.emojis) {
for (auto code_point : emoji.code_points) {
generator.append(first ? " "sv : ", "sv);
- generator.append(String::formatted("{:#x}", code_point));
+ generator.append(DeprecatedString::formatted("{:#x}", code_point));
first = false;
}
}
@@ -245,11 +245,11 @@ struct EmojiData {
static constexpr Array<EmojiData, @emojis_size@> s_emojis { {)~~~");
for (auto const& emoji : emoji_data.emojis) {
- generator.set("name"sv, String::number(emoji.name));
- generator.set("group"sv, String::number(to_underlying(emoji.group)));
- generator.set("display_order"sv, String::number(emoji.display_order));
- generator.set("code_point_start"sv, String::number(emoji.code_point_array_index));
- generator.set("code_point_count"sv, String::number(emoji.code_points.size()));
+ generator.set("name"sv, DeprecatedString::number(emoji.name));
+ generator.set("group"sv, DeprecatedString::number(to_underlying(emoji.group)));
+ generator.set("display_order"sv, DeprecatedString::number(emoji.display_order));
+ generator.set("code_point_start"sv, DeprecatedString::number(emoji.code_point_array_index));
+ generator.set("code_point_count"sv, DeprecatedString::number(emoji.code_points.size()));
generator.append(R"~~~(
{ @name@, @group@, @display_order@, @code_point_start@, @code_point_count@ },)~~~");
@@ -312,7 +312,7 @@ static ErrorOr<void> generate_emoji_installation(Core::Stream::BufferedFile& fil
generator.append("@emoji@"sv);
generator.append(" - "sv);
- generator.append(String::join(" "sv, emoji.code_points, "U+{:X}"sv));
+ generator.append(DeprecatedString::join(" "sv, emoji.code_points, "U+{:X}"sv));
generator.append(" @name@ (@status@)\n"sv);
}
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp
index d9c16d5fd9..82cb41784d 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp
@@ -8,12 +8,12 @@
#include <AK/AllOf.h>
#include <AK/Array.h>
#include <AK/CharacterTypes.h>
+#include <AK/DeprecatedString.h>
#include <AK/Find.h>
#include <AK/HashMap.h>
#include <AK/Optional.h>
#include <AK/QuickSort.h>
#include <AK/SourceGenerator.h>
-#include <AK/String.h>
#include <AK/StringUtils.h>
#include <AK/Types.h>
#include <AK/Vector.h>
@@ -37,21 +37,21 @@ struct SpecialCasing {
Vector<u32> lowercase_mapping;
Vector<u32> uppercase_mapping;
Vector<u32> titlecase_mapping;
- String locale;
- String condition;
+ DeprecatedString locale;
+ DeprecatedString condition;
};
// Field descriptions: https://www.unicode.org/reports/tr44/#Character_Decomposition_Mappings
struct CodePointDecomposition {
// `tag` is a string since it's used for codegen as an enum value.
- String tag { "Canonical"sv };
+ DeprecatedString tag { "Canonical"sv };
size_t decomposition_index { 0 };
size_t decomposition_size { 0 };
};
// PropList source: https://www.unicode.org/Public/13.0.0/ucd/PropList.txt
// Property descriptions: https://www.unicode.org/reports/tr44/tr44-13.html#PropList.txt
-using PropList = HashMap<String, Vector<CodePointRange>>;
+using PropList = HashMap<DeprecatedString, Vector<CodePointRange>>;
// Normalization source: https://www.unicode.org/Public/13.0.0/ucd/DerivedNormalizationProps.txt
// Normalization descriptions: https://www.unicode.org/reports/tr44/#DerivedNormalizationProps.txt
@@ -67,7 +67,7 @@ struct Normalization {
QuickCheck quick_check { QuickCheck::Yes };
};
-using NormalizationProps = HashMap<String, Vector<Normalization>>;
+using NormalizationProps = HashMap<DeprecatedString, Vector<Normalization>>;
struct CodePointName {
CodePointRange code_point_range;
@@ -79,17 +79,17 @@ struct CodePointName {
// https://www.unicode.org/reports/tr44/#General_Category_Values
struct CodePointData {
u32 code_point { 0 };
- String name;
+ DeprecatedString name;
Optional<size_t> abbreviation;
u8 canonical_combining_class { 0 };
- String bidi_class;
+ DeprecatedString bidi_class;
Optional<CodePointDecomposition> decomposition_mapping;
Optional<i8> numeric_value_decimal;
Optional<i8> numeric_value_digit;
Optional<i8> numeric_value_numeric;
bool bidi_mirrored { false };
- String unicode_1_name;
- String iso_comment;
+ DeprecatedString unicode_1_name;
+ DeprecatedString iso_comment;
Optional<u32> simple_uppercase_mapping;
Optional<u32> simple_lowercase_mapping;
Optional<u32> simple_titlecase_mapping;
@@ -108,7 +108,7 @@ struct UnicodeData {
u32 code_points_with_decomposition_mapping { 0 };
Vector<u32> decomposition_mappings;
- Vector<String> compatibility_tags;
+ Vector<DeprecatedString> compatibility_tags;
u32 simple_uppercase_mapping_size { 0 };
u32 simple_lowercase_mapping_size { 0 };
@@ -117,8 +117,8 @@ struct UnicodeData {
u32 code_points_with_special_casing { 0 };
u32 largest_casing_transform_size { 0 };
u32 largest_special_casing_size { 0 };
- Vector<String> conditions;
- Vector<String> locales;
+ Vector<DeprecatedString> conditions;
+ Vector<DeprecatedString> locales;
Vector<CodePointData> code_point_data;
@@ -159,7 +159,7 @@ struct UnicodeData {
PropList sentence_break_props;
};
-static String sanitize_entry(String const& entry)
+static DeprecatedString sanitize_entry(DeprecatedString const& entry)
{
auto sanitized = entry.replace("-"sv, "_"sv, ReplaceMode::All);
sanitized = sanitized.replace(" "sv, "_"sv, ReplaceMode::All);
@@ -243,7 +243,7 @@ static ErrorOr<void> parse_special_casing(Core::Stream::BufferedFile& file, Unic
}
if (!casing.locale.is_empty()) {
- casing.locale = String::formatted("{:c}{}", to_ascii_uppercase(casing.locale[0]), casing.locale.substring_view(1));
+ casing.locale = DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(casing.locale[0]), casing.locale.substring_view(1));
if (!unicode_data.locales.contains_slow(casing.locale))
unicode_data.locales.append(casing.locale);
@@ -313,7 +313,7 @@ static ErrorOr<void> parse_prop_list(Core::Stream::BufferedFile& file, PropList&
static ErrorOr<void> parse_alias_list(Core::Stream::BufferedFile& file, PropList const& prop_list, Vector<Alias>& prop_aliases)
{
- String current_property;
+ DeprecatedString current_property;
Array<u8, 1024> buffer;
auto append_alias = [&](auto alias, auto property) {
@@ -388,7 +388,7 @@ static ErrorOr<void> parse_name_aliases(Core::Stream::BufferedFile& file, Unicod
return {};
}
-static ErrorOr<void> parse_value_alias_list(Core::Stream::BufferedFile& file, StringView desired_category, Vector<String> const& value_list, Vector<Alias>& prop_aliases, bool primary_value_is_first = true, bool sanitize_alias = false)
+static ErrorOr<void> parse_value_alias_list(Core::Stream::BufferedFile& file, StringView desired_category, Vector<DeprecatedString> const& value_list, Vector<Alias>& prop_aliases, bool primary_value_is_first = true, bool sanitize_alias = false)
{
TRY(file.seek(0, Core::Stream::SeekMode::SetPosition));
Array<u8, 1024> buffer;
@@ -553,7 +553,7 @@ static Optional<CodePointDecomposition> parse_decomposition_mapping(StringView s
if (parts.first().starts_with('<')) {
auto const tag = parts.take_first().trim("<>"sv);
- mapping.tag = String::formatted("{:c}{}", to_ascii_uppercase(tag[0]), tag.substring_view(1));
+ mapping.tag = DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(tag[0]), tag.substring_view(1));
if (!unicode_data.compatibility_tags.contains_slow(mapping.tag))
unicode_data.compatibility_tags.append(mapping.tag);
@@ -689,14 +689,14 @@ static ErrorOr<void> generate_unicode_data_header(Core::Stream::BufferedFile& fi
{
StringBuilder builder;
SourceGenerator generator { builder };
- generator.set("casing_transform_size", String::number(unicode_data.largest_casing_transform_size));
+ generator.set("casing_transform_size", DeprecatedString::number(unicode_data.largest_casing_transform_size));
- auto generate_enum = [&](StringView name, StringView default_, Vector<String> values, Vector<Alias> aliases = {}) {
+ auto generate_enum = [&](StringView name, StringView default_, Vector<DeprecatedString> values, Vector<Alias> aliases = {}) {
quick_sort(values);
quick_sort(aliases, [](auto& alias1, auto& alias2) { return alias1.alias < alias2.alias; });
generator.set("name", name);
- generator.set("underlying", String::formatted("{}UnderlyingType", name));
+ generator.set("underlying", DeprecatedString::formatted("{}UnderlyingType", name));
generator.set("type", ((values.size() + !default_.is_empty()) < 256) ? "u8"sv : "u16"sv);
generator.append(R"~~~(
@@ -793,8 +793,8 @@ static ErrorOr<void> generate_unicode_data_implementation(Core::Stream::Buffered
SourceGenerator generator { builder };
generator.set("string_index_type"sv, unicode_data.unique_strings.type_that_fits());
- generator.set("largest_special_casing_size", String::number(unicode_data.largest_special_casing_size));
- generator.set("special_casing_size", String::number(unicode_data.special_casing.size()));
+ generator.set("largest_special_casing_size", DeprecatedString::number(unicode_data.largest_special_casing_size));
+ generator.set("special_casing_size", DeprecatedString::number(unicode_data.special_casing.size()));
generator.append(R"~~~(
#include <AK/Array.h>
@@ -802,7 +802,7 @@ static ErrorOr<void> generate_unicode_data_implementation(Core::Stream::Buffered
#include <AK/CharacterTypes.h>
#include <AK/Optional.h>
#include <AK/Span.h>
-#include <AK/String.h>
+#include <AK/DeprecatedString.h>
#include <AK/StringView.h>
#include <LibUnicode/CharacterTypes.h>
#include <LibUnicode/UnicodeData.h>
@@ -823,17 +823,17 @@ namespace Unicode {
generator.append(", {");
for (auto const& item : list) {
generator.append(first ? " "sv : ", "sv);
- generator.append(String::formatted(format, item));
+ generator.append(DeprecatedString::formatted(format, item));
first = false;
}
- generator.append(String::formatted(" }}, {}", list.size()));
+ generator.append(DeprecatedString::formatted(" }}, {}", list.size()));
};
generator.append(R"~~~(
static constexpr Array<SpecialCasing, @special_casing_size@> s_special_casing { {)~~~");
for (auto const& casing : unicode_data.special_casing) {
- generator.set("code_point", String::formatted("{:#x}", casing.code_point));
+ generator.set("code_point", DeprecatedString::formatted("{:#x}", casing.code_point));
generator.append(R"~~~(
{ @code_point@)~~~");
@@ -910,15 +910,15 @@ struct CodePointNameComparator : public CodePointRangeComparator {
};
)~~~");
- generator.set("decomposition_mappings_size", String::number(unicode_data.decomposition_mappings.size()));
+ generator.set("decomposition_mappings_size", DeprecatedString::number(unicode_data.decomposition_mappings.size()));
generator.append("\nstatic constexpr Array<u32, @decomposition_mappings_size@> s_decomposition_mappings_data { ");
- generator.append(String::join(", "sv, unicode_data.decomposition_mappings, "{:#x}"sv));
+ generator.append(DeprecatedString::join(", "sv, unicode_data.decomposition_mappings, "{:#x}"sv));
generator.append(" };\n");
auto append_code_point_mappings = [&](StringView name, StringView mapping_type, u32 size, auto mapping_getter) {
generator.set("name", name);
generator.set("mapping_type", mapping_type);
- generator.set("size", String::number(size));
+ generator.set("size", DeprecatedString::number(size));
generator.append(R"~~~(
static constexpr Array<@mapping_type@, @size@> s_@name@_mappings { {
@@ -941,16 +941,16 @@ static constexpr Array<@mapping_type@, @size@> s_@name@_mappings { {
if (mappings_in_current_row++ > 0)
generator.append(" ");
- generator.set("code_point", String::formatted("{:#x}", data.code_point));
+ generator.set("code_point", DeprecatedString::formatted("{:#x}", data.code_point));
generator.append("{ @code_point@");
if constexpr (IsSame<decltype(mapping), Optional<u32>> || IsSame<decltype(mapping), Optional<size_t>>) {
- generator.set("mapping", String::formatted("{:#x}", *mapping));
+ generator.set("mapping", DeprecatedString::formatted("{:#x}", *mapping));
generator.append(", @mapping@ },");
} else if constexpr (IsSame<decltype(mapping), Optional<CodePointDecomposition>>) {
generator.set("tag", mapping->tag);
- generator.set("start", String::number(mapping->decomposition_index));
- generator.set("size", String::number(mapping->decomposition_size));
+ generator.set("start", DeprecatedString::number(mapping->decomposition_index));
+ generator.set("size", DeprecatedString::number(mapping->decomposition_size));
generator.append(", CompatibilityFormattingTag::@tag@, @start@, @size@ },");
} else {
append_list_and_size(data.special_casing_indices, "&s_special_casing[{}]"sv);
@@ -983,9 +983,9 @@ static constexpr Array<@mapping_type@, @size@> s_@name@_mappings { {
return data.decomposition_mapping;
});
- auto append_code_point_range_list = [&](String name, Vector<CodePointRange> const& ranges) {
+ auto append_code_point_range_list = [&](DeprecatedString name, Vector<CodePointRange> const& ranges) {
generator.set("name", name);
- generator.set("size", String::number(ranges.size()));
+ generator.set("size", DeprecatedString::number(ranges.size()));
generator.append(R"~~~(
static constexpr Array<CodePointRange, @size@> @name@ { {
)~~~");
@@ -997,8 +997,8 @@ static constexpr Array<CodePointRange, @size@> @name@ { {
if (ranges_in_current_row++ > 0)
generator.append(" ");
- generator.set("first", String::formatted("{:#x}", range.first));
- generator.set("last", String::formatted("{:#x}", range.last));
+ generator.set("first", DeprecatedString::formatted("{:#x}", range.first));
+ generator.set("last", DeprecatedString::formatted("{:#x}", range.last));
generator.append("{ @first@, @last@ },");
if (ranges_in_current_row == max_ranges_per_row) {
@@ -1014,7 +1014,7 @@ static constexpr Array<CodePointRange, @size@> @name@ { {
auto append_prop_list = [&](StringView collection_name, StringView property_format, PropList const& property_list) {
for (auto const& property : property_list) {
- auto name = String::formatted(property_format, property.key);
+ auto name = DeprecatedString::formatted(property_format, property.key);
append_code_point_range_list(move(name), property.value);
}
@@ -1022,12 +1022,12 @@ static constexpr Array<CodePointRange, @size@> @name@ { {
quick_sort(property_names);
generator.set("name", collection_name);
- generator.set("size", String::number(property_names.size()));
+ generator.set("size", DeprecatedString::number(property_names.size()));
generator.append(R"~~~(
static constexpr Array<Span<CodePointRange const>, @size@> @name@ { {)~~~");
for (auto const& property_name : property_names) {
- generator.set("name", String::formatted(property_format, property_name));
+ generator.set("name", DeprecatedString::formatted(property_format, property_name));
generator.append(R"~~~(
@name@.span(),)~~~");
}
@@ -1052,7 +1052,7 @@ static constexpr Array<Span<CodePointRange const>, @size@> @name@ { {)~~~");
generator.set("type", type);
generator.set("name", name);
- generator.set("size", String::number(display_names.size()));
+ generator.set("size", DeprecatedString::number(display_names.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> @name@ { {
@@ -1061,9 +1061,9 @@ static constexpr Array<@type@, @size@> @name@ { {
if (values_in_current_row++ > 0)
generator.append(", ");
- generator.set("first", String::formatted("{:#x}", display_name.code_point_range.first));
- generator.set("last", String::formatted("{:#x}", display_name.code_point_range.last));
- generator.set("name", String::number(display_name.name));
+ generator.set("first", DeprecatedString::formatted("{:#x}", display_name.code_point_range.first));
+ generator.set("last", DeprecatedString::formatted("{:#x}", display_name.code_point_range.last));
+ generator.set("name", DeprecatedString::number(display_name.name));
generator.append("{ { @first@, @last@ }, @name@ }");
if (values_in_current_row == max_values_per_row) {
@@ -1104,13 +1104,13 @@ Span<BlockName const> block_display_names()
return display_names.span();
}
-Optional<String> code_point_display_name(u32 code_point)
+Optional<DeprecatedString> code_point_display_name(u32 code_point)
{
if (auto const* entry = binary_search(s_code_point_display_names, code_point, nullptr, CodePointNameComparator {})) {
auto display_name = decode_string(entry->display_name);
if (display_name.ends_with("{:X}"sv))
- return String::formatted(display_name, code_point);
+ return DeprecatedString::formatted(display_name, code_point);
return display_name;
}
@@ -1197,7 +1197,7 @@ bool code_point_has_@enum_snake@(u32 code_point, @enum_title@ @enum_snake@)
ValueFromStringOptions options {};
for (auto const& prop : prop_list) {
- if constexpr (IsSame<RemoveCVReference<decltype(prop)>, String>) {
+ if constexpr (IsSame<RemoveCVReference<decltype(prop)>, DeprecatedString>) {
hashes.set(CaseInsensitiveStringViewTraits::hash(prop), prop);
options.sensitivity = CaseSensitivity::CaseInsensitive;
} else {
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h
index 1c28e08bca..9a8753e980 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h
+++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h
@@ -6,6 +6,7 @@
#pragma once
+#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/HashFunctions.h>
#include <AK/HashMap.h>
@@ -15,7 +16,6 @@
#include <AK/Optional.h>
#include <AK/QuickSort.h>
#include <AK/SourceGenerator.h>
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
#include <AK/Traits.h>
@@ -102,7 +102,7 @@ public:
{
generator.set("type"sv, type);
generator.set("name"sv, name);
- generator.set("size"sv, String::number(m_storage.size()));
+ generator.set("size"sv, DeprecatedString::number(m_storage.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@ + 1> @name@ { {
@@ -114,10 +114,10 @@ static constexpr Array<@type@, @size@ + 1> @name@ { {
if (values_in_current_row++ > 0)
generator.append(", ");
- if constexpr (IsSame<StorageType, String>)
- generator.append(String::formatted("\"{}\"sv", value));
+ if constexpr (IsSame<StorageType, DeprecatedString>)
+ generator.append(DeprecatedString::formatted("\"{}\"sv", value));
else
- generator.append(String::formatted("{}", value));
+ generator.append(DeprecatedString::formatted("{}", value));
if (values_in_current_row == max_values_per_row) {
values_in_current_row = 0;
@@ -139,8 +139,8 @@ static constexpr Array<@type@, @size@ + 1> @name@ { {
for (size_t i = 0; i < m_storage.size(); ++i) {
auto const& list = m_storage[i];
- generator.set("index"sv, String::number(i));
- generator.set("size"sv, String::number(list.size()));
+ generator.set("index"sv, DeprecatedString::number(i));
+ generator.set("size"sv, DeprecatedString::number(list.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> @name@@index@ { {)~~~");
@@ -148,14 +148,14 @@ static constexpr Array<@type@, @size@> @name@@index@ { {)~~~");
bool first = true;
for (auto const& value : list) {
generator.append(first ? " "sv : ", "sv);
- generator.append(String::formatted("{}", value));
+ generator.append(DeprecatedString::formatted("{}", value));
first = false;
}
generator.append(" } };");
}
- generator.set("size"sv, String::number(m_storage.size()));
+ generator.set("size"sv, DeprecatedString::number(m_storage.size()));
generator.append(R"~~~(
@@ -169,7 +169,7 @@ static constexpr Array<Span<@type@ const>, @size@ + 1> @name@ { {
if (values_in_current_row++ > 0)
generator.append(", ");
- generator.set("index"sv, String::number(i));
+ generator.set("index"sv, DeprecatedString::number(i));
generator.append("@name@@index@.span()");
if (values_in_current_row == max_values_per_row) {
@@ -188,8 +188,8 @@ protected:
HashMap<StorageType, size_t> m_storage_indices;
};
-class UniqueStringStorage : public UniqueStorage<String> {
- using Base = UniqueStorage<String>;
+class UniqueStringStorage : public UniqueStorage<DeprecatedString> {
+ using Base = UniqueStorage<DeprecatedString>;
public:
// The goal of the string table generator is to ensure the table is located within the read-only
@@ -205,7 +205,7 @@ public:
if (values_in_current_row++ > 0)
generator.append(", ");
- generator.append(String::formatted("{:#x}", value));
+ generator.append(DeprecatedString::formatted("{:#x}", value));
if (values_in_current_row == max_values_per_row) {
values_in_current_row = 0;
@@ -225,7 +225,7 @@ public:
next_index += string.length() + 2;
}
- generator.set("size", String::number(next_index));
+ generator.set("size", DeprecatedString::number(next_index));
generator.append(R"~~~(
static constexpr Array<u8, @size@> s_encoded_strings { {
)~~~");
@@ -243,7 +243,7 @@ static constexpr Array<u8, @size@> s_encoded_strings { {
} };
)~~~");
- generator.set("size", String::number(string_indices.size()));
+ generator.set("size", DeprecatedString::number(string_indices.size()));
generator.append(R"~~~(
static constexpr Array<u32, @size@> s_encoded_string_indices { {
)~~~");
@@ -277,8 +277,8 @@ static constexpr StringView decode_string(size_t index)
};
struct Alias {
- String name;
- String alias;
+ DeprecatedString name;
+ DeprecatedString alias;
};
struct CanonicalLanguageID {
@@ -342,7 +342,7 @@ inline ErrorOr<JsonValue> read_json_file(StringView path)
return JsonValue::from_string(buffer);
}
-inline ErrorOr<Core::DirIterator> path_to_dir_iterator(String path, StringView subpath = "main"sv)
+inline ErrorOr<Core::DirIterator> path_to_dir_iterator(DeprecatedString path, StringView subpath = "main"sv)
{
LexicalPath lexical_path(move(path));
if (!subpath.is_empty())
@@ -359,7 +359,7 @@ inline ErrorOr<Core::DirIterator> path_to_dir_iterator(String path, StringView s
return iterator;
}
-inline ErrorOr<String> next_path_from_dir_iterator(Core::DirIterator& iterator)
+inline ErrorOr<DeprecatedString> next_path_from_dir_iterator(Core::DirIterator& iterator)
{
auto next_path = iterator.next_full_path();
if (iterator.has_error()) {
@@ -416,11 +416,11 @@ void generate_value_from_string(SourceGenerator& generator, StringView method_na
{
ensure_from_string_types_are_generated(generator);
- generator.set("method_name", String::formatted(method_name_format, value_name));
+ generator.set("method_name", DeprecatedString::formatted(method_name_format, value_name));
generator.set("value_type", value_type);
generator.set("value_name", value_name);
generator.set("return_type", options.return_type.has_value() ? *options.return_type : value_type);
- generator.set("size", String::number(hashes.size()));
+ generator.set("size", DeprecatedString::number(hashes.size()));
generator.append(R"~~~(
Optional<@return_type@> @method_name@(StringView key)
@@ -439,11 +439,11 @@ Optional<@return_type@> @method_name@(StringView key)
generator.append(" ");
if constexpr (IsIntegral<ValueType>)
- generator.set("value"sv, String::number(hashes.get(hash_key).value()));
+ generator.set("value"sv, DeprecatedString::number(hashes.get(hash_key).value()));
else
- generator.set("value"sv, String::formatted("{}::{}", value_type, hashes.get(hash_key).value()));
+ generator.set("value"sv, DeprecatedString::formatted("{}::{}", value_type, hashes.get(hash_key).value()));
- generator.set("hash"sv, String::number(hash_key));
+ generator.set("hash"sv, DeprecatedString::number(hash_key));
generator.append("{ @hash@U, @value@ },"sv);
if (values_in_current_row == max_values_per_row) {
@@ -452,7 +452,7 @@ Optional<@return_type@> @method_name@(StringView key)
}
}
- generator.set("return_statement", String::formatted(options.return_format, "value->value"sv));
+ generator.set("return_statement", DeprecatedString::formatted(options.return_format, "value->value"sv));
generator.append(R"~~~(
} };
)~~~");
@@ -476,9 +476,9 @@ Optional<@return_type@> @method_name@(StringView key)
}
template<typename IdentifierFormatter>
-void generate_value_to_string(SourceGenerator& generator, StringView method_name_format, StringView value_type, StringView value_name, IdentifierFormatter&& format_identifier, Span<String const> values)
+void generate_value_to_string(SourceGenerator& generator, StringView method_name_format, StringView value_type, StringView value_name, IdentifierFormatter&& format_identifier, Span<DeprecatedString const> values)
{
- generator.set("method_name", String::formatted(method_name_format, value_name));
+ generator.set("method_name", DeprecatedString::formatted(method_name_format, value_name));
generator.set("value_type", value_type);
generator.set("value_name", value_name);
@@ -506,7 +506,7 @@ StringView @method_name@(@value_type@ @value_name@)
}
template<typename IdentifierFormatter>
-void generate_enum(SourceGenerator& generator, IdentifierFormatter&& format_identifier, StringView name, StringView default_, Vector<String>& values, Vector<Alias> aliases = {})
+void generate_enum(SourceGenerator& generator, IdentifierFormatter&& format_identifier, StringView name, StringView default_, Vector<DeprecatedString>& values, Vector<Alias> aliases = {})
{
quick_sort(values, [](auto const& value1, auto const& value2) { return value1.to_lowercase() < value2.to_lowercase(); });
quick_sort(aliases, [](auto const& alias1, auto const& alias2) { return alias1.alias.to_lowercase() < alias2.alias.to_lowercase(); });
@@ -545,20 +545,20 @@ template<typename LocalesType, typename IdentifierFormatter, typename ListFormat
void generate_mapping(SourceGenerator& generator, LocalesType const& locales, StringView type, StringView name, StringView format, IdentifierFormatter&& format_identifier, ListFormatter&& format_list)
{
auto format_mapping_name = [&](StringView format, StringView name) {
- String mapping_name;
+ DeprecatedString mapping_name;
if constexpr (IsNullPointer<IdentifierFormatter>)
mapping_name = name.replace("-"sv, "_"sv, ReplaceMode::All);
else
mapping_name = format_identifier(type, name);
- return String::formatted(format, mapping_name.to_lowercase());
+ return DeprecatedString::formatted(format, mapping_name.to_lowercase());
};
- Vector<String> mapping_names;
+ Vector<DeprecatedString> mapping_names;
for (auto const& locale : locales) {
- String mapping_name;
+ DeprecatedString mapping_name;
if constexpr (requires { locale.key; }) {
mapping_name = format_mapping_name(format, locale.key);
@@ -575,7 +575,7 @@ void generate_mapping(SourceGenerator& generator, LocalesType const& locales, St
generator.set("type", type);
generator.set("name", name);
- generator.set("size", String::number(locales.size()));
+ generator.set("size", DeprecatedString::number(locales.size()));
generator.append(R"~~~(
static constexpr Array<Span<@type@ const>, @size@> @name@ { {
)~~~");
@@ -620,9 +620,9 @@ Span<StringView const> @name@()
first = false;
if (auto it = aliases.find_if([&](auto const& alias) { return alias.alias == value; }); it != aliases.end())
- generator.append(String::formatted("\"{}\"sv", it->name));
+ generator.append(DeprecatedString::formatted("\"{}\"sv", it->name));
else
- generator.append(String::formatted("\"{}\"sv", value));
+ generator.append(DeprecatedString::formatted("\"{}\"sv", value));
}
generator.append(R"~~~( };
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp
index a316d696a9..5ceab3934d 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp
@@ -69,7 +69,7 @@ static StringView sequence_storage_type_to_cpp_storage_type_name(SequenceStorage
CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface);
-static String union_type_to_variant(UnionType const& union_type, Interface const& interface)
+static DeprecatedString union_type_to_variant(UnionType const& union_type, Interface const& interface)
{
StringBuilder builder;
builder.append("Variant<"sv);
@@ -95,10 +95,10 @@ static String union_type_to_variant(UnionType const& union_type, Interface const
CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
{
if (is_platform_object(type))
- return { .name = String::formatted("JS::Handle<{}>", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector };
+ return { .name = DeprecatedString::formatted("JS::Handle<{}>", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector };
if (type.is_string())
- return { .name = "String", .sequence_storage_type = SequenceStorageType::Vector };
+ return { .name = "DeprecatedString", .sequence_storage_type = SequenceStorageType::Vector };
if (type.name() == "double" && !type.is_nullable())
return { .name = "double", .sequence_storage_type = SequenceStorageType::Vector };
@@ -139,7 +139,7 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
if (sequence_cpp_type.sequence_storage_type == SequenceStorageType::MarkedVector)
return { .name = storage_type_name, .sequence_storage_type = SequenceStorageType::Vector };
- return { .name = String::formatted("{}<{}>", storage_type_name, sequence_cpp_type.name), .sequence_storage_type = SequenceStorageType::Vector };
+ return { .name = DeprecatedString::formatted("{}<{}>", storage_type_name, sequence_cpp_type.name), .sequence_storage_type = SequenceStorageType::Vector };
}
if (type.name() == "record") {
@@ -149,7 +149,7 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
auto record_key_cpp_type = idl_type_name_to_cpp_type(record_key_type, interface);
auto record_value_cpp_type = idl_type_name_to_cpp_type(record_value_type, interface);
- return { .name = String::formatted("OrderedHashMap<{}, {}>", record_key_cpp_type.name, record_value_cpp_type.name), .sequence_storage_type = SequenceStorageType::Vector };
+ return { .name = DeprecatedString::formatted("OrderedHashMap<{}, {}>", record_key_cpp_type.name, record_value_cpp_type.name), .sequence_storage_type = SequenceStorageType::Vector };
}
if (is<UnionType>(type)) {
@@ -168,7 +168,7 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
TODO();
}
-static String make_input_acceptable_cpp(String const& input)
+static DeprecatedString make_input_acceptable_cpp(DeprecatedString const& input)
{
if (input.is_one_of("class", "template", "for", "default", "char", "namespace", "delete", "inline")) {
StringBuilder builder;
@@ -206,7 +206,7 @@ static void generate_include_for(auto& generator, auto& path)
}
LexicalPath include_path { path_string };
- forked_generator.set("include.path", String::formatted("{}/{}.h", include_path.dirname(), include_path.title()));
+ forked_generator.set("include.path", DeprecatedString::formatted("{}/{}.h", include_path.dirname(), include_path.title()));
forked_generator.append(R"~~~(
#include <@include.path@>
)~~~");
@@ -215,7 +215,7 @@ static void generate_include_for(auto& generator, auto& path)
static void emit_includes_for_all_imports(auto& interface, auto& generator, bool is_iterator = false)
{
Queue<RemoveCVReference<decltype(interface)> const*> interfaces;
- HashTable<String> paths_imported;
+ HashTable<DeprecatedString> paths_imported;
interfaces.enqueue(&interface);
@@ -236,15 +236,15 @@ static void emit_includes_for_all_imports(auto& interface, auto& generator, bool
generate_include_for(generator, interface->module_own_path);
if (is_iterator) {
- auto iterator_name = String::formatted("{}Iterator", interface->name);
- auto iterator_path = String::formatted("{}Iterator", interface->fully_qualified_name.replace("::"sv, "/"sv, ReplaceMode::All));
+ auto iterator_name = DeprecatedString::formatted("{}Iterator", interface->name);
+ auto iterator_path = DeprecatedString::formatted("{}Iterator", interface->fully_qualified_name.replace("::"sv, "/"sv, ReplaceMode::All));
generate_include_for_iterator(generator, iterator_path, iterator_name);
}
}
}
template<typename ParameterType>
-static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter, String const& js_name, String const& js_suffix, String const& cpp_name, IDL::Interface const& interface, bool legacy_null_to_empty_string = false, bool optional = false, Optional<String> optional_default_value = {}, bool variadic = false, size_t recursion_depth = 0)
+static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter, DeprecatedString const& js_name, DeprecatedString const& js_suffix, DeprecatedString const& cpp_name, IDL::Interface const& interface, bool legacy_null_to_empty_string = false, bool optional = false, Optional<DeprecatedString> optional_default_value = {}, bool variadic = false, size_t recursion_depth = 0)
{
auto scoped_generator = generator.fork();
auto acceptable_cpp_name = make_input_acceptable_cpp(cpp_name);
@@ -261,7 +261,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
if (parameter.type->is_string()) {
if (variadic) {
scoped_generator.append(R"~~~(
- Vector<String> @cpp_name@;
+ Vector<DeprecatedString> @cpp_name@;
@cpp_name@.ensure_capacity(vm.argument_count() - @js_suffix@);
for (size_t i = @js_suffix@; i < vm.argument_count(); ++i) {
@@ -272,26 +272,26 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
} else if (!optional) {
if (!parameter.type->is_nullable()) {
scoped_generator.append(R"~~~(
- String @cpp_name@;
+ DeprecatedString @cpp_name@;
if (@js_name@@js_suffix@.is_null() && @legacy_null_to_empty_string@) {
- @cpp_name@ = String::empty();
+ @cpp_name@ = DeprecatedString::empty();
} else {
@cpp_name@ = TRY(@js_name@@js_suffix@.to_string(vm));
}
)~~~");
} else {
scoped_generator.append(R"~~~(
- String @cpp_name@;
+ DeprecatedString @cpp_name@;
if (!@js_name@@js_suffix@.is_nullish())
@cpp_name@ = TRY(@js_name@@js_suffix@.to_string(vm));
)~~~");
}
} else {
scoped_generator.append(R"~~~(
- String @cpp_name@;
+ DeprecatedString @cpp_name@;
if (!@js_name@@js_suffix@.is_undefined()) {
if (@js_name@@js_suffix@.is_null() && @legacy_null_to_empty_string@)
- @cpp_name@ = String::empty();
+ @cpp_name@ = DeprecatedString::empty();
else
@cpp_name@ = TRY(@js_name@@js_suffix@.to_string(vm));
})~~~");
@@ -573,7 +573,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
auto default_value_cpp_name = enumeration.translated_cpp_names.get(enum_member_name);
VERIFY(default_value_cpp_name.has_value());
enum_generator.set("enum.default.cpp_value", *default_value_cpp_name);
- enum_generator.set("js_name.as_string", String::formatted("{}{}_string", enum_generator.get("js_name"sv), enum_generator.get("js_suffix"sv)));
+ enum_generator.set("js_name.as_string", DeprecatedString::formatted("{}{}_string", enum_generator.get("js_name"sv), enum_generator.get("js_suffix"sv)));
enum_generator.append(R"~~~(
@parameter.type.name@ @cpp_name@ { @parameter.type.name@::@enum.default.cpp_value@ };
)~~~");
@@ -634,8 +634,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
for (auto& member : current_dictionary->members) {
dictionary_generator.set("member_key", member.name);
auto member_js_name = make_input_acceptable_cpp(member.name.to_snakecase());
- auto member_value_name = String::formatted("{}_value", member_js_name);
- auto member_property_value_name = String::formatted("{}_property_value", member_js_name);
+ auto member_value_name = DeprecatedString::formatted("{}_value", member_js_name);
+ auto member_property_value_name = DeprecatedString::formatted("{}_property_value", member_js_name);
dictionary_generator.set("member_name", member_js_name);
dictionary_generator.set("member_value_name", member_value_name);
dictionary_generator.set("member_property_value_name", member_property_value_name);
@@ -705,7 +705,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
auto sequence_generator = scoped_generator.fork();
auto& parameterized_type = verify_cast<IDL::ParameterizedType>(*parameter.type);
- sequence_generator.set("recursion_depth", String::number(recursion_depth));
+ sequence_generator.set("recursion_depth", DeprecatedString::number(recursion_depth));
// An ECMAScript value V is converted to an IDL sequence<T> value as follows:
// 1. If Type(V) is not Object, throw a TypeError.
@@ -757,7 +757,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
return vm.throw_completion<JS::TypeError>(JS::ErrorType::NotIterable, @js_name@@js_suffix@.to_string_without_side_effects());
)~~~");
- parameterized_type.generate_sequence_from_iterable(sequence_generator, String::formatted("{}{}", acceptable_cpp_name, optional ? "_non_optional" : ""), String::formatted("{}{}", js_name, js_suffix), String::formatted("iterator_method{}", recursion_depth), interface, recursion_depth + 1);
+ parameterized_type.generate_sequence_from_iterable(sequence_generator, DeprecatedString::formatted("{}{}", acceptable_cpp_name, optional ? "_non_optional" : ""), DeprecatedString::formatted("{}{}", js_name, js_suffix), DeprecatedString::formatted("iterator_method{}", recursion_depth), interface, recursion_depth + 1);
if (optional) {
sequence_generator.append(R"~~~(
@@ -770,7 +770,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
auto record_generator = scoped_generator.fork();
auto& parameterized_type = verify_cast<IDL::ParameterizedType>(*parameter.type);
- record_generator.set("recursion_depth", String::number(recursion_depth));
+ record_generator.set("recursion_depth", DeprecatedString::number(recursion_depth));
// A record can only have two types: key type and value type.
VERIFY(parameterized_type.parameters().size() == 2);
@@ -820,7 +820,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
)~~~");
IDL::Parameter key_parameter { .type = parameterized_type.parameters()[0], .name = acceptable_cpp_name, .optional_default_value = {}, .extended_attributes = {} };
- generate_to_cpp(record_generator, key_parameter, "key", String::number(recursion_depth), String::formatted("typed_key{}", recursion_depth), interface, false, false, {}, false, recursion_depth + 1);
+ generate_to_cpp(record_generator, key_parameter, "key", DeprecatedString::number(recursion_depth), DeprecatedString::formatted("typed_key{}", recursion_depth), interface, false, false, {}, false, recursion_depth + 1);
record_generator.append(R"~~~(
auto value@recursion_depth@ = TRY(@js_name@@js_suffix@_object.get(property_key@recursion_depth@));
@@ -828,7 +828,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// FIXME: Record value types should be TypeWithExtendedAttributes, which would allow us to get [LegacyNullToEmptyString] here.
IDL::Parameter value_parameter { .type = parameterized_type.parameters()[1], .name = acceptable_cpp_name, .optional_default_value = {}, .extended_attributes = {} };
- generate_to_cpp(record_generator, value_parameter, "value", String::number(recursion_depth), String::formatted("typed_value{}", recursion_depth), interface, false, false, {}, false, recursion_depth + 1);
+ generate_to_cpp(record_generator, value_parameter, "value", DeprecatedString::number(recursion_depth), DeprecatedString::formatted("typed_value{}", recursion_depth), interface, false, false, {}, false, recursion_depth + 1);
record_generator.append(R"~~~(
@cpp_name@.set(typed_key@recursion_depth@, typed_value@recursion_depth@);
@@ -841,7 +841,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
auto& union_type = verify_cast<IDL::UnionType>(*parameter.type);
union_generator.set("union_type", union_type_to_variant(union_type, interface));
- union_generator.set("recursion_depth", String::number(recursion_depth));
+ union_generator.set("recursion_depth", DeprecatedString::number(recursion_depth));
// NOTE: This is handled out here as we need the dictionary conversion code for the {} optional default value.
// 3. Let types be the flattened member types of the union type.
@@ -891,7 +891,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
to_variant_captures.append("&vm, &realm"sv);
if (dictionary_type)
- to_variant_captures.append(String::formatted(", &{}{}_to_dictionary", js_name, js_suffix));
+ to_variant_captures.append(DeprecatedString::formatted(", &{}{}_to_dictionary", js_name, js_suffix));
union_generator.set("to_variant_captures", to_variant_captures.to_string());
@@ -1028,7 +1028,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
if (method) {
)~~~");
- sequence_type->generate_sequence_from_iterable(union_generator, acceptable_cpp_name, String::formatted("{}{}", js_name, js_suffix), "method", interface, recursion_depth + 1);
+ sequence_type->generate_sequence_from_iterable(union_generator, acceptable_cpp_name, DeprecatedString::formatted("{}{}", js_name, js_suffix), "method", interface, recursion_depth + 1);
union_generator.append(R"~~~(
@@ -1113,8 +1113,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
)~~~");
// NOTE: generate_to_cpp doesn't use the parameter name.
// NOTE: generate_to_cpp will use to_{u32,etc.} which uses to_number internally and will thus use TRY, but it cannot throw as we know we are dealing with a number.
- IDL::Parameter parameter { .type = *numeric_type, .name = String::empty(), .optional_default_value = {}, .extended_attributes = {} };
- generate_to_cpp(union_generator, parameter, js_name, js_suffix, String::formatted("{}{}_number", js_name, js_suffix), interface, false, false, {}, false, recursion_depth + 1);
+ IDL::Parameter parameter { .type = *numeric_type, .name = DeprecatedString::empty(), .optional_default_value = {}, .extended_attributes = {} };
+ generate_to_cpp(union_generator, parameter, js_name, js_suffix, DeprecatedString::formatted("{}{}_number", js_name, js_suffix), interface, false, false, {}, false, recursion_depth + 1);
union_generator.append(R"~~~(
return @js_name@@js_suffix@_number;
@@ -1178,8 +1178,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// NOTE: generate_to_cpp doesn't use the parameter name.
// NOTE: generate_to_cpp will use to_{u32,etc.} which uses to_number internally and will thus use TRY, but it cannot throw as we know we are dealing with a number.
- IDL::Parameter parameter { .type = *numeric_type, .name = String::empty(), .optional_default_value = {}, .extended_attributes = {} };
- generate_to_cpp(union_numeric_type_generator, parameter, "x", String::empty(), "x_number", interface, false, false, {}, false, recursion_depth + 1);
+ IDL::Parameter parameter { .type = *numeric_type, .name = DeprecatedString::empty(), .optional_default_value = {}, .extended_attributes = {} };
+ generate_to_cpp(union_numeric_type_generator, parameter, "x", DeprecatedString::empty(), "x_number", interface, false, false, {}, false, recursion_depth + 1);
union_numeric_type_generator.append(R"~~~(
return x_number;
@@ -1189,8 +1189,8 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
// NOTE: generate_to_cpp doesn't use the parameter name.
// NOTE: generate_to_cpp will use to_{u32,etc.} which uses to_number internally and will thus use TRY, but it cannot throw as we know we are dealing with a number.
- IDL::Parameter parameter { .type = *numeric_type, .name = String::empty(), .optional_default_value = {}, .extended_attributes = {} };
- generate_to_cpp(union_generator, parameter, js_name, js_suffix, String::formatted("{}{}_number", js_name, js_suffix), interface, false, false, {}, false, recursion_depth + 1);
+ IDL::Parameter parameter { .type = *numeric_type, .name = DeprecatedString::empty(), .optional_default_value = {}, .extended_attributes = {} };
+ generate_to_cpp(union_generator, parameter, js_name, js_suffix, DeprecatedString::formatted("{}{}_number", js_name, js_suffix), interface, false, false, {}, false, recursion_depth + 1);
union_generator.append(R"~~~(
return @js_name@@js_suffix@_number;
@@ -1233,7 +1233,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
} else {
if (optional_default_value == "\"\"") {
union_generator.append(R"~~~(
- @union_type@ @cpp_name@ = @js_name@@js_suffix@.is_undefined() ? String::empty() : TRY(@js_name@@js_suffix@_to_variant(@js_name@@js_suffix@));
+ @union_type@ @cpp_name@ = @js_name@@js_suffix@.is_undefined() ? DeprecatedString::empty() : TRY(@js_name@@js_suffix@_to_variant(@js_name@@js_suffix@));
)~~~");
} else if (optional_default_value == "{}") {
VERIFY(dictionary_type);
@@ -1266,21 +1266,21 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
}
}
-static void generate_argument_count_check(SourceGenerator& generator, String const& function_name, size_t argument_count)
+static void generate_argument_count_check(SourceGenerator& generator, DeprecatedString const& function_name, size_t argument_count)
{
if (argument_count == 0)
return;
auto argument_count_check_generator = generator.fork();
argument_count_check_generator.set("function.name", function_name);
- argument_count_check_generator.set("function.nargs", String::number(argument_count));
+ argument_count_check_generator.set("function.nargs", DeprecatedString::number(argument_count));
if (argument_count == 1) {
argument_count_check_generator.set(".bad_arg_count", "JS::ErrorType::BadArgCountOne");
argument_count_check_generator.set(".arg_count_suffix", "");
} else {
argument_count_check_generator.set(".bad_arg_count", "JS::ErrorType::BadArgCountMany");
- argument_count_check_generator.set(".arg_count_suffix", String::formatted(", \"{}\"", argument_count));
+ argument_count_check_generator.set(".arg_count_suffix", DeprecatedString::formatted(", \"{}\"", argument_count));
}
argument_count_check_generator.append(R"~~~(
@@ -1293,20 +1293,20 @@ static void generate_arguments(SourceGenerator& generator, Vector<IDL::Parameter
{
auto arguments_generator = generator.fork();
- Vector<String> parameter_names;
+ Vector<DeprecatedString> parameter_names;
size_t argument_index = 0;
for (auto& parameter : parameters) {
parameter_names.append(make_input_acceptable_cpp(parameter.name.to_snakecase()));
if (!parameter.variadic) {
- arguments_generator.set("argument.index", String::number(argument_index));
+ arguments_generator.set("argument.index", DeprecatedString::number(argument_index));
arguments_generator.append(R"~~~(
auto arg@argument.index@ = vm.argument(@argument.index@);
)~~~");
}
bool legacy_null_to_empty_string = parameter.extended_attributes.contains("LegacyNullToEmptyString");
- generate_to_cpp(generator, parameter, "arg", String::number(argument_index), parameter.name.to_snakecase(), interface, legacy_null_to_empty_string, parameter.optional, parameter.optional_default_value, parameter.variadic, 0);
+ generate_to_cpp(generator, parameter, "arg", DeprecatedString::number(argument_index), parameter.name.to_snakecase(), interface, legacy_null_to_empty_string, parameter.optional, parameter.optional_default_value, parameter.variadic, 0);
++argument_index;
}
@@ -1314,13 +1314,13 @@ static void generate_arguments(SourceGenerator& generator, Vector<IDL::Parameter
}
// https://webidl.spec.whatwg.org/#create-sequence-from-iterable
-void IDL::ParameterizedType::generate_sequence_from_iterable(SourceGenerator& generator, String const& cpp_name, String const& iterable_cpp_name, String const& iterator_method_cpp_name, IDL::Interface const& interface, size_t recursion_depth) const
+void IDL::ParameterizedType::generate_sequence_from_iterable(SourceGenerator& generator, DeprecatedString const& cpp_name, DeprecatedString const& iterable_cpp_name, DeprecatedString const& iterator_method_cpp_name, IDL::Interface const& interface, size_t recursion_depth) const
{
auto sequence_generator = generator.fork();
sequence_generator.set("cpp_name", cpp_name);
sequence_generator.set("iterable_cpp_name", iterable_cpp_name);
sequence_generator.set("iterator_method_cpp_name", iterator_method_cpp_name);
- sequence_generator.set("recursion_depth", String::number(recursion_depth));
+ sequence_generator.set("recursion_depth", DeprecatedString::number(recursion_depth));
auto sequence_cpp_type = idl_type_name_to_cpp_type(parameters().first(), interface);
sequence_generator.set("sequence.type", sequence_cpp_type.name);
sequence_generator.set("sequence.storage_type", sequence_storage_type_to_cpp_storage_type_name(sequence_cpp_type.sequence_storage_type));
@@ -1360,7 +1360,7 @@ void IDL::ParameterizedType::generate_sequence_from_iterable(SourceGenerator& ge
// FIXME: Sequences types should be TypeWithExtendedAttributes, which would allow us to get [LegacyNullToEmptyString] here.
IDL::Parameter parameter { .type = parameters().first(), .name = iterable_cpp_name, .optional_default_value = {}, .extended_attributes = {} };
- generate_to_cpp(sequence_generator, parameter, "next_item", String::number(recursion_depth), String::formatted("sequence_item{}", recursion_depth), interface, false, false, {}, false, recursion_depth);
+ generate_to_cpp(sequence_generator, parameter, "next_item", DeprecatedString::number(recursion_depth), DeprecatedString::formatted("sequence_item{}", recursion_depth), interface, false, false, {}, false, recursion_depth);
sequence_generator.append(R"~~~(
@cpp_name@.append(sequence_item@recursion_depth@);
@@ -1373,13 +1373,13 @@ enum class WrappingReference {
Yes,
};
-static void generate_wrap_statement(SourceGenerator& generator, String const& value, IDL::Type const& type, IDL::Interface const& interface, StringView result_expression, WrappingReference wrapping_reference = WrappingReference::No, size_t recursion_depth = 0)
+static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString const& value, IDL::Type const& type, IDL::Interface const& interface, StringView result_expression, WrappingReference wrapping_reference = WrappingReference::No, size_t recursion_depth = 0)
{
auto scoped_generator = generator.fork();
scoped_generator.set("value", value);
scoped_generator.set("type", type.name());
scoped_generator.set("result_expression", result_expression);
- scoped_generator.set("recursion_depth", String::number(recursion_depth));
+ scoped_generator.set("recursion_depth", DeprecatedString::number(recursion_depth));
if (type.name() == "undefined") {
scoped_generator.append(R"~~~(
@@ -1443,7 +1443,7 @@ static void generate_wrap_statement(SourceGenerator& generator, String const& va
auto* wrapped_element@recursion_depth@ = &(*element@recursion_depth@);
)~~~");
} else {
- generate_wrap_statement(scoped_generator, String::formatted("element{}", recursion_depth), sequence_generic_type.parameters().first(), interface, String::formatted("auto wrapped_element{} =", recursion_depth), WrappingReference::Yes, recursion_depth + 1);
+ generate_wrap_statement(scoped_generator, DeprecatedString::formatted("element{}", recursion_depth), sequence_generic_type.parameters().first(), interface, DeprecatedString::formatted("auto wrapped_element{} =", recursion_depth), WrappingReference::Yes, recursion_depth + 1);
}
scoped_generator.append(R"~~~(
@@ -1498,7 +1498,7 @@ static void generate_wrap_statement(SourceGenerator& generator, String const& va
)~~~");
// NOTE: While we are using const&, the underlying type for wrappable types in unions is (Nonnull)RefPtr, which are not references.
- generate_wrap_statement(union_generator, String::formatted("visited_union_value{}", recursion_depth), current_union_type, interface, "return"sv, WrappingReference::No, recursion_depth + 1);
+ generate_wrap_statement(union_generator, DeprecatedString::formatted("visited_union_value{}", recursion_depth), current_union_type, interface, "return"sv, WrappingReference::No, recursion_depth + 1);
// End of current visit lambda.
// The last lambda cannot have a trailing comma on the closing brace, unless the type is nullable, where an extra lambda will be generated for the Empty case.
@@ -1561,14 +1561,14 @@ static void generate_wrap_statement(SourceGenerator& generator, String const& va
while (true) {
for (auto& member : current_dictionary->members) {
dictionary_generator.set("member_key", member.name);
- auto member_key_js_name = String::formatted("{}{}", make_input_acceptable_cpp(member.name.to_snakecase()), recursion_depth);
+ auto member_key_js_name = DeprecatedString::formatted("{}{}", make_input_acceptable_cpp(member.name.to_snakecase()), recursion_depth);
dictionary_generator.set("member_name", member_key_js_name);
- auto member_value_js_name = String::formatted("{}_value", member_key_js_name);
+ auto member_value_js_name = DeprecatedString::formatted("{}_value", member_key_js_name);
dictionary_generator.set("member_value", member_value_js_name);
- auto wrapped_value_name = String::formatted("auto wrapped_{}", member_value_js_name);
+ auto wrapped_value_name = DeprecatedString::formatted("auto wrapped_{}", member_value_js_name);
dictionary_generator.set("wrapped_value_name", wrapped_value_name);
- generate_wrap_statement(dictionary_generator, String::formatted("{}.{}", value, member.name), member.type, interface, wrapped_value_name, WrappingReference::No, recursion_depth + 1);
+ generate_wrap_statement(dictionary_generator, DeprecatedString::formatted("{}.{}", value, member.name), member.type, interface, wrapped_value_name, WrappingReference::No, recursion_depth + 1);
dictionary_generator.append(R"~~~(
MUST(dictionary_object@recursion_depth@->create_data_property("@member_key@", @wrapped_value_name@));
@@ -1617,24 +1617,24 @@ static void generate_return_statement(SourceGenerator& generator, IDL::Type cons
return generate_wrap_statement(generator, "retval", return_type, interface, "return"sv);
}
-static void generate_variable_statement(SourceGenerator& generator, String const& variable_name, IDL::Type const& value_type, String const& value_name, IDL::Interface const& interface)
+static void generate_variable_statement(SourceGenerator& generator, DeprecatedString const& variable_name, IDL::Type const& value_type, DeprecatedString const& value_name, IDL::Interface const& interface)
{
auto variable_generator = generator.fork();
variable_generator.set("variable_name", variable_name);
variable_generator.append(R"~~~(
JS::Value @variable_name@;
)~~~");
- return generate_wrap_statement(generator, value_name, value_type, interface, String::formatted("{} = ", variable_name));
+ return generate_wrap_statement(generator, value_name, value_type, interface, DeprecatedString::formatted("{} = ", variable_name));
}
-static void generate_function(SourceGenerator& generator, IDL::Function const& function, StaticFunction is_static_function, String const& class_name, String const& interface_fully_qualified_name, IDL::Interface const& interface)
+static void generate_function(SourceGenerator& generator, IDL::Function const& function, StaticFunction is_static_function, DeprecatedString const& class_name, DeprecatedString const& interface_fully_qualified_name, IDL::Interface const& interface)
{
auto function_generator = generator.fork();
function_generator.set("class_name", class_name);
function_generator.set("interface_fully_qualified_name", interface_fully_qualified_name);
function_generator.set("function.name", function.name);
function_generator.set("function.name:snakecase", make_input_acceptable_cpp(function.name.to_snakecase()));
- function_generator.set("overload_suffix", function.is_overloaded ? String::number(function.overload_index) : String::empty());
+ function_generator.set("overload_suffix", function.is_overloaded ? DeprecatedString::number(function.overload_index) : DeprecatedString::empty());
if (function.extended_attributes.contains("ImplementedAs")) {
auto implemented_as = function.extended_attributes.get("ImplementedAs").value();
@@ -1672,7 +1672,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@@overload_suffi
if (arguments_builder.is_empty())
function_generator.set(".arguments", "vm");
else
- function_generator.set(".arguments", String::formatted("vm, {}", arguments_builder.string_view()));
+ function_generator.set(".arguments", DeprecatedString::formatted("vm, {}", arguments_builder.string_view()));
function_generator.append(R"~~~(
[[maybe_unused]] auto retval = TRY(throw_dom_exception_if_needed(vm, [&] { return @interface_fully_qualified_name@::@function.cpp_name@(@.arguments@); }));
@@ -1813,7 +1813,7 @@ static EffectiveOverloadSet compute_the_effective_overload_set(auto const& overl
return EffectiveOverloadSet { move(overloads) };
}
-static String generate_constructor_for_idl_type(Type const& type)
+static DeprecatedString generate_constructor_for_idl_type(Type const& type)
{
auto append_type_list = [](auto& builder, auto const& type_list) {
bool first = true;
@@ -1830,7 +1830,7 @@ static String generate_constructor_for_idl_type(Type const& type)
switch (type.kind()) {
case Type::Kind::Plain:
- return String::formatted("make_ref_counted<IDL::Type>(\"{}\", {})", type.name(), type.is_nullable());
+ return DeprecatedString::formatted("make_ref_counted<IDL::Type>(\"{}\", {})", type.name(), type.is_nullable());
case Type::Kind::Parameterized: {
auto const& parameterized_type = type.as_parameterized();
StringBuilder builder;
@@ -1852,7 +1852,7 @@ static String generate_constructor_for_idl_type(Type const& type)
VERIFY_NOT_REACHED();
}
-static void generate_overload_arbiter(SourceGenerator& generator, auto const& overload_set, String const& class_name)
+static void generate_overload_arbiter(SourceGenerator& generator, auto const& overload_set, DeprecatedString const& class_name)
{
auto function_generator = generator.fork();
function_generator.set("class_name", class_name);
@@ -1869,7 +1869,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@)
auto maximum_argument_count = 0u;
for (auto const& overload : overloads_set)
maximum_argument_count = max(maximum_argument_count, overload.types.size());
- function_generator.set("max_argument_count", String::number(maximum_argument_count));
+ function_generator.set("max_argument_count", DeprecatedString::number(maximum_argument_count));
function_generator.appendln(" switch (min(@max_argument_count@, vm.argument_count())) {");
// Generate the effective overload set for each argument count.
@@ -1888,8 +1888,8 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@)
if (effective_overload_count == 0)
continue;
- function_generator.set("current_argument_count", String::number(argument_count));
- function_generator.set("overload_count", String::number(effective_overload_count));
+ function_generator.set("current_argument_count", DeprecatedString::number(argument_count));
+ function_generator.set("overload_count", DeprecatedString::number(effective_overload_count));
function_generator.appendln(R"~~~(
case @current_argument_count@: {
Vector<IDL::EffectiveOverloadSet::Item> overloads;
@@ -1930,7 +1930,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@)
types_builder.append("}"sv);
optionality_builder.append("}"sv);
- function_generator.set("overload.callable_id", String::number(overload.callable_id));
+ function_generator.set("overload.callable_id", DeprecatedString::number(overload.callable_id));
function_generator.set("overload.types", types_builder.to_string());
function_generator.set("overload.optionality_values", optionality_builder.to_string());
@@ -1955,7 +1955,7 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@)
)~~~");
for (auto i = 0u; i < overload_set.value.size(); ++i) {
- function_generator.set("overload_id", String::number(i));
+ function_generator.set("overload_id", DeprecatedString::number(i));
function_generator.append(R"~~~(
case @overload_id@:
return @function.name:snakecase@@overload_id@(vm);
@@ -2009,7 +2009,7 @@ private:
)~~~");
if (overload_set.value.size() > 1) {
for (auto i = 0u; i < overload_set.value.size(); ++i) {
- function_generator.set("overload_suffix", String::number(i));
+ function_generator.set("overload_suffix", DeprecatedString::number(i));
function_generator.append(R"~~~(
JS_DECLARE_NATIVE_FUNCTION(@function.name:snakecase@@overload_suffix@);
)~~~");
@@ -2143,7 +2143,7 @@ JS::ThrowCompletionOr<JS::Object*> @constructor_class@::construct(FunctionObject
// Single constructor
auto& constructor = interface.constructors[0];
- generator.set("constructor.length", String::number(constructor.shortest_length()));
+ generator.set("constructor.length", DeprecatedString::number(constructor.shortest_length()));
generator.append(R"~~~(
auto& vm = this->vm();
@@ -2191,7 +2191,7 @@ void @constructor_class@::initialize(JS::Realm& realm)
auto constant_generator = generator.fork();
constant_generator.set("constant.name", constant.name);
- generate_wrap_statement(constant_generator, constant.value, constant.type, interface, String::formatted("auto constant_{}_value =", constant.name));
+ generate_wrap_statement(constant_generator, constant.value, constant.type, interface, DeprecatedString::formatted("auto constant_{}_value =", constant.name));
constant_generator.append(R"~~~(
define_direct_property("@constant.name@", constant_@constant.name@_value, JS::Attribute::Enumerable);
@@ -2203,7 +2203,7 @@ void @constructor_class@::initialize(JS::Realm& realm)
auto function_generator = generator.fork();
function_generator.set("function.name", overload_set.key);
function_generator.set("function.name:snakecase", make_input_acceptable_cpp(overload_set.key.to_snakecase()));
- function_generator.set("function.length", String::number(get_shortest_function_length(overload_set.value)));
+ function_generator.set("function.length", DeprecatedString::number(get_shortest_function_length(overload_set.value)));
function_generator.append(R"~~~(
define_native_function(realm, "@function.name@", @function.name:snakecase@, @function.length@, default_attributes);
@@ -2264,7 +2264,7 @@ private:
)~~~");
if (overload_set.value.size() > 1) {
for (auto i = 0u; i < overload_set.value.size(); ++i) {
- function_generator.set("overload_suffix", String::number(i));
+ function_generator.set("overload_suffix", DeprecatedString::number(i));
function_generator.append(R"~~~(
JS_DECLARE_NATIVE_FUNCTION(@function.name:snakecase@@overload_suffix@);
)~~~");
@@ -2326,7 +2326,7 @@ enum class @enum.type.name@ {
enum_generator.append(R"~~~(
};
-inline String idl_enum_to_string(@enum.type.name@ value) {
+inline DeprecatedString idl_enum_to_string(@enum.type.name@ value) {
switch(value) {
)~~~");
for (auto& entry : it.value.translated_cpp_names) {
@@ -2364,7 +2364,7 @@ void generate_prototype_implementation(IDL::Interface const& interface)
generator.set("fully_qualified_name", interface.fully_qualified_name);
if (interface.pair_iterator_types.has_value()) {
- generator.set("iterator_name", String::formatted("{}Iterator", interface.name));
+ generator.set("iterator_name", DeprecatedString::formatted("{}Iterator", interface.name));
}
generator.append(R"~~~(
@@ -2500,7 +2500,7 @@ void @prototype_class@::initialize(JS::Realm& realm)
auto constant_generator = generator.fork();
constant_generator.set("constant.name", constant.name);
- generate_wrap_statement(constant_generator, constant.value, constant.type, interface, String::formatted("auto constant_{}_value =", constant.name));
+ generate_wrap_statement(constant_generator, constant.value, constant.type, interface, DeprecatedString::formatted("auto constant_{}_value =", constant.name));
constant_generator.append(R"~~~(
define_direct_property("@constant.name@", constant_@constant.name@_value, JS::Attribute::Enumerable);
@@ -2512,7 +2512,7 @@ void @prototype_class@::initialize(JS::Realm& realm)
auto function_generator = generator.fork();
function_generator.set("function.name", overload_set.key);
function_generator.set("function.name:snakecase", make_input_acceptable_cpp(overload_set.key.to_snakecase()));
- function_generator.set("function.length", String::number(get_shortest_function_length(overload_set.value)));
+ function_generator.set("function.length", DeprecatedString::number(get_shortest_function_length(overload_set.value)));
// FIXME: What if only some of the overloads are Unscopable?
if (any_of(overload_set.value, [](auto const& function) { return function.extended_attributes.contains("Unscopable"); })) {
@@ -2686,7 +2686,7 @@ JS_DEFINE_NATIVE_FUNCTION(@prototype_class@::@attribute.setter_callback@)
if (!cpp_value)
impl->remove_attribute(HTML::AttributeNames::@attribute.reflect_name@);
else
- MUST(impl->set_attribute(HTML::AttributeNames::@attribute.reflect_name@, String::empty()));
+ MUST(impl->set_attribute(HTML::AttributeNames::@attribute.reflect_name@, DeprecatedString::empty()));
)~~~");
}
} else {
@@ -2801,7 +2801,7 @@ void generate_iterator_prototype_header(IDL::Interface const& interface)
StringBuilder builder;
SourceGenerator generator { builder };
- generator.set("prototype_class", String::formatted("{}IteratorPrototype", interface.name));
+ generator.set("prototype_class", DeprecatedString::formatted("{}IteratorPrototype", interface.name));
generator.append(R"~~~(
#pragma once
@@ -2833,10 +2833,10 @@ void generate_iterator_prototype_implementation(IDL::Interface const& interface)
StringBuilder builder;
SourceGenerator generator { builder };
- generator.set("name", String::formatted("{}Iterator", interface.name));
- generator.set("prototype_class", String::formatted("{}IteratorPrototype", interface.name));
- generator.set("fully_qualified_name", String::formatted("{}Iterator", interface.fully_qualified_name));
- generator.set("possible_include_path", String::formatted("{}Iterator", interface.name.replace("::"sv, "/"sv, ReplaceMode::All)));
+ generator.set("name", DeprecatedString::formatted("{}Iterator", interface.name));
+ generator.set("prototype_class", DeprecatedString::formatted("{}IteratorPrototype", interface.name));
+ generator.set("fully_qualified_name", DeprecatedString::formatted("{}Iterator", interface.fully_qualified_name));
+ generator.set("possible_include_path", DeprecatedString::formatted("{}Iterator", interface.name.replace("::"sv, "/"sv, ReplaceMode::All)));
generator.append(R"~~~(
#include <AK/Function.h>
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
index cc25e51e3f..acfbfe9c4b 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp
@@ -58,8 +58,8 @@ enum class PropertyID {
Custom,
)~~~");
- Vector<String> shorthand_property_ids;
- Vector<String> longhand_property_ids;
+ Vector<DeprecatedString> shorthand_property_ids;
+ Vector<DeprecatedString> longhand_property_ids;
properties.for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp
index 5285b7ba8f..8976edacf3 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp
@@ -39,7 +39,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 0;
}
-static String title_casify_transform_function(StringView input)
+static DeprecatedString title_casify_transform_function(StringView input)
{
// Transform function names look like `fooBar`, so we just have to make the first character uppercase.
StringBuilder builder;
@@ -189,7 +189,7 @@ TransformFunctionMetadata transform_function_metadata(TransformFunction transfor
member_generator.append(first ? " "sv : ", "sv);
first = false;
- member_generator.append(String::formatted("{{ TransformFunctionParameterType::{}, {}}}", parameter_type, value.as_object().get("required"sv).to_string()));
+ member_generator.append(DeprecatedString::formatted("{{ TransformFunctionParameterType::{}, {}}}", parameter_type, value.as_object().get("required"sv).to_string()));
});
member_generator.append(R"~~~( }
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp
index b831b2a458..7d23b67f1b 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateWindowOrWorkerInterfaces.cpp
@@ -5,9 +5,9 @@
*/
#include <AK/Debug.h>
+#include <AK/DeprecatedString.h>
#include <AK/LexicalPath.h>
#include <AK/SourceGenerator.h>
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/Stream.h>
@@ -16,14 +16,14 @@
#include <LibMain/Main.h>
static ErrorOr<void> add_to_interface_sets(IDL::Interface&, Vector<IDL::Interface&>& window_exposed, Vector<IDL::Interface&>& dedicated_worker_exposed, Vector<IDL::Interface&>& shared_worker_exposed);
-static String s_error_string;
+static DeprecatedString s_error_string;
static ErrorOr<void> generate_exposed_interface_header(StringView class_name, StringView output_path)
{
StringBuilder builder;
SourceGenerator generator(builder);
- generator.set("global_object_snake_name", String(class_name).to_snakecase());
+ generator.set("global_object_snake_name", DeprecatedString(class_name).to_snakecase());
generator.append(R"~~~(
#pragma once
@@ -37,7 +37,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object&, JS::Realm&);
)~~~");
- auto generated_header_path = LexicalPath(output_path).append(String::formatted("{}ExposedInterfaces.h", class_name)).string();
+ auto generated_header_path = LexicalPath(output_path).append(DeprecatedString::formatted("{}ExposedInterfaces.h", class_name)).string();
auto generated_header_file = TRY(Core::Stream::File::open(generated_header_path, Core::Stream::OpenMode::Write));
TRY(generated_header_file->write(generator.as_string_view().bytes()));
@@ -50,7 +50,7 @@ static ErrorOr<void> generate_exposed_interface_implementation(StringView class_
SourceGenerator generator(builder);
generator.set("global_object_name", class_name);
- generator.set("global_object_snake_name", String(class_name).to_snakecase());
+ generator.set("global_object_snake_name", DeprecatedString(class_name).to_snakecase());
generator.append(R"~~~(
#include <LibJS/Heap/DeferGC.h>
@@ -123,7 +123,7 @@ void add_@global_object_snake_name@_exposed_interfaces(JS::Object& global, JS::R
}
}
)~~~");
- auto generated_implementation_path = LexicalPath(output_path).append(String::formatted("{}ExposedInterfaces.cpp", class_name)).string();
+ auto generated_implementation_path = LexicalPath(output_path).append(DeprecatedString::formatted("{}ExposedInterfaces.cpp", class_name)).string();
auto generated_implementation_file = TRY(Core::Stream::File::open(generated_implementation_path, Core::Stream::OpenMode::Write));
TRY(generated_implementation_file->write(generator.as_string_view().bytes()));
@@ -136,7 +136,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
StringView output_path;
StringView base_path;
- Vector<String> paths;
+ Vector<DeprecatedString> paths;
args_parser.add_option(output_path, "Path to output generated files into", "output-path", 'o', "output-path");
args_parser.add_option(base_path, "Path to root of IDL file tree", "base-path", 'b', "base-path");
@@ -149,16 +149,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
const LexicalPath lexical_base(base_path);
// Read in all IDL files, we must own the storage for all of these for the lifetime of the program
- Vector<String> file_contents;
- for (String const& path : paths) {
+ Vector<DeprecatedString> file_contents;
+ for (DeprecatedString const& path : paths) {
auto file_or_error = Core::Stream::File::open(path, Core::Stream::OpenMode::Read);
if (file_or_error.is_error()) {
- s_error_string = String::formatted("Unable to open file {}", path);
+ s_error_string = DeprecatedString::formatted("Unable to open file {}", path);
return Error::from_string_view(s_error_string);
}
auto file = file_or_error.release_value();
auto string = MUST(file->read_all());
- file_contents.append(String(ReadonlyBytes(string)));
+ file_contents.append(DeprecatedString(ReadonlyBytes(string)));
}
VERIFY(paths.size() == file_contents.size());
@@ -220,7 +220,7 @@ static ErrorOr<ExposedTo> parse_exposure_set(IDL::Interface& interface)
auto maybe_exposed = interface.extended_attributes.get("Exposed");
if (!maybe_exposed.has_value()) {
- s_error_string = String::formatted("Interface {} is missing extended attribute Exposed", interface.name);
+ s_error_string = DeprecatedString::formatted("Interface {} is missing extended attribute Exposed", interface.name);
return Error::from_string_view(s_error_string);
}
auto exposed = maybe_exposed.value().trim_whitespace();
@@ -250,18 +250,18 @@ static ErrorOr<ExposedTo> parse_exposure_set(IDL::Interface& interface)
} else if (candidate == "AudioWorklet"sv) {
whom |= ExposedTo::AudioWorklet;
} else {
- s_error_string = String::formatted("Unknown Exposed attribute candidate {} in {} in {}", candidate, exposed, interface.name);
+ s_error_string = DeprecatedString::formatted("Unknown Exposed attribute candidate {} in {} in {}", candidate, exposed, interface.name);
return Error::from_string_view(s_error_string);
}
}
if (whom == ExposedTo::Nobody) {
- s_error_string = String::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name);
+ s_error_string = DeprecatedString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name);
return Error::from_string_view(s_error_string);
}
return whom;
}
- s_error_string = String::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name);
+ s_error_string = DeprecatedString::formatted("Unknown Exposed attribute {} in {}", exposed, interface.name);
return Error::from_string_view(s_error_string);
}
@@ -275,7 +275,7 @@ static IDL::Interface& add_synthetic_interface(IDL::Interface& reference_interfa
auto new_interface = make<IDL::Interface>();
new_interface->name = name;
- new_interface->constructor_class = String::formatted("{}Constructor", new_interface->name);
+ new_interface->constructor_class = DeprecatedString::formatted("{}Constructor", new_interface->name);
new_interface->prototype_class = reference_interface.prototype_class;
new_interface->parent_name = "[Synthetic Interface]";
diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GeneratorUtil.h b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GeneratorUtil.h
index c1e6489f7b..e86d7c9451 100644
--- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GeneratorUtil.h
+++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GeneratorUtil.h
@@ -7,13 +7,13 @@
#pragma once
+#include <AK/DeprecatedString.h>
#include <AK/JsonObject.h>
-#include <AK/String.h>
#include <AK/Vector.h>
#include <LibCore/Stream.h>
#include <ctype.h>
-String title_casify(String const& dashy_name)
+DeprecatedString title_casify(DeprecatedString const& dashy_name)
{
auto parts = dashy_name.split('-');
StringBuilder builder;
@@ -28,7 +28,7 @@ String title_casify(String const& dashy_name)
return builder.to_string();
}
-String camel_casify(StringView dashy_name)
+DeprecatedString camel_casify(StringView dashy_name)
{
auto parts = dashy_name.split_view('-');
StringBuilder builder;
@@ -49,7 +49,7 @@ String camel_casify(StringView dashy_name)
return builder.to_string();
}
-String snake_casify(String const& dashy_name)
+DeprecatedString snake_casify(DeprecatedString const& dashy_name)
{
return dashy_name.replace("-"sv, "_"sv, ReplaceMode::All);
}
diff --git a/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp b/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp
index e1c00c8e42..aff038ba59 100644
--- a/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp
+++ b/Meta/Lagom/Tools/CodeGenerators/StateMachineGenerator/main.cpp
@@ -4,11 +4,11 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <AK/DeprecatedString.h>
#include <AK/GenericLexer.h>
#include <AK/HashTable.h>
#include <AK/OwnPtr.h>
#include <AK/SourceGenerator.h>
-#include <AK/String.h>
#include <AK/StringBuilder.h>
#include <AK/Types.h>
#include <LibCore/ArgsParser.h>
@@ -22,8 +22,8 @@ struct Range {
};
struct StateTransition {
- Optional<String> new_state;
- Optional<String> action;
+ Optional<DeprecatedString> new_state;
+ Optional<DeprecatedString> action;
};
struct MatchedAction {
@@ -32,18 +32,18 @@ struct MatchedAction {
};
struct State {
- String name;
+ DeprecatedString name;
Vector<MatchedAction> actions;
- Optional<String> entry_action;
- Optional<String> exit_action;
+ Optional<DeprecatedString> entry_action;
+ Optional<DeprecatedString> exit_action;
};
struct StateMachine {
- String name;
- String initial_state;
+ DeprecatedString name;
+ DeprecatedString initial_state;
Vector<State> states;
Optional<State> anywhere;
- Optional<String> namespaces;
+ Optional<DeprecatedString> namespaces;
};
static OwnPtr<StateMachine>
@@ -232,9 +232,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 0;
}
-HashTable<String> actions(StateMachine const& machine)
+HashTable<DeprecatedString> actions(StateMachine const& machine)
{
- HashTable<String> table;
+ HashTable<DeprecatedString> table;
auto do_state = [&](State const& state) {
if (state.entry_action.has_value())
@@ -296,7 +296,7 @@ void output_header(StateMachine const& machine, SourceGenerator& generator)
{
generator.set("class_name", machine.name);
generator.set("initial_state", machine.initial_state);
- generator.set("state_count", String::number(machine.states.size() + 1));
+ generator.set("state_count", DeprecatedString::number(machine.states.size() + 1));
generator.append(R"~~~(
#pragma once
diff --git a/Meta/Lagom/Tools/ConfigureComponents/main.cpp b/Meta/Lagom/Tools/ConfigureComponents/main.cpp
index 052d2d1ec1..c499ceff2f 100644
--- a/Meta/Lagom/Tools/ConfigureComponents/main.cpp
+++ b/Meta/Lagom/Tools/ConfigureComponents/main.cpp
@@ -4,11 +4,11 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/LexicalPath.h>
#include <AK/QuickSort.h>
#include <AK/Result.h>
-#include <AK/String.h>
#include <AK/StringView.h>
#include <AK/Vector.h>
#include <LibCore/ConfigFile.h>
@@ -25,18 +25,18 @@ enum class ComponentCategory {
};
struct ComponentData {
- String name;
- String description;
+ DeprecatedString name;
+ DeprecatedString description;
ComponentCategory category { ComponentCategory::Optional };
bool was_selected { false };
- Vector<String> dependencies;
+ Vector<DeprecatedString> dependencies;
bool is_selected { false };
};
struct WhiptailOption {
- String tag;
- String name;
- String description;
+ DeprecatedString tag;
+ DeprecatedString name;
+ DeprecatedString description;
bool checked { false };
};
@@ -77,7 +77,7 @@ static Vector<ComponentData> read_component_data(Core::ConfigFile const& config_
return components;
}
-static Result<Vector<String>, int> run_whiptail(WhiptailMode mode, Vector<WhiptailOption> const& options, StringView title, StringView description)
+static Result<Vector<DeprecatedString>, int> run_whiptail(WhiptailMode mode, Vector<WhiptailOption> const& options, StringView title, StringView description)
{
struct winsize w;
if (ioctl(0, TIOCGWINSZ, &w) < 0) {
@@ -97,7 +97,7 @@ static Result<Vector<String>, int> run_whiptail(WhiptailMode mode, Vector<Whipta
int read_fd = pipefd[0];
int write_fd = pipefd[1];
- Vector<String> arguments = { "whiptail", "--notags", "--separate-output", "--output-fd", String::number(write_fd) };
+ Vector<DeprecatedString> arguments = { "whiptail", "--notags", "--separate-output", "--output-fd", DeprecatedString::number(write_fd) };
if (!title.is_empty()) {
arguments.append("--title");
@@ -116,13 +116,13 @@ static Result<Vector<String>, int> run_whiptail(WhiptailMode mode, Vector<Whipta
}
if (description.is_empty())
- arguments.append(String::empty());
+ arguments.append(DeprecatedString::empty());
else
- arguments.append(String::formatted("\n {}", description));
+ arguments.append(DeprecatedString::formatted("\n {}", description));
- arguments.append(String::number(height));
- arguments.append(String::number(width));
- arguments.append(String::number(height - 9));
+ arguments.append(DeprecatedString::number(height));
+ arguments.append(DeprecatedString::number(width));
+ arguments.append(DeprecatedString::number(height - 9));
// Check how wide the name field needs to be.
size_t max_name_width = 0;
@@ -133,7 +133,7 @@ static Result<Vector<String>, int> run_whiptail(WhiptailMode mode, Vector<Whipta
for (auto& option : options) {
arguments.append(option.tag);
- arguments.append(String::formatted("{:{2}} {}", option.name, option.description, max_name_width));
+ arguments.append(DeprecatedString::formatted("{:{2}} {}", option.name, option.description, max_name_width));
if (mode == WhiptailMode::Checklist)
arguments.append(option.checked ? "1" : "0");
}
@@ -151,7 +151,7 @@ static Result<Vector<String>, int> run_whiptail(WhiptailMode mode, Vector<Whipta
return -1;
}
- auto full_term_variable = String::formatted("TERM={}", term_variable);
+ auto full_term_variable = DeprecatedString::formatted("TERM={}", term_variable);
auto colors = "NEWT_COLORS=root=,black\ncheckbox=black,lightgray";
char* env[3];
@@ -194,11 +194,11 @@ static Result<Vector<String>, int> run_whiptail(WhiptailMode mode, Vector<Whipta
auto file = Core::File::construct();
file->open(read_fd, Core::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes);
- auto data = String::copy(file->read_all());
+ auto data = DeprecatedString::copy(file->read_all());
return data.split('\n');
}
-static bool run_system_command(String const& command, StringView command_name)
+static bool run_system_command(DeprecatedString const& command, StringView command_name)
{
if (command.starts_with("cmake"sv))
warnln("\e[34mRunning CMake...\e[0m");
@@ -274,7 +274,7 @@ int main()
StringView build_type = customize ? type.substring_view(7) : type.view();
// Step 4: Customize the configuration if the user requested to. In any case, set the components component.is_selected value correctly.
- Vector<String> activated_components;
+ Vector<DeprecatedString> activated_components;
if (customize) {
Vector<WhiptailOption> options;
@@ -336,12 +336,12 @@ int main()
}
// Step 5: Generate the cmake command.
- Vector<String> cmake_arguments = { "cmake", "../..", "-G", "Ninja", "-DBUILD_EVERYTHING=OFF" };
+ Vector<DeprecatedString> cmake_arguments = { "cmake", "../..", "-G", "Ninja", "-DBUILD_EVERYTHING=OFF" };
for (auto& component : components)
- cmake_arguments.append(String::formatted("-DBUILD_{}={}", component.name.to_uppercase(), component.is_selected ? "ON" : "OFF"));
+ cmake_arguments.append(DeprecatedString::formatted("-DBUILD_{}={}", component.name.to_uppercase(), component.is_selected ? "ON" : "OFF"));
warnln("\e[34mThe following command will be run:\e[0m");
- outln("{} \\", String::join(' ', cmake_arguments));
+ outln("{} \\", DeprecatedString::join(' ', cmake_arguments));
outln(" && ninja clean\n && rm -rf Root");
warn("\e[34mDo you want to run the command?\e[0m [Y/n] ");
auto character = getchar();
@@ -351,7 +351,7 @@ int main()
}
// Step 6: Run CMake, 'ninja clean' and 'rm -rf Root'
- auto command = String::join(' ', cmake_arguments);
+ auto command = DeprecatedString::join(' ', cmake_arguments);
if (!run_system_command(command, "CMake"sv))
return 1;
if (!run_system_command("ninja clean"sv, "Ninja"sv))
diff --git a/Meta/Lagom/Tools/IPCMagicLinter/main.cpp b/Meta/Lagom/Tools/IPCMagicLinter/main.cpp
index ee7697eb73..5c482fc1fd 100644
--- a/Meta/Lagom/Tools/IPCMagicLinter/main.cpp
+++ b/Meta/Lagom/Tools/IPCMagicLinter/main.cpp
@@ -21,10 +21,10 @@ int main(int argc, char** argv)
}
// Read files, compute their hashes, ignore collisions for now.
- HashMap<u32, Vector<String>> inverse_hashes;
+ HashMap<u32, Vector<DeprecatedString>> inverse_hashes;
bool had_errors = false;
for (int file_index = 1; file_index < argc; ++file_index) {
- String filename(argv[file_index]);
+ DeprecatedString filename(argv[file_index]);
auto file_or_error = Core::File::open(filename, Core::OpenMode::ReadOnly);
if (file_or_error.is_error()) {
warnln("Error: Cannot open '{}': {}", filename, file_or_error.error());
@@ -32,9 +32,9 @@ int main(int argc, char** argv)
continue; // next file
}
auto file = file_or_error.value();
- String endpoint_name;
+ DeprecatedString endpoint_name;
while (true) {
- String line = file->read_line();
+ DeprecatedString line = file->read_line();
if (file->error() != 0 || line.is_null())
break;
if (!line.starts_with("endpoint "sv))
diff --git a/Meta/Lagom/Wasm/js_repl.cpp b/Meta/Lagom/Wasm/js_repl.cpp
index cb798241bf..316279f186 100644
--- a/Meta/Lagom/Wasm/js_repl.cpp
+++ b/Meta/Lagom/Wasm/js_repl.cpp
@@ -50,7 +50,7 @@ EM_JS(void, user_display, (char const* string, u32 length), { globalDisplayToUse
template<typename... Args>
void display(CheckedFormatString<Args...> format_string, Args const&... args)
{
- auto string = String::formatted(format_string.view(), args...);
+ auto string = DeprecatedString::formatted(format_string.view(), args...);
user_display(string.characters(), string.length());
}
@@ -269,7 +269,7 @@ JS_DEFINE_NATIVE_FUNCTION(ReplObject::print)
{
auto result = ::print(vm.argument(0));
if (result.is_error())
- return g_vm->throw_completion<JS::InternalError>(String::formatted("Failed to print value: {}", result.error()));
+ return g_vm->throw_completion<JS::InternalError>(DeprecatedString::formatted("Failed to print value: {}", result.error()));
displayln();
@@ -298,7 +298,7 @@ public:
// 2.3. Printer(logLevel, args[, options]), https://console.spec.whatwg.org/#printer
virtual JS::ThrowCompletionOr<JS::Value> printer(JS::Console::LogLevel log_level, PrinterArguments arguments) override
{
- String indent = String::repeated(" "sv, m_group_stack_depth);
+ DeprecatedString indent = DeprecatedString::repeated(" "sv, m_group_stack_depth);
if (log_level == JS::Console::LogLevel::Trace) {
auto trace = arguments.get<JS::Console::Trace>();
@@ -320,7 +320,7 @@ public:
return JS::js_undefined();
}
- auto output = String::join(' ', arguments.get<JS::MarkedVector<JS::Value>>());
+ auto output = DeprecatedString::join(' ', arguments.get<JS::MarkedVector<JS::Value>>());
switch (log_level) {
case JS::Console::LogLevel::Debug:
displayln("{}{}", indent, output);