Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -5,8 +5,8 @@
*/
#include <AK/ByteBuffer.h>
#include <AK/ByteString.h>
#include <AK/DeprecatedFlyString.h>
#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/Function.h>
#include <AK/StdLibExtras.h>
@ -16,17 +16,17 @@
namespace AK {
bool DeprecatedString::operator==(DeprecatedFlyString const& fly_string) const
bool ByteString::operator==(DeprecatedFlyString const& fly_string) const
{
return m_impl == fly_string.impl() || view() == fly_string.view();
}
bool DeprecatedString::operator==(DeprecatedString const& other) const
bool ByteString::operator==(ByteString const& other) const
{
return m_impl == other.impl() || view() == other.view();
}
bool DeprecatedString::operator==(StringView other) const
bool ByteString::operator==(StringView other) const
{
if (other.is_null())
return is_empty();
@ -34,17 +34,17 @@ bool DeprecatedString::operator==(StringView other) const
return view() == other;
}
bool DeprecatedString::operator<(DeprecatedString const& other) const
bool ByteString::operator<(ByteString const& other) const
{
return view() < other.view();
}
bool DeprecatedString::operator>(DeprecatedString const& other) const
bool ByteString::operator>(ByteString const& other) const
{
return view() > other.view();
}
bool DeprecatedString::copy_characters_to_buffer(char* buffer, size_t buffer_size) const
bool ByteString::copy_characters_to_buffer(char* buffer, size_t buffer_size) const
{
// We must fit at least the NUL-terminator.
VERIFY(buffer_size > 0);
@ -56,55 +56,55 @@ bool DeprecatedString::copy_characters_to_buffer(char* buffer, size_t buffer_siz
return characters_to_copy == length();
}
DeprecatedString DeprecatedString::isolated_copy() const
ByteString ByteString::isolated_copy() const
{
if (m_impl->length() == 0)
return empty();
char* buffer;
auto impl = StringImpl::create_uninitialized(length(), buffer);
memcpy(buffer, m_impl->characters(), m_impl->length());
return DeprecatedString(move(*impl));
return ByteString(move(*impl));
}
DeprecatedString DeprecatedString::substring(size_t start, size_t length) const
ByteString ByteString::substring(size_t start, size_t length) const
{
if (!length)
return DeprecatedString::empty();
return ByteString::empty();
VERIFY(!Checked<size_t>::addition_would_overflow(start, length));
VERIFY(start + length <= m_impl->length());
return { characters() + start, length };
}
DeprecatedString DeprecatedString::substring(size_t start) const
ByteString ByteString::substring(size_t start) const
{
VERIFY(start <= length());
return { characters() + start, length() - start };
}
StringView DeprecatedString::substring_view(size_t start, size_t length) const
StringView ByteString::substring_view(size_t start, size_t length) const
{
VERIFY(!Checked<size_t>::addition_would_overflow(start, length));
VERIFY(start + length <= m_impl->length());
return { characters() + start, length };
}
StringView DeprecatedString::substring_view(size_t start) const
StringView ByteString::substring_view(size_t start) const
{
VERIFY(start <= length());
return { characters() + start, length() - start };
}
Vector<DeprecatedString> DeprecatedString::split(char separator, SplitBehavior split_behavior) const
Vector<ByteString> ByteString::split(char separator, SplitBehavior split_behavior) const
{
return split_limit(separator, 0, split_behavior);
}
Vector<DeprecatedString> DeprecatedString::split_limit(char separator, size_t limit, SplitBehavior split_behavior) const
Vector<ByteString> ByteString::split_limit(char separator, size_t limit, SplitBehavior split_behavior) const
{
if (is_empty())
return {};
Vector<DeprecatedString> v;
Vector<ByteString> v;
size_t substart = 0;
bool keep_empty = has_flag(split_behavior, SplitBehavior::KeepEmpty);
bool keep_separator = has_flag(split_behavior, SplitBehavior::KeepTrailingSeparator);
@ -123,7 +123,7 @@ Vector<DeprecatedString> DeprecatedString::split_limit(char separator, size_t li
return v;
}
Vector<StringView> DeprecatedString::split_view(Function<bool(char)> separator, SplitBehavior split_behavior) const
Vector<StringView> ByteString::split_view(Function<bool(char)> separator, SplitBehavior split_behavior) const
{
if (is_empty())
return {};
@ -147,78 +147,78 @@ Vector<StringView> DeprecatedString::split_view(Function<bool(char)> separator,
return v;
}
Vector<StringView> DeprecatedString::split_view(char const separator, SplitBehavior split_behavior) const
Vector<StringView> ByteString::split_view(char const separator, SplitBehavior split_behavior) const
{
return split_view([separator](char ch) { return ch == separator; }, split_behavior);
}
ByteBuffer DeprecatedString::to_byte_buffer() const
ByteBuffer ByteString::to_byte_buffer() const
{
// FIXME: Handle OOM failure.
return ByteBuffer::copy(bytes()).release_value_but_fixme_should_propagate_errors();
}
template<typename T>
Optional<T> DeprecatedString::to_int(TrimWhitespace trim_whitespace) const
Optional<T> ByteString::to_int(TrimWhitespace trim_whitespace) const
{
return StringUtils::convert_to_int<T>(view(), trim_whitespace);
}
template Optional<i8> DeprecatedString::to_int(TrimWhitespace) const;
template Optional<i16> DeprecatedString::to_int(TrimWhitespace) const;
template Optional<i32> DeprecatedString::to_int(TrimWhitespace) const;
template Optional<long> DeprecatedString::to_int(TrimWhitespace) const;
template Optional<long long> DeprecatedString::to_int(TrimWhitespace) const;
template Optional<i8> ByteString::to_int(TrimWhitespace) const;
template Optional<i16> ByteString::to_int(TrimWhitespace) const;
template Optional<i32> ByteString::to_int(TrimWhitespace) const;
template Optional<long> ByteString::to_int(TrimWhitespace) const;
template Optional<long long> ByteString::to_int(TrimWhitespace) const;
template<typename T>
Optional<T> DeprecatedString::to_uint(TrimWhitespace trim_whitespace) const
Optional<T> ByteString::to_uint(TrimWhitespace trim_whitespace) const
{
return StringUtils::convert_to_uint<T>(view(), trim_whitespace);
}
template Optional<u8> DeprecatedString::to_uint(TrimWhitespace) const;
template Optional<u16> DeprecatedString::to_uint(TrimWhitespace) const;
template Optional<u32> DeprecatedString::to_uint(TrimWhitespace) const;
template Optional<unsigned long> DeprecatedString::to_uint(TrimWhitespace) const;
template Optional<unsigned long long> DeprecatedString::to_uint(TrimWhitespace) const;
template Optional<u8> ByteString::to_uint(TrimWhitespace) const;
template Optional<u16> ByteString::to_uint(TrimWhitespace) const;
template Optional<u32> ByteString::to_uint(TrimWhitespace) const;
template Optional<unsigned long> ByteString::to_uint(TrimWhitespace) const;
template Optional<unsigned long long> ByteString::to_uint(TrimWhitespace) const;
#ifndef KERNEL
Optional<double> DeprecatedString::to_double(TrimWhitespace trim_whitespace) const
Optional<double> ByteString::to_double(TrimWhitespace trim_whitespace) const
{
return StringUtils::convert_to_floating_point<double>(*this, trim_whitespace);
}
Optional<float> DeprecatedString::to_float(TrimWhitespace trim_whitespace) const
Optional<float> ByteString::to_float(TrimWhitespace trim_whitespace) const
{
return StringUtils::convert_to_floating_point<float>(*this, trim_whitespace);
}
#endif
bool DeprecatedString::starts_with(StringView str, CaseSensitivity case_sensitivity) const
bool ByteString::starts_with(StringView str, CaseSensitivity case_sensitivity) const
{
return StringUtils::starts_with(*this, str, case_sensitivity);
}
bool DeprecatedString::starts_with(char ch) const
bool ByteString::starts_with(char ch) const
{
if (is_empty())
return false;
return characters()[0] == ch;
}
bool DeprecatedString::ends_with(StringView str, CaseSensitivity case_sensitivity) const
bool ByteString::ends_with(StringView str, CaseSensitivity case_sensitivity) const
{
return StringUtils::ends_with(*this, str, case_sensitivity);
}
bool DeprecatedString::ends_with(char ch) const
bool ByteString::ends_with(char ch) const
{
if (is_empty())
return false;
return characters()[length() - 1] == ch;
}
DeprecatedString DeprecatedString::repeated(char ch, size_t count)
ByteString ByteString::repeated(char ch, size_t count)
{
if (!count)
return empty();
@ -228,7 +228,7 @@ DeprecatedString DeprecatedString::repeated(char ch, size_t count)
return *impl;
}
DeprecatedString DeprecatedString::repeated(StringView string, size_t count)
ByteString ByteString::repeated(StringView string, size_t count)
{
if (!count || string.is_empty())
return empty();
@ -239,7 +239,7 @@ DeprecatedString DeprecatedString::repeated(StringView string, size_t count)
return *impl;
}
DeprecatedString DeprecatedString::bijective_base_from(size_t value, unsigned base, StringView map)
ByteString ByteString::bijective_base_from(size_t value, unsigned base, StringView map)
{
value++;
if (map.is_null())
@ -265,13 +265,13 @@ DeprecatedString DeprecatedString::bijective_base_from(size_t value, unsigned ba
for (size_t j = 0; j < i / 2; ++j)
swap(buffer[j], buffer[i - j - 1]);
return DeprecatedString { ReadonlyBytes(buffer.data(), i) };
return ByteString { ReadonlyBytes(buffer.data(), i) };
}
DeprecatedString DeprecatedString::roman_number_from(size_t value)
ByteString ByteString::roman_number_from(size_t value)
{
if (value > 3999)
return DeprecatedString::number(value);
return ByteString::number(value);
StringBuilder builder;
@ -318,44 +318,44 @@ DeprecatedString DeprecatedString::roman_number_from(size_t value)
}
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
bool DeprecatedString::matches(StringView mask, Vector<MaskSpan>& mask_spans, CaseSensitivity case_sensitivity) const
bool ByteString::matches(StringView mask, Vector<MaskSpan>& mask_spans, CaseSensitivity case_sensitivity) const
{
return StringUtils::matches(*this, mask, case_sensitivity, &mask_spans);
}
bool DeprecatedString::matches(StringView mask, CaseSensitivity case_sensitivity) const
bool ByteString::matches(StringView mask, CaseSensitivity case_sensitivity) const
{
return StringUtils::matches(*this, mask, case_sensitivity);
}
bool DeprecatedString::contains(StringView needle, CaseSensitivity case_sensitivity) const
bool ByteString::contains(StringView needle, CaseSensitivity case_sensitivity) const
{
return StringUtils::contains(*this, needle, case_sensitivity);
}
bool DeprecatedString::contains(char needle, CaseSensitivity case_sensitivity) const
bool ByteString::contains(char needle, CaseSensitivity case_sensitivity) const
{
return StringUtils::contains(*this, StringView(&needle, 1), case_sensitivity);
}
bool DeprecatedString::equals_ignoring_ascii_case(StringView other) const
bool ByteString::equals_ignoring_ascii_case(StringView other) const
{
return StringUtils::equals_ignoring_ascii_case(view(), other);
}
DeprecatedString DeprecatedString::reverse() const
ByteString ByteString::reverse() const
{
StringBuilder reversed_string(length());
for (size_t i = length(); i-- > 0;) {
reversed_string.append(characters()[i]);
}
return reversed_string.to_deprecated_string();
return reversed_string.to_byte_string();
}
DeprecatedString escape_html_entities(StringView html)
ByteString escape_html_entities(StringView html)
{
StringBuilder builder;
for (size_t i = 0; i < html.length(); ++i) {
@ -370,40 +370,40 @@ DeprecatedString escape_html_entities(StringView html)
else
builder.append(html[i]);
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString::DeprecatedString(DeprecatedFlyString const& string)
ByteString::ByteString(DeprecatedFlyString const& string)
: m_impl(*(string.impl() ?: &StringImpl::the_empty_stringimpl()))
{
}
DeprecatedString DeprecatedString::to_lowercase() const
ByteString ByteString::to_lowercase() const
{
return m_impl->to_lowercase();
}
DeprecatedString DeprecatedString::to_uppercase() const
ByteString ByteString::to_uppercase() const
{
return m_impl->to_uppercase();
}
DeprecatedString DeprecatedString::to_snakecase() const
ByteString ByteString::to_snakecase() const
{
return StringUtils::to_snakecase(*this);
}
DeprecatedString DeprecatedString::to_titlecase() const
ByteString ByteString::to_titlecase() const
{
return StringUtils::to_titlecase(*this);
}
DeprecatedString DeprecatedString::invert_case() const
ByteString ByteString::invert_case() const
{
return StringUtils::invert_case(*this);
}
bool DeprecatedString::operator==(char const* cstring) const
bool ByteString::operator==(char const* cstring) const
{
if (!cstring)
return is_empty();
@ -411,28 +411,28 @@ bool DeprecatedString::operator==(char const* cstring) const
return view() == cstring;
}
DeprecatedString DeprecatedString::vformatted(StringView fmtstr, TypeErasedFormatParams& params)
ByteString ByteString::vformatted(StringView fmtstr, TypeErasedFormatParams& params)
{
StringBuilder builder;
MUST(vformat(builder, fmtstr, params));
return builder.to_deprecated_string();
return builder.to_byte_string();
}
Vector<size_t> DeprecatedString::find_all(StringView needle) const
Vector<size_t> ByteString::find_all(StringView needle) const
{
return StringUtils::find_all(*this, needle);
}
DeprecatedStringCodePointIterator DeprecatedString::code_points() const
DeprecatedStringCodePointIterator ByteString::code_points() const
{
return DeprecatedStringCodePointIterator(*this);
}
ErrorOr<DeprecatedString> DeprecatedString::from_utf8(ReadonlyBytes bytes)
ErrorOr<ByteString> ByteString::from_utf8(ReadonlyBytes bytes)
{
if (!Utf8View(bytes).validate())
return Error::from_string_literal("DeprecatedString::from_utf8: Input was not valid UTF-8");
return DeprecatedString { *StringImpl::create(bytes) };
return Error::from_string_literal("ByteString::from_utf8: Input was not valid UTF-8");
return ByteString { *StringImpl::create(bytes) };
}
}

View file

@ -16,93 +16,93 @@
namespace AK {
// DeprecatedString is a convenience wrapper around StringImpl, suitable for passing
// ByteString is a convenience wrapper around StringImpl, suitable for passing
// around as a value type. It's basically the same as passing around a
// RefPtr<StringImpl const>, with a bit of syntactic sugar.
//
// Note that StringImpl is an immutable object that cannot shrink or grow.
// Its allocation size is snugly tailored to the specific string it contains.
// Copying a DeprecatedString is very efficient, since the internal StringImpl is
// Copying a ByteString is very efficient, since the internal StringImpl is
// retainable and so copying only requires modifying the ref count.
//
// There are three main ways to construct a new DeprecatedString:
// There are three main ways to construct a new ByteString:
//
// s = DeprecatedString("some literal");
// s = ByteString("some literal");
//
// s = DeprecatedString::formatted("{} little piggies", m_piggies);
// s = ByteString::formatted("{} little piggies", m_piggies);
//
// StringBuilder builder;
// builder.append("abc");
// builder.append("123");
// s = builder.to_deprecated_string();
// s = builder.to_byte_string();
class DeprecatedString {
class ByteString {
public:
~DeprecatedString() = default;
~ByteString() = default;
DeprecatedString()
ByteString()
: m_impl(StringImpl::the_empty_stringimpl())
{
}
DeprecatedString(StringView view)
ByteString(StringView view)
: m_impl(*StringImpl::create(view.characters_without_null_termination(), view.length()))
{
}
DeprecatedString(DeprecatedString const& other)
ByteString(ByteString const& other)
: m_impl(other.m_impl)
{
}
DeprecatedString(DeprecatedString&& other)
ByteString(ByteString&& other)
: m_impl(move(other.m_impl))
{
other.m_impl = StringImpl::the_empty_stringimpl();
}
DeprecatedString(char const* cstring, ShouldChomp shouldChomp = NoChomp)
ByteString(char const* cstring, ShouldChomp shouldChomp = NoChomp)
: m_impl(*StringImpl::create(cstring, shouldChomp))
{
}
DeprecatedString(char const* cstring, size_t length, ShouldChomp shouldChomp = NoChomp)
ByteString(char const* cstring, size_t length, ShouldChomp shouldChomp = NoChomp)
: m_impl(*StringImpl::create(cstring, length, shouldChomp))
{
}
explicit DeprecatedString(ReadonlyBytes bytes, ShouldChomp shouldChomp = NoChomp)
explicit ByteString(ReadonlyBytes bytes, ShouldChomp shouldChomp = NoChomp)
: m_impl(*StringImpl::create(bytes, shouldChomp))
{
}
DeprecatedString(StringImpl const& impl)
ByteString(StringImpl const& impl)
: m_impl(impl)
{
}
DeprecatedString(NonnullRefPtr<StringImpl const>&& impl)
ByteString(NonnullRefPtr<StringImpl const>&& impl)
: m_impl(*move(impl))
{
}
DeprecatedString(DeprecatedFlyString const&);
ByteString(DeprecatedFlyString const&);
static ErrorOr<DeprecatedString> from_utf8(ReadonlyBytes);
static ErrorOr<DeprecatedString> from_utf8(StringView string) { return from_utf8(string.bytes()); }
static ErrorOr<ByteString> from_utf8(ReadonlyBytes);
static ErrorOr<ByteString> from_utf8(StringView string) { return from_utf8(string.bytes()); }
[[nodiscard]] static DeprecatedString repeated(char, size_t count);
[[nodiscard]] static DeprecatedString repeated(StringView, size_t count);
[[nodiscard]] static ByteString repeated(char, size_t count);
[[nodiscard]] static ByteString repeated(StringView, size_t count);
[[nodiscard]] static DeprecatedString bijective_base_from(size_t value, unsigned base = 26, StringView map = {});
[[nodiscard]] static DeprecatedString roman_number_from(size_t value);
[[nodiscard]] static ByteString bijective_base_from(size_t value, unsigned base = 26, StringView map = {});
[[nodiscard]] static ByteString roman_number_from(size_t value);
template<class SeparatorType, class CollectionType>
[[nodiscard]] static DeprecatedString join(SeparatorType const& separator, CollectionType const& collection, StringView fmtstr = "{}"sv)
[[nodiscard]] static ByteString join(SeparatorType const& separator, CollectionType const& collection, StringView fmtstr = "{}"sv)
{
StringBuilder builder;
builder.join(separator, collection, fmtstr);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
[[nodiscard]] bool matches(StringView mask, CaseSensitivity = CaseSensitivity::CaseInsensitive) const;
@ -117,17 +117,17 @@ public:
[[nodiscard]] Optional<float> to_float(TrimWhitespace = TrimWhitespace::Yes) const;
#endif
[[nodiscard]] DeprecatedString to_lowercase() const;
[[nodiscard]] DeprecatedString to_uppercase() const;
[[nodiscard]] DeprecatedString to_snakecase() const;
[[nodiscard]] DeprecatedString to_titlecase() const;
[[nodiscard]] DeprecatedString invert_case() const;
[[nodiscard]] ByteString to_lowercase() const;
[[nodiscard]] ByteString to_uppercase() const;
[[nodiscard]] ByteString to_snakecase() const;
[[nodiscard]] ByteString to_titlecase() const;
[[nodiscard]] ByteString invert_case() const;
[[nodiscard]] bool is_whitespace() const { return StringUtils::is_whitespace(*this); }
[[nodiscard]] DeprecatedStringCodePointIterator code_points() const;
[[nodiscard]] DeprecatedString trim(StringView characters, TrimMode mode = TrimMode::Both) const
[[nodiscard]] ByteString trim(StringView characters, TrimMode mode = TrimMode::Both) const
{
auto trimmed_view = StringUtils::trim(view(), characters, mode);
if (view() == trimmed_view)
@ -135,7 +135,7 @@ public:
return trimmed_view;
}
[[nodiscard]] DeprecatedString trim_whitespace(TrimMode mode = TrimMode::Both) const
[[nodiscard]] ByteString trim_whitespace(TrimMode mode = TrimMode::Both) const
{
auto trimmed_view = StringUtils::trim_whitespace(view(), mode);
if (view() == trimmed_view)
@ -148,8 +148,8 @@ public:
[[nodiscard]] bool contains(StringView, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
[[nodiscard]] bool contains(char, CaseSensitivity = CaseSensitivity::CaseSensitive) const;
[[nodiscard]] Vector<DeprecatedString> split_limit(char separator, size_t limit, SplitBehavior = SplitBehavior::Nothing) const;
[[nodiscard]] Vector<DeprecatedString> split(char separator, SplitBehavior = SplitBehavior::Nothing) const;
[[nodiscard]] Vector<ByteString> split_limit(char separator, size_t limit, SplitBehavior = SplitBehavior::Nothing) const;
[[nodiscard]] Vector<ByteString> split(char separator, SplitBehavior = SplitBehavior::Nothing) const;
[[nodiscard]] Vector<StringView> split_view(char separator, SplitBehavior = SplitBehavior::Nothing) const;
[[nodiscard]] Vector<StringView> split_view(Function<bool(char)> separator, SplitBehavior = SplitBehavior::Nothing) const;
@ -163,8 +163,8 @@ public:
[[nodiscard]] StringView find_last_split_view(char separator) const { return view().find_last_split_view(separator); }
[[nodiscard]] DeprecatedString substring(size_t start, size_t length) const;
[[nodiscard]] DeprecatedString substring(size_t start) const;
[[nodiscard]] ByteString substring(size_t start, size_t length) const;
[[nodiscard]] ByteString substring(size_t start) const;
[[nodiscard]] StringView substring_view(size_t start, size_t length) const;
[[nodiscard]] StringView substring_view(size_t start) const;
@ -190,7 +190,7 @@ public:
return bit_cast<u8>((*m_impl)[i]);
}
using ConstIterator = SimpleIterator<const DeprecatedString, char const>;
using ConstIterator = SimpleIterator<const ByteString, char const>;
[[nodiscard]] constexpr ConstIterator begin() const { return ConstIterator::begin(*this); }
[[nodiscard]] constexpr ConstIterator end() const { return ConstIterator::end(*this); }
@ -200,47 +200,47 @@ public:
[[nodiscard]] bool starts_with(char) const;
[[nodiscard]] bool ends_with(char) const;
bool operator==(DeprecatedString const&) const;
bool operator==(ByteString const&) const;
bool operator==(StringView) const;
bool operator==(DeprecatedFlyString const&) const;
bool operator<(DeprecatedString const&) const;
bool operator>=(DeprecatedString const& other) const { return !(*this < other); }
bool operator<(ByteString const&) const;
bool operator>=(ByteString const& other) const { return !(*this < other); }
bool operator>=(char const* other) const { return !(*this < other); }
bool operator>(DeprecatedString const&) const;
bool operator<=(DeprecatedString const& other) const { return !(*this > other); }
bool operator>(ByteString const&) const;
bool operator<=(ByteString const& other) const { return !(*this > other); }
bool operator<=(char const* other) const { return !(*this > other); }
bool operator==(char const* cstring) const;
[[nodiscard]] DeprecatedString isolated_copy() const;
[[nodiscard]] ByteString isolated_copy() const;
[[nodiscard]] static DeprecatedString empty()
[[nodiscard]] static ByteString empty()
{
return StringImpl::the_empty_stringimpl();
}
[[nodiscard]] StringImpl const* impl() const { return m_impl.ptr(); }
DeprecatedString& operator=(DeprecatedString&& other)
ByteString& operator=(ByteString&& other)
{
if (this != &other)
m_impl = move(other.m_impl);
return *this;
}
DeprecatedString& operator=(DeprecatedString const& other)
ByteString& operator=(ByteString const& other)
{
if (this != &other)
m_impl = const_cast<DeprecatedString&>(other).m_impl;
m_impl = const_cast<ByteString&>(other).m_impl;
return *this;
}
template<OneOf<ReadonlyBytes, Bytes> T>
DeprecatedString& operator=(T bytes)
ByteString& operator=(T bytes)
{
m_impl = *StringImpl::create(bytes);
return *this;
@ -254,24 +254,24 @@ public:
[[nodiscard]] ByteBuffer to_byte_buffer() const;
template<typename BufferType>
[[nodiscard]] static DeprecatedString copy(BufferType const& buffer, ShouldChomp should_chomp = NoChomp)
[[nodiscard]] static ByteString copy(BufferType const& buffer, ShouldChomp should_chomp = NoChomp)
{
if (buffer.is_empty())
return empty();
return DeprecatedString(reinterpret_cast<char const*>(buffer.data()), buffer.size(), should_chomp);
return ByteString(reinterpret_cast<char const*>(buffer.data()), buffer.size(), should_chomp);
}
[[nodiscard]] static DeprecatedString vformatted(StringView fmtstr, TypeErasedFormatParams&);
[[nodiscard]] static ByteString vformatted(StringView fmtstr, TypeErasedFormatParams&);
template<typename... Parameters>
[[nodiscard]] static DeprecatedString formatted(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
[[nodiscard]] static ByteString formatted(CheckedFormatString<Parameters...>&& fmtstr, Parameters const&... parameters)
{
VariadicFormatParams<AllowDebugOnlyFormatters::No, Parameters...> variadic_format_parameters { parameters... };
return vformatted(fmtstr.view(), variadic_format_parameters);
}
template<Arithmetic T>
[[nodiscard]] static DeprecatedString number(T value)
[[nodiscard]] static ByteString number(T value)
{
return formatted("{}", value);
}
@ -281,9 +281,9 @@ public:
return { characters(), length() };
}
[[nodiscard]] DeprecatedString replace(StringView needle, StringView replacement, ReplaceMode replace_mode = ReplaceMode::All) const { return StringUtils::replace(*this, needle, replacement, replace_mode); }
[[nodiscard]] ByteString replace(StringView needle, StringView replacement, ReplaceMode replace_mode = ReplaceMode::All) const { return StringUtils::replace(*this, needle, replacement, replace_mode); }
[[nodiscard]] size_t count(StringView needle) const { return StringUtils::count(*this, needle); }
[[nodiscard]] DeprecatedString reverse() const;
[[nodiscard]] ByteString reverse() const;
template<typename... Ts>
[[nodiscard]] ALWAYS_INLINE constexpr bool is_one_of(Ts&&... strings) const
@ -308,17 +308,17 @@ private:
};
template<>
struct Traits<DeprecatedString> : public DefaultTraits<DeprecatedString> {
static unsigned hash(DeprecatedString const& s) { return s.impl() ? s.impl()->hash() : 0; }
struct Traits<ByteString> : public DefaultTraits<ByteString> {
static unsigned hash(ByteString const& s) { return s.impl() ? s.impl()->hash() : 0; }
};
// FIXME: Rename this to indicate that it's about ASCII-only case insensitivity.
struct CaseInsensitiveStringTraits : public Traits<DeprecatedString> {
static unsigned hash(DeprecatedString const& s) { return s.impl() ? s.impl()->case_insensitive_hash() : 0; }
static bool equals(DeprecatedString const& a, DeprecatedString const& b) { return a.equals_ignoring_ascii_case(b); }
struct CaseInsensitiveStringTraits : public Traits<ByteString> {
static unsigned hash(ByteString const& s) { return s.impl() ? s.impl()->case_insensitive_hash() : 0; }
static bool equals(ByteString const& a, ByteString const& b) { return a.equals_ignoring_ascii_case(b); }
};
DeprecatedString escape_html_entities(StringView html);
ByteString escape_html_entities(StringView html);
}

View file

@ -6,7 +6,7 @@ set(AK_SOURCES
CountingStream.cpp
DOSPackedTime.cpp
DeprecatedFlyString.cpp
DeprecatedString.cpp
ByteString.cpp
Error.cpp
FloatingPointStringConversions.cpp
FlyString.cpp

View file

@ -8,17 +8,17 @@
#ifndef KERNEL
# include <AK/DeprecatedString.h>
# include <AK/ByteString.h>
# include <AK/StringView.h>
# include <cxxabi.h>
namespace AK {
inline DeprecatedString demangle(StringView name)
inline ByteString demangle(StringView name)
{
int status = 0;
auto* demangled_name = abi::__cxa_demangle(name.to_deprecated_string().characters(), nullptr, nullptr, &status);
auto string = DeprecatedString(status == 0 ? StringView { demangled_name, strlen(demangled_name) } : name);
auto* demangled_name = abi::__cxa_demangle(name.to_byte_string().characters(), nullptr, nullptr, &status);
auto string = ByteString(status == 0 ? StringView { demangled_name, strlen(demangled_name) } : name);
if (status == 0)
free(demangled_name);
return string;

View file

@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/ByteString.h>
#include <AK/DeprecatedFlyString.h>
#include <AK/DeprecatedString.h>
#include <AK/HashTable.h>
#include <AK/Optional.h>
#include <AK/Singleton.h>
@ -36,7 +36,7 @@ void DeprecatedFlyString::did_destroy_impl(Badge<StringImpl>, StringImpl& impl)
fly_impls().remove(&impl);
}
DeprecatedFlyString::DeprecatedFlyString(DeprecatedString const& string)
DeprecatedFlyString::DeprecatedFlyString(ByteString const& string)
{
if (string.impl()->is_fly()) {
m_impl = string.impl();
@ -61,7 +61,7 @@ DeprecatedFlyString::DeprecatedFlyString(StringView string)
return string == *candidate;
});
if (it == fly_impls().end()) {
auto new_string = string.to_deprecated_string();
auto new_string = string.to_byte_string();
fly_impls().set(new_string.impl());
new_string.impl()->set_fly({}, true);
m_impl = new_string.impl();
@ -122,10 +122,10 @@ bool DeprecatedFlyString::ends_with(StringView str, CaseSensitivity case_sensiti
DeprecatedFlyString DeprecatedFlyString::to_lowercase() const
{
return DeprecatedString(*m_impl).to_lowercase();
return ByteString(*m_impl).to_lowercase();
}
bool DeprecatedFlyString::operator==(DeprecatedString const& other) const
bool DeprecatedFlyString::operator==(ByteString const& other) const
{
return m_impl == other.impl() || view() == other.view();
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/StringUtils.h>
namespace AK {
@ -22,10 +22,10 @@ public:
: m_impl(move(other.m_impl))
{
}
DeprecatedFlyString(DeprecatedString const&);
DeprecatedFlyString(ByteString const&);
DeprecatedFlyString(StringView);
DeprecatedFlyString(char const* string)
: DeprecatedFlyString(static_cast<DeprecatedString>(string))
: DeprecatedFlyString(static_cast<ByteString>(string))
{
}
@ -54,7 +54,7 @@ public:
bool operator==(DeprecatedFlyString const& other) const { return m_impl == other.m_impl; }
bool operator==(DeprecatedString const&) const;
bool operator==(ByteString const&) const;
bool operator==(StringView) const;

View file

@ -43,10 +43,10 @@ public:
}
static Error from_string_view(StringView string_literal) { return Error(string_literal); }
template<OneOf<DeprecatedString, DeprecatedFlyString, String, FlyString> T>
template<OneOf<ByteString, DeprecatedFlyString, String, FlyString> T>
static Error from_string_view(T)
{
// `Error::from_string_view(DeprecatedString::formatted(...))` is a somewhat common mistake, which leads to a UAF situation.
// `Error::from_string_view(ByteString::formatted(...))` is a somewhat common mistake, which leads to a UAF situation.
// If your string outlives this error and _isn't_ a temporary being passed to this function, explicitly call .view() on it to resolve to the StringView overload.
static_assert(DependentFalse<T>, "Error::from_string_view(String) is almost always a use-after-free");
VERIFY_NOT_REACHED();

View file

@ -22,7 +22,7 @@ public:
static ErrorOr<FlyString> from_utf8(StringView);
template<typename T>
requires(IsOneOf<RemoveCVReference<T>, DeprecatedString, DeprecatedFlyString, FlyString, String>)
requires(IsOneOf<RemoveCVReference<T>, ByteString, DeprecatedFlyString, FlyString, String>)
static ErrorOr<String> from_utf8(T&&) = delete;
FlyString(String const&);

View file

@ -274,7 +274,7 @@ ErrorOr<void> FormatBuilder::put_u64(
size_t used_by_prefix = 0;
if (align == Align::Right && zero_pad) {
// We want DeprecatedString::formatted("{:#08x}", 32) to produce '0x00000020' instead of '0x000020'. This
// We want ByteString::formatted("{:#08x}", 32) to produce '0x00000020' instead of '0x000020'. This
// behavior differs from both fmtlib and printf, but is more intuitive.
used_by_prefix = 0;
} else {
@ -1131,13 +1131,13 @@ void vout(LogLevel log_level, StringView fmtstr, TypeErasedFormatParams& params,
#ifndef KERNEL
// FIXME: Deduplicate with Core::Process:get_name()
[[gnu::used]] static DeprecatedString process_name_helper()
[[gnu::used]] static ByteString process_name_helper()
{
# if defined(AK_OS_SERENITY)
char buffer[BUFSIZ] = {};
int rc = get_process_name(buffer, BUFSIZ);
if (rc != 0)
return DeprecatedString {};
return ByteString {};
return StringView { buffer, strlen(buffer) };
# elif defined(AK_LIBC_GLIBC) || (defined(AK_OS_LINUX) && !defined(AK_OS_ANDROID))
return StringView { program_invocation_name, strlen(program_invocation_name) };

View file

@ -501,7 +501,7 @@ struct Formatter<unsigned char[Size]> : Formatter<StringView> {
}
};
template<>
struct Formatter<DeprecatedString> : Formatter<StringView> {
struct Formatter<ByteString> : Formatter<StringView> {
};
template<>
struct Formatter<DeprecatedFlyString> : Formatter<StringView> {

View file

@ -27,7 +27,7 @@ class CircularBuffer;
class ConstrainedStream;
class CountingStream;
class DeprecatedFlyString;
class DeprecatedString;
class ByteString;
class DeprecatedStringCodePointIterator;
class Duration;
class Error;
@ -159,12 +159,12 @@ using AK::BigEndianOutputBitStream;
using AK::Bitmap;
using AK::ByteBuffer;
using AK::Bytes;
using AK::ByteString;
using AK::CircularBuffer;
using AK::CircularQueue;
using AK::ConstrainedStream;
using AK::CountingStream;
using AK::DeprecatedFlyString;
using AK::DeprecatedString;
using AK::DeprecatedStringCodePointIterator;
using AK::DoublyLinkedList;
using AK::Duration;

View file

@ -11,7 +11,7 @@
#include <AK/StringBuilder.h>
#ifndef KERNEL
# include <AK/DeprecatedString.h>
# include <AK/ByteString.h>
# include <AK/Utf16View.h>
#endif
@ -186,7 +186,7 @@ template ErrorOr<u64> GenericLexer::consume_decimal_integer<u64>();
template ErrorOr<i64> GenericLexer::consume_decimal_integer<i64>();
#ifndef KERNEL
Optional<DeprecatedString> GenericLexer::consume_and_unescape_string(char escape_char)
Optional<ByteString> GenericLexer::consume_and_unescape_string(char escape_char)
{
auto view = consume_quoted_string(escape_char);
if (view.is_null())
@ -195,7 +195,7 @@ Optional<DeprecatedString> GenericLexer::consume_and_unescape_string(char escape
StringBuilder builder;
for (size_t i = 0; i < view.length(); ++i)
builder.append(consume_escaped_character(escape_char));
return builder.to_deprecated_string();
return builder.to_byte_string();
}
auto GenericLexer::consume_escaped_code_point(bool combine_surrogate_pairs) -> Result<u32, UnicodeEscapeError>

View file

@ -92,7 +92,7 @@ public:
}
#ifndef KERNEL
bool consume_specific(DeprecatedString const& next)
bool consume_specific(ByteString const& next)
{
return consume_specific(StringView { next });
}
@ -126,7 +126,7 @@ public:
StringView consume_until(StringView);
StringView consume_quoted_string(char escape_char = 0);
#ifndef KERNEL
Optional<DeprecatedString> consume_and_unescape_string(char escape_char = '\\');
Optional<ByteString> consume_and_unescape_string(char escape_char = '\\');
#endif
template<Integral T>
ErrorOr<T> consume_decimal_integer();

View file

@ -45,14 +45,14 @@ ErrorOr<NonnullOwnPtr<Kernel::KString>> encode_hex(const ReadonlyBytes input)
return Kernel::KString::try_create(output.string_view());
}
#else
DeprecatedString encode_hex(const ReadonlyBytes input)
ByteString encode_hex(const ReadonlyBytes input)
{
StringBuilder output(input.size() * 2);
for (auto ch : input)
output.appendff("{:02x}", ch);
return output.to_deprecated_string();
return output.to_byte_string();
}
#endif

View file

@ -13,7 +13,7 @@
#ifdef KERNEL
# include <Kernel/Library/KString.h>
#else
# include <AK/DeprecatedString.h>
# include <AK/ByteString.h>
#endif
namespace AK {
@ -34,7 +34,7 @@ ErrorOr<ByteBuffer> decode_hex(StringView);
#ifdef KERNEL
ErrorOr<NonnullOwnPtr<Kernel::KString>> encode_hex(ReadonlyBytes);
#else
DeprecatedString encode_hex(ReadonlyBytes);
ByteString encode_hex(ReadonlyBytes);
#endif
}

View file

@ -17,7 +17,7 @@
# include <AK/Error.h>
# include <Kernel/Library/KString.h>
#else
# include <AK/DeprecatedString.h>
# include <AK/ByteString.h>
# include <AK/String.h>
#endif
@ -67,18 +67,18 @@ public:
octet(SubnetClass::D));
}
#else
DeprecatedString to_deprecated_string() const
ByteString to_byte_string() const
{
return DeprecatedString::formatted("{}.{}.{}.{}",
return ByteString::formatted("{}.{}.{}.{}",
octet(SubnetClass::A),
octet(SubnetClass::B),
octet(SubnetClass::C),
octet(SubnetClass::D));
}
DeprecatedString to_deprecated_string_reversed() const
ByteString to_byte_string_reversed() const
{
return DeprecatedString::formatted("{}.{}.{}.{}",
return ByteString::formatted("{}.{}.{}.{}",
octet(SubnetClass::D),
octet(SubnetClass::C),
octet(SubnetClass::B),
@ -179,7 +179,7 @@ template<>
struct Formatter<IPv4Address> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, IPv4Address value)
{
return Formatter<StringView>::format(builder, value.to_deprecated_string());
return Formatter<StringView>::format(builder, value.to_byte_string());
}
};
#endif

View file

@ -71,7 +71,7 @@ private:
{
using RawContainerType = RemoveCV<Container>;
if constexpr (IsSame<StringView, RawContainerType> || IsSame<DeprecatedString, RawContainerType>)
if constexpr (IsSame<StringView, RawContainerType> || IsSame<ByteString, RawContainerType>)
return { container, container.length() };
else
return { container, container.size() };

View file

@ -73,7 +73,7 @@ public:
template<typename Builder>
void serialize(Builder&) const;
[[nodiscard]] DeprecatedString to_deprecated_string() const { return serialized<StringBuilder>(); }
[[nodiscard]] ByteString to_byte_string() const { return serialized<StringBuilder>(); }
template<typename Callback>
void for_each(Callback callback) const
@ -111,7 +111,7 @@ inline typename Builder::OutputType JsonArray::serialized() const
{
Builder builder;
serialize(builder);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
}

View file

@ -68,7 +68,7 @@ public:
}
#ifndef KERNEL
ErrorOr<void> add(DeprecatedString const& value)
ErrorOr<void> add(ByteString const& value)
{
TRY(begin_item());
if constexpr (IsLegacyBuilder<Builder>) {

View file

@ -109,7 +109,7 @@ Optional<bool> JsonObject::get_bool(StringView key) const
}
#if !defined(KERNEL)
Optional<DeprecatedString> JsonObject::get_deprecated_string(StringView key) const
Optional<ByteString> JsonObject::get_byte_string(StringView key) const
{
auto maybe_value = get(key);
if (maybe_value.has_value() && maybe_value->is_string())
@ -249,7 +249,7 @@ bool JsonObject::has_double(StringView key) const
}
#endif
void JsonObject::set(DeprecatedString const& key, JsonValue value)
void JsonObject::set(ByteString const& key, JsonValue value)
{
m_members.set(key, move(value));
}
@ -259,7 +259,7 @@ bool JsonObject::remove(StringView key)
return m_members.remove(key);
}
DeprecatedString JsonObject::to_deprecated_string() const
ByteString JsonObject::to_byte_string() const
{
return serialized<StringBuilder>();
}

View file

@ -8,8 +8,8 @@
#pragma once
#include <AK/ByteString.h>
#include <AK/Concepts.h>
#include <AK/DeprecatedString.h>
#include <AK/Error.h>
#include <AK/HashMap.h>
#include <AK/JsonArray.h>
@ -20,7 +20,7 @@ namespace AK {
class JsonObject {
template<typename Callback>
using CallbackErrorType = decltype(declval<Callback>()(declval<DeprecatedString const&>(), declval<JsonValue const&>()).release_error());
using CallbackErrorType = decltype(declval<Callback>()(declval<ByteString const&>(), declval<JsonValue const&>()).release_error());
public:
JsonObject();
@ -78,7 +78,7 @@ public:
Optional<bool> get_bool(StringView key) const;
#if !defined(KERNEL)
Optional<DeprecatedString> get_deprecated_string(StringView key) const;
Optional<ByteString> get_byte_string(StringView key) const;
#endif
Optional<JsonObject const&> get_object(StringView key) const;
@ -89,7 +89,7 @@ public:
Optional<float> get_float_with_precision_loss(StringView key) const;
#endif
void set(DeprecatedString const& key, JsonValue value);
void set(ByteString const& key, JsonValue value);
template<typename Callback>
void for_each_member(Callback callback) const
@ -98,7 +98,7 @@ public:
callback(member.key, member.value);
}
template<FallibleFunction<DeprecatedString const&, JsonValue const&> Callback>
template<FallibleFunction<ByteString const&, JsonValue const&> Callback>
ErrorOr<void, CallbackErrorType<Callback>> try_for_each_member(Callback&& callback) const
{
for (auto const& member : m_members)
@ -114,10 +114,10 @@ public:
template<typename Builder>
void serialize(Builder&) const;
[[nodiscard]] DeprecatedString to_deprecated_string() const;
[[nodiscard]] ByteString to_byte_string() const;
private:
OrderedHashMap<DeprecatedString, JsonValue> m_members;
OrderedHashMap<ByteString, JsonValue> m_members;
};
template<typename Builder>
@ -135,7 +135,7 @@ inline typename Builder::OutputType JsonObject::serialized() const
{
Builder builder;
serialize(builder);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
template<typename Builder>
@ -186,7 +186,7 @@ inline typename Builder::OutputType JsonValue::serialized() const
{
Builder builder;
serialize(builder);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
}

View file

@ -63,7 +63,7 @@ public:
}
#ifndef KERNEL
ErrorOr<void> add(StringView key, DeprecatedString const& value)
ErrorOr<void> add(StringView key, ByteString const& value)
{
TRY(begin_item(key));
if constexpr (IsLegacyBuilder<Builder>) {

View file

@ -31,7 +31,7 @@ constexpr bool is_space(int ch)
// │ │
// ╰─── u[0-9A-Za-z]{4} ──╯
//
ErrorOr<DeprecatedString> JsonParser::consume_and_unescape_string()
ErrorOr<ByteString> JsonParser::consume_and_unescape_string()
{
if (!consume_specific('"'))
return Error::from_string_literal("JsonParser: Expected '\"'");
@ -128,7 +128,7 @@ ErrorOr<DeprecatedString> JsonParser::consume_and_unescape_string()
}
}
return final_sb.to_deprecated_string();
return final_sb.to_byte_string();
}
ErrorOr<JsonValue> JsonParser::parse_object()

View file

@ -23,7 +23,7 @@ public:
private:
ErrorOr<JsonValue> parse_helper();
ErrorOr<DeprecatedString> consume_and_unescape_string();
ErrorOr<ByteString> consume_and_unescape_string();
ErrorOr<JsonValue> parse_array();
ErrorOr<JsonValue> parse_object();
ErrorOr<JsonValue> parse_number();

View file

@ -31,16 +31,16 @@ JsonValue JsonPath::resolve(JsonValue const& top_root) const
return root;
}
DeprecatedString JsonPath::to_deprecated_string() const
ByteString JsonPath::to_byte_string() const
{
StringBuilder builder;
builder.append("{ ."sv);
for (auto const& el : *this) {
builder.append("sv > "sv);
builder.append(el.to_deprecated_string());
builder.append(el.to_byte_string());
}
builder.append("sv }"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Types.h>
#include <AK/Vector.h>
@ -34,7 +34,7 @@ public:
}
Kind kind() const { return m_kind; }
DeprecatedString const& key() const
ByteString const& key() const
{
VERIFY(m_kind == Kind::Key);
return m_key;
@ -46,13 +46,13 @@ public:
return m_index;
}
DeprecatedString to_deprecated_string() const
ByteString to_byte_string() const
{
switch (m_kind) {
case Kind::Key:
return key();
case Kind::Index:
return DeprecatedString::number(index());
return ByteString::number(index());
default:
return "*";
}
@ -78,7 +78,7 @@ public:
private:
Kind m_kind;
DeprecatedString m_key;
ByteString m_key;
size_t m_index { 0 };
JsonPathElement(Kind kind)
@ -90,7 +90,7 @@ private:
class JsonPath : public Vector<JsonPathElement> {
public:
JsonValue resolve(JsonValue const&) const;
DeprecatedString to_deprecated_string() const;
ByteString to_byte_string() const;
};
}

View file

@ -155,7 +155,7 @@ JsonValue::JsonValue(long long unsigned value)
}
JsonValue::JsonValue(char const* cstring)
: JsonValue(DeprecatedString(cstring))
: JsonValue(ByteString(cstring))
{
}
@ -167,7 +167,7 @@ JsonValue::JsonValue(double value)
}
#endif
JsonValue::JsonValue(DeprecatedString const& value)
JsonValue::JsonValue(ByteString const& value)
{
m_type = Type::String;
m_value.as_string = const_cast<StringImpl*>(value.impl());
@ -175,7 +175,7 @@ JsonValue::JsonValue(DeprecatedString const& value)
}
JsonValue::JsonValue(StringView value)
: JsonValue(value.to_deprecated_string())
: JsonValue(value.to_byte_string())
{
}

View file

@ -10,7 +10,7 @@
# error "JsonValue does not propagate allocation failures, so it is not safe to use in the kernel."
#endif
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Forward.h>
#include <AK/Optional.h>
#include <AK/StringBuilder.h>
@ -52,7 +52,7 @@ public:
JsonValue(double);
JsonValue(char const*);
JsonValue(DeprecatedString const&);
JsonValue(ByteString const&);
JsonValue(StringView);
template<typename T>
@ -78,14 +78,14 @@ public:
template<typename Builder>
void serialize(Builder&) const;
DeprecatedString as_string_or(DeprecatedString const& alternative) const
ByteString as_string_or(ByteString const& alternative) const
{
if (is_string())
return as_string();
return alternative;
}
DeprecatedString to_deprecated_string() const
ByteString to_byte_string() const
{
if (is_string())
return as_string();
@ -148,7 +148,7 @@ public:
return m_value.as_bool;
}
DeprecatedString as_string() const
ByteString as_string() const
{
VERIFY(is_string());
return *m_value.as_string;
@ -290,7 +290,7 @@ template<>
struct Formatter<JsonValue> : Formatter<StringView> {
ErrorOr<void> format(FormatBuilder& builder, JsonValue const& value)
{
return Formatter<StringView>::format(builder, value.to_deprecated_string());
return Formatter<StringView>::format(builder, value.to_byte_string());
}
};

View file

@ -14,7 +14,7 @@ namespace AK {
char s_single_dot = '.';
LexicalPath::LexicalPath(DeprecatedString path)
LexicalPath::LexicalPath(ByteString path)
: m_string(canonicalized_path(move(path)))
{
if (m_string.is_empty()) {
@ -58,9 +58,9 @@ LexicalPath::LexicalPath(DeprecatedString path)
}
}
Vector<DeprecatedString> LexicalPath::parts() const
Vector<ByteString> LexicalPath::parts() const
{
Vector<DeprecatedString> vector;
Vector<ByteString> vector;
vector.ensure_capacity(m_parts.size());
for (auto& part : m_parts)
vector.unchecked_append(part);
@ -88,7 +88,7 @@ bool LexicalPath::is_child_of(LexicalPath const& possible_parent) const
return common_parts_with_parent == possible_parent.parts_view().span();
}
DeprecatedString LexicalPath::canonicalized_path(DeprecatedString path)
ByteString LexicalPath::canonicalized_path(ByteString path)
{
// NOTE: We never allow an empty m_string, if it's empty, we just set it to '.'.
if (path.is_empty())
@ -101,7 +101,7 @@ DeprecatedString LexicalPath::canonicalized_path(DeprecatedString path)
auto is_absolute = path[0] == '/';
auto parts = path.split_view('/');
size_t approximate_canonical_length = 0;
Vector<DeprecatedString> canonical_parts;
Vector<ByteString> canonical_parts;
for (auto& part : parts) {
if (part == ".")
@ -131,10 +131,10 @@ DeprecatedString LexicalPath::canonicalized_path(DeprecatedString path)
if (is_absolute)
builder.append('/');
builder.join('/', canonical_parts);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString LexicalPath::absolute_path(DeprecatedString dir_path, DeprecatedString target)
ByteString LexicalPath::absolute_path(ByteString dir_path, ByteString target)
{
if (LexicalPath(target).is_absolute()) {
return LexicalPath::canonicalized_path(target);
@ -142,10 +142,10 @@ DeprecatedString LexicalPath::absolute_path(DeprecatedString dir_path, Deprecate
return LexicalPath::canonicalized_path(join(dir_path, target).string());
}
DeprecatedString LexicalPath::relative_path(StringView a_path, StringView a_prefix)
ByteString LexicalPath::relative_path(StringView a_path, StringView a_prefix)
{
if (!a_path.starts_with('/') || !a_prefix.starts_with('/')) {
// FIXME: This should probably VERIFY or return an Optional<DeprecatedString>.
// FIXME: This should probably VERIFY or return an Optional<ByteString>.
return ""sv;
}
@ -186,7 +186,7 @@ DeprecatedString LexicalPath::relative_path(StringView a_path, StringView a_pref
builder.append('/');
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
LexicalPath LexicalPath::append(StringView value) const

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Vector.h>
// On Linux distros that use mlibc `basename` is defined as a macro that expands to `__mlibc_gnu_basename` or `__mlibc_gnu_basename_c`, so we undefine it.
@ -24,10 +24,10 @@ public:
Yes
};
explicit LexicalPath(DeprecatedString);
explicit LexicalPath(ByteString);
bool is_absolute() const { return !m_string.is_empty() && m_string[0] == '/'; }
DeprecatedString const& string() const { return m_string; }
ByteString const& string() const { return m_string; }
StringView dirname() const { return m_dirname; }
StringView basename(StripExtension s = StripExtension::No) const { return s == StripExtension::No ? m_basename : m_basename.substring_view(0, m_basename.length() - m_extension.length() - 1); }
@ -35,7 +35,7 @@ public:
StringView extension() const { return m_extension; }
Vector<StringView> const& parts_view() const { return m_parts; }
[[nodiscard]] Vector<DeprecatedString> parts() const;
[[nodiscard]] Vector<ByteString> parts() const;
bool has_extension(StringView) const;
bool is_child_of(LexicalPath const& possible_parent) const;
@ -44,9 +44,9 @@ public:
[[nodiscard]] LexicalPath prepend(StringView) const;
[[nodiscard]] LexicalPath parent() const;
[[nodiscard]] static DeprecatedString canonicalized_path(DeprecatedString);
[[nodiscard]] static DeprecatedString absolute_path(DeprecatedString dir_path, DeprecatedString target);
[[nodiscard]] static DeprecatedString relative_path(StringView absolute_path, StringView prefix);
[[nodiscard]] static ByteString canonicalized_path(ByteString);
[[nodiscard]] static ByteString absolute_path(ByteString dir_path, ByteString target);
[[nodiscard]] static ByteString relative_path(StringView absolute_path, StringView prefix);
template<typename... S>
[[nodiscard]] static LexicalPath join(StringView first, S&&... rest)
@ -55,28 +55,28 @@ public:
builder.append(first);
((builder.append('/'), builder.append(forward<S>(rest))), ...);
return LexicalPath { builder.to_deprecated_string() };
return LexicalPath { builder.to_byte_string() };
}
[[nodiscard]] static DeprecatedString dirname(DeprecatedString path)
[[nodiscard]] static ByteString dirname(ByteString path)
{
auto lexical_path = LexicalPath(move(path));
return lexical_path.dirname();
}
[[nodiscard]] static DeprecatedString basename(DeprecatedString path, StripExtension s = StripExtension::No)
[[nodiscard]] static ByteString basename(ByteString path, StripExtension s = StripExtension::No)
{
auto lexical_path = LexicalPath(move(path));
return lexical_path.basename(s);
}
[[nodiscard]] static DeprecatedString title(DeprecatedString path)
[[nodiscard]] static ByteString title(ByteString path)
{
auto lexical_path = LexicalPath(move(path));
return lexical_path.title();
}
[[nodiscard]] static DeprecatedString extension(DeprecatedString path)
[[nodiscard]] static ByteString extension(ByteString path)
{
auto lexical_path = LexicalPath(move(path));
return lexical_path.extension();
@ -84,7 +84,7 @@ public:
private:
Vector<StringView> m_parts;
DeprecatedString m_string;
ByteString m_string;
StringView m_dirname;
StringView m_basename;
StringView m_title;

View file

@ -15,7 +15,7 @@
#ifdef KERNEL
# include <Kernel/Library/KString.h>
#else
# include <AK/DeprecatedString.h>
# include <AK/ByteString.h>
#endif
class [[gnu::packed]] MACAddress {
@ -64,9 +64,9 @@ public:
return Kernel::KString::formatted("{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", m_data[0], m_data[1], m_data[2], m_data[3], m_data[4], m_data[5]);
}
#else
DeprecatedString to_deprecated_string() const
ByteString to_byte_string() const
{
return DeprecatedString::formatted("{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", m_data[0], m_data[1], m_data[2], m_data[3], m_data[4], m_data[5]);
return ByteString::formatted("{:02x}:{:02x}:{:02x}:{:02x}:{:02x}:{:02x}", m_data[0], m_data[1], m_data[2], m_data[3], m_data[4], m_data[5]);
}
#endif

View file

@ -5,7 +5,7 @@
*/
#include <AK/Assertions.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/NumberFormat.h>
#include <AK/NumericLimits.h>
#include <AK/StringView.h>
@ -13,7 +13,7 @@
namespace AK {
// FIXME: Remove this hackery once printf() supports floats.
static DeprecatedString number_string_with_one_decimal(u64 number, u64 unit, StringView suffix, UseThousandsSeparator use_thousands_separator)
static ByteString number_string_with_one_decimal(u64 number, u64 unit, StringView suffix, UseThousandsSeparator use_thousands_separator)
{
constexpr auto max_unit_size = NumericLimits<u64>::max() / 10;
VERIFY(unit < max_unit_size);
@ -21,25 +21,25 @@ static DeprecatedString number_string_with_one_decimal(u64 number, u64 unit, Str
auto integer_part = number / unit;
auto decimal_part = (number % unit) * 10 / unit;
if (use_thousands_separator == UseThousandsSeparator::Yes)
return DeprecatedString::formatted("{:'d}.{} {}", integer_part, decimal_part, suffix);
return ByteString::formatted("{:'d}.{} {}", integer_part, decimal_part, suffix);
return DeprecatedString::formatted("{}.{} {}", integer_part, decimal_part, suffix);
return ByteString::formatted("{}.{} {}", integer_part, decimal_part, suffix);
}
DeprecatedString human_readable_quantity(u64 quantity, HumanReadableBasedOn based_on, StringView unit, UseThousandsSeparator use_thousands_separator)
ByteString human_readable_quantity(u64 quantity, HumanReadableBasedOn based_on, StringView unit, UseThousandsSeparator use_thousands_separator)
{
u64 size_of_unit = based_on == HumanReadableBasedOn::Base2 ? 1024 : 1000;
constexpr auto unit_prefixes = AK::Array { "", "K", "M", "G", "T", "P", "E" };
auto full_unit_suffix = [&](int index) {
auto binary_infix = (based_on == HumanReadableBasedOn::Base2 && index != 0) ? "i"sv : ""sv;
return DeprecatedString::formatted("{}{}{}",
return ByteString::formatted("{}{}{}",
unit_prefixes[index], binary_infix, unit);
};
auto size_of_current_unit = size_of_unit;
if (quantity < size_of_unit)
return DeprecatedString::formatted("{} {}", quantity, full_unit_suffix(0));
return ByteString::formatted("{} {}", quantity, full_unit_suffix(0));
for (size_t i = 1; i < unit_prefixes.size() - 1; i++) {
auto suffix = full_unit_suffix(i);
@ -54,28 +54,28 @@ DeprecatedString human_readable_quantity(u64 quantity, HumanReadableBasedOn base
size_of_current_unit, full_unit_suffix(unit_prefixes.size() - 1), use_thousands_separator);
}
DeprecatedString human_readable_size(u64 size, HumanReadableBasedOn based_on, UseThousandsSeparator use_thousands_separator)
ByteString human_readable_size(u64 size, HumanReadableBasedOn based_on, UseThousandsSeparator use_thousands_separator)
{
return human_readable_quantity(size, based_on, "B"sv, use_thousands_separator);
}
DeprecatedString human_readable_size_long(u64 size, UseThousandsSeparator use_thousands_separator)
ByteString human_readable_size_long(u64 size, UseThousandsSeparator use_thousands_separator)
{
if (size < 1 * KiB) {
if (use_thousands_separator == UseThousandsSeparator::Yes)
return DeprecatedString::formatted("{:'d} bytes", size);
return ByteString::formatted("{:'d} bytes", size);
return DeprecatedString::formatted("{} bytes", size);
return ByteString::formatted("{} bytes", size);
}
auto human_readable_size_string = human_readable_size(size, HumanReadableBasedOn::Base2, use_thousands_separator);
if (use_thousands_separator == UseThousandsSeparator::Yes)
return DeprecatedString::formatted("{} ({:'d} bytes)", human_readable_size_string, size);
return ByteString::formatted("{} ({:'d} bytes)", human_readable_size_string, size);
return DeprecatedString::formatted("{} ({} bytes)", human_readable_size_string, size);
return ByteString::formatted("{} ({} bytes)", human_readable_size_string, size);
}
DeprecatedString human_readable_time(i64 time_in_seconds)
ByteString human_readable_time(i64 time_in_seconds)
{
auto days = time_in_seconds / 86400;
time_in_seconds = time_in_seconds % 86400;
@ -99,10 +99,10 @@ DeprecatedString human_readable_time(i64 time_in_seconds)
builder.appendff("{} second{}", time_in_seconds, time_in_seconds == 1 ? "" : "s");
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString human_readable_digital_time(i64 time_in_seconds)
ByteString human_readable_digital_time(i64 time_in_seconds)
{
auto hours = time_in_seconds / 3600;
time_in_seconds = time_in_seconds % 3600;
@ -117,7 +117,7 @@ DeprecatedString human_readable_digital_time(i64 time_in_seconds)
builder.appendff("{:02}:", minutes);
builder.appendff("{:02}", time_in_seconds);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
namespace AK {
@ -20,12 +20,12 @@ enum class UseThousandsSeparator {
No
};
DeprecatedString human_readable_size(u64 size, HumanReadableBasedOn based_on = HumanReadableBasedOn::Base2, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No);
DeprecatedString human_readable_quantity(u64 quantity, HumanReadableBasedOn based_on = HumanReadableBasedOn::Base2, StringView unit = "B"sv, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No);
ByteString human_readable_size(u64 size, HumanReadableBasedOn based_on = HumanReadableBasedOn::Base2, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No);
ByteString human_readable_quantity(u64 quantity, HumanReadableBasedOn based_on = HumanReadableBasedOn::Base2, StringView unit = "B"sv, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No);
DeprecatedString human_readable_size_long(u64 size, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No);
DeprecatedString human_readable_time(i64 time_in_seconds);
DeprecatedString human_readable_digital_time(i64 time_in_seconds);
ByteString human_readable_size_long(u64 size, UseThousandsSeparator use_thousands_separator = UseThousandsSeparator::No);
ByteString human_readable_time(i64 time_in_seconds);
ByteString human_readable_digital_time(i64 time_in_seconds);
}

View file

@ -66,7 +66,7 @@ private:
static constexpr SimpleReverseIterator rbegin(Container& container)
{
using RawContainerType = RemoveCV<Container>;
if constexpr (IsSame<StringView, RawContainerType> || IsSame<DeprecatedString, RawContainerType>)
if constexpr (IsSame<StringView, RawContainerType> || IsSame<ByteString, RawContainerType>)
return { container, static_cast<int>(container.length()) - 1 };
else
return { container, static_cast<int>(container.size()) - 1 };

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/SourceLocation.h>
#include <AK/StringBuilder.h>
@ -24,9 +24,9 @@ public:
for (auto indent = m_depth++; indent > 0; indent--)
sb.append(' ');
if (m_extra.is_empty())
dbgln("\033[1;{}m{}entering {}\033[0m", m_depth % 8 + 30, sb.to_deprecated_string(), m_location);
dbgln("\033[1;{}m{}entering {}\033[0m", m_depth % 8 + 30, sb.to_byte_string(), m_location);
else
dbgln("\033[1;{}m{}entering {}\033[0m ({})", m_depth % 8 + 30, sb.to_deprecated_string(), m_location, m_extra);
dbgln("\033[1;{}m{}entering {}\033[0m ({})", m_depth % 8 + 30, sb.to_byte_string(), m_location, m_extra);
}
ScopeLogger(SourceLocation location = SourceLocation::current())
@ -42,15 +42,15 @@ public:
for (auto indent = --m_depth; indent > 0; indent--)
sb.append(' ');
if (m_extra.is_empty())
dbgln("\033[1;{}m{}leaving {}\033[0m", depth % 8 + 30, sb.to_deprecated_string(), m_location);
dbgln("\033[1;{}m{}leaving {}\033[0m", depth % 8 + 30, sb.to_byte_string(), m_location);
else
dbgln("\033[1;{}m{}leaving {}\033[0m ({})", depth % 8 + 30, sb.to_deprecated_string(), m_location, m_extra);
dbgln("\033[1;{}m{}leaving {}\033[0m ({})", depth % 8 + 30, sb.to_byte_string(), m_location, m_extra);
}
private:
static inline size_t m_depth = 0;
SourceLocation m_location;
DeprecatedString m_extra;
ByteString m_extra;
};
template<>

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/GenericLexer.h>
#include <AK/HashMap.h>
#include <AK/String.h>
@ -116,12 +116,12 @@ public:
}
// FIXME: These are deprecated.
void set(StringView key, DeprecatedString value)
void set(StringView key, ByteString value)
{
set(key, MUST(String::from_deprecated_string(value)));
set(key, MUST(String::from_byte_string(value)));
}
template<size_t N>
void set(char const (&key)[N], DeprecatedString value)
void set(char const (&key)[N], ByteString value)
{
set(StringView { key, N - 1 }, value);
}

View file

@ -621,14 +621,14 @@ void String::did_create_fly_string(Badge<FlyString>) const
m_data->set_fly_string(true);
}
DeprecatedString String::to_deprecated_string() const
ByteString String::to_byte_string() const
{
return DeprecatedString(bytes_as_string_view());
return ByteString(bytes_as_string_view());
}
ErrorOr<String> String::from_deprecated_string(DeprecatedString const& deprecated_string)
ErrorOr<String> String::from_byte_string(ByteString const& byte_string)
{
return String::from_utf8(deprecated_string.view());
return String::from_utf8(byte_string.view());
}
bool String::equals_ignoring_ascii_case(StringView other) const

View file

@ -67,7 +67,7 @@ public:
// Creates a new String from a sequence of UTF-8 encoded code points.
static ErrorOr<String> from_utf8(StringView);
template<typename T>
requires(IsOneOf<RemoveCVReference<T>, DeprecatedString, DeprecatedFlyString, FlyString, String>)
requires(IsOneOf<RemoveCVReference<T>, ByteString, DeprecatedFlyString, FlyString, String>)
static ErrorOr<String> from_utf8(T&&) = delete;
// Creates a new String by reading byte_count bytes from a UTF-8 encoded Stream.
@ -221,11 +221,11 @@ public:
void did_create_fly_string(Badge<FlyString>) const;
// FIXME: Remove these once all code has been ported to String
[[nodiscard]] DeprecatedString to_deprecated_string() const;
static ErrorOr<String> from_deprecated_string(DeprecatedString const&);
[[nodiscard]] ByteString to_byte_string() const;
static ErrorOr<String> from_byte_string(ByteString const&);
template<typename T>
requires(IsSame<RemoveCVReference<T>, StringView>)
static ErrorOr<String> from_deprecated_string(T&&) = delete;
static ErrorOr<String> from_byte_string(T&&) = delete;
private:
// NOTE: If the least significant bit of the pointer is set, this is a short string.

View file

@ -15,7 +15,7 @@
#include <AK/Utf32View.h>
#ifndef KERNEL
# include <AK/DeprecatedString.h>
# include <AK/ByteString.h>
# include <AK/FlyString.h>
# include <AK/Utf16View.h>
#endif
@ -144,11 +144,11 @@ ErrorOr<ByteBuffer> StringBuilder::to_byte_buffer() const
}
#ifndef KERNEL
DeprecatedString StringBuilder::to_deprecated_string() const
ByteString StringBuilder::to_byte_string() const
{
if (is_empty())
return DeprecatedString::empty();
return DeprecatedString((char const*)data(), length());
return ByteString::empty();
return ByteString((char const*)data(), length());
}
ErrorOr<String> StringBuilder::to_string() const

View file

@ -18,7 +18,7 @@ class StringBuilder {
public:
static constexpr size_t inline_capacity = 256;
using OutputType = DeprecatedString;
using OutputType = ByteString;
static ErrorOr<StringBuilder> create(size_t initial_capacity = inline_capacity);
@ -70,7 +70,7 @@ public:
}
#ifndef KERNEL
[[nodiscard]] DeprecatedString to_deprecated_string() const;
[[nodiscard]] ByteString to_byte_string() const;
#endif
ErrorOr<String> to_string() const;

View file

@ -17,7 +17,7 @@
#ifdef KERNEL
# include <Kernel/Library/StdLib.h>
#else
# include <AK/DeprecatedString.h>
# include <AK/ByteString.h>
# include <AK/FloatingPointStringConversions.h>
# include <string.h>
#endif
@ -465,7 +465,7 @@ Optional<size_t> find_any_of(StringView haystack, StringView needles, SearchDire
}
#ifndef KERNEL
DeprecatedString to_snakecase(StringView str)
ByteString to_snakecase(StringView str)
{
auto should_insert_underscore = [&](auto i, auto current_char) {
if (i == 0)
@ -488,10 +488,10 @@ DeprecatedString to_snakecase(StringView str)
builder.append('_');
builder.append_as_lowercase(ch);
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString to_titlecase(StringView str)
ByteString to_titlecase(StringView str)
{
StringBuilder builder;
bool next_is_upper = true;
@ -504,10 +504,10 @@ DeprecatedString to_titlecase(StringView str)
next_is_upper = ch == ' ';
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString invert_case(StringView str)
ByteString invert_case(StringView str)
{
StringBuilder builder(str.length());
@ -518,10 +518,10 @@ DeprecatedString invert_case(StringView str)
builder.append(to_ascii_lowercase(ch));
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString replace(StringView str, StringView needle, StringView replacement, ReplaceMode replace_mode)
ByteString replace(StringView str, StringView needle, StringView replacement, ReplaceMode replace_mode)
{
if (str.is_empty())
return str;
@ -546,7 +546,7 @@ DeprecatedString replace(StringView str, StringView needle, StringView replaceme
last_position = position + needle.length();
}
replaced_string.append(str.substring_view(last_position, str.length() - last_position));
return replaced_string.to_deprecated_string();
return replaced_string.to_byte_string();
}
ErrorOr<String> replace(String const& haystack, StringView needle, StringView replacement, ReplaceMode replace_mode)

View file

@ -106,11 +106,11 @@ enum class SearchDirection {
};
Optional<size_t> find_any_of(StringView haystack, StringView needles, SearchDirection);
DeprecatedString to_snakecase(StringView);
DeprecatedString to_titlecase(StringView);
DeprecatedString invert_case(StringView);
ByteString to_snakecase(StringView);
ByteString to_titlecase(StringView);
ByteString invert_case(StringView);
DeprecatedString replace(StringView, StringView needle, StringView replacement, ReplaceMode);
ByteString replace(StringView, StringView needle, StringView replacement, ReplaceMode);
ErrorOr<String> replace(String const&, StringView needle, StringView replacement, ReplaceMode);
size_t count(StringView, StringView needle);

View file

@ -13,8 +13,8 @@
#include <AK/Vector.h>
#ifndef KERNEL
# include <AK/ByteString.h>
# include <AK/DeprecatedFlyString.h>
# include <AK/DeprecatedString.h>
# include <AK/FlyString.h>
# include <AK/String.h>
#endif
@ -34,7 +34,7 @@ StringView::StringView(FlyString const& string)
{
}
StringView::StringView(DeprecatedString const& string)
StringView::StringView(ByteString const& string)
: m_characters(string.characters())
, m_length(string.length())
{
@ -176,17 +176,17 @@ bool StringView::equals_ignoring_ascii_case(StringView other) const
}
#ifndef KERNEL
DeprecatedString StringView::to_lowercase_string() const
ByteString StringView::to_lowercase_string() const
{
return StringImpl::create_lowercased(characters_without_null_termination(), length()).release_nonnull();
}
DeprecatedString StringView::to_uppercase_string() const
ByteString StringView::to_uppercase_string() const
{
return StringImpl::create_uppercased(characters_without_null_termination(), length()).release_nonnull();
}
DeprecatedString StringView::to_titlecase_string() const
ByteString StringView::to_titlecase_string() const
{
return StringUtils::to_titlecase(*this);
}
@ -257,14 +257,14 @@ Optional<float> StringView::to_float(TrimWhitespace trim_whitespace) const
return StringUtils::convert_to_floating_point<float>(*this, trim_whitespace);
}
bool StringView::operator==(DeprecatedString const& string) const
bool StringView::operator==(ByteString const& string) const
{
return *this == string.view();
}
DeprecatedString StringView::to_deprecated_string() const { return DeprecatedString { *this }; }
ByteString StringView::to_byte_string() const { return ByteString { *this }; }
DeprecatedString StringView::replace(StringView needle, StringView replacement, ReplaceMode replace_mode) const
ByteString StringView::replace(StringView needle, StringView replacement, ReplaceMode replace_mode) const
{
return StringUtils::replace(*this, needle, replacement, replace_mode);
}

View file

@ -50,7 +50,7 @@ public:
#ifndef KERNEL
StringView(String const&);
StringView(FlyString const&);
StringView(DeprecatedString const&);
StringView(ByteString const&);
StringView(DeprecatedFlyString const&);
#endif
@ -58,11 +58,11 @@ public:
#ifndef KERNEL
explicit StringView(String&&) = delete;
explicit StringView(FlyString&&) = delete;
explicit StringView(DeprecatedString&&) = delete;
explicit StringView(ByteString&&) = delete;
explicit StringView(DeprecatedFlyString&&) = delete;
#endif
template<OneOf<String, FlyString, DeprecatedString, DeprecatedFlyString, ByteBuffer> StringType>
template<OneOf<String, FlyString, ByteString, DeprecatedFlyString, ByteBuffer> StringType>
StringView& operator=(StringType&&) = delete;
[[nodiscard]] constexpr bool is_null() const
@ -110,9 +110,9 @@ public:
[[nodiscard]] StringView trim_whitespace(TrimMode mode = TrimMode::Both) const { return StringUtils::trim_whitespace(*this, mode); }
#ifndef KERNEL
[[nodiscard]] DeprecatedString to_lowercase_string() const;
[[nodiscard]] DeprecatedString to_uppercase_string() const;
[[nodiscard]] DeprecatedString to_titlecase_string() const;
[[nodiscard]] ByteString to_lowercase_string() const;
[[nodiscard]] ByteString to_uppercase_string() const;
[[nodiscard]] ByteString to_titlecase_string() const;
#endif
[[nodiscard]] Optional<size_t> find(char needle, size_t start = 0) const
@ -272,7 +272,7 @@ public:
}
#ifndef KERNEL
bool operator==(DeprecatedString const&) const;
bool operator==(ByteString const&) const;
#endif
[[nodiscard]] constexpr int compare(StringView other) const
@ -314,7 +314,7 @@ public:
constexpr bool operator>=(StringView other) const { return compare(other) >= 0; }
#ifndef KERNEL
[[nodiscard]] DeprecatedString to_deprecated_string() const;
[[nodiscard]] ByteString to_byte_string() const;
#endif
[[nodiscard]] bool is_whitespace() const
@ -323,7 +323,7 @@ public:
}
#ifndef KERNEL
[[nodiscard]] DeprecatedString replace(StringView needle, StringView replacement, ReplaceMode) const;
[[nodiscard]] ByteString replace(StringView needle, StringView replacement, ReplaceMode) const;
#endif
[[nodiscard]] size_t count(StringView needle) const
{
@ -354,7 +354,7 @@ public:
}
private:
friend class DeprecatedString;
friend class ByteString;
char const* m_characters { nullptr };
size_t m_length { 0 };
};

View file

@ -38,21 +38,21 @@ URL URL::complete_url(StringView relative_url) const
ErrorOr<String> URL::username() const
{
return String::from_deprecated_string(percent_decode(m_username));
return String::from_byte_string(percent_decode(m_username));
}
ErrorOr<String> URL::password() const
{
return String::from_deprecated_string(percent_decode(m_password));
return String::from_byte_string(percent_decode(m_password));
}
DeprecatedString URL::path_segment_at_index(size_t index) const
ByteString URL::path_segment_at_index(size_t index) const
{
VERIFY(index < path_segment_count());
return percent_decode(m_paths[index]);
}
DeprecatedString URL::basename() const
ByteString URL::basename() const
{
if (!m_valid)
return {};
@ -72,7 +72,7 @@ void URL::set_scheme(String scheme)
ErrorOr<void> URL::set_username(StringView username)
{
// To set the username given a url and username, set urls username to the result of running UTF-8 percent-encode on username using the userinfo percent-encode set.
m_username = TRY(String::from_deprecated_string(percent_encode(username, PercentEncodeSet::Userinfo)));
m_username = TRY(String::from_byte_string(percent_encode(username, PercentEncodeSet::Userinfo)));
m_valid = compute_validity();
return {};
}
@ -81,7 +81,7 @@ ErrorOr<void> URL::set_username(StringView username)
ErrorOr<void> URL::set_password(StringView password)
{
// To set the password given a url and password, set urls password to the result of running UTF-8 percent-encode on password using the userinfo percent-encode set.
m_password = TRY(String::from_deprecated_string(percent_encode(password, PercentEncodeSet::Userinfo)));
m_password = TRY(String::from_byte_string(percent_encode(password, PercentEncodeSet::Userinfo)));
m_valid = compute_validity();
return {};
}
@ -108,18 +108,18 @@ void URL::set_port(Optional<u16> port)
m_valid = compute_validity();
}
void URL::set_paths(Vector<DeprecatedString> const& paths)
void URL::set_paths(Vector<ByteString> const& paths)
{
m_paths.clear_with_capacity();
m_paths.ensure_capacity(paths.size());
for (auto const& segment : paths)
m_paths.unchecked_append(String::from_deprecated_string(percent_encode(segment, PercentEncodeSet::Path)).release_value_but_fixme_should_propagate_errors());
m_paths.unchecked_append(String::from_byte_string(percent_encode(segment, PercentEncodeSet::Path)).release_value_but_fixme_should_propagate_errors());
m_valid = compute_validity();
}
void URL::append_path(StringView path)
{
m_paths.append(String::from_deprecated_string(percent_encode(path, PercentEncodeSet::Path)).release_value_but_fixme_should_propagate_errors());
m_paths.append(String::from_byte_string(percent_encode(path, PercentEncodeSet::Path)).release_value_but_fixme_should_propagate_errors());
}
// https://url.spec.whatwg.org/#cannot-have-a-username-password-port
@ -182,7 +182,7 @@ Optional<u16> URL::default_port_for_scheme(StringView scheme)
return {};
}
URL URL::create_with_file_scheme(DeprecatedString const& path, DeprecatedString const& fragment, DeprecatedString const& hostname)
URL URL::create_with_file_scheme(ByteString const& path, ByteString const& fragment, ByteString const& hostname)
{
LexicalPath lexical_path(path);
if (!lexical_path.is_absolute())
@ -190,38 +190,38 @@ URL URL::create_with_file_scheme(DeprecatedString const& path, DeprecatedString
URL url;
url.set_scheme("file"_string);
url.set_host(hostname == "localhost" ? String {} : String::from_deprecated_string(hostname).release_value_but_fixme_should_propagate_errors());
url.set_host(hostname == "localhost" ? String {} : String::from_byte_string(hostname).release_value_but_fixme_should_propagate_errors());
url.set_paths(lexical_path.parts());
if (path.ends_with('/'))
url.append_slash();
if (!fragment.is_empty())
url.set_fragment(String::from_deprecated_string(fragment).release_value_but_fixme_should_propagate_errors());
url.set_fragment(String::from_byte_string(fragment).release_value_but_fixme_should_propagate_errors());
return url;
}
URL URL::create_with_help_scheme(DeprecatedString const& path, DeprecatedString const& fragment, DeprecatedString const& hostname)
URL URL::create_with_help_scheme(ByteString const& path, ByteString const& fragment, ByteString const& hostname)
{
LexicalPath lexical_path(path);
URL url;
url.set_scheme("help"_string);
url.set_host(hostname == "localhost" ? String {} : String::from_deprecated_string(hostname).release_value_but_fixme_should_propagate_errors());
url.set_host(hostname == "localhost" ? String {} : String::from_byte_string(hostname).release_value_but_fixme_should_propagate_errors());
url.set_paths(lexical_path.parts());
if (path.ends_with('/'))
url.append_slash();
if (!fragment.is_empty())
url.set_fragment(String::from_deprecated_string(fragment).release_value_but_fixme_should_propagate_errors());
url.set_fragment(String::from_byte_string(fragment).release_value_but_fixme_should_propagate_errors());
return url;
}
URL URL::create_with_url_or_path(DeprecatedString const& url_or_path)
URL URL::create_with_url_or_path(ByteString const& url_or_path)
{
URL url = url_or_path;
if (url.is_valid())
return url;
DeprecatedString path = LexicalPath::canonicalized_path(url_or_path);
ByteString path = LexicalPath::canonicalized_path(url_or_path);
return URL::create_with_file_scheme(path);
}
@ -237,7 +237,7 @@ URL URL::create_with_data(StringView mime_type, StringView payload, bool is_base
builder.append(";base64"sv);
builder.append(',');
builder.append(payload);
url.set_paths({ builder.to_deprecated_string() });
url.set_paths({ builder.to_byte_string() });
return url;
}
@ -248,12 +248,12 @@ bool URL::is_special_scheme(StringView scheme)
}
// https://url.spec.whatwg.org/#url-path-serializer
DeprecatedString URL::serialize_path(ApplyPercentDecoding apply_percent_decoding) const
ByteString URL::serialize_path(ApplyPercentDecoding apply_percent_decoding) const
{
// 1. If url has an opaque path, then return urls path.
// FIXME: Reimplement this step once we modernize the URL implementation to meet the spec.
if (cannot_be_a_base_url())
return m_paths[0].to_deprecated_string();
return m_paths[0].to_byte_string();
// 2. Let output be the empty string.
StringBuilder output;
@ -261,15 +261,15 @@ DeprecatedString URL::serialize_path(ApplyPercentDecoding apply_percent_decoding
// 3. For each segment of urls path: append U+002F (/) followed by segment to output.
for (auto const& segment : m_paths) {
output.append('/');
output.append(apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(segment) : segment.to_deprecated_string());
output.append(apply_percent_decoding == ApplyPercentDecoding::Yes ? percent_decode(segment) : segment.to_byte_string());
}
// 4. Return output.
return output.to_deprecated_string();
return output.to_byte_string();
}
// https://url.spec.whatwg.org/#concept-url-serializer
DeprecatedString URL::serialize(ExcludeFragment exclude_fragment) const
ByteString URL::serialize(ExcludeFragment exclude_fragment) const
{
// 1. Let output be urls scheme and U+003A (:) concatenated.
StringBuilder output;
@ -331,14 +331,14 @@ DeprecatedString URL::serialize(ExcludeFragment exclude_fragment) const
}
// 7. Return output.
return output.to_deprecated_string();
return output.to_byte_string();
}
// https://url.spec.whatwg.org/#url-rendering
// NOTE: This does e.g. not display credentials.
// FIXME: Parts of the URL other than the host should have their sequences of percent-encoded bytes replaced with code points
// resulting from percent-decoding those sequences converted to bytes, unless that renders those sequences invisible.
DeprecatedString URL::serialize_for_display() const
ByteString URL::serialize_for_display() const
{
VERIFY(m_valid);
@ -374,17 +374,17 @@ DeprecatedString URL::serialize_for_display() const
builder.append(*m_fragment);
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
ErrorOr<String> URL::to_string() const
{
return String::from_deprecated_string(serialize());
return String::from_byte_string(serialize());
}
// https://html.spec.whatwg.org/multipage/origin.html#ascii-serialisation-of-an-origin
// https://url.spec.whatwg.org/#concept-url-origin
DeprecatedString URL::serialize_origin() const
ByteString URL::serialize_origin() const
{
VERIFY(m_valid);
@ -407,7 +407,7 @@ DeprecatedString URL::serialize_origin() const
builder.append(serialized_host().release_value_but_fixme_should_propagate_errors());
if (m_port.has_value())
builder.appendff(":{}", *m_port);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
bool URL::equals(URL const& other, ExcludeFragment exclude_fragments) const
@ -544,7 +544,7 @@ void URL::append_percent_encoded_if_necessary(StringBuilder& builder, u32 code_p
builder.append_code_point(code_point);
}
DeprecatedString URL::percent_encode(StringView input, URL::PercentEncodeSet set, SpaceAsPlus space_as_plus)
ByteString URL::percent_encode(StringView input, URL::PercentEncodeSet set, SpaceAsPlus space_as_plus)
{
StringBuilder builder;
for (auto code_point : Utf8View(input)) {
@ -553,10 +553,10 @@ DeprecatedString URL::percent_encode(StringView input, URL::PercentEncodeSet set
else
append_percent_encoded_if_necessary(builder, code_point, set);
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
DeprecatedString URL::percent_decode(StringView input)
ByteString URL::percent_decode(StringView input)
{
if (!input.contains('%'))
return input;
@ -575,7 +575,7 @@ DeprecatedString URL::percent_decode(StringView input)
builder.append(byte);
}
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
}

View file

@ -8,7 +8,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <AK/Vector.h>
@ -45,7 +45,7 @@ public:
URL() = default;
URL(StringView);
URL(DeprecatedString const& string)
URL(ByteString const& string)
: URL(string.view())
{
}
@ -77,11 +77,11 @@ public:
ErrorOr<String> password() const;
Host const& host() const { return m_host; }
ErrorOr<String> serialized_host() const;
DeprecatedString basename() const;
ByteString basename() const;
Optional<String> const& query() const { return m_query; }
Optional<String> const& fragment() const { return m_fragment; }
Optional<u16> port() const { return m_port; }
DeprecatedString path_segment_at_index(size_t index) const;
ByteString path_segment_at_index(size_t index) const;
size_t path_segment_count() const { return m_paths.size(); }
u16 port_or_default() const { return m_port.value_or(default_port_for_scheme(m_scheme).value_or(0)); }
@ -96,7 +96,7 @@ public:
ErrorOr<void> set_password(StringView);
void set_host(Host);
void set_port(Optional<u16>);
void set_paths(Vector<DeprecatedString> const&);
void set_paths(Vector<ByteString> const&);
void set_query(Optional<String> query) { m_query = move(query); }
void set_fragment(Optional<String> fragment) { m_fragment = move(fragment); }
void set_cannot_be_a_base_url(bool value) { m_cannot_be_a_base_url = value; }
@ -111,14 +111,14 @@ public:
Yes,
No
};
DeprecatedString serialize_path(ApplyPercentDecoding = ApplyPercentDecoding::Yes) const;
DeprecatedString serialize(ExcludeFragment = ExcludeFragment::No) const;
DeprecatedString serialize_for_display() const;
DeprecatedString to_deprecated_string() const { return serialize(); }
ByteString serialize_path(ApplyPercentDecoding = ApplyPercentDecoding::Yes) const;
ByteString serialize(ExcludeFragment = ExcludeFragment::No) const;
ByteString serialize_for_display() const;
ByteString to_byte_string() const { return serialize(); }
ErrorOr<String> to_string() const;
// HTML origin
DeprecatedString serialize_origin() const;
ByteString serialize_origin() const;
bool equals(URL const& other, ExcludeFragment = ExcludeFragment::No) const;
@ -130,9 +130,9 @@ public:
};
ErrorOr<DataURL> process_data_url() const;
static URL create_with_url_or_path(DeprecatedString const&);
static URL create_with_file_scheme(DeprecatedString const& path, DeprecatedString const& fragment = {}, DeprecatedString const& hostname = {});
static URL create_with_help_scheme(DeprecatedString const& path, DeprecatedString const& fragment = {}, DeprecatedString const& hostname = {});
static URL create_with_url_or_path(ByteString const&);
static URL create_with_file_scheme(ByteString const& path, ByteString const& fragment = {}, ByteString const& hostname = {});
static URL create_with_help_scheme(ByteString const& path, ByteString const& fragment = {}, ByteString const& hostname = {});
static URL create_with_data(StringView mime_type, StringView payload, bool is_base64 = false);
static Optional<u16> default_port_for_scheme(StringView);
@ -142,8 +142,8 @@ public:
No,
Yes,
};
static DeprecatedString percent_encode(StringView input, PercentEncodeSet set = PercentEncodeSet::Userinfo, SpaceAsPlus = SpaceAsPlus::No);
static DeprecatedString percent_decode(StringView input);
static ByteString percent_encode(StringView input, PercentEncodeSet set = PercentEncodeSet::Userinfo, SpaceAsPlus = SpaceAsPlus::No);
static ByteString percent_decode(StringView input);
bool operator==(URL const& other) const { return equals(other, ExcludeFragment::No); }
@ -198,7 +198,7 @@ struct Formatter<URL> : Formatter<StringView> {
template<>
struct Traits<URL> : public DefaultTraits<URL> {
static unsigned hash(URL const& url) { return url.to_deprecated_string().hash(); }
static unsigned hash(URL const& url) { return url.to_byte_string().hash(); }
};
}

View file

@ -5,9 +5,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/ByteString.h>
#include <AK/CharacterTypes.h>
#include <AK/Debug.h>
#include <AK/DeprecatedString.h>
#include <AK/IntegralMath.h>
#include <AK/Optional.h>
#include <AK/SourceLocation.h>
@ -57,7 +57,7 @@ static Optional<URL::Host> parse_opaque_host(StringView input)
// currently report validation errors, they are only useful for debugging efforts in the URL parsing code.
// 4. Return the result of running UTF-8 percent-encode on input using the C0 control percent-encode set.
return String::from_deprecated_string(URL::percent_encode(input, URL::PercentEncodeSet::C0Control)).release_value_but_fixme_should_propagate_errors();
return String::from_byte_string(URL::percent_encode(input, URL::PercentEncodeSet::C0Control)).release_value_but_fixme_should_propagate_errors();
}
struct ParsedIPv4Number {
@ -606,7 +606,7 @@ static Optional<URL::Host> parse_host(StringView input, bool is_opaque = false)
// NOTE: This is handled in Unicode::create_unicode_url, to work around the fact that we can't call into LibUnicode here
// FIXME: 5. Let asciiDomain be the result of running domain to ASCII with domain and false.
// FIXME: 6. If asciiDomain is failure, then return failure.
auto ascii_domain_or_error = String::from_deprecated_string(domain);
auto ascii_domain_or_error = String::from_byte_string(domain);
if (ascii_domain_or_error.is_error())
return {};
@ -792,7 +792,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
if (start_index >= end_index)
return {};
DeprecatedString processed_input = raw_input.substring_view(start_index, end_index - start_index);
ByteString processed_input = raw_input.substring_view(start_index, end_index - start_index);
// 2. If input contains any ASCII tab or newline, invalid-URL-unit validation error.
// 3. Remove all ASCII tab or newline from input.
@ -1116,7 +1116,7 @@ URL URLParser::basic_parse(StringView raw_input, Optional<URL> const& base_url,
// 2. If atSignSeen is true, then prepend "%40" to buffer.
if (at_sign_seen) {
auto content = buffer.to_deprecated_string();
auto content = buffer.to_byte_string();
buffer.clear();
buffer.append("%40"sv);
buffer.append(content);

View file

@ -81,9 +81,9 @@ u32 Utf16View::decode_surrogate_pair(u16 high_surrogate, u16 low_surrogate)
return ((high_surrogate - high_surrogate_min) << 10) + (low_surrogate - low_surrogate_min) + first_supplementary_plane_code_point;
}
ErrorOr<DeprecatedString> Utf16View::to_deprecated_string(AllowInvalidCodeUnits allow_invalid_code_units) const
ErrorOr<ByteString> Utf16View::to_byte_string(AllowInvalidCodeUnits allow_invalid_code_units) const
{
return TRY(to_utf8(allow_invalid_code_units)).to_deprecated_string();
return TRY(to_utf8(allow_invalid_code_units)).to_byte_string();
}
ErrorOr<String> Utf16View::to_utf8(AllowInvalidCodeUnits allow_invalid_code_units) const

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Error.h>
#include <AK/Format.h>
#include <AK/Forward.h>
@ -78,7 +78,7 @@ public:
No,
};
ErrorOr<DeprecatedString> to_deprecated_string(AllowInvalidCodeUnits = AllowInvalidCodeUnits::No) const;
ErrorOr<ByteString> to_byte_string(AllowInvalidCodeUnits = AllowInvalidCodeUnits::No) const;
ErrorOr<String> to_utf8(AllowInvalidCodeUnits = AllowInvalidCodeUnits::No) const;
bool is_null() const { return m_code_units.is_null(); }

View file

@ -12,7 +12,7 @@
#include <AK/Types.h>
#ifndef KERNEL
# include <AK/DeprecatedString.h>
# include <AK/ByteString.h>
#endif
namespace AK {
@ -72,12 +72,12 @@ public:
}
#ifndef KERNEL
explicit Utf8View(DeprecatedString& string)
explicit Utf8View(ByteString& string)
: m_string(string.view())
{
}
explicit Utf8View(DeprecatedString&&) = delete;
explicit Utf8View(ByteString&&) = delete;
#endif
~Utf8View() = default;
@ -255,14 +255,14 @@ public:
return Utf8View(m_string).byte_offset_of(m_it);
}
DeprecatedStringCodePointIterator(DeprecatedString string)
DeprecatedStringCodePointIterator(ByteString string)
: m_string(move(string))
, m_it(Utf8View(m_string).begin())
{
}
private:
DeprecatedString m_string;
ByteString m_string;
Utf8CodePointIterator m_it;
};
#endif

View file

@ -5,17 +5,17 @@ clipboard - Data formats specific to Clipboard and drag & drop
## Clipboard
The clipboard feature works through the Clipboard server, which generally acts as a global storage or three things:
- a `DeprecatedString` mime type,
- a `ByteString` mime type,
- a (potentially large) block of data, shared as an anonymous file,
- a `HashMap<DeprecatedString, DeprecatedString>` of arbitrary metadata, depending on the mime type.
- a `HashMap<ByteString, ByteString>` of arbitrary metadata, depending on the mime type.
See also [`Userland/Libraries/LibGUI/Clipboard.h`](../../../../../Userland/Libraries/LibGUI/Clipboard.h).
## Drag & drop
In contrast to the clipboard, the drag & drop feature works through WindowServer, and a bouquet of data is transmitted:
- a `[UTF8] DeprecatedString` to be displayed while dragging,
- a `HashMap<DeprecatedString, ByteBuffer>` map that contains arbitrary data for a variety of possible mime types,
- a `[UTF8] ByteString` to be displayed while dragging,
- a `HashMap<ByteString, ByteBuffer>` map that contains arbitrary data for a variety of possible mime types,
- a `Gfx::ShareableBitmap` to be displayed while dragging
Drag & drop is most prominently supported by File Manager, Spreadsheet, and Terminal.

View file

@ -91,7 +91,7 @@ Start from defining an endpoint in the IPC file in `MyServer.ipc`.
```ipc
endpoint MyServer
{
SyncAPI(DeprecatedString text) => (i32 status)
SyncAPI(ByteString text) => (i32 status)
AsyncAPI(i32 mode) =|
}
```
@ -102,7 +102,7 @@ Part of the generated C++ messages:
class SyncAPI final : public IPC::Message {
public:
using ResponseType = SyncAPIResponse;
SyncAPI(const DeprecatedString& text) : m_text(text) {}
SyncAPI(const ByteString& text) : m_text(text) {}
virtual ~SyncAPI() override {}
static OwnPtr<SyncAPI> decode(...);
virtual IPC::MessageBuffer encode(...) const override;

View file

@ -1,6 +1,6 @@
# String Formatting
Many places in Serenity allow you to format strings, similar to `printf()`, for example `DeprecatedString::formatted()`
Many places in Serenity allow you to format strings, similar to `printf()`, for example `ByteString::formatted()`
, `StringBuilder::appendff()`, or `dbgln()`. These are checked at compile time to ensure the format string matches the
number of parameters. The syntax is largely based on
the [C++ `std::formatter` syntax](https://en.cppreference.com/w/cpp/utility/format/formatter#Standard_format_specification)
@ -10,27 +10,27 @@ For basic usage, any occurrences of `{}` in the format string are replaced with
form, in order:
```c++
DeprecatedString::formatted("Well, {} my {} friends!", "hello", 42) == "Well, hello my 42 friends!";
ByteString::formatted("Well, {} my {} friends!", "hello", 42) == "Well, hello my 42 friends!";
```
If you want to include a literal `{` in the output, use `{{`:
```c++
DeprecatedString::formatted("{{ {}", "hello") == "{ hello";
ByteString::formatted("{{ {}", "hello") == "{ hello";
```
You can refer to the arguments by index, if you want to repeat one or change the order:
```c++
DeprecatedString::formatted("{2}{0}{1}", "a", "b", "c") == "cab";
ByteString::formatted("{2}{0}{1}", "a", "b", "c") == "cab";
```
To control how the arguments are formatted, add colon after the optional index, and then add format specifier
characters:
```c++
DeprecatedString::formatted("{:.4}", "cool dude") == "cool";
DeprecatedString::formatted("{0:.4}", "cool dude") == "cool";
ByteString::formatted("{:.4}", "cool dude") == "cool";
ByteString::formatted("{0:.4}", "cool dude") == "cool";
```
## Format specifiers
@ -135,6 +135,6 @@ type cannot be formatted. For example:
```c++
// B has a Formatter defined, but A does not.
DeprecatedString::formatted("{}", FormatIfSupported { A {} }) == "?";
DeprecatedString::formatted("{}", FormatIfSupported { B {} }) == "B";
ByteString::formatted("{}", FormatIfSupported { A {} }) == "?";
ByteString::formatted("{}", FormatIfSupported { B {} }) == "B";
```

View file

@ -6,7 +6,7 @@
#include "ALooperEventLoopImplementation.h"
#include "JNIHelpers.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Format.h>
#include <AK/HashMap.h>
#include <AK/LexicalPath.h>
@ -21,7 +21,7 @@
#include <LibFileSystem/FileSystem.h>
#include <jni.h>
static ErrorOr<void> extract_tar_archive(String archive_file, DeprecatedString output_directory);
static ErrorOr<void> extract_tar_archive(String archive_file, ByteString output_directory);
JavaVM* global_vm;
static OwnPtr<Core::EventLoop> s_main_event_loop;
@ -89,29 +89,29 @@ Java_org_serenityos_ladybird_LadybirdActivity_disposeNativeCode(JNIEnv* env, job
delete &Core::EventLoopManager::the();
}
ErrorOr<void> extract_tar_archive(String archive_file, DeprecatedString output_directory)
ErrorOr<void> extract_tar_archive(String archive_file, ByteString output_directory)
{
constexpr size_t buffer_size = 4096;
auto file = TRY(Core::InputBufferedFile::create(TRY(Core::File::open(archive_file, Core::File::OpenMode::Read))));
DeprecatedString old_pwd = TRY(Core::System::getcwd());
ByteString old_pwd = TRY(Core::System::getcwd());
TRY(Core::System::chdir(output_directory));
ScopeGuard go_back = [&old_pwd] { MUST(Core::System::chdir(old_pwd)); };
auto tar_stream = TRY(Archive::TarInputStream::construct(move(file)));
HashMap<DeprecatedString, DeprecatedString> global_overrides;
HashMap<DeprecatedString, DeprecatedString> local_overrides;
HashMap<ByteString, ByteString> global_overrides;
HashMap<ByteString, ByteString> local_overrides;
auto get_override = [&](StringView key) -> Optional<DeprecatedString> {
Optional<DeprecatedString> maybe_local = local_overrides.get(key);
auto get_override = [&](StringView key) -> Optional<ByteString> {
Optional<ByteString> maybe_local = local_overrides.get(key);
if (maybe_local.has_value())
return maybe_local;
Optional<DeprecatedString> maybe_global = global_overrides.get(key);
Optional<ByteString> maybe_global = global_overrides.get(key);
if (maybe_global.has_value())
return maybe_global;
@ -163,7 +163,7 @@ ErrorOr<void> extract_tar_archive(String archive_file, DeprecatedString output_d
long_name.append(reinterpret_cast<char*>(slice.data()), slice.size());
}
local_overrides.set("path", long_name.to_deprecated_string());
local_overrides.set("path", long_name.to_byte_string());
TRY(tar_stream->advance());
continue;
}
@ -175,9 +175,9 @@ ErrorOr<void> extract_tar_archive(String archive_file, DeprecatedString output_d
LexicalPath path = LexicalPath(header.filename());
if (!header.prefix().is_empty())
path = path.prepend(header.prefix());
DeprecatedString filename = get_override("path"sv).value_or(path.string());
ByteString filename = get_override("path"sv).value_or(path.string());
DeprecatedString absolute_path = TRY(FileSystem::absolute_path(filename)).to_deprecated_string();
ByteString absolute_path = TRY(FileSystem::absolute_path(filename)).to_byte_string();
auto parent_path = LexicalPath(absolute_path).parent();
auto header_mode = TRY(header.mode());

View file

@ -122,9 +122,9 @@ ErrorOr<NonnullRefPtr<Client>> bind_service(void (*bind_method)(int, int))
static ErrorOr<void> load_content_filters()
{
auto file_or_error = Core::File::open(DeprecatedString::formatted("{}/home/anon/.config/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read);
auto file_or_error = Core::File::open(ByteString::formatted("{}/home/anon/.config/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read);
if (file_or_error.is_error())
file_or_error = Core::File::open(DeprecatedString::formatted("{}/res/ladybird/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read);
file_or_error = Core::File::open(ByteString::formatted("{}/res/ladybird/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read);
if (file_or_error.is_error())
return file_or_error.release_error();

View file

@ -474,7 +474,7 @@
[submenu addItem:[NSMenuItem separatorItem]];
auto* spoof_user_agent_menu = [[NSMenu alloc] init];
auto add_user_agent = [spoof_user_agent_menu](DeprecatedString name) {
auto add_user_agent = [spoof_user_agent_menu](ByteString name) {
[spoof_user_agent_menu addItem:[[NSMenuItem alloc] initWithTitle:Ladybird::string_to_ns_string(name)
action:@selector(setUserAgentSpoof:)
keyEquivalent:@""]];

View file

@ -27,7 +27,7 @@
- (void)onLoadStart:(URL const&)url isRedirect:(BOOL)is_redirect;
- (void)onLoadFinish:(URL const&)url;
- (void)onTitleChange:(DeprecatedString const&)title;
- (void)onTitleChange:(ByteString const&)title;
- (void)onFaviconChange:(Gfx::Bitmap const&)bitmap;
- (void)onNavigateBack;
@ -58,7 +58,7 @@
- (void)resetZoom;
- (float)zoomLevel;
- (void)debugRequest:(DeprecatedString const&)request argument:(DeprecatedString const&)argument;
- (void)debugRequest:(ByteString const&)request argument:(ByteString const&)argument;
- (void)viewSource;

View file

@ -180,7 +180,7 @@ struct HideCursor {
m_web_view_bridge->set_preferred_color_scheme(color_scheme);
}
- (void)debugRequest:(DeprecatedString const&)request argument:(DeprecatedString const&)argument
- (void)debugRequest:(ByteString const&)request argument:(ByteString const&)argument
{
m_web_view_bridge->debug_request(request, argument);
}
@ -634,7 +634,7 @@ static void copy_data_to_clipboard(StringView data, NSPasteboardType pasteboard_
return [delegate cookieJar].get_named_cookie(url, name);
};
m_web_view_bridge->on_get_cookie = [](auto const& url, auto source) -> DeprecatedString {
m_web_view_bridge->on_get_cookie = [](auto const& url, auto source) -> ByteString {
auto* delegate = (ApplicationDelegate*)[NSApp delegate];
return [delegate cookieJar].get_cookie(url, source);
};

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <Ladybird/Utilities.h>
#include <LibCore/Resource.h>
#include <LibGfx/Palette.h>
@ -33,7 +33,7 @@ Core::AnonymousBuffer create_system_palette()
auto theme_file = is_dark ? "Dark"sv : "Default"sv;
auto theme_ini = MUST(Core::Resource::load_from_uri(MUST(String::formatted("resource://themes/{}.ini", theme_file))));
auto theme = Gfx::load_system_theme(theme_ini->filesystem_path().to_deprecated_string()).release_value_but_fixme_should_propagate_errors();
auto theme = Gfx::load_system_theme(theme_ini->filesystem_path().to_byte_string()).release_value_but_fixme_should_propagate_errors();
auto palette_impl = Gfx::PaletteImpl::create_with_anonymous_buffer(theme);
auto palette = Gfx::Palette(move(palette_impl));

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/String.h>
#include <AK/URL.h>
#include <Ladybird/Utilities.h>
@ -247,7 +247,7 @@ static constexpr CGFloat const WINDOW_HEIGHT = 800;
}
}
- (void)onTitleChange:(DeprecatedString const&)title
- (void)onTitleChange:(ByteString const&)title
{
[[self tabController] onTitleChange:title];

View file

@ -16,7 +16,7 @@ struct TabSettings {
BOOL scripting_enabled { YES };
BOOL block_popups { YES };
BOOL same_origin_policy_enabled { NO };
DeprecatedString user_agent_name { "Disabled"sv };
ByteString user_agent_name { "Disabled"sv };
};
@interface TabController : NSWindowController <NSWindowDelegate>
@ -27,14 +27,14 @@ struct TabSettings {
- (void)loadHTML:(StringView)html url:(URL const&)url;
- (void)onLoadStart:(URL const&)url isRedirect:(BOOL)isRedirect;
- (void)onTitleChange:(DeprecatedString const&)title;
- (void)onTitleChange:(ByteString const&)title;
- (void)navigateBack:(id)sender;
- (void)navigateForward:(id)sender;
- (void)reload:(id)sender;
- (void)clearHistory;
- (void)debugRequest:(DeprecatedString const&)request argument:(DeprecatedString const&)argument;
- (void)debugRequest:(ByteString const&)request argument:(ByteString const&)argument;
- (void)focusLocationToolbarItem;

View file

@ -54,7 +54,7 @@ enum class IsHistoryNavigation {
@interface TabController () <NSToolbarDelegate, NSSearchFieldDelegate>
{
DeprecatedString m_title;
ByteString m_title;
WebView::History m_history;
IsHistoryNavigation m_is_history_navigation;
@ -133,7 +133,7 @@ enum class IsHistoryNavigation {
[self updateNavigationButtonStates];
}
- (void)onTitleChange:(DeprecatedString const&)title
- (void)onTitleChange:(ByteString const&)title
{
m_title = title;
m_history.update_title(m_title);
@ -201,7 +201,7 @@ enum class IsHistoryNavigation {
[self updateNavigationButtonStates];
}
- (void)debugRequest:(DeprecatedString const&)request argument:(DeprecatedString const&)argument
- (void)debugRequest:(ByteString const&)request argument:(ByteString const&)argument
{
if (request == "dump-history") {
m_history.dump();
@ -390,8 +390,8 @@ enum class IsHistoryNavigation {
- (void)setUserAgentSpoof:(NSMenuItem*)sender
{
DeprecatedString const user_agent_name = [[sender title] UTF8String];
DeprecatedString user_agent = "";
ByteString const user_agent_name = [[sender title] UTF8String];
ByteString user_agent = "";
if (user_agent_name == "Disabled"sv) {
user_agent = Web::default_user_agent;
} else {

View file

@ -6,13 +6,13 @@
*/
#include "FontPlugin.h"
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/String.h>
#include <LibCore/StandardPaths.h>
#include <LibGfx/Font/Emoji.h>
#include <LibGfx/Font/FontDatabase.h>
extern DeprecatedString s_serenity_resource_root;
extern ByteString s_serenity_resource_root;
namespace Ladybird {

View file

@ -45,7 +45,7 @@ ErrorOr<void> AutoComplete::parse_google_autocomplete(Vector<JsonValue> const& j
if (!json[0].is_string())
return Error::from_string_view("Invalid JSON, expected first element to be a string"sv);
auto query = TRY(String::from_deprecated_string(json[0].as_string()));
auto query = TRY(String::from_byte_string(json[0].as_string()));
if (!json[1].is_array())
return Error::from_string_view("Invalid JSON, expected second element to be an array"sv);
@ -55,7 +55,7 @@ ErrorOr<void> AutoComplete::parse_google_autocomplete(Vector<JsonValue> const& j
return Error::from_string_view("Invalid JSON, query does not match"sv);
for (auto& suggestion : suggestions_array) {
m_auto_complete_model->add(TRY(String::from_deprecated_string(suggestion.as_string())));
m_auto_complete_model->add(TRY(String::from_byte_string(suggestion.as_string())));
}
return {};
@ -67,7 +67,7 @@ ErrorOr<void> AutoComplete::parse_duckduckgo_autocomplete(Vector<JsonValue> cons
auto maybe_value = suggestion.as_object().get("phrase"sv);
if (!maybe_value.has_value())
continue;
m_auto_complete_model->add(TRY(String::from_deprecated_string(maybe_value->as_string())));
m_auto_complete_model->add(TRY(String::from_byte_string(maybe_value->as_string())));
}
return {};
@ -77,7 +77,7 @@ ErrorOr<void> AutoComplete::parse_yahoo_autocomplete(JsonObject const& json)
{
if (!json.get("q"sv).has_value() || !json.get("q"sv)->is_string())
return Error::from_string_view("Invalid JSON, expected \"q\" to be a string"sv);
auto query = TRY(String::from_deprecated_string(json.get("q"sv)->as_string()));
auto query = TRY(String::from_byte_string(json.get("q"sv)->as_string()));
if (!json.get("r"sv).has_value() || !json.get("r"sv)->is_array())
return Error::from_string_view("Invalid JSON, expected \"r\" to be an object"sv);
@ -94,7 +94,7 @@ ErrorOr<void> AutoComplete::parse_yahoo_autocomplete(JsonObject const& json)
if (!suggestion.get("k"sv).has_value() || !suggestion.get("k"sv)->is_string())
return Error::from_string_view("Invalid JSON, expected \"k\" to be a string"sv);
m_auto_complete_model->add(TRY(String::from_deprecated_string(suggestion.get("k"sv)->as_string())));
m_auto_complete_model->add(TRY(String::from_byte_string(suggestion.get("k"sv)->as_string())));
};
return {};
@ -105,7 +105,7 @@ ErrorOr<void> AutoComplete::got_network_response(QNetworkReply* reply)
if (reply->error() == QNetworkReply::NetworkError::OperationCanceledError)
return {};
AK::JsonParser parser(ak_deprecated_string_from_qstring(reply->readAll()));
AK::JsonParser parser(ak_byte_string_from_qstring(reply->readAll()));
auto json = TRY(parser.parse());
auto engine_name = Settings::the()->autocomplete_engine().name;

View file

@ -331,7 +331,7 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
auto* disable_spoofing = add_user_agent("Disabled"sv, Web::default_user_agent);
disable_spoofing->setChecked(true);
for (auto const& user_agent : WebView::user_agents)
add_user_agent(user_agent.key, user_agent.value.to_deprecated_string());
add_user_agent(user_agent.key, user_agent.value.to_byte_string());
auto* custom_user_agent_action = new QAction("Custom...", this);
custom_user_agent_action->setCheckable(true);
@ -340,7 +340,7 @@ BrowserWindow::BrowserWindow(Vector<URL> const& initial_urls, WebView::CookieJar
QObject::connect(custom_user_agent_action, &QAction::triggered, this, [this, disable_spoofing] {
auto user_agent = QInputDialog::getText(this, "Custom User Agent", "Enter User Agent:");
if (!user_agent.isEmpty()) {
debug_request("spoof-user-agent", ak_deprecated_string_from_qstring(user_agent));
debug_request("spoof-user-agent", ak_byte_string_from_qstring(user_agent));
debug_request("clear-cache"); // clear the cache to ensure requests are re-done with the new user agent
} else {
disable_spoofing->activate(QAction::Trigger);
@ -455,7 +455,7 @@ void BrowserWindow::set_current_tab(Tab* tab)
update_displayed_zoom_level();
}
void BrowserWindow::debug_request(DeprecatedString const& request, DeprecatedString const& argument)
void BrowserWindow::debug_request(ByteString const& request, ByteString const& argument)
{
if (!m_current_tab)
return;
@ -505,7 +505,7 @@ Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab)
};
tab->view().on_tab_open_request = [this](auto url, auto activate_tab) {
auto& tab = new_tab(qstring_from_ak_string(url.to_deprecated_string()), activate_tab);
auto& tab = new_tab(qstring_from_ak_string(url.to_byte_string()), activate_tab);
return tab.view().handle();
};
@ -533,7 +533,7 @@ Tab& BrowserWindow::create_new_tab(Web::HTML::ActivateTab activate_tab)
return m_cookie_jar.get_named_cookie(url, name);
};
tab->view().on_get_cookie = [this](auto& url, auto source) -> DeprecatedString {
tab->view().on_get_cookie = [this](auto& url, auto source) -> ByteString {
return m_cookie_jar.get_cookie(url, source);
};

View file

@ -102,7 +102,7 @@ private:
Tab& create_new_tab(Web::HTML::ActivateTab activate_tab);
void debug_request(DeprecatedString const& request, DeprecatedString const& argument = "");
void debug_request(ByteString const& request, ByteString const& argument = "");
void set_current_tab(Tab* tab);
void update_displayed_zoom_level();

View file

@ -24,7 +24,7 @@ void RequestManagerQt::reply_finished(QNetworkReply* reply)
request->did_finish();
}
RefPtr<Web::ResourceLoaderConnectorRequest> RequestManagerQt::start_request(DeprecatedString const& method, AK::URL const& url, HashMap<DeprecatedString, DeprecatedString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const& proxy)
RefPtr<Web::ResourceLoaderConnectorRequest> RequestManagerQt::start_request(ByteString const& method, AK::URL const& url, HashMap<ByteString, ByteString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const& proxy)
{
if (!url.scheme().bytes_as_string_view().is_one_of_ignoring_ascii_case("http"sv, "https"sv)) {
return nullptr;
@ -38,9 +38,9 @@ RefPtr<Web::ResourceLoaderConnectorRequest> RequestManagerQt::start_request(Depr
return request;
}
ErrorOr<NonnullRefPtr<RequestManagerQt::Request>> RequestManagerQt::Request::create(QNetworkAccessManager& qnam, DeprecatedString const& method, AK::URL const& url, HashMap<DeprecatedString, DeprecatedString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&)
ErrorOr<NonnullRefPtr<RequestManagerQt::Request>> RequestManagerQt::Request::create(QNetworkAccessManager& qnam, ByteString const& method, AK::URL const& url, HashMap<ByteString, ByteString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&)
{
QNetworkRequest request { QString(url.to_deprecated_string().characters()) };
QNetworkRequest request { QString(url.to_byte_string().characters()) };
request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::ManualRedirectPolicy);
request.setAttribute(QNetworkRequest::CookieLoadControlAttribute, QNetworkRequest::Manual);
request.setAttribute(QNetworkRequest::CookieSaveControlAttribute, QNetworkRequest::Manual);
@ -87,11 +87,11 @@ void RequestManagerQt::Request::did_finish()
{
auto buffer = m_reply.readAll();
auto http_status_code = m_reply.attribute(QNetworkRequest::Attribute::HttpStatusCodeAttribute).toInt();
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> response_headers;
Vector<DeprecatedString> set_cookie_headers;
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> response_headers;
Vector<ByteString> set_cookie_headers;
for (auto& it : m_reply.rawHeaderPairs()) {
auto name = DeprecatedString(it.first.data(), it.first.length());
auto value = DeprecatedString(it.second.data(), it.second.length());
auto name = ByteString(it.first.data(), it.first.length());
auto value = ByteString(it.second.data(), it.second.length());
if (name.equals_ignoring_ascii_case("set-cookie"sv)) {
// NOTE: Qt may have bundled multiple Set-Cookie headers into a single one.
// We have to extract the full list of cookies via QNetworkReply::header().
@ -104,7 +104,7 @@ void RequestManagerQt::Request::did_finish()
}
}
if (!set_cookie_headers.is_empty()) {
response_headers.set("set-cookie"sv, JsonArray { set_cookie_headers }.to_deprecated_string());
response_headers.set("set-cookie"sv, JsonArray { set_cookie_headers }.to_byte_string());
}
bool success = http_status_code != 0;
on_buffered_request_finish(success, buffer.length(), response_headers, http_status_code, ReadonlyBytes { buffer.data(), (size_t)buffer.size() });

View file

@ -27,7 +27,7 @@ public:
virtual void prefetch_dns(AK::URL const&) override { }
virtual void preconnect(AK::URL const&) override { }
virtual RefPtr<Web::ResourceLoaderConnectorRequest> start_request(DeprecatedString const& method, AK::URL const&, HashMap<DeprecatedString, DeprecatedString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&) override;
virtual RefPtr<Web::ResourceLoaderConnectorRequest> start_request(ByteString const& method, AK::URL const&, HashMap<ByteString, ByteString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&) override;
private slots:
void reply_finished(QNetworkReply*);
@ -38,7 +38,7 @@ private:
class Request
: public Web::ResourceLoaderConnectorRequest {
public:
static ErrorOr<NonnullRefPtr<Request>> create(QNetworkAccessManager& qnam, DeprecatedString const& method, AK::URL const& url, HashMap<DeprecatedString, DeprecatedString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&);
static ErrorOr<NonnullRefPtr<Request>> create(QNetworkAccessManager& qnam, ByteString const& method, AK::URL const& url, HashMap<ByteString, ByteString> const& request_headers, ReadonlyBytes request_body, Core::ProxyData const&);
virtual ~Request() override;

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/OwnPtr.h>
#include <LibWebView/SearchEngine.h>
#include <QPoint>

View file

@ -6,9 +6,9 @@
#include "StringUtils.h"
AK::DeprecatedString ak_deprecated_string_from_qstring(QString const& qstring)
AK::ByteString ak_byte_string_from_qstring(QString const& qstring)
{
return AK::DeprecatedString(qstring.toUtf8().data());
return AK::ByteString(qstring.toUtf8().data());
}
String ak_string_from_qstring(QString const& qstring)

View file

@ -6,12 +6,12 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Error.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <QString>
AK::DeprecatedString ak_deprecated_string_from_qstring(QString const&);
AK::ByteString ak_byte_string_from_qstring(QString const&);
String ak_string_from_qstring(QString const&);
QString qstring_from_ak_string(StringView);

View file

@ -107,7 +107,7 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St
};
view().on_link_hover = [this](auto const& url) {
m_hover_label->setText(qstring_from_ak_string(url.to_deprecated_string()));
m_hover_label->setText(qstring_from_ak_string(url.to_byte_string()));
update_hover_label();
m_hover_label->show();
};
@ -123,7 +123,7 @@ Tab::Tab(BrowserWindow* window, WebContentOptions const& web_content_options, St
m_history.replace_current(url, m_title.toUtf8().data());
}
m_location_edit->setText(url.to_deprecated_string().characters());
m_location_edit->setText(url.to_byte_string().characters());
m_location_edit->setCursorPosition(0);
// Don't add to history if back or forward is pressed
@ -648,7 +648,7 @@ void Tab::back()
m_is_history_navigation = true;
m_history.go_back();
view().load(m_history.current().url.to_deprecated_string());
view().load(m_history.current().url.to_byte_string());
}
void Tab::forward()
@ -658,7 +658,7 @@ void Tab::forward()
m_is_history_navigation = true;
m_history.go_forward();
view().load(m_history.current().url.to_deprecated_string());
view().load(m_history.current().url.to_byte_string());
}
void Tab::reload()
@ -667,7 +667,7 @@ void Tab::reload()
return;
m_is_history_navigation = true;
view().load(m_history.current().url.to_deprecated_string());
view().load(m_history.current().url.to_byte_string());
}
void Tab::open_link(URL const& url)
@ -703,7 +703,7 @@ int Tab::tab_index()
return m_window->tab_index(this);
}
void Tab::debug_request(DeprecatedString const& request, DeprecatedString const& argument)
void Tab::debug_request(ByteString const& request, ByteString const& argument)
{
if (request == "dump-history")
m_history.dump();

View file

@ -40,7 +40,7 @@ public:
void forward();
void reload();
void debug_request(DeprecatedString const& request, DeprecatedString const& argument);
void debug_request(ByteString const& request, ByteString const& argument);
void open_file();
void update_reset_zoom_button();

View file

@ -576,7 +576,7 @@ static Core::AnonymousBuffer make_system_theme_from_qt_palette(QWidget& widget,
auto theme_file = mode == WebContentView::PaletteMode::Default ? "Default"sv : "Dark"sv;
auto theme_ini = MUST(Core::Resource::load_from_uri(MUST(String::formatted("resource://themes/{}.ini", theme_file))));
auto theme = Gfx::load_system_theme(theme_ini->filesystem_path().to_deprecated_string()).release_value_but_fixme_should_propagate_errors();
auto theme = Gfx::load_system_theme(theme_ini->filesystem_path().to_byte_string()).release_value_but_fixme_should_propagate_errors();
auto palette_impl = Gfx::PaletteImpl::create_with_anonymous_buffer(theme);
auto palette = Gfx::Palette(move(palette_impl));
@ -752,7 +752,7 @@ bool WebContentView::event(QEvent* event)
ErrorOr<String> WebContentView::dump_layout_tree()
{
return String::from_deprecated_string(client().dump_layout_tree());
return String::from_byte_string(client().dump_layout_tree());
}
}

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Function.h>
#include <AK/HashMap.h>
#include <AK/OwnPtr.h>

View file

@ -19,7 +19,7 @@ NonnullRefPtr<WebSocketClientManagerQt> WebSocketClientManagerQt::create()
WebSocketClientManagerQt::WebSocketClientManagerQt() = default;
WebSocketClientManagerQt::~WebSocketClientManagerQt() = default;
RefPtr<Web::WebSockets::WebSocketClientSocket> WebSocketClientManagerQt::connect(AK::URL const& url, DeprecatedString const& origin, Vector<DeprecatedString> const& protocols)
RefPtr<Web::WebSockets::WebSocketClientSocket> WebSocketClientManagerQt::connect(AK::URL const& url, ByteString const& origin, Vector<ByteString> const& protocols)
{
WebSocket::ConnectionInfo connection_info(url);
connection_info.set_origin(origin);

View file

@ -19,7 +19,7 @@ public:
static NonnullRefPtr<WebSocketClientManagerQt> create();
virtual ~WebSocketClientManagerQt() override;
virtual RefPtr<Web::WebSockets::WebSocketClientSocket> connect(AK::URL const&, DeprecatedString const& origin, Vector<DeprecatedString> const& protocols) override;
virtual RefPtr<Web::WebSockets::WebSocketClientSocket> connect(AK::URL const&, ByteString const& origin, Vector<ByteString> const& protocols) override;
private:
WebSocketClientManagerQt();

View file

@ -85,13 +85,13 @@ ErrorOr<ByteBuffer> WebSocketImplQt::read(int max_size)
return buffer.slice(0, bytes_read);
}
ErrorOr<DeprecatedString> WebSocketImplQt::read_line(size_t size)
ErrorOr<ByteString> WebSocketImplQt::read_line(size_t size)
{
auto buffer = TRY(ByteBuffer::create_uninitialized(size));
auto bytes_read = m_socket->readLine(reinterpret_cast<char*>(buffer.data()), buffer.size());
if (bytes_read == -1)
return Error::from_string_literal("WebSocketImplQt::read_line(): Error reading from socket");
return DeprecatedString::copy(buffer.span().slice(0, bytes_read));
return ByteString::copy(buffer.span().slice(0, bytes_read));
}
}

View file

@ -22,7 +22,7 @@ public:
virtual void connect(WebSocket::ConnectionInfo const&) override;
virtual bool can_read_line() override;
virtual ErrorOr<DeprecatedString> read_line(size_t) override;
virtual ErrorOr<ByteString> read_line(size_t) override;
virtual ErrorOr<ByteBuffer> read(int max_size) override;
virtual bool send(ReadonlyBytes) override;
virtual bool eof() override;

View file

@ -50,7 +50,7 @@ WebSocketQt::WebSocketQt(NonnullRefPtr<WebSocket::WebSocket> underlying_socket)
}
}
};
m_websocket->on_close = [weak_this = make_weak_ptr()](u16 code, DeprecatedString reason, bool was_clean) {
m_websocket->on_close = [weak_this = make_weak_ptr()](u16 code, ByteString reason, bool was_clean) {
if (auto strong_this = weak_this.strong_ref())
if (strong_this->on_close)
strong_this->on_close(code, move(reason), was_clean);
@ -74,7 +74,7 @@ Web::WebSockets::WebSocket::ReadyState WebSocketQt::ready_state()
VERIFY_NOT_REACHED();
}
DeprecatedString WebSocketQt::subprotocol_in_use()
ByteString WebSocketQt::subprotocol_in_use()
{
return m_websocket->subprotocol_in_use();
}
@ -89,7 +89,7 @@ void WebSocketQt::send(StringView message)
m_websocket->send(WebSocket::Message(message));
}
void WebSocketQt::close(u16 code, DeprecatedString reason)
void WebSocketQt::close(u16 code, ByteString reason)
{
m_websocket->close(code, reason);
}

View file

@ -21,10 +21,10 @@ public:
virtual ~WebSocketQt() override;
virtual Web::WebSockets::WebSocket::ReadyState ready_state() override;
virtual DeprecatedString subprotocol_in_use() override;
virtual ByteString subprotocol_in_use() override;
virtual void send(ByteBuffer binary_or_text_message, bool is_text) override;
virtual void send(StringView message) override;
virtual void close(u16 code, DeprecatedString reason) override;
virtual void close(u16 code, ByteString reason) override;
private:
explicit WebSocketQt(NonnullRefPtr<WebSocket::WebSocket>);

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/Directory.h>
#include <LibCore/EventLoop.h>
@ -17,7 +17,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
AK::set_rich_debug_enabled(true);
DeprecatedString pid_file;
ByteString pid_file;
Core::ArgsParser args_parser;
args_parser.add_option(pid_file, "Path to the PID file for the SQLServer singleton process", "pid-file", 'p', "pid_file");
@ -25,7 +25,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
VERIFY(!pid_file.is_empty());
auto database_path = DeprecatedString::formatted("{}/Ladybird", Core::StandardPaths::data_directory());
auto database_path = ByteString::formatted("{}/Ladybird", Core::StandardPaths::data_directory());
TRY(Core::Directory::create(database_path, Core::Directory::CreateDirectories::Yes));
Core::EventLoop loop;

View file

@ -12,13 +12,13 @@
#include <LibCore/System.h>
#include <LibFileSystem/FileSystem.h>
DeprecatedString s_serenity_resource_root;
ByteString s_serenity_resource_root;
ErrorOr<String> application_directory()
{
auto current_executable_path = TRY(Core::System::current_executable_path());
auto dirname = LexicalPath::dirname(current_executable_path);
return String::from_deprecated_string(dirname);
return String::from_byte_string(dirname);
}
void platform_init()
@ -26,14 +26,14 @@ void platform_init()
s_serenity_resource_root = [] {
auto const* source_dir = getenv("SERENITY_SOURCE_DIR");
if (source_dir) {
return DeprecatedString::formatted("{}/Base", source_dir);
return ByteString::formatted("{}/Base", source_dir);
}
auto* home = getenv("XDG_CONFIG_HOME") ?: getenv("HOME");
VERIFY(home);
auto home_lagom = DeprecatedString::formatted("{}/.lagom", home);
auto home_lagom = ByteString::formatted("{}/.lagom", home);
if (FileSystem::is_directory(home_lagom))
return home_lagom;
auto app_dir = application_directory().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
auto app_dir = application_directory().release_value_but_fixme_should_propagate_errors().to_byte_string();
#ifdef AK_OS_MACOS
return LexicalPath(app_dir).parent().append("Resources"sv).string();
#else

View file

@ -7,7 +7,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Error.h>
#include <AK/String.h>
#include <AK/Vector.h>
@ -16,4 +16,4 @@ void platform_init();
ErrorOr<String> application_directory();
ErrorOr<Vector<String>> get_paths_for_helper_process(StringView process_name);
extern DeprecatedString s_serenity_resource_root;
extern ByteString s_serenity_resource_root;

View file

@ -131,9 +131,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
static ErrorOr<void> load_content_filters()
{
auto file_or_error = Core::File::open(DeprecatedString::formatted("{}/home/anon/.config/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read);
auto file_or_error = Core::File::open(ByteString::formatted("{}/home/anon/.config/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read);
if (file_or_error.is_error())
file_or_error = Core::File::open(DeprecatedString::formatted("{}/res/ladybird/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read);
file_or_error = Core::File::open(ByteString::formatted("{}/res/ladybird/BrowserContentFilters.txt", s_serenity_resource_root), Core::File::OpenMode::Read);
if (file_or_error.is_error())
return file_or_error.release_error();

View file

@ -30,7 +30,7 @@ static ErrorOr<pid_t> launch_process(StringView application, ReadonlySpan<char c
return result;
}
static ErrorOr<pid_t> launch_browser(DeprecatedString const& socket_path)
static ErrorOr<pid_t> launch_browser(ByteString const& socket_path)
{
return launch_process("Ladybird"sv,
Array {
@ -40,9 +40,9 @@ static ErrorOr<pid_t> launch_browser(DeprecatedString const& socket_path)
});
}
static ErrorOr<pid_t> launch_headless_browser(DeprecatedString const& socket_path)
static ErrorOr<pid_t> launch_headless_browser(ByteString const& socket_path)
{
auto resources = DeprecatedString::formatted("{}/res", s_serenity_resource_root);
auto resources = ByteString::formatted("{}/res", s_serenity_resource_root);
return launch_process("headless-browser"sv,
Array {
"--resources",
@ -78,7 +78,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
platform_init();
auto webdriver_socket_path = DeprecatedString::formatted("{}/webdriver", TRY(Core::StandardPaths::runtime_directory()));
auto webdriver_socket_path = ByteString::formatted("{}/webdriver", TRY(Core::StandardPaths::runtime_directory()));
TRY(Core::Directory::create(webdriver_socket_path, Core::Directory::CreateDirectories::Yes));
Core::EventLoop loop;

View file

@ -22,7 +22,7 @@
NSString* source_root = [[NSBundle mainBundle] executablePath];
for (int i = 0; i < 7; ++i)
source_root = [source_root stringByDeletingLastPathComponent];
auto source_root_string = DeprecatedString([source_root UTF8String]);
auto source_root_string = ByteString([source_root UTF8String]);
Core::ResourceImplementation::install(make<Core::ResourceImplementationFile>(MUST(String::formatted("{}/Base/res", source_root_string))));
}

View file

@ -68,16 +68,16 @@ static bool is_ui_dimension_property(StringView property)
}
// FIXME: Since normal string-based properties take either String or StringView (and the latter can be implicitly constructed from the former),
// we need to special-case DeprecatedString property setters while those still exist.
// we need to special-case ByteString property setters while those still exist.
// Please remove a setter from this list once it uses StringView or String.
static bool takes_deprecated_string(StringView property)
static bool takes_byte_string(StringView property)
{
static HashTable<StringView> deprecated_string_properties;
if (deprecated_string_properties.is_empty()) {
deprecated_string_properties.set("icon_from_path"sv);
deprecated_string_properties.set("name"sv);
static HashTable<StringView> byte_string_properties;
if (byte_string_properties.is_empty()) {
byte_string_properties.set("icon_from_path"sv);
byte_string_properties.set("name"sv);
}
return deprecated_string_properties.contains(property);
return byte_string_properties.contains(property);
}
static ErrorOr<String> include_path_for(StringView class_name, LexicalPath const& gml_file_name)
@ -141,7 +141,7 @@ static char const footer[] = R"~~~(
static ErrorOr<String> escape_string(JsonValue to_escape)
{
auto string = TRY(String::from_deprecated_string(to_escape.as_string()));
auto string = TRY(String::from_byte_string(to_escape.as_string()));
// All C++ simple escape sequences; see https://en.cppreference.com/w/cpp/language/escape
// Other commonly-escaped characters are hard-to-type Unicode and therefore fine to include verbatim in UTF-8 coded strings.
@ -194,7 +194,7 @@ static ErrorOr<String> generate_initializer_for(Optional<StringView> property_na
{
if (value.is_string()) {
if (property_name.has_value()) {
if (takes_deprecated_string(*property_name))
if (takes_byte_string(*property_name))
return String::formatted(R"~~~("{}"sv)~~~", TRY(escape_string(value)));
if (auto const enum_value = TRY(generate_enum_initializer_for(*property_name, value)); enum_value.has_value())
@ -252,7 +252,7 @@ static ErrorOr<String> generate_initializer_for(Optional<StringView> property_na
// All loading happens in a separate block.
static ErrorOr<void> generate_loader_for_object(GUI::GML::Object const& gml_object, SourceGenerator generator, String object_name, size_t indentation, UseObjectConstructor use_object_constructor)
{
generator.set("object_name", object_name.to_deprecated_string());
generator.set("object_name", object_name.to_byte_string());
generator.set("class_name", gml_object.name());
auto append = [&]<size_t N>(auto& generator, char const(&text)[N]) -> ErrorOr<void> {

View file

@ -17,12 +17,12 @@
#include <stdio.h>
struct Parameter {
Vector<DeprecatedString> attributes;
DeprecatedString type;
DeprecatedString name;
Vector<ByteString> attributes;
ByteString type;
ByteString name;
};
static DeprecatedString pascal_case(DeprecatedString const& identifier)
static ByteString pascal_case(ByteString const& identifier)
{
StringBuilder builder;
bool was_new_word = true;
@ -37,48 +37,48 @@ static DeprecatedString pascal_case(DeprecatedString const& identifier)
} else
builder.append(ch);
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
struct Message {
DeprecatedString name;
ByteString name;
bool is_synchronous { false };
Vector<Parameter> inputs;
Vector<Parameter> outputs;
DeprecatedString response_name() const
ByteString response_name() const
{
StringBuilder builder;
builder.append(pascal_case(name));
builder.append("Response"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
};
struct Endpoint {
Vector<DeprecatedString> includes;
DeprecatedString name;
Vector<ByteString> includes;
ByteString name;
u32 magic;
Vector<Message> messages;
};
static bool is_primitive_type(DeprecatedString const& type)
static bool is_primitive_type(ByteString const& type)
{
return type.is_one_of("u8", "i8", "u16", "i16", "u32", "i32", "u64", "i64", "size_t", "bool", "double", "float", "int", "unsigned", "unsigned int");
}
static bool is_simple_type(DeprecatedString const& type)
static bool is_simple_type(ByteString const& type)
{
// Small types that it makes sense just to pass by value.
return type.is_one_of("Gfx::Color", "Web::DevicePixels", "Gfx::IntPoint", "Gfx::FloatPoint", "Web::DevicePixelPoint", "Gfx::IntSize", "Gfx::FloatSize", "Web::DevicePixelSize", "Core::File::OpenMode");
}
static bool is_primitive_or_simple_type(DeprecatedString const& type)
static bool is_primitive_or_simple_type(ByteString const& type)
{
return is_primitive_type(type) || is_simple_type(type);
}
static DeprecatedString message_name(DeprecatedString const& endpoint, DeprecatedString const& message, bool is_response)
static ByteString message_name(ByteString const& endpoint, ByteString const& message, bool is_response)
{
StringBuilder builder;
builder.append("Messages::"sv);
@ -87,7 +87,7 @@ static DeprecatedString message_name(DeprecatedString const& endpoint, Deprecate
builder.append(pascal_case(message));
if (is_response)
builder.append("Response"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
Vector<Endpoint> parse(ByteBuffer const& file_contents)
@ -133,7 +133,7 @@ Vector<Endpoint> parse(ByteBuffer const& file_contents)
consume_whitespace();
}
}
// FIXME: This is not entirely correct. Types can have spaces, for example `HashMap<int, DeprecatedString>`.
// FIXME: This is not entirely correct. Types can have spaces, for example `HashMap<int, ByteString>`.
// Maybe we should use LibCpp::Parser for parsing types.
parameter.type = lexer.consume_until([](char ch) { return isspace(ch); });
if (parameter.type.ends_with(',')) {
@ -208,7 +208,7 @@ Vector<Endpoint> parse(ByteBuffer const& file_contents)
};
auto parse_include = [&] {
DeprecatedString include;
ByteString include;
consume_whitespace();
include = lexer.consume_while([](char ch) { return ch != '\n'; });
consume_whitespace();
@ -234,7 +234,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<DeprecatedString>::hash(endpoints.last().name);
endpoints.last().magic = Traits<ByteString>::hash(endpoints.last().name);
consume_whitespace();
assert_specific('{');
parse_messages();
@ -248,22 +248,22 @@ Vector<Endpoint> parse(ByteBuffer const& file_contents)
return endpoints;
}
HashMap<DeprecatedString, int> build_message_ids_for_endpoint(SourceGenerator generator, Endpoint const& endpoint)
HashMap<ByteString, int> build_message_ids_for_endpoint(SourceGenerator generator, Endpoint const& endpoint)
{
HashMap<DeprecatedString, int> message_ids;
HashMap<ByteString, 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", DeprecatedString::number(message_ids.size()));
generator.set("message.id", ByteString::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", DeprecatedString::number(message_ids.size()));
generator.set("message.id", ByteString::number(message_ids.size()));
generator.appendln(" @message.pascal_name@ = @message.id@,");
}
@ -272,14 +272,14 @@ HashMap<DeprecatedString, int> build_message_ids_for_endpoint(SourceGenerator ge
return message_ids;
}
DeprecatedString constructor_for_message(DeprecatedString const& name, Vector<Parameter> const& parameters)
ByteString constructor_for_message(ByteString const& name, Vector<Parameter> const& parameters)
{
StringBuilder builder;
builder.append(name);
if (parameters.is_empty()) {
builder.append("() {}"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
builder.append('(');
for (size_t i = 0; i < parameters.size(); ++i) {
@ -296,10 +296,10 @@ DeprecatedString constructor_for_message(DeprecatedString const& name, Vector<Pa
builder.append(", "sv);
}
builder.append(" {}"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
void do_message(SourceGenerator message_generator, DeprecatedString const& name, Vector<Parameter> const& parameters, DeprecatedString const& response_type = {})
void do_message(SourceGenerator message_generator, ByteString const& name, Vector<Parameter> const& parameters, ByteString const& response_type = {})
{
auto pascal_name = pascal_case(name);
message_generator.set("message.name", name);
@ -377,7 +377,7 @@ public:)~~~");
builder.append(", "sv);
}
message_generator.set("message.constructor_call_parameters", builder.to_deprecated_string());
message_generator.set("message.constructor_call_parameters", builder.to_byte_string());
message_generator.appendln(R"~~~(
return make<@message.pascal_name@>(@message.constructor_call_parameters@);
})~~~");
@ -432,17 +432,17 @@ private:
void do_message_for_proxy(SourceGenerator message_generator, Endpoint const& endpoint, Message const& message)
{
auto do_implement_proxy = [&](DeprecatedString const& name, Vector<Parameter> const& parameters, bool is_synchronous, bool is_try) {
DeprecatedString return_type = "void";
auto do_implement_proxy = [&](ByteString const& name, Vector<Parameter> const& parameters, bool is_synchronous, bool is_try) {
ByteString 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);
}
DeprecatedString inner_return_type = return_type;
ByteString inner_return_type = return_type;
if (is_try)
return_type = DeprecatedString::formatted("IPC::IPCErrorOr<{}>", return_type);
return_type = ByteString::formatted("IPC::IPCErrorOr<{}>", return_type);
message_generator.set("message.name", message.name);
message_generator.set("message.pascal_name", pascal_case(message.name));
@ -541,14 +541,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", DeprecatedString::number(endpoint.magic));
generator.set("endpoint.magic", ByteString::number(endpoint.magic));
generator.appendln("\nnamespace Messages::@endpoint.name@ {");
HashMap<DeprecatedString, int> message_ids = build_message_ids_for_endpoint(generator.fork(), endpoint);
HashMap<ByteString, int> message_ids = build_message_ids_for_endpoint(generator.fork(), endpoint);
for (auto const& message : endpoint.messages) {
DeprecatedString response_name;
ByteString response_name;
if (message.is_synchronous) {
response_name = message.response_name();
do_message(generator.fork(), response_name, message.outputs);
@ -611,7 +611,7 @@ public:
switch (message_id) {)~~~");
for (auto const& message : endpoint.messages) {
auto do_decode_message = [&](DeprecatedString const& name) {
auto do_decode_message = [&](ByteString const& name) {
auto message_generator = generator.fork();
message_generator.set("message.name", name);
@ -649,13 +649,13 @@ public:
virtual ~@endpoint.name@Stub() override { }
virtual u32 magic() const override { return @endpoint.magic@; }
virtual DeprecatedString name() const override { return "@endpoint.name@"; }
virtual ByteString name() const override { return "@endpoint.name@"; }
virtual ErrorOr<OwnPtr<IPC::MessageBuffer>> handle(const IPC::Message& message) override
{
switch (message.message_id()) {)~~~");
for (auto const& message : endpoint.messages) {
auto do_handle_message = [&](DeprecatedString const& name, Vector<Parameter> const& parameters, bool returns_something) {
auto do_handle_message = [&](ByteString const& name, Vector<Parameter> const& parameters, bool returns_something) {
auto message_generator = generator.fork();
StringBuilder argument_generator;
@ -671,7 +671,7 @@ public:
message_generator.set("message.pascal_name", pascal_case(name));
message_generator.set("message.response_type", pascal_case(message.response_name()));
message_generator.set("handler_name", name);
message_generator.set("arguments", argument_generator.to_deprecated_string());
message_generator.set("arguments", argument_generator.to_byte_string());
message_generator.appendln(R"~~~(
case (int)Messages::@endpoint.name@::MessageID::@message.pascal_name@: {)~~~");
if (returns_something) {
@ -709,8 +709,8 @@ public:
for (auto const& message : endpoint.messages) {
auto message_generator = generator.fork();
auto do_handle_message_decl = [&](DeprecatedString const& name, Vector<Parameter> const& parameters, bool is_response) {
DeprecatedString return_type = "void";
auto do_handle_message_decl = [&](ByteString const& name, Vector<Parameter> const& parameters, bool is_response) {
ByteString 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);
@ -719,7 +719,7 @@ public:
message_generator.appendln(R"~~~(
virtual @message.complex_return_type@ @handler_name@()~~~");
auto make_argument_type = [](DeprecatedString const& type) {
auto make_argument_type = [](ByteString const& type) {
StringBuilder builder;
bool const_ref = !is_primitive_or_simple_type(type);
@ -728,7 +728,7 @@ public:
if (const_ref)
builder.append(" const&"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
};
for (size_t i = 0; i < parameters.size(); ++i) {

View file

@ -5,7 +5,7 @@
*/
#include <AK/Array.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/JsonObject.h>
#include <AK/NumericLimits.h>
#include <AK/Optional.h>
@ -18,40 +18,40 @@
#include <LibMain/Main.h>
struct ArgumentDefinition {
Optional<DeprecatedString> name;
Optional<DeprecatedString> cpp_type;
DeprecatedString expression;
Optional<DeprecatedString> cast_to;
Optional<ByteString> name;
Optional<ByteString> cpp_type;
ByteString expression;
Optional<ByteString> cast_to;
};
struct FunctionDefinition {
DeprecatedString name;
DeprecatedString return_type;
ByteString name;
ByteString return_type;
Vector<ArgumentDefinition> arguments;
DeprecatedString implementation;
ByteString implementation;
bool unimplemented;
DeprecatedString variant_gl_type;
ByteString variant_gl_type;
};
struct VariantType {
DeprecatedString encoded_type;
Optional<DeprecatedString> implementation;
ByteString encoded_type;
Optional<ByteString> implementation;
bool unimplemented;
};
struct Variants {
Vector<DeprecatedString> api_suffixes { "" };
Vector<ByteString> api_suffixes { "" };
Vector<u32> argument_counts { NumericLimits<u32>::max() };
Vector<DeprecatedString> argument_defaults { "" };
Vector<ByteString> argument_defaults { "" };
bool convert_range { false };
Vector<VariantType> types {
{
.encoded_type = "",
.implementation = Optional<DeprecatedString> {},
.implementation = Optional<ByteString> {},
.unimplemented = false,
}
};
DeprecatedString pointer_argument { "" };
ByteString pointer_argument { "" };
};
struct EncodedTypeEntry {
@ -76,18 +76,18 @@ constexpr static Array<EncodedTypeEntry, 9> type_definitions = {
struct EncodedType {
EncodedTypeEntry type_entry;
DeprecatedString cpp_type;
DeprecatedString function_name_suffix;
ByteString cpp_type;
ByteString function_name_suffix;
bool is_pointer;
bool is_const_pointer;
};
Vector<DeprecatedString> get_name_list(Optional<JsonValue const&> name_definition)
Vector<ByteString> get_name_list(Optional<JsonValue const&> name_definition)
{
if (!name_definition.has_value() || name_definition->is_null())
return {};
Vector<DeprecatedString, 1> names;
Vector<ByteString, 1> names;
if (name_definition->is_string()) {
names.append(name_definition->as_string());
} else if (name_definition->is_array()) {
@ -101,12 +101,12 @@ Vector<DeprecatedString> get_name_list(Optional<JsonValue const&> name_definitio
return names;
}
Optional<EncodedType> get_encoded_type(DeprecatedString encoded_type)
Optional<EncodedType> get_encoded_type(ByteString encoded_type)
{
bool is_const_pointer = !encoded_type.ends_with('!');
if (!is_const_pointer)
encoded_type = encoded_type.substring_view(0, encoded_type.length() - 1);
DeprecatedString function_name_suffix = encoded_type;
ByteString function_name_suffix = encoded_type;
bool is_pointer = encoded_type.ends_with('v');
if (is_pointer)
@ -127,7 +127,7 @@ Optional<EncodedType> get_encoded_type(DeprecatedString encoded_type)
return EncodedType {
.type_entry = type_definition.value(),
.cpp_type = DeprecatedString::formatted(
.cpp_type = ByteString::formatted(
"{}{}{}",
type_definition->cpp_type,
is_pointer && is_const_pointer ? " const" : "",
@ -138,7 +138,7 @@ Optional<EncodedType> get_encoded_type(DeprecatedString encoded_type)
};
}
DeprecatedString wrap_expression_in_range_conversion(DeprecatedString source_type, DeprecatedString target_type, DeprecatedString expression)
ByteString wrap_expression_in_range_conversion(ByteString source_type, ByteString target_type, ByteString expression)
{
VERIFY(target_type == "GLfloat" || target_type == "GLdouble");
@ -147,19 +147,19 @@ DeprecatedString wrap_expression_in_range_conversion(DeprecatedString source_typ
return expression;
if (source_type == "GLbyte")
return DeprecatedString::formatted("({} + 128.) / 127.5 - 1.", expression);
return ByteString::formatted("({} + 128.) / 127.5 - 1.", expression);
else if (source_type == "GLfloat")
return DeprecatedString::formatted("static_cast<GLdouble>({})", expression);
return ByteString::formatted("static_cast<GLdouble>({})", expression);
else if (source_type == "GLint")
return DeprecatedString::formatted("({} + 2147483648.) / 2147483647.5 - 1.", expression);
return ByteString::formatted("({} + 2147483648.) / 2147483647.5 - 1.", expression);
else if (source_type == "GLshort")
return DeprecatedString::formatted("({} + 32768.) / 32767.5 - 1.", expression);
return ByteString::formatted("({} + 32768.) / 32767.5 - 1.", expression);
else if (source_type == "GLubyte")
return DeprecatedString::formatted("{} / 255.", expression);
return ByteString::formatted("{} / 255.", expression);
else if (source_type == "GLuint")
return DeprecatedString::formatted("{} / 4294967296.", expression);
return ByteString::formatted("{} / 4294967296.", expression);
else if (source_type == "GLushort")
return DeprecatedString::formatted("{} / 65536.", expression);
return ByteString::formatted("{} / 65536.", expression);
VERIFY_NOT_REACHED();
}
@ -189,7 +189,7 @@ Variants read_variants_settings(JsonObject const& variants_obj)
});
}
if (variants_obj.has_string("pointer_argument"sv)) {
variants.pointer_argument = variants_obj.get_deprecated_string("pointer_argument"sv).value();
variants.pointer_argument = variants_obj.get_byte_string("pointer_argument"sv).value();
}
if (variants_obj.has_object("types"sv)) {
variants.types.clear_with_capacity();
@ -197,7 +197,7 @@ Variants read_variants_settings(JsonObject const& variants_obj)
auto const& type = type_value.as_object();
variants.types.append(VariantType {
.encoded_type = key,
.implementation = type.get_deprecated_string("implementation"sv),
.implementation = type.get_byte_string("implementation"sv),
.unimplemented = type.get_bool("unimplemented"sv).value_or(false),
});
});
@ -223,20 +223,20 @@ Vector<ArgumentDefinition> copy_arguments_for_variant(Vector<ArgumentDefinition>
// Pointer argument
if (encoded_type.is_pointer) {
variant_arguments[i].name = (variadic_index == 0) ? variants.pointer_argument : Optional<DeprecatedString> {};
variant_arguments[i].name = (variadic_index == 0) ? variants.pointer_argument : Optional<ByteString> {};
if (variadic_index >= argument_count) {
// If this variable argument is past the argument count, fall back to the defaults
variant_arguments[i].expression = variants.argument_defaults[variadic_index];
variant_arguments[i].cast_to = Optional<DeprecatedString> {};
variant_arguments[i].cast_to = Optional<ByteString> {};
} else if (argument_count == 1 && variants.argument_counts.size() == 1) {
// Otherwise, if the pointer is the only variadic argument, pass it through unchanged
variant_arguments[i].cast_to = Optional<DeprecatedString> {};
variant_arguments[i].cast_to = Optional<ByteString> {};
} else {
// Otherwise, index into the pointer argument
auto indexed_expression = DeprecatedString::formatted("{}[{}]", variants.pointer_argument, variadic_index);
auto indexed_expression = ByteString::formatted("{}[{}]", variants.pointer_argument, variadic_index);
if (variants.convert_range && cast_to.has_value())
indexed_expression = wrap_expression_in_range_conversion(base_cpp_type, cast_to.value(), indexed_expression);
variant_arguments[i].expression = indexed_expression;
@ -246,9 +246,9 @@ Vector<ArgumentDefinition> copy_arguments_for_variant(Vector<ArgumentDefinition>
// Regular argument
if (variadic_index >= argument_count) {
// If the variable argument is past the argument count, fall back to the defaults
variant_arguments[i].name = Optional<DeprecatedString> {};
variant_arguments[i].name = Optional<ByteString> {};
variant_arguments[i].expression = variants.argument_defaults[variadic_index];
variant_arguments[i].cast_to = Optional<DeprecatedString> {};
variant_arguments[i].cast_to = Optional<ByteString> {};
} else if (variants.convert_range && cast_to.has_value()) {
// Otherwise, if we need to convert the input values, wrap the expression in a range conversion
@ -261,7 +261,7 @@ Vector<ArgumentDefinition> copy_arguments_for_variant(Vector<ArgumentDefinition>
// Determine if we can skip casting to the target type
if (cast_to == base_cpp_type || (variants.convert_range && cast_to == "GLdouble"))
variant_arguments[i].cast_to = Optional<DeprecatedString> {};
variant_arguments[i].cast_to = Optional<ByteString> {};
variadic_index++;
}
@ -269,7 +269,7 @@ Vector<ArgumentDefinition> copy_arguments_for_variant(Vector<ArgumentDefinition>
return variant_arguments;
}
Vector<FunctionDefinition> create_function_definitions(DeprecatedString function_name, JsonObject const& function_definition)
Vector<FunctionDefinition> create_function_definitions(ByteString function_name, JsonObject const& function_definition)
{
// A single function definition can expand to multiple generated functions by way of:
// - differing API suffices (ARB, EXT, etc.);
@ -284,17 +284,17 @@ Vector<FunctionDefinition> create_function_definitions(DeprecatedString function
VERIFY(argument_value.is_object());
auto const& argument = argument_value.as_object();
auto type = argument.get_deprecated_string("type"sv);
auto type = argument.get_byte_string("type"sv);
auto argument_names = get_name_list(argument.get("name"sv));
auto expression = argument.get_deprecated_string("expression"sv).value_or("@argument_name@");
auto cast_to = argument.get_deprecated_string("cast_to"sv);
auto expression = argument.get_byte_string("expression"sv).value_or("@argument_name@");
auto cast_to = argument.get_byte_string("cast_to"sv);
// Add an empty dummy name when all we have is an expression
if (argument_names.is_empty() && !expression.is_empty())
argument_names.append("");
for (auto const& argument_name : argument_names) {
argument_definitions.append({ .name = argument_name.is_empty() ? Optional<DeprecatedString> {} : argument_name,
argument_definitions.append({ .name = argument_name.is_empty() ? Optional<ByteString> {} : argument_name,
.cpp_type = type,
.expression = expression,
.cast_to = cast_to });
@ -304,8 +304,8 @@ Vector<FunctionDefinition> create_function_definitions(DeprecatedString function
// Create functions for each name and/or variant
Vector<FunctionDefinition> functions;
auto return_type = function_definition.get_deprecated_string("return_type"sv).value_or("void");
auto function_implementation = function_definition.get_deprecated_string("implementation"sv).value_or(function_name.to_snakecase());
auto return_type = function_definition.get_byte_string("return_type"sv).value_or("void");
auto function_implementation = function_definition.get_byte_string("implementation"sv).value_or(function_name.to_snakecase());
auto function_unimplemented = function_definition.get_bool("unimplemented"sv).value_or(false);
if (!function_definition.has("variants"sv)) {
@ -336,10 +336,10 @@ Vector<FunctionDefinition> create_function_definitions(DeprecatedString function
for (auto const& api_suffix : variants.api_suffixes) {
functions.append({
.name = DeprecatedString::formatted(
.name = ByteString::formatted(
"{}{}{}{}",
function_name,
variants.argument_counts.size() > 1 ? DeprecatedString::formatted("{}", argument_count) : "",
variants.argument_counts.size() > 1 ? ByteString::formatted("{}", argument_count) : "",
encoded_type.has_value() && variants.types.size() > 1 ? encoded_type->function_name_suffix : "",
api_suffix),
.return_type = return_type,

View file

@ -6,8 +6,8 @@
#include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common.
#include <AK/AllOf.h>
#include <AK/ByteString.h>
#include <AK/CharacterTypes.h>
#include <AK/DeprecatedString.h>
#include <AK/Error.h>
#include <AK/Find.h>
#include <AK/Format.h>
@ -487,7 +487,7 @@ struct AK::Formatter<Locale::HourCycle> : Formatter<FormatString> {
};
struct LocaleData {
HashMap<DeprecatedString, size_t> calendars;
HashMap<ByteString, 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<DeprecatedString, LocaleData> locales;
HashMap<ByteString, LocaleData> locales;
HashMap<DeprecatedString, size_t> hour_cycles;
Vector<DeprecatedString> hour_cycle_regions;
HashMap<ByteString, size_t> hour_cycles;
Vector<ByteString> hour_cycle_regions;
HashMap<DeprecatedString, u8> minimum_days;
Vector<DeprecatedString> minimum_days_regions;
HashMap<ByteString, u8> minimum_days;
Vector<ByteString> minimum_days_regions;
HashMap<DeprecatedString, Locale::Weekday> first_day;
Vector<DeprecatedString> first_day_regions;
HashMap<ByteString, Locale::Weekday> first_day;
Vector<ByteString> first_day_regions;
HashMap<DeprecatedString, Locale::Weekday> weekend_start;
Vector<DeprecatedString> weekend_start_regions;
HashMap<ByteString, Locale::Weekday> weekend_start;
Vector<ByteString> weekend_start_regions;
HashMap<DeprecatedString, Locale::Weekday> weekend_end;
Vector<DeprecatedString> weekend_end_regions;
HashMap<ByteString, Locale::Weekday> weekend_end;
Vector<ByteString> weekend_end_regions;
HashMap<DeprecatedString, Vector<TimeZone::TimeZone>> meta_zones;
Vector<DeprecatedString> time_zones { "UTC"sv };
HashMap<ByteString, Vector<TimeZone::TimeZone>> meta_zones;
Vector<ByteString> time_zones { "UTC"sv };
Vector<DeprecatedString> calendars;
Vector<ByteString> 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(DeprecatedString core_path, CLDR& cldr)
static ErrorOr<void> parse_hour_cycles(ByteString core_path, CLDR& cldr)
{
// https://unicode.org/reports/tr35/tr35-dates.html#Time_Data
LexicalPath time_data_path(move(core_path));
@ -587,7 +587,7 @@ static ErrorOr<void> parse_hour_cycles(DeprecatedString core_path, CLDR& cldr)
};
time_data_object.for_each_member([&](auto const& key, JsonValue const& value) {
auto allowed_hour_cycles_string = value.as_object().get_deprecated_string("_allowed"sv).value();
auto allowed_hour_cycles_string = value.as_object().get_byte_string("_allowed"sv).value();
auto allowed_hour_cycles = allowed_hour_cycles_string.split_view(' ');
Vector<Locale::HourCycle> hour_cycles;
@ -607,7 +607,7 @@ static ErrorOr<void> parse_hour_cycles(DeprecatedString core_path, CLDR& cldr)
return {};
}
static ErrorOr<void> parse_week_data(DeprecatedString core_path, CLDR& cldr)
static ErrorOr<void> parse_week_data(ByteString 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(DeprecatedString core_path, CLDR& cldr)
return {};
}
static ErrorOr<void> parse_meta_zones(DeprecatedString core_path, CLDR& cldr)
static ErrorOr<void> parse_meta_zones(ByteString core_path, CLDR& cldr)
{
// https://unicode.org/reports/tr35/tr35-dates.html#Metazones
LexicalPath meta_zone_path(move(core_path));
@ -686,8 +686,8 @@ static ErrorOr<void> parse_meta_zones(DeprecatedString core_path, CLDR& cldr)
meta_zone_array.for_each([&](JsonValue const& value) {
auto const& mapping = value.as_object().get_object("mapZone"sv).value();
auto const& meta_zone = mapping.get_deprecated_string("_other"sv).value();
auto const& golden_zone = mapping.get_deprecated_string("_type"sv).value();
auto const& meta_zone = mapping.get_byte_string("_other"sv).value();
auto const& golden_zone = mapping.get_byte_string("_type"sv).value();
if (auto time_zone = TimeZone::time_zone_from_string(golden_zone); time_zone.has_value()) {
auto& golden_zones = cldr.meta_zones.ensure(meta_zone);
@ -770,7 +770,7 @@ static ErrorOr<String> remove_period_from_pattern(String pattern)
return pattern;
}
static ErrorOr<Optional<CalendarPattern>> parse_date_time_pattern_raw(DeprecatedString pattern, DeprecatedString skeleton, CLDR& cldr)
static ErrorOr<Optional<CalendarPattern>> parse_date_time_pattern_raw(ByteString pattern, ByteString skeleton, CLDR& cldr)
{
// https://unicode.org/reports/tr35/tr35-dates.html#Date_Field_Symbol_Table
using Locale::CalendarPatternStyle;
@ -989,16 +989,16 @@ static ErrorOr<Optional<CalendarPattern>> parse_date_time_pattern_raw(Deprecated
return format;
}
static ErrorOr<Optional<size_t>> parse_date_time_pattern(DeprecatedString pattern, DeprecatedString skeleton, CLDR& cldr)
static ErrorOr<Optional<size_t>> parse_date_time_pattern(ByteString pattern, ByteString skeleton, CLDR& cldr)
{
auto format = TRY(parse_date_time_pattern_raw(move(pattern), move(skeleton), cldr));
if (!format.has_value())
return OptionalNone {};
format->pattern_index = cldr.unique_strings.ensure(format->pattern.to_deprecated_string());
format->pattern_index = cldr.unique_strings.ensure(format->pattern.to_byte_string());
if (format->pattern12.has_value())
format->pattern12_index = cldr.unique_strings.ensure(format->pattern12->to_deprecated_string());
format->pattern12_index = cldr.unique_strings.ensure(format->pattern12->to_byte_string());
return Optional<size_t> { cldr.unique_patterns.ensure(format.release_value()) };
}
@ -1388,7 +1388,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(DeprecatedString locale_calendars_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_calendars(ByteString locale_calendars_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath calendars_path(move(locale_calendars_path));
if (!calendars_path.basename().starts_with("ca-"sv))
@ -1402,10 +1402,10 @@ static ErrorOr<void> parse_calendars(DeprecatedString locale_calendars_path, CLD
auto parse_patterns = [&](auto const& patterns_object, auto const& skeletons_object, Vector<CalendarPattern>* patterns) -> ErrorOr<size_t> {
auto parse_pattern = [&](auto name) -> ErrorOr<size_t> {
auto format = patterns_object.get_deprecated_string(name);
auto skeleton = skeletons_object.get_deprecated_string(name);
auto format = patterns_object.get_byte_string(name);
auto skeleton = skeletons_object.get_byte_string(name);
auto format_index = TRY(parse_date_time_pattern(format.value(), skeleton.value_or(DeprecatedString::empty()), cldr)).value();
auto format_index = TRY(parse_date_time_pattern(format.value(), skeleton.value_or(ByteString::empty()), cldr)).value();
if (patterns)
patterns->append(cldr.unique_patterns.get(format_index));
@ -1483,7 +1483,7 @@ static ErrorOr<void> parse_calendars(DeprecatedString locale_calendars_path, CLD
return {};
}
static ErrorOr<void> parse_time_zone_names(DeprecatedString locale_time_zone_names_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_time_zone_names(ByteString 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);
@ -1494,9 +1494,9 @@ static ErrorOr<void> parse_time_zone_names(DeprecatedString locale_time_zone_nam
auto const& dates_object = locale_object.get_object("dates"sv).value();
auto const& time_zone_names_object = dates_object.get_object("timeZoneNames"sv).value();
auto const& meta_zone_object = time_zone_names_object.get_object("metazone"sv);
auto const& hour_format_string = time_zone_names_object.get_deprecated_string("hourFormat"sv).value();
auto const& gmt_format_string = time_zone_names_object.get_deprecated_string("gmtFormat"sv).value();
auto const& gmt_zero_format_string = time_zone_names_object.get_deprecated_string("gmtZeroFormat"sv).value();
auto const& hour_format_string = time_zone_names_object.get_byte_string("hourFormat"sv).value();
auto const& gmt_format_string = time_zone_names_object.get_byte_string("gmtFormat"sv).value();
auto const& gmt_zero_format_string = time_zone_names_object.get_byte_string("gmtZeroFormat"sv).value();
if (!meta_zone_object.has_value())
return {};
@ -1506,7 +1506,7 @@ static ErrorOr<void> parse_time_zone_names(DeprecatedString locale_time_zone_nam
if (!names.has_value())
return {};
auto const& name = names->get_deprecated_string(key);
auto const& name = names->get_byte_string(key);
if (name.has_value())
return cldr.unique_strings.ensure(name.value());
@ -1592,7 +1592,7 @@ static ErrorOr<void> parse_time_zone_names(DeprecatedString locale_time_zone_nam
return {};
}
static ErrorOr<void> parse_day_periods(DeprecatedString core_path, CLDR& cldr)
static ErrorOr<void> parse_day_periods(ByteString core_path, CLDR& cldr)
{
// https://unicode.org/reports/tr35/tr35-dates.html#Day_Period_Rule_Sets
LexicalPath day_periods_path(move(core_path));
@ -1622,8 +1622,8 @@ static ErrorOr<void> parse_day_periods(DeprecatedString core_path, CLDR& cldr)
if (!day_period.has_value())
return {};
auto begin = parse_hour(ranges.get_deprecated_string("_from"sv).value());
auto end = parse_hour(ranges.get_deprecated_string("_before"sv).value());
auto begin = parse_hour(ranges.get_byte_string("_from"sv).value());
auto end = parse_hour(ranges.get_byte_string("_before"sv).value());
return DayPeriod { *day_period, begin, end };
};
@ -1648,13 +1648,13 @@ static ErrorOr<void> parse_day_periods(DeprecatedString core_path, CLDR& cldr)
return {};
}
static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedString dates_path, CLDR& cldr)
static ErrorOr<void> parse_all_locales(ByteString core_path, ByteString dates_path, CLDR& cldr)
{
TRY(parse_hour_cycles(core_path, cldr));
TRY(parse_week_data(core_path, cldr));
TRY(parse_meta_zones(core_path, cldr));
auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr<DeprecatedString> {
auto remove_variants_from_path = [&](ByteString path) -> ErrorOr<ByteString> {
auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path)));
StringBuilder builder;
@ -1664,7 +1664,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedStr
if (auto region = cldr.unique_strings.get(parsed_locale.region); !region.is_empty())
builder.appendff("-{}", region);
return builder.to_deprecated_string();
return builder.to_byte_string();
};
TRY(Core::Directory::for_each_entry(TRY(String::formatted("{}/main", dates_path)), Core::DirIterator::SkipParentAndBaseDir, [&](auto& entry, auto& directory) -> ErrorOr<IterationDecision> {
@ -1687,15 +1687,15 @@ static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedStr
return {};
}
static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier)
static ByteString format_identifier(StringView owner, ByteString identifier)
{
identifier = identifier.replace("-"sv, "_"sv, ReplaceMode::All);
identifier = identifier.replace("/"sv, "_"sv, ReplaceMode::All);
if (all_of(identifier, is_ascii_digit))
return DeprecatedString::formatted("{}_{}", owner[0], identifier);
return ByteString::formatted("{}_{}", owner[0], identifier);
if (is_ascii_lower_alpha(identifier[0]))
return DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
return ByteString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
return identifier;
}
@ -1953,9 +1953,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 = [&](DeprecatedString name, auto const& calendars) {
auto append_calendars = [&](ByteString name, auto const& calendars) {
generator.set("name", name);
generator.set("size", DeprecatedString::number(calendars.size()));
generator.set("size", ByteString::number(calendars.size()));
generator.append(R"~~~(
static constexpr Array<@calendar_index_type@, @size@> @name@ { {)~~~");
@ -1965,7 +1965,7 @@ static constexpr Array<@calendar_index_type@, @size@> @name@ { {)~~~");
auto calendar = calendars.find(calendar_key)->value;
generator.append(first ? " "sv : ", "sv);
generator.append(DeprecatedString::number(calendar));
generator.append(ByteString::number(calendar));
first = false;
}
@ -1975,7 +1975,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", DeprecatedString::number(keys.size()));
generator.set("size", ByteString::number(keys.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> @name@ { {)~~~");
@ -1986,7 +1986,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~");
auto mapping = mapping_getter(value);
generator.append(first ? " "sv : ", "sv);
generator.append(DeprecatedString::number(mapping));
generator.append(ByteString::number(mapping));
first = false;
}
@ -2008,7 +2008,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 = {}) -> ErrorOr<void> {
HashValueMap<DeprecatedString> hashes;
HashValueMap<ByteString> hashes;
TRY(hashes.try_ensure_capacity(values.size()));
for (auto const& value : values)

View file

@ -6,8 +6,8 @@
#include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common.
#include <AK/AllOf.h>
#include <AK/ByteString.h>
#include <AK/CharacterTypes.h>
#include <AK/DeprecatedString.h>
#include <AK/Error.h>
#include <AK/Format.h>
#include <AK/HashMap.h>
@ -22,14 +22,14 @@
#include <LibCore/Directory.h>
#include <LibFileSystem/FileSystem.h>
static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier)
static ByteString format_identifier(StringView owner, ByteString identifier)
{
identifier = identifier.replace("-"sv, "_"sv, ReplaceMode::All);
if (all_of(identifier, is_ascii_digit))
return DeprecatedString::formatted("{}_{}", owner[0], identifier);
return ByteString::formatted("{}_{}", owner[0], identifier);
if (is_ascii_lower_alpha(identifier[0]))
return DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
return ByteString::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 {
DeprecatedString language;
Optional<DeprecatedString> territory;
Optional<DeprecatedString> variant;
ByteString language;
Optional<ByteString> territory;
Optional<ByteString> variant;
size_t display_patterns { 0 };
size_t languages { 0 };
size_t territories { 0 };
@ -195,25 +195,25 @@ struct CLDR {
UniqueStorage<ListPatternList> unique_list_pattern_lists;
UniqueStorage<TextLayout> unique_text_layouts;
HashMap<DeprecatedString, LocaleData> locales;
HashMap<ByteString, LocaleData> locales;
Vector<Alias> locale_aliases;
Vector<DeprecatedString> languages;
Vector<ByteString> languages;
HashMap<StringView, size_t> language_indices;
Vector<DeprecatedString> territories;
Vector<ByteString> territories;
HashMap<StringView, size_t> territory_indices;
Vector<DeprecatedString> scripts;
Vector<ByteString> scripts;
HashMap<StringView, size_t> script_indices;
Vector<DeprecatedString> variants;
Vector<ByteString> variants;
HashMap<StringView, size_t> variant_indices;
Vector<DeprecatedString> currencies;
Vector<ByteString> currencies;
HashMap<StringView, size_t> currency_indices;
Vector<DeprecatedString> date_fields;
Vector<ByteString> date_fields;
HashMap<StringView, size_t> date_fields_indices;
Vector<Alias> date_field_aliases {
@ -224,17 +224,17 @@ struct CLDR {
{ "zone"sv, "timeZoneName"sv },
};
HashMap<DeprecatedString, Vector<DeprecatedString>> keywords;
HashMap<DeprecatedString, Vector<Alias>> keyword_aliases;
HashMap<DeprecatedString, DeprecatedString> keyword_names;
HashMap<ByteString, Vector<ByteString>> keywords;
HashMap<ByteString, Vector<Alias>> keyword_aliases;
HashMap<ByteString, ByteString> 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<ByteString> list_pattern_types;
Vector<ByteString> character_orders;
HashMap<ByteString, size_t> language_aliases;
HashMap<ByteString, size_t> territory_aliases;
HashMap<ByteString, size_t> script_aliases;
HashMap<ByteString, size_t> variant_aliases;
HashMap<ByteString, size_t> subdivision_aliases;
Vector<LanguageMapping> complex_mappings;
Vector<LanguageMapping> likely_subtags;
size_t max_variant_size { 0 };
@ -253,9 +253,9 @@ struct CLDR {
})
// NOTE: We return a pointer only because ErrorOr cannot store references. You may safely assume the pointer is non-null.
ErrorOr<JsonValue const*> read_json_file_with_cache(DeprecatedString const& path)
ErrorOr<JsonValue const*> read_json_file_with_cache(ByteString const& path)
{
static HashMap<DeprecatedString, JsonValue> parsed_json_cache;
static HashMap<ByteString, JsonValue> parsed_json_cache;
if (auto parsed_json = parsed_json_cache.get(path); parsed_json.has_value())
return &parsed_json.value();
@ -273,7 +273,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(DeprecatedString core_supplemental_path, CLDR& cldr)
static ErrorOr<void> parse_core_aliases(ByteString core_supplemental_path, CLDR& cldr)
{
LexicalPath core_aliases_path(move(core_supplemental_path));
core_aliases_path = core_aliases_path.append("aliases.json"sv);
@ -285,7 +285,7 @@ static ErrorOr<void> parse_core_aliases(DeprecatedString core_supplemental_path,
auto append_aliases = [&](auto& alias_object, auto& alias_map) {
alias_object.for_each_member([&](auto const& key, JsonValue const& value) {
auto alias = value.as_object().get_deprecated_string("_replacement"sv).value();
auto alias = value.as_object().get_byte_string("_replacement"sv).value();
if (key.contains('-')) {
auto mapping = TRY_OR_DISCARD(parse_language_mapping(cldr, key, alias));
@ -307,7 +307,7 @@ static ErrorOr<void> parse_core_aliases(DeprecatedString core_supplemental_path,
return {};
}
static ErrorOr<void> parse_likely_subtags(DeprecatedString core_supplemental_path, CLDR& cldr)
static ErrorOr<void> parse_likely_subtags(ByteString core_supplemental_path, CLDR& cldr)
{
LexicalPath likely_subtags_path(move(core_supplemental_path));
likely_subtags_path = likely_subtags_path.append("likelySubtags.json"sv);
@ -326,7 +326,7 @@ static ErrorOr<void> parse_likely_subtags(DeprecatedString core_supplemental_pat
return {};
}
static ErrorOr<void> parse_identity(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_identity(ByteString locale_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath locale_display_names_path(move(locale_path)); // Note: Every JSON file defines identity data, so we can use any of them.
locale_display_names_path = locale_display_names_path.append("localeDisplayNames.json"sv);
@ -335,10 +335,10 @@ static ErrorOr<void> parse_identity(DeprecatedString locale_path, CLDR& cldr, Lo
auto const& main_object = locale_display_names.as_object().get_object("main"sv).value();
auto const& locale_object = main_object.get_object(locale_display_names_path.parent().basename()).value();
auto const& identity_object = locale_object.get_object("identity"sv).value();
auto const& language_string = identity_object.get_deprecated_string("language"sv).value();
auto const& territory_string = identity_object.get_deprecated_string("territory"sv);
auto const& script_string = identity_object.get_deprecated_string("script"sv);
auto const& variant_string = identity_object.get_deprecated_string("variant"sv);
auto const& language_string = identity_object.get_byte_string("language"sv).value();
auto const& territory_string = identity_object.get_byte_string("territory"sv);
auto const& script_string = identity_object.get_byte_string("script"sv);
auto const& variant_string = identity_object.get_byte_string("variant"sv);
locale.language = language_string;
@ -372,7 +372,7 @@ static ErrorOr<void> parse_identity(DeprecatedString locale_path, CLDR& cldr, Lo
return {};
}
static ErrorOr<void> parse_locale_display_patterns(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_locale_display_patterns(ByteString 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);
@ -382,8 +382,8 @@ static ErrorOr<void> parse_locale_display_patterns(DeprecatedString locale_path,
auto const& locale_object = main_object.get_object(locale_display_names_path.parent().basename()).value();
auto const& locale_display_names_object = locale_object.get_object("localeDisplayNames"sv).value();
auto const& locale_display_patterns_object = locale_display_names_object.get_object("localeDisplayPattern"sv).value();
auto const& locale_pattern = locale_display_patterns_object.get_deprecated_string("localePattern"sv).value();
auto const& locale_separator = locale_display_patterns_object.get_deprecated_string("localeSeparator"sv).value();
auto const& locale_pattern = locale_display_patterns_object.get_byte_string("localePattern"sv).value();
auto const& locale_separator = locale_display_patterns_object.get_byte_string("localeSeparator"sv).value();
DisplayPattern patterns {};
patterns.locale_pattern = cldr.unique_strings.ensure(locale_pattern);
@ -393,7 +393,7 @@ static ErrorOr<void> parse_locale_display_patterns(DeprecatedString locale_path,
return {};
}
static ErrorOr<void> preprocess_languages(DeprecatedString locale_path, CLDR& cldr)
static ErrorOr<void> preprocess_languages(ByteString locale_path, CLDR& cldr)
{
LexicalPath languages_path(move(locale_path));
languages_path = languages_path.append("languages.json"sv);
@ -417,7 +417,7 @@ static ErrorOr<void> preprocess_languages(DeprecatedString locale_path, CLDR& cl
return {};
}
static ErrorOr<void> preprocess_currencies(DeprecatedString numbers_path, CLDR& cldr)
static ErrorOr<void> preprocess_currencies(ByteString numbers_path, CLDR& cldr)
{
LexicalPath currencies_path(move(numbers_path));
currencies_path = currencies_path.append("currencies.json"sv);
@ -445,7 +445,7 @@ static bool is_sanctioned_date_field(StringView field)
return field.is_one_of("era"sv, "year"sv, "quarter"sv, "month"sv, "week"sv, "weekday"sv, "day"sv, "dayperiod"sv, "hour"sv, "minute"sv, "second"sv, "zone"sv);
}
static ErrorOr<void> preprocess_date_fields(DeprecatedString dates_path, CLDR& cldr)
static ErrorOr<void> preprocess_date_fields(ByteString dates_path, CLDR& cldr)
{
LexicalPath date_fields_path(move(dates_path));
date_fields_path = date_fields_path.append("dateFields.json"sv);
@ -469,7 +469,7 @@ static ErrorOr<void> preprocess_date_fields(DeprecatedString dates_path, CLDR& c
return {};
}
static ErrorOr<void> parse_unicode_extension_keywords(DeprecatedString bcp47_path, CLDR& cldr)
static ErrorOr<void> parse_unicode_extension_keywords(ByteString 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));
@ -483,7 +483,7 @@ static ErrorOr<void> parse_unicode_extension_keywords(DeprecatedString bcp47_pat
if (!desired_keywords.span().contains_slow(key))
return;
auto const& name = value.as_object().get_deprecated_string("_alias"sv).value();
auto const& name = value.as_object().get_byte_string("_alias"sv).value();
cldr.keyword_names.set(key, name);
auto& keywords = cldr.keywords.ensure(key);
@ -505,12 +505,12 @@ static ErrorOr<void> parse_unicode_extension_keywords(DeprecatedString bcp47_pat
if (key == "nu"sv && keyword.is_one_of("finance"sv, "native"sv, "traditio"sv))
return;
if (auto const& preferred = properties.as_object().get_deprecated_string("_preferred"sv); preferred.has_value()) {
if (auto const& preferred = properties.as_object().get_byte_string("_preferred"sv); preferred.has_value()) {
cldr.keyword_aliases.ensure(key).append({ preferred.value(), keyword });
return;
}
if (auto const& alias = properties.as_object().get_deprecated_string("_alias"sv); alias.has_value())
if (auto const& alias = properties.as_object().get_byte_string("_alias"sv); alias.has_value())
cldr.keyword_aliases.ensure(key).append({ keyword, alias.value() });
keywords.append(keyword);
@ -520,7 +520,7 @@ static ErrorOr<void> parse_unicode_extension_keywords(DeprecatedString bcp47_pat
return {};
}
static Optional<DeprecatedString> find_keyword_alias(StringView key, StringView calendar, CLDR& cldr)
static Optional<ByteString> find_keyword_alias(StringView key, StringView calendar, CLDR& cldr)
{
auto it = cldr.keyword_aliases.find(key);
if (it == cldr.keyword_aliases.end())
@ -533,7 +533,7 @@ static Optional<DeprecatedString> find_keyword_alias(StringView key, StringView
return alias->name;
}
static ErrorOr<void> parse_locale_languages(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_locale_languages(ByteString locale_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath languages_path(move(locale_path));
languages_path = languages_path.append("languages.json"sv);
@ -567,7 +567,7 @@ static ErrorOr<void> parse_locale_languages(DeprecatedString locale_path, CLDR&
return {};
}
static ErrorOr<void> parse_locale_territories(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_locale_territories(ByteString locale_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath territories_path(move(locale_path));
territories_path = territories_path.append("territories.json"sv);
@ -598,7 +598,7 @@ static ErrorOr<void> parse_locale_territories(DeprecatedString locale_path, CLDR
return {};
}
static ErrorOr<void> parse_locale_scripts(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_locale_scripts(ByteString locale_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath scripts_path(move(locale_path));
scripts_path = scripts_path.append("scripts.json"sv);
@ -629,7 +629,7 @@ static ErrorOr<void> parse_locale_scripts(DeprecatedString locale_path, CLDR& cl
return {};
}
static ErrorOr<void> parse_locale_list_patterns(DeprecatedString misc_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_locale_list_patterns(ByteString misc_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath list_patterns_path(move(misc_path));
list_patterns_path = list_patterns_path.append("listPatterns.json"sv);
@ -664,10 +664,10 @@ static ErrorOr<void> parse_locale_list_patterns(DeprecatedString misc_path, CLDR
auto type = list_pattern_type(key);
auto style = list_pattern_style(key);
auto start = cldr.unique_strings.ensure(value.as_object().get_deprecated_string("start"sv).value());
auto middle = cldr.unique_strings.ensure(value.as_object().get_deprecated_string("middle"sv).value());
auto end = cldr.unique_strings.ensure(value.as_object().get_deprecated_string("end"sv).value());
auto pair = cldr.unique_strings.ensure(value.as_object().get_deprecated_string("2"sv).value());
auto start = cldr.unique_strings.ensure(value.as_object().get_byte_string("start"sv).value());
auto middle = cldr.unique_strings.ensure(value.as_object().get_byte_string("middle"sv).value());
auto end = cldr.unique_strings.ensure(value.as_object().get_byte_string("end"sv).value());
auto pair = cldr.unique_strings.ensure(value.as_object().get_byte_string("2"sv).value());
if (!cldr.list_pattern_types.contains_slow(type))
cldr.list_pattern_types.append(type);
@ -680,7 +680,7 @@ static ErrorOr<void> parse_locale_list_patterns(DeprecatedString misc_path, CLDR
return {};
}
static ErrorOr<void> parse_locale_layout(DeprecatedString misc_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_locale_layout(ByteString misc_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath layout_path(move(misc_path));
layout_path = layout_path.append("layout.json"sv);
@ -699,7 +699,7 @@ static ErrorOr<void> parse_locale_layout(DeprecatedString misc_path, CLDR& cldr,
VERIFY_NOT_REACHED();
};
auto character_order = orientation_object.get_deprecated_string("characterOrder"sv).value();
auto character_order = orientation_object.get_byte_string("characterOrder"sv).value();
TextLayout layout {};
layout.character_order = text_layout_character_order(character_order);
@ -711,7 +711,7 @@ static ErrorOr<void> parse_locale_layout(DeprecatedString misc_path, CLDR& cldr,
return {};
}
static ErrorOr<void> parse_locale_currencies(DeprecatedString numbers_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_locale_currencies(ByteString numbers_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath currencies_path(move(numbers_path));
currencies_path = currencies_path.append("currencies.json"sv);
@ -735,10 +735,10 @@ static ErrorOr<void> parse_locale_currencies(DeprecatedString numbers_path, CLDR
numeric_currencies.resize(cldr.currencies.size());
currencies_object.for_each_member([&](auto const& key, JsonValue const& value) {
auto long_name = value.as_object().get_deprecated_string("displayName"sv).value_or(key);
auto short_name = value.as_object().get_deprecated_string("symbol"sv).value_or(key);
auto narrow_name = value.as_object().get_deprecated_string("symbol-alt-narrow"sv);
auto numeric_name = value.as_object().get_deprecated_string("displayName-count-other"sv);
auto long_name = value.as_object().get_byte_string("displayName"sv).value_or(key);
auto short_name = value.as_object().get_byte_string("symbol"sv).value_or(key);
auto narrow_name = value.as_object().get_byte_string("symbol-alt-narrow"sv);
auto numeric_name = value.as_object().get_byte_string("displayName-count-other"sv);
auto index = cldr.currency_indices.get(key).value();
long_currencies[index] = cldr.unique_strings.ensure(move(long_name));
@ -754,7 +754,7 @@ static ErrorOr<void> parse_locale_currencies(DeprecatedString numbers_path, CLDR
return {};
}
static ErrorOr<void> parse_locale_calendars(DeprecatedString locale_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_locale_calendars(ByteString 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);
@ -789,7 +789,7 @@ static ErrorOr<void> parse_locale_calendars(DeprecatedString locale_path, CLDR&
return {};
}
static ErrorOr<void> parse_locale_date_fields(DeprecatedString dates_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_locale_date_fields(ByteString dates_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath date_fields_path(move(dates_path));
date_fields_path = date_fields_path.append("dateFields.json"sv);
@ -813,9 +813,9 @@ static ErrorOr<void> parse_locale_date_fields(DeprecatedString dates_path, CLDR&
if (!is_sanctioned_date_field(key))
return;
auto const& long_name = value.as_object().get_deprecated_string("displayName"sv).value();
auto const& short_name = fields_object.get_object(DeprecatedString::formatted("{}-short", key))->get_deprecated_string("displayName"sv).value();
auto const& narrow_name = fields_object.get_object(DeprecatedString::formatted("{}-narrow", key))->get_deprecated_string("displayName"sv).value();
auto const& long_name = value.as_object().get_byte_string("displayName"sv).value();
auto const& short_name = fields_object.get_object(ByteString::formatted("{}-short", key))->get_byte_string("displayName"sv).value();
auto const& narrow_name = fields_object.get_object(ByteString::formatted("{}-narrow", key))->get_byte_string("displayName"sv).value();
auto index = cldr.date_fields_indices.get(key).value();
long_date_fields[index] = cldr.unique_strings.ensure(long_name);
@ -829,7 +829,7 @@ static ErrorOr<void> parse_locale_date_fields(DeprecatedString dates_path, CLDR&
return {};
}
static ErrorOr<void> parse_number_system_keywords(DeprecatedString locale_numbers_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_number_system_keywords(ByteString locale_numbers_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath numbers_path(move(locale_numbers_path));
numbers_path = numbers_path.append("numbers.json"sv);
@ -838,12 +838,12 @@ static ErrorOr<void> parse_number_system_keywords(DeprecatedString locale_number
auto const& main_object = numbers.as_object().get_object("main"sv).value();
auto const& locale_object = main_object.get_object(numbers_path.parent().basename()).value();
auto const& locale_numbers_object = locale_object.get_object("numbers"sv).value();
auto const& default_numbering_system_object = locale_numbers_object.get_deprecated_string("defaultNumberingSystem"sv).value();
auto const& default_numbering_system_object = locale_numbers_object.get_byte_string("defaultNumberingSystem"sv).value();
auto const& other_numbering_systems_object = locale_numbers_object.get_object("otherNumberingSystems"sv).value();
KeywordList keywords {};
auto append_numbering_system = [&](DeprecatedString system_name) {
auto append_numbering_system = [&](ByteString system_name) {
if (auto system_alias = find_keyword_alias("nu"sv, system_name, cldr); system_alias.has_value())
system_name = system_alias.release_value();
@ -868,7 +868,7 @@ static ErrorOr<void> parse_number_system_keywords(DeprecatedString locale_number
return {};
}
static ErrorOr<void> parse_calendar_keywords(DeprecatedString locale_dates_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_calendar_keywords(ByteString locale_dates_path, CLDR& cldr, LocaleData& locale)
{
KeywordList keywords {};
@ -934,7 +934,7 @@ static void fill_in_collation_keywords(CLDR& cldr, LocaleData& locale)
locale.collation_numeric_keywords = kn_index;
}
static ErrorOr<void> parse_default_content_locales(DeprecatedString core_path, CLDR& cldr)
static ErrorOr<void> parse_default_content_locales(ByteString core_path, CLDR& cldr)
{
LexicalPath default_content_path(move(core_path));
default_content_path = default_content_path.append("defaultContent.json"sv);
@ -983,7 +983,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 = DeprecatedString::formatted("{}-{}",
auto locale_without_script = ByteString::formatted("{}-{}",
cldr.unique_strings.get(parsed_locale.language),
cldr.unique_strings.get(parsed_locale.region));
@ -1008,7 +1008,7 @@ static ErrorOr<void> define_aliases_without_scripts(CLDR& cldr)
return {};
}
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)
static ErrorOr<void> parse_all_locales(ByteString bcp47_path, ByteString core_path, ByteString locale_names_path, ByteString misc_path, ByteString numbers_path, ByteString dates_path, CLDR& cldr)
{
LexicalPath core_supplemental_path(core_path);
core_supplemental_path = core_supplemental_path.append("supplemental"sv);
@ -1017,7 +1017,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString bcp47_path, DeprecatedSt
TRY(parse_core_aliases(core_supplemental_path.string(), cldr));
TRY(parse_likely_subtags(core_supplemental_path.string(), cldr));
auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr<DeprecatedString> {
auto remove_variants_from_path = [&](ByteString path) -> ErrorOr<ByteString> {
auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path)));
StringBuilder builder;
@ -1027,7 +1027,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString bcp47_path, DeprecatedSt
if (auto region = cldr.unique_strings.get(parsed_locale.region); !region.is_empty())
builder.appendff("-{}", region);
return builder.to_deprecated_string();
return builder.to_byte_string();
};
TRY(Core::Directory::for_each_entry(TRY(String::formatted("{}/main", locale_names_path)), Core::DirIterator::SkipParentAndBaseDir, [&](auto& entry, auto& directory) -> ErrorOr<IterationDecision> {
@ -1156,7 +1156,7 @@ namespace Locale {
for (auto& keyword : cldr.keywords) {
auto const& keyword_name = cldr.keyword_names.find(keyword.key)->value;
auto enum_name = DeprecatedString::formatted("Keyword{}", format_identifier({}, keyword_name));
auto enum_name = ByteString::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);
@ -1179,9 +1179,9 @@ static ErrorOr<void> generate_unicode_locale_implementation(Core::InputBufferedF
StringBuilder builder;
SourceGenerator generator { builder };
generator.set("string_index_type"sv, string_index_type);
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.set("locales_size"sv, ByteString::number(cldr.locales.size()));
generator.set("territories_size", ByteString::number(cldr.territories.size()));
generator.set("variants_size", ByteString::number(cldr.max_variant_size));
generator.append(R"~~~(
#include <AK/Array.h>
@ -1285,7 +1285,7 @@ ReadonlySpan<StringView> 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(DeprecatedString::formatted(", {}", index));
generator.append(ByteString::formatted(", {}", index));
};
auto append_list_and_size = [&](auto const& list) {
@ -1298,16 +1298,16 @@ ReadonlySpan<StringView> get_available_keyword_values(StringView key)
generator.append(", {");
for (auto const& item : list) {
generator.append(first ? " "sv : ", "sv);
generator.append(DeprecatedString::number(item));
generator.append(ByteString::number(item));
first = false;
}
generator.append(DeprecatedString::formatted(" }}, {}", list.size()));
generator.append(ByteString::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", DeprecatedString::number(keys.size()));
generator.set("size", ByteString::number(keys.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> @name@ { {)~~~");
@ -1318,7 +1318,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~");
auto mapping = mapping_getter(value);
generator.append(first ? " "sv : ", "sv);
generator.append(DeprecatedString::number(mapping));
generator.append(ByteString::number(mapping));
first = false;
}
@ -1396,7 +1396,7 @@ struct LanguageMapping {
)~~~");
auto append_complex_mapping = [&](StringView name, auto& mappings) {
generator.set("size", DeprecatedString::number(mappings.size()));
generator.set("size", ByteString::number(mappings.size()));
generator.set("name"sv, name);
generator.append(R"~~~(
@ -1416,14 +1416,14 @@ static constexpr Array<LanguageMapping, @size@> s_@name@ { {
});
for (auto const& mapping : mappings) {
generator.set("language"sv, DeprecatedString::number(mapping.key.language));
generator.set("language"sv, ByteString::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, DeprecatedString::number(mapping.alias.language));
generator.set("language"sv, ByteString::number(mapping.alias.language));
generator.append(" }, { @language@");
append_index(mapping.alias.script);
@ -1563,7 +1563,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 = {}) -> ErrorOr<void> {
HashValueMap<DeprecatedString> hashes;
HashValueMap<ByteString> hashes;
TRY(hashes.try_ensure_capacity(values.size()));
for (auto const& value : values)
@ -1621,8 +1621,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 = DeprecatedString::formatted("Keyword{}", format_identifier({}, keyword_name));
auto enum_snake = DeprecatedString::formatted("keyword_{}", keyword.key);
auto enum_name = ByteString::formatted("Keyword{}", format_identifier({}, keyword_name));
auto enum_snake = ByteString::formatted("keyword_{}", keyword.key);
if (auto aliases = cldr.keyword_aliases.find(keyword.key); aliases != cldr.keyword_aliases.end())
TRY(append_from_string(enum_name, enum_snake, keyword.value, aliases->value));

View file

@ -7,8 +7,8 @@
#include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common.
#include <AK/AllOf.h>
#include <AK/Array.h>
#include <AK/ByteString.h>
#include <AK/CharacterTypes.h>
#include <AK/DeprecatedString.h>
#include <AK/Find.h>
#include <AK/Format.h>
#include <AK/HashFunctions.h>
@ -85,7 +85,7 @@ struct AK::Formatter<NumberFormat> : Formatter<FormatString> {
format.zero_format_index,
format.positive_format_index,
format.negative_format_index,
identifier_indices.to_deprecated_string());
identifier_indices.to_byte_string());
}
};
@ -215,7 +215,7 @@ struct AK::Traits<Unit> : public DefaultTraits<Unit> {
struct LocaleData {
Vector<size_t> number_systems;
HashMap<DeprecatedString, size_t> units {};
HashMap<ByteString, size_t> units {};
u8 minimum_grouping_digits { 0 };
};
@ -227,14 +227,14 @@ struct CLDR {
UniqueStorage<NumberSystem> unique_systems;
UniqueStorage<Unit> unique_units;
HashMap<DeprecatedString, Array<u32, 10>> number_system_digits;
Vector<DeprecatedString> number_systems;
HashMap<ByteString, Array<u32, 10>> number_system_digits;
Vector<ByteString> number_systems;
HashMap<DeprecatedString, LocaleData> locales;
HashMap<ByteString, LocaleData> locales;
size_t max_identifier_count { 0 };
};
static ErrorOr<void> parse_number_system_digits(DeprecatedString core_supplemental_path, CLDR& cldr)
static ErrorOr<void> parse_number_system_digits(ByteString core_supplemental_path, CLDR& cldr)
{
LexicalPath number_systems_path(move(core_supplemental_path));
number_systems_path = number_systems_path.append("numberingSystems.json"sv);
@ -244,11 +244,11 @@ static ErrorOr<void> parse_number_system_digits(DeprecatedString core_supplement
auto const& number_systems_object = supplemental_object.get_object("numberingSystems"sv).value();
number_systems_object.for_each_member([&](auto const& number_system, auto const& digits_object) {
auto type = digits_object.as_object().get_deprecated_string("_type"sv).value();
auto type = digits_object.as_object().get_byte_string("_type"sv).value();
if (type != "numeric"sv)
return;
auto digits = digits_object.as_object().get_deprecated_string("_digits"sv).value();
auto digits = digits_object.as_object().get_byte_string("_digits"sv).value();
Utf8View utf8_digits { digits };
VERIFY(utf8_digits.length() == 10);
@ -266,7 +266,7 @@ static ErrorOr<void> parse_number_system_digits(DeprecatedString core_supplement
return {};
}
static DeprecatedString parse_identifiers(DeprecatedString pattern, StringView replacement, CLDR& cldr, NumberFormat& format)
static ByteString parse_identifiers(ByteString pattern, StringView replacement, CLDR& cldr, NumberFormat& format)
{
static constexpr Utf8View whitespace { "\u0020\u00a0\u200f"sv };
@ -312,7 +312,7 @@ static DeprecatedString parse_identifiers(DeprecatedString pattern, StringView r
cldr.max_identifier_count = max(cldr.max_identifier_count, format.identifier_indices.size());
}
pattern = DeprecatedString::formatted("{}{{{}:{}}}{}",
pattern = ByteString::formatted("{}{{{}:{}}}{}",
*start_index > 0 ? pattern.substring_view(0, *start_index) : ""sv,
replacement,
replacement_index,
@ -320,13 +320,13 @@ static DeprecatedString parse_identifiers(DeprecatedString pattern, StringView r
}
}
static void parse_number_pattern(Vector<DeprecatedString> patterns, CLDR& cldr, NumberFormatType type, NumberFormat& format, NumberSystem* number_system_for_groupings = nullptr)
static void parse_number_pattern(Vector<ByteString> 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 = [&](DeprecatedString pattern) {
auto replace_patterns = [&](ByteString pattern) {
static HashMap<StringView, StringView> replacements = {
{ "{0}"sv, "{number}"sv },
{ "{1}"sv, "{currency}"sv },
@ -340,7 +340,7 @@ static void parse_number_pattern(Vector<DeprecatedString> patterns, CLDR& cldr,
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, DeprecatedString::SearchDirection::Forward); start_number_index.has_value()) {
if (auto start_number_index = pattern.find_any_of("#0"sv, ByteString::SearchDirection::Forward); start_number_index.has_value()) {
auto end_number_index = *start_number_index + 1;
for (; end_number_index < pattern.length(); ++end_number_index) {
@ -367,7 +367,7 @@ static void parse_number_pattern(Vector<DeprecatedString> patterns, CLDR& cldr,
}
}
pattern = DeprecatedString::formatted("{}{{number}}{}",
pattern = ByteString::formatted("{}{{number}}{}",
*start_number_index > 0 ? pattern.substring_view(0, *start_number_index) : ""sv,
pattern.substring_view(end_number_index));
@ -384,19 +384,19 @@ static void parse_number_pattern(Vector<DeprecatedString> patterns, CLDR& cldr,
};
auto zero_format = replace_patterns(move(patterns[0]));
format.positive_format_index = cldr.unique_strings.ensure(DeprecatedString::formatted("{{plusSign}}{}", zero_format));
format.positive_format_index = cldr.unique_strings.ensure(ByteString::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(DeprecatedString::formatted("{{minusSign}}{}", zero_format));
format.negative_format_index = cldr.unique_strings.ensure(ByteString::formatted("{{minusSign}}{}", zero_format));
}
format.zero_format_index = cldr.unique_strings.ensure(move(zero_format));
}
static void parse_number_pattern(Vector<DeprecatedString> patterns, CLDR& cldr, NumberFormatType type, size_t& format_index, NumberSystem* number_system_for_groupings = nullptr)
static void parse_number_pattern(Vector<ByteString> 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);
@ -404,7 +404,7 @@ static void parse_number_pattern(Vector<DeprecatedString> patterns, CLDR& cldr,
format_index = cldr.unique_formats.ensure(move(format));
}
static ErrorOr<void> parse_number_systems(DeprecatedString locale_numbers_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_number_systems(ByteString locale_numbers_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath numbers_path(move(locale_numbers_path));
numbers_path = numbers_path.append("numbers.json"sv);
@ -413,7 +413,7 @@ static ErrorOr<void> parse_number_systems(DeprecatedString locale_numbers_path,
auto const& main_object = numbers.as_object().get_object("main"sv).value();
auto const& locale_object = main_object.get_object(numbers_path.parent().basename()).value();
auto const& locale_numbers_object = locale_object.get_object("numbers"sv).value();
auto const& minimum_grouping_digits = locale_numbers_object.get_deprecated_string("minimumGroupingDigits"sv).value();
auto const& minimum_grouping_digits = locale_numbers_object.get_byte_string("minimumGroupingDigits"sv).value();
Vector<Optional<NumberSystem>> number_systems;
number_systems.resize(cldr.number_systems.size());
@ -517,9 +517,9 @@ static ErrorOr<void> parse_number_systems(DeprecatedString locale_numbers_path,
// The range separator does not appear in the symbols list, we have to extract it from
// the range pattern.
auto misc_patterns_key = DeprecatedString::formatted("{}{}", misc_patterns_prefix, system);
auto misc_patterns_key = ByteString::formatted("{}{}", misc_patterns_prefix, system);
auto misc_patterns = locale_numbers_object.get_object(misc_patterns_key).value();
auto range_separator = misc_patterns.get_deprecated_string("range"sv).value();
auto range_separator = misc_patterns.get_byte_string("range"sv).value();
auto begin_index = range_separator.find("{0}"sv).value() + "{0}"sv.length();
auto end_index = range_separator.find("{1}"sv).value();
@ -536,7 +536,7 @@ static ErrorOr<void> parse_number_systems(DeprecatedString locale_numbers_path,
auto system = key.substring(decimal_formats_prefix.length());
auto& number_system = ensure_number_system(system);
auto format_object = value.as_object().get_deprecated_string("standard"sv).value();
auto format_object = value.as_object().get_byte_string("standard"sv).value();
parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.decimal_format, &number_system);
auto const& long_format = value.as_object().get_object("long"sv)->get_object("decimalFormat"sv).value();
@ -548,10 +548,10 @@ static ErrorOr<void> parse_number_systems(DeprecatedString locale_numbers_path,
auto system = key.substring(currency_formats_prefix.length());
auto& number_system = ensure_number_system(system);
auto format_object = value.as_object().get_deprecated_string("standard"sv).value();
auto format_object = value.as_object().get_byte_string("standard"sv).value();
parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.currency_format);
format_object = value.as_object().get_deprecated_string("accounting"sv).value();
format_object = value.as_object().get_byte_string("accounting"sv).value();
parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.accounting_format);
number_system.currency_unit_formats = parse_number_format(value.as_object());
@ -559,13 +559,13 @@ static ErrorOr<void> parse_number_systems(DeprecatedString locale_numbers_path,
auto system = key.substring(percent_formats_prefix.length());
auto& number_system = ensure_number_system(system);
auto format_object = value.as_object().get_deprecated_string("standard"sv).value();
auto format_object = value.as_object().get_byte_string("standard"sv).value();
parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.percent_format);
} else if (key.starts_with(scientific_formats_prefix)) {
auto system = key.substring(scientific_formats_prefix.length());
auto& number_system = ensure_number_system(system);
auto format_object = value.as_object().get_deprecated_string("standard"sv).value();
auto format_object = value.as_object().get_byte_string("standard"sv).value();
parse_number_pattern(format_object.split(';'), cldr, NumberFormatType::Standard, number_system.scientific_format);
}
});
@ -584,7 +584,7 @@ static ErrorOr<void> parse_number_systems(DeprecatedString locale_numbers_path,
return {};
}
static ErrorOr<void> parse_units(DeprecatedString locale_units_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_units(ByteString locale_units_path, CLDR& cldr, LocaleData& locale)
{
LexicalPath units_path(move(locale_units_path));
units_path = units_path.append("units.json"sv);
@ -597,7 +597,7 @@ static ErrorOr<void> parse_units(DeprecatedString locale_units_path, CLDR& cldr,
auto const& short_object = locale_units_object.get_object("short"sv).value();
auto const& narrow_object = locale_units_object.get_object("narrow"sv).value();
HashMap<DeprecatedString, Unit> units;
HashMap<ByteString, Unit> units;
auto ensure_unit = [&](auto const& unit) -> Unit& {
return units.ensure(unit, [&]() {
@ -687,7 +687,7 @@ static ErrorOr<void> parse_units(DeprecatedString locale_units_path, CLDR& cldr,
return {};
}
static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedString numbers_path, DeprecatedString units_path, CLDR& cldr)
static ErrorOr<void> parse_all_locales(ByteString core_path, ByteString numbers_path, ByteString units_path, CLDR& cldr)
{
LexicalPath core_supplemental_path(move(core_path));
core_supplemental_path = core_supplemental_path.append("supplemental"sv);
@ -695,7 +695,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedStr
TRY(parse_number_system_digits(core_supplemental_path.string(), cldr));
auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr<DeprecatedString> {
auto remove_variants_from_path = [&](ByteString path) -> ErrorOr<ByteString> {
auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path)));
StringBuilder builder;
@ -705,7 +705,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedStr
if (auto region = cldr.unique_strings.get(parsed_locale.region); !region.is_empty())
builder.appendff("-{}", region);
return builder.to_deprecated_string();
return builder.to_byte_string();
};
TRY(Core::Directory::for_each_entry(TRY(String::formatted("{}/main", numbers_path)), Core::DirIterator::SkipParentAndBaseDir, [&](auto& entry, auto& directory) -> ErrorOr<IterationDecision> {
@ -729,7 +729,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedStr
return {};
}
static DeprecatedString format_identifier(StringView, DeprecatedString identifier)
static ByteString format_identifier(StringView, ByteString identifier)
{
return identifier.to_titlecase();
}
@ -765,7 +765,7 @@ static ErrorOr<void> generate_unicode_locale_implementation(Core::InputBufferedF
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", DeprecatedString::number(cldr.max_identifier_count));
generator.set("identifier_count", ByteString::number(cldr.max_identifier_count));
generator.append(R"~~~(
#include <AK/Array.h>
@ -848,22 +848,22 @@ struct Unit {
auto locales = cldr.locales.keys();
quick_sort(locales);
generator.set("size", DeprecatedString::number(locales.size()));
generator.set("size", ByteString::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(DeprecatedString::number(cldr.locales.find(locale)->value.minimum_grouping_digits));
generator.append(ByteString::number(cldr.locales.find(locale)->value.minimum_grouping_digits));
first = false;
}
generator.append(" } };\n");
auto append_map = [&](DeprecatedString name, auto type, auto const& map) {
auto append_map = [&](ByteString name, auto type, auto const& map) {
generator.set("name", name);
generator.set("type", type);
generator.set("size", DeprecatedString::number(map.size()));
generator.set("size", ByteString::number(map.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> @name@ { {)~~~");
@ -872,9 +872,9 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~");
for (auto const& item : map) {
generator.append(first ? " "sv : ", "sv);
if constexpr (requires { item.value; })
generator.append(DeprecatedString::number(item.value));
generator.append(ByteString::number(item.value));
else
generator.append(DeprecatedString::number(item));
generator.append(ByteString::number(item));
first = false;
}

View file

@ -5,7 +5,7 @@
*/
#include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common.
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/JsonObject.h>
#include <AK/JsonParser.h>
#include <AK/JsonValue.h>
@ -18,14 +18,14 @@
#include <LibFileSystem/FileSystem.h>
#include <LibLocale/PluralRules.h>
static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier)
static ByteString format_identifier(StringView owner, ByteString identifier)
{
identifier = identifier.replace("-"sv, "_"sv, ReplaceMode::All);
if (all_of(identifier, is_ascii_digit))
return DeprecatedString::formatted("{}_{}", owner[0], identifier);
return ByteString::formatted("{}_{}", owner[0], identifier);
if (is_ascii_lower_alpha(identifier[0]))
return DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
return ByteString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
return identifier;
}
@ -38,20 +38,20 @@ struct Relation {
Inequality,
};
DeprecatedString const& modulus_variable_name() const
ByteString const& modulus_variable_name() const
{
VERIFY(modulus.has_value());
if (!cached_modulus_variable_name.has_value())
cached_modulus_variable_name = DeprecatedString::formatted("mod_{}_{}", symbol, *modulus);
cached_modulus_variable_name = ByteString::formatted("mod_{}_{}", symbol, *modulus);
return *cached_modulus_variable_name;
}
DeprecatedString const& exponential_variable_name() const
ByteString const& exponential_variable_name() const
{
if (!cached_exponential_variable_name.has_value())
cached_exponential_variable_name = DeprecatedString::formatted("exp_{}", symbol);
cached_exponential_variable_name = ByteString::formatted("exp_{}", symbol);
return *cached_exponential_variable_name;
}
@ -64,25 +64,25 @@ struct Relation {
else if (symbol == 'e' || symbol == 'c')
generator.append(exponential_variable_name());
else
generator.append(DeprecatedString::formatted("ops.{}", Locale::PluralOperands::symbol_to_variable_name(symbol)));
generator.append(ByteString::formatted("ops.{}", Locale::PluralOperands::symbol_to_variable_name(symbol)));
};
auto append_value = [&](u32 value) {
append_variable_name();
generator.append(" == "sv);
generator.append(DeprecatedString::number(value));
generator.append(ByteString::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(DeprecatedString::formatted("{} <= ", range[0]));
generator.append(ByteString::formatted("{} <= ", range[0]));
append_variable_name();
generator.append(" && "sv);
}
append_variable_name();
generator.append(DeprecatedString::formatted(" <= {}", range[1]));
generator.append(ByteString::formatted(" <= {}", range[1]));
};
if (type == Type::Inequality)
@ -105,7 +105,7 @@ struct Relation {
generator.append(")"sv);
}
void generate_precomputed_variables(SourceGenerator& generator, HashTable<DeprecatedString>& generated_variables) const
void generate_precomputed_variables(SourceGenerator& generator, HashTable<ByteString>& generated_variables) const
{
// FIXME: How do we handle the exponential symbols? They seem unused by ECMA-402.
if (symbol == 'e' || symbol == 'c') {
@ -127,7 +127,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, DeprecatedString::number(*modulus));
generator.set("modulus"sv, ByteString::number(*modulus));
if (Locale::PluralOperands::symbol_requires_floating_point_modulus(symbol)) {
generator.append(R"~~~(
@ -144,8 +144,8 @@ struct Relation {
Vector<Comparator> comparators;
private:
mutable Optional<DeprecatedString> cached_modulus_variable_name;
mutable Optional<DeprecatedString> cached_exponential_variable_name;
mutable Optional<ByteString> cached_modulus_variable_name;
mutable Optional<ByteString> cached_exponential_variable_name;
};
struct Condition {
@ -170,7 +170,7 @@ struct Condition {
}
}
void generate_precomputed_variables(SourceGenerator& generator, HashTable<DeprecatedString>& generated_variables) const
void generate_precomputed_variables(SourceGenerator& generator, HashTable<ByteString>& generated_variables) const
{
for (auto const& conjunctions : relations) {
for (auto const& relation : conjunctions)
@ -182,18 +182,18 @@ struct Condition {
};
struct Range {
DeprecatedString start;
DeprecatedString end;
DeprecatedString category;
ByteString start;
ByteString end;
ByteString category;
};
using Conditions = HashMap<DeprecatedString, Condition>;
using Conditions = HashMap<ByteString, Condition>;
using Ranges = Vector<Range>;
struct LocaleData {
static DeprecatedString generated_method_name(StringView form, StringView locale)
static ByteString generated_method_name(StringView form, StringView locale)
{
return DeprecatedString::formatted("{}_plurality_{}", form, format_identifier({}, locale));
return ByteString::formatted("{}_plurality_{}", form, format_identifier({}, locale));
}
Conditions& rules_for_form(StringView form)
@ -213,7 +213,7 @@ struct LocaleData {
struct CLDR {
UniqueStringStorage unique_strings;
HashMap<DeprecatedString, LocaleData> locales;
HashMap<ByteString, LocaleData> locales;
};
static Relation parse_relation(StringView relation)
@ -321,7 +321,7 @@ static void parse_condition(StringView category, StringView rule, Conditions& ru
});
}
static ErrorOr<void> parse_plural_rules(DeprecatedString core_supplemental_path, StringView file_name, CLDR& cldr)
static ErrorOr<void> parse_plural_rules(ByteString core_supplemental_path, StringView file_name, CLDR& cldr)
{
static constexpr auto form_prefix = "plurals-type-"sv;
static constexpr auto rule_prefix = "pluralRule-count-"sv;
@ -356,7 +356,7 @@ static ErrorOr<void> parse_plural_rules(DeprecatedString core_supplemental_path,
}
// https://unicode.org/reports/tr35/tr35-numbers.html#Plural_Ranges
static ErrorOr<void> parse_plural_ranges(DeprecatedString core_supplemental_path, CLDR& cldr)
static ErrorOr<void> parse_plural_ranges(ByteString core_supplemental_path, CLDR& cldr)
{
static constexpr auto start_segment = "-start-"sv;
static constexpr auto end_segment = "-end-"sv;
@ -392,13 +392,13 @@ static ErrorOr<void> parse_plural_ranges(DeprecatedString core_supplemental_path
return {};
}
static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedString locale_names_path, CLDR& cldr)
static ErrorOr<void> parse_all_locales(ByteString core_path, ByteString locale_names_path, CLDR& cldr)
{
LexicalPath core_supplemental_path(move(core_path));
core_supplemental_path = core_supplemental_path.append("supplemental"sv);
VERIFY(FileSystem::is_directory(core_supplemental_path.string()));
auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr<DeprecatedString> {
auto remove_variants_from_path = [&](ByteString path) -> ErrorOr<ByteString> {
auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path)));
StringBuilder builder;
@ -408,7 +408,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString core_path, DeprecatedStr
if (auto region = cldr.unique_strings.get(parsed_locale.region); !region.is_empty())
builder.appendff("-{}", region);
return builder.to_deprecated_string();
return builder.to_byte_string();
};
TRY(Core::Directory::for_each_entry(TRY(String::formatted("{}/main", locale_names_path)), Core::DirIterator::SkipParentAndBaseDir, [&](auto& entry, auto& directory) -> ErrorOr<IterationDecision> {
@ -484,7 +484,7 @@ static PluralCategory default_range(PluralCategory, PluralCategory end)
return;
generator.set("method"sv, LocaleData::generated_method_name(form, locale));
HashTable<DeprecatedString> generated_variables;
HashTable<ByteString> generated_variables;
generator.append(R"~~~(
static PluralCategory @method@([[maybe_unused]] PluralOperands ops)
@ -539,7 +539,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, DeprecatedString::number(locales.size()));
generator.set("size"sv, ByteString::number(locales.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> s_@form@_functions { {)~~~");
@ -564,7 +564,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", DeprecatedString::number(rules.size() + 1));
generator.set("size", ByteString::number(rules.size() + 1));
generator.append(R"~~~(
static constexpr Array<PluralCategory, @size@> @name@ { { PluralCategory::Other)~~~");

View file

@ -5,7 +5,7 @@
*/
#include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common.
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Format.h>
#include <AK/HashMap.h>
#include <AK/JsonObject.h>
@ -39,9 +39,9 @@ struct RelativeTimeFormat {
&& (pattern == other.pattern);
}
DeprecatedString time_unit;
DeprecatedString style;
DeprecatedString plurality;
ByteString time_unit;
ByteString style;
ByteString plurality;
size_t tense_or_number { 0 };
size_t pattern { 0 };
};
@ -73,10 +73,10 @@ struct CLDR {
UniqueStringStorage unique_strings;
UniqueStorage<RelativeTimeFormat> unique_formats;
HashMap<DeprecatedString, LocaleData> locales;
HashMap<ByteString, LocaleData> locales;
};
static ErrorOr<void> parse_date_fields(DeprecatedString locale_dates_path, CLDR& cldr, LocaleData& locale)
static ErrorOr<void> parse_date_fields(ByteString 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);
@ -135,9 +135,9 @@ static ErrorOr<void> parse_date_fields(DeprecatedString locale_dates_path, CLDR&
return {};
}
static ErrorOr<void> parse_all_locales(DeprecatedString dates_path, CLDR& cldr)
static ErrorOr<void> parse_all_locales(ByteString dates_path, CLDR& cldr)
{
auto remove_variants_from_path = [&](DeprecatedString path) -> ErrorOr<DeprecatedString> {
auto remove_variants_from_path = [&](ByteString path) -> ErrorOr<ByteString> {
auto parsed_locale = TRY(CanonicalLanguageID::parse(cldr.unique_strings, LexicalPath::basename(path)));
StringBuilder builder;
@ -147,7 +147,7 @@ static ErrorOr<void> parse_all_locales(DeprecatedString dates_path, CLDR& cldr)
if (auto region = cldr.unique_strings.get(parsed_locale.region); !region.is_empty())
builder.appendff("-{}", region);
return builder.to_deprecated_string();
return builder.to_byte_string();
};
TRY(Core::Directory::for_each_entry(TRY(String::formatted("{}/main", dates_path)), Core::DirIterator::SkipParentAndBaseDir, [&](auto& entry, auto& directory) -> ErrorOr<IterationDecision> {
@ -225,9 +225,9 @@ struct RelativeTimeFormatImpl {
cldr.unique_formats.generate(generator, "RelativeTimeFormatImpl"sv, "s_relative_time_formats"sv, 10);
auto append_list = [&](DeprecatedString name, auto const& list) {
auto append_list = [&](ByteString name, auto const& list) {
generator.set("name", name);
generator.set("size", DeprecatedString::number(list.size()));
generator.set("size", ByteString::number(list.size()));
generator.append(R"~~~(
static constexpr Array<@relative_time_format_index_type@, @size@> @name@ { {)~~~");
@ -235,7 +235,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(DeprecatedString::number(index));
generator.append(ByteString::number(index));
first = false;
}

View file

@ -5,8 +5,8 @@
*/
#include "../LibUnicode/GeneratorUtil.h" // FIXME: Move this somewhere common.
#include <AK/ByteString.h>
#include <AK/DateConstants.h>
#include <AK/DeprecatedString.h>
#include <AK/Error.h>
#include <AK/Format.h>
#include <AK/HashMap.h>
@ -36,7 +36,7 @@ struct TimeZoneOffset {
i64 offset { 0 };
Optional<DateTime> until;
Optional<DeprecatedString> dst_rule;
Optional<ByteString> dst_rule;
Optional<i32> dst_rule_index;
i64 dst_offset { 0 };
@ -56,17 +56,17 @@ struct DaylightSavingsOffset {
struct TimeZoneData {
UniqueStringStorage unique_strings;
HashMap<DeprecatedString, Vector<TimeZoneOffset>> time_zones;
Vector<DeprecatedString> time_zone_names;
HashMap<ByteString, Vector<TimeZoneOffset>> time_zones;
Vector<ByteString> time_zone_names;
Vector<Alias> time_zone_aliases;
HashMap<DeprecatedString, Vector<DaylightSavingsOffset>> dst_offsets;
Vector<DeprecatedString> dst_offset_names;
HashMap<ByteString, Vector<DaylightSavingsOffset>> dst_offsets;
Vector<ByteString> dst_offset_names;
HashMap<DeprecatedString, TimeZone::Location> time_zone_coordinates;
HashMap<ByteString, TimeZone::Location> time_zone_coordinates;
HashMap<DeprecatedString, Vector<size_t>> time_zone_regions;
Vector<DeprecatedString> time_zone_region_names;
HashMap<ByteString, Vector<size_t>> time_zone_regions;
Vector<ByteString> time_zone_region_names;
Vector<TimeZone::TimeZoneIdentifier> time_zones_and_links;
};
@ -112,10 +112,10 @@ struct AK::Formatter<DaylightSavingsOffset> : Formatter<FormatString> {
ErrorOr<void> format(FormatBuilder& builder, DaylightSavingsOffset const& dst_offset)
{
auto format_time = [&](auto year) {
return DeprecatedString::formatted("AK::UnixDateTime::from_unix_time_parts({}, 1, 1, 0, 0, 0, 0)", year);
return ByteString::formatted("AK::UnixDateTime::from_unix_time_parts({}, 1, 1, 0, 0, 0, 0)", year);
};
static DeprecatedString max_year_as_time("max_year_as_time"sv);
static ByteString max_year_as_time("max_year_as_time"sv);
return Formatter<FormatString>::format(builder,
"{{ {}, {}, {}, {}, {} }}"sv,
@ -439,7 +439,7 @@ static void set_dst_rule_indices(TimeZoneData& time_zone_data)
}
}
static DeprecatedString format_identifier(StringView owner, DeprecatedString identifier)
static ByteString format_identifier(StringView owner, ByteString identifier)
{
constexpr auto gmt_time_zones = Array { "Etc/GMT"sv, "GMT"sv };
@ -448,9 +448,9 @@ static DeprecatedString format_identifier(StringView owner, DeprecatedString ide
auto offset = identifier.substring_view(gmt_time_zone.length());
if (offset.starts_with('+'))
identifier = DeprecatedString::formatted("{}_Ahead_{}", gmt_time_zone, offset.substring_view(1));
identifier = ByteString::formatted("{}_Ahead_{}", gmt_time_zone, offset.substring_view(1));
else if (offset.starts_with('-'))
identifier = DeprecatedString::formatted("{}_Behind_{}", gmt_time_zone, offset.substring_view(1));
identifier = ByteString::formatted("{}_Behind_{}", gmt_time_zone, offset.substring_view(1));
}
}
@ -458,9 +458,9 @@ static DeprecatedString format_identifier(StringView owner, DeprecatedString ide
identifier = identifier.replace("/"sv, "_"sv, ReplaceMode::All);
if (all_of(identifier, is_ascii_digit))
return DeprecatedString::formatted("{}_{}", owner[0], identifier);
return ByteString::formatted("{}_{}", owner[0], identifier);
if (is_ascii_lower_alpha(identifier[0]))
return DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
return ByteString::formatted("{:c}{}", to_ascii_uppercase(identifier[0]), identifier.substring_view(1));
return identifier;
}
@ -568,14 +568,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", DeprecatedString::number(offsets.size()));
generator.set("size", ByteString::number(offsets.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> @name@ { {
)~~~");
for (auto const& offset : offsets)
generator.append(DeprecatedString::formatted(" {},\n", offset));
generator.append(ByteString::formatted(" {},\n", offset));
generator.append("} };\n");
};
@ -597,7 +597,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", DeprecatedString::number(time_zones.size()));
generator.set("size", ByteString::number(time_zones.size()));
generator.append(R"~~~(
static constexpr Array<@string_index_type@, @size@> @name@ { {)~~~");
@ -605,14 +605,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(DeprecatedString::number(time_zone));
generator.append(ByteString::number(time_zone));
first = false;
}
generator.append(" } };");
});
generator.set("size", DeprecatedString::number(time_zone_data.time_zone_names.size()));
generator.set("size", ByteString::number(time_zone_data.time_zone_names.size()));
generator.append(R"~~~(
static constexpr Array<Location, @size@> s_time_zone_locations { {
)~~~");
@ -620,12 +620,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(DeprecatedString::formatted(" {},\n", location));
generator.append(ByteString::formatted(" {},\n", location));
}
generator.append("} };\n");
auto append_string_conversions = [&](StringView enum_title, StringView enum_snake, auto const& values, Vector<Alias> const& aliases = {}) -> ErrorOr<void> {
HashValueMap<DeprecatedString> hashes;
HashValueMap<ByteString> hashes;
TRY(hashes.try_ensure_capacity(values.size()));
auto hash = [](auto const& value) {
@ -750,10 +750,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) -> DeprecatedString {
auto format_name = [](auto format, auto offset) -> ByteString {
if (offset == 0)
return decode_string(format).replace("{}"sv, ""sv, ReplaceMode::FirstOnly);
return DeprecatedString::formatted(decode_string(format), decode_string(offset));
return ByteString::formatted(decode_string(format), decode_string(offset));
};
auto set_named_offset = [&](auto& named_offset, auto dst_offset, auto in_dst, auto format, auto offset) {

View file

@ -6,7 +6,7 @@
#include "GeneratorUtil.h"
#include <AK/AnyOf.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/QuickSort.h>
#include <AK/SourceGenerator.h>
#include <AK/StringUtils.h>
@ -20,11 +20,11 @@ struct Emoji {
size_t name { 0 };
Optional<size_t> image_path;
Unicode::EmojiGroup group;
DeprecatedString subgroup;
ByteString subgroup;
u32 display_order { 0 };
Vector<u32> code_points;
DeprecatedString encoded_code_points;
DeprecatedString status;
ByteString encoded_code_points;
ByteString status;
size_t code_point_array_index { 0 };
};
@ -45,8 +45,8 @@ static void set_image_path_for_emoji(StringView emoji_resource_path, EmojiData&
builder.appendff("U+{:X}", code_point);
}
auto file = DeprecatedString::formatted("{}.png", builder.to_deprecated_string());
auto path = DeprecatedString::formatted("{}/{}", emoji_resource_path, file);
auto file = ByteString::formatted("{}.png", builder.to_byte_string());
auto path = ByteString::formatted("{}/{}", emoji_resource_path, file);
if (!FileSystem::exists(path))
return;
@ -61,7 +61,7 @@ static ErrorOr<void> parse_emoji_test_data(Core::InputBufferedFile& file, EmojiD
Array<u8, 1024> buffer;
Unicode::EmojiGroup group;
DeprecatedString subgroup;
ByteString subgroup;
u32 display_order { 0 };
while (TRY(file.can_read_line())) {
@ -157,7 +157,7 @@ static ErrorOr<void> parse_emoji_serenity_data(Core::InputBufferedFile& file, Em
return {};
}));
auto name = builder.to_deprecated_string();
auto name = builder.to_byte_string();
if (!any_of(name, is_ascii_lower_alpha))
name = name.to_titlecase();
@ -218,7 +218,7 @@ static ErrorOr<void> generate_emoji_data_implementation(Core::InputBufferedFile&
SourceGenerator generator { builder };
generator.set("string_index_type"sv, emoji_data.unique_strings.type_that_fits());
generator.set("emojis_size"sv, DeprecatedString::number(emoji_data.emojis.size()));
generator.set("emojis_size"sv, ByteString::number(emoji_data.emojis.size()));
generator.append(R"~~~(
#include <AK/Array.h>
@ -238,7 +238,7 @@ namespace Unicode {
for (auto const& emoji : emoji_data.emojis) {
total_code_point_count += emoji.code_points.size();
}
generator.set("total_code_point_count", DeprecatedString::number(total_code_point_count));
generator.set("total_code_point_count", ByteString::number(total_code_point_count));
generator.append(R"~~~(
static constexpr Array<u32, @total_code_point_count@> s_emoji_code_points { {)~~~");
@ -247,7 +247,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(DeprecatedString::formatted("{:#x}", code_point));
generator.append(ByteString::formatted("{:#x}", code_point));
first = false;
}
}
@ -288,12 +288,12 @@ struct EmojiData {
static constexpr Array<EmojiData, @emojis_size@> s_emojis { {)~~~");
for (auto const& emoji : emoji_data.emojis) {
generator.set("name"sv, DeprecatedString::number(emoji.name));
generator.set("image_path"sv, DeprecatedString::number(emoji.image_path.value_or(0)));
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.set("name"sv, ByteString::number(emoji.name));
generator.set("image_path"sv, ByteString::number(emoji.image_path.value_or(0)));
generator.set("group"sv, ByteString::number(to_underlying(emoji.group)));
generator.set("display_order"sv, ByteString::number(emoji.display_order));
generator.set("code_point_start"sv, ByteString::number(emoji.code_point_array_index));
generator.set("code_point_count"sv, ByteString::number(emoji.code_points.size()));
generator.append(R"~~~(
{ @name@, @image_path@, @group@, @display_order@, @code_point_start@, @code_point_count@ },)~~~");
@ -370,7 +370,7 @@ static ErrorOr<void> generate_emoji_installation(Core::InputBufferedFile& file,
generator.append("@emoji@"sv);
generator.append(" - "sv);
generator.append(DeprecatedString::join(" "sv, emoji.code_points, "U+{:X}"sv));
generator.append(ByteString::join(" "sv, emoji.code_points, "U+{:X}"sv));
generator.append(" @name@ (@status@)\n"sv);
}

View file

@ -7,8 +7,8 @@
#include "GeneratorUtil.h"
#include <AK/AllOf.h>
#include <AK/Array.h>
#include <AK/ByteString.h>
#include <AK/CharacterTypes.h>
#include <AK/DeprecatedString.h>
#include <AK/Error.h>
#include <AK/Find.h>
#include <AK/HashMap.h>
@ -28,8 +28,8 @@ struct SpecialCasing {
Vector<u32> lowercase_mapping;
Vector<u32> uppercase_mapping;
Vector<u32> titlecase_mapping;
DeprecatedString locale;
DeprecatedString condition;
ByteString locale;
ByteString condition;
};
// https://www.unicode.org/reports/tr44/#CaseFolding.txt
@ -42,13 +42,13 @@ struct CaseFolding {
// 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.
DeprecatedString tag { "Canonical"sv };
ByteString tag { "Canonical"sv };
size_t decomposition_index { 0 };
size_t decomposition_size { 0 };
};
// https://www.unicode.org/reports/tr44/#PropList.txt
using PropList = HashMap<DeprecatedString, Vector<Unicode::CodePointRange>>;
using PropList = HashMap<ByteString, Vector<Unicode::CodePointRange>>;
// https://www.unicode.org/reports/tr44/#DerivedNormalizationProps.txt
enum class QuickCheck {
@ -63,7 +63,7 @@ struct Normalization {
QuickCheck quick_check { QuickCheck::Yes };
};
using NormalizationProps = HashMap<DeprecatedString, Vector<Normalization>>;
using NormalizationProps = HashMap<ByteString, Vector<Normalization>>;
struct CodePointName {
Unicode::CodePointRange code_point_range;
@ -92,16 +92,16 @@ struct CasingTable {
// https://www.unicode.org/reports/tr44/#UnicodeData.txt
struct CodePointData {
u32 code_point { 0 };
DeprecatedString name;
ByteString name;
Optional<size_t> abbreviation;
DeprecatedString bidi_class;
ByteString 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 };
DeprecatedString unicode_1_name;
DeprecatedString iso_comment;
ByteString unicode_1_name;
ByteString iso_comment;
CasingTable casing;
};
@ -127,7 +127,7 @@ struct CodePointTables {
struct CodePointBidiClass {
Unicode::CodePointRange code_point_range;
DeprecatedString bidi_class;
ByteString bidi_class;
};
struct UnicodeData {
@ -135,12 +135,12 @@ struct UnicodeData {
u32 code_points_with_decomposition_mapping { 0 };
Vector<u32> decomposition_mappings;
Vector<DeprecatedString> compatibility_tags;
Vector<ByteString> compatibility_tags;
Vector<SpecialCasing> special_casing;
u32 largest_special_casing_mapping_size { 0 };
Vector<DeprecatedString> conditions;
Vector<DeprecatedString> locales;
Vector<ByteString> conditions;
Vector<ByteString> locales;
Vector<CaseFolding> case_folding;
u32 largest_case_folding_mapping_size { 0 };
@ -190,11 +190,11 @@ struct UnicodeData {
CodePointTables<PropertyTable> word_break_tables;
CodePointTables<PropertyTable> sentence_break_tables;
HashTable<DeprecatedString> bidirectional_classes;
HashTable<ByteString> bidirectional_classes;
Vector<CodePointBidiClass> code_point_bidirectional_classes;
};
static DeprecatedString sanitize_entry(DeprecatedString const& entry)
static ByteString sanitize_entry(ByteString const& entry)
{
auto sanitized = entry.replace("-"sv, "_"sv, ReplaceMode::All);
sanitized = sanitized.replace(" "sv, "_"sv, ReplaceMode::All);
@ -209,7 +209,7 @@ static DeprecatedString sanitize_entry(DeprecatedString const& entry)
next_is_upper = ch == '_';
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
static ErrorOr<void> parse_special_casing(Core::InputBufferedFile& file, UnicodeData& unicode_data)
@ -248,7 +248,7 @@ static ErrorOr<void> parse_special_casing(Core::InputBufferedFile& file, Unicode
}
if (!casing.locale.is_empty()) {
casing.locale = DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(casing.locale[0]), casing.locale.substring_view(1));
casing.locale = ByteString::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);
@ -380,7 +380,7 @@ static ErrorOr<void> parse_prop_list(Core::InputBufferedFile& file, PropList& pr
static ErrorOr<void> parse_alias_list(Core::InputBufferedFile& file, PropList const& prop_list, Vector<Alias>& prop_aliases)
{
DeprecatedString current_property;
ByteString current_property;
Array<u8, 1024> buffer;
auto append_alias = [&](auto alias, auto property) {
@ -455,7 +455,7 @@ static ErrorOr<void> parse_name_aliases(Core::InputBufferedFile& file, UnicodeDa
return {};
}
static ErrorOr<void> parse_value_alias_list(Core::InputBufferedFile& file, StringView desired_category, Vector<DeprecatedString> 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::InputBufferedFile& file, StringView desired_category, Vector<ByteString> const& value_list, Vector<Alias>& prop_aliases, bool primary_value_is_first = true, bool sanitize_alias = false)
{
TRY(file.seek(0, SeekMode::SetPosition));
Array<u8, 1024> buffer;
@ -518,7 +518,7 @@ static ErrorOr<void> parse_normalization_props(Core::InputBufferedFile& file, Un
VERIFY((segments.size() == 2) || (segments.size() == 3));
auto code_point_range = parse_code_point_range(segments[0].trim_whitespace());
auto property = segments[1].trim_whitespace().to_deprecated_string();
auto property = segments[1].trim_whitespace().to_byte_string();
Vector<u32> value;
QuickCheck quick_check = QuickCheck::Yes;
@ -620,7 +620,7 @@ static Optional<CodePointDecomposition> parse_decomposition_mapping(StringView s
if (parts.first().starts_with('<')) {
auto const tag = parts.take_first().trim("<>"sv);
mapping.tag = DeprecatedString::formatted("{:c}{}", to_ascii_uppercase(tag[0]), tag.substring_view(1));
mapping.tag = ByteString::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);
@ -755,15 +755,15 @@ static ErrorOr<void> generate_unicode_data_header(Core::InputBufferedFile& file,
{
StringBuilder builder;
SourceGenerator generator { builder };
generator.set("special_casing_mapping_size", DeprecatedString::number(unicode_data.largest_special_casing_mapping_size));
generator.set("case_folding_mapping_size", DeprecatedString::number(unicode_data.largest_case_folding_mapping_size));
generator.set("special_casing_mapping_size", ByteString::number(unicode_data.largest_special_casing_mapping_size));
generator.set("case_folding_mapping_size", ByteString::number(unicode_data.largest_case_folding_mapping_size));
auto generate_enum = [&](StringView name, StringView default_, auto 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", DeprecatedString::formatted("{}UnderlyingType", name));
generator.set("underlying", ByteString::formatted("{}UnderlyingType", name));
generator.set("type", ((values.size() + !default_.is_empty()) < 256) ? "u8"sv : "u16"sv);
generator.append(R"~~~(
@ -872,8 +872,8 @@ static ErrorOr<void> generate_unicode_data_implementation(Core::InputBufferedFil
SourceGenerator generator { builder };
generator.set("string_index_type"sv, unicode_data.unique_strings.type_that_fits());
generator.set("special_casing_size", DeprecatedString::number(unicode_data.special_casing.size()));
generator.set("case_folding_size", DeprecatedString::number(unicode_data.case_folding.size()));
generator.set("special_casing_size", ByteString::number(unicode_data.special_casing.size()));
generator.set("case_folding_size", ByteString::number(unicode_data.case_folding.size()));
generator.set("CODE_POINT_TABLES_LSB_COUNT", TRY(String::number(CODE_POINT_TABLES_LSB_COUNT)));
generator.set("CODE_POINT_TABLES_LSB_MASK", TRY(String::formatted("{:#x}", CODE_POINT_TABLES_LSB_MASK)));
@ -884,7 +884,7 @@ static ErrorOr<void> generate_unicode_data_implementation(Core::InputBufferedFil
#include <AK/CharacterTypes.h>
#include <AK/Optional.h>
#include <AK/Span.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/StringView.h>
#include <LibUnicode/CharacterTypes.h>
#include <LibUnicode/UnicodeData.h>
@ -905,17 +905,17 @@ namespace Unicode {
generator.append(", {");
for (auto const& item : list) {
generator.append(first ? " "sv : ", "sv);
generator.append(DeprecatedString::formatted(format, item));
generator.append(ByteString::formatted(format, item));
first = false;
}
generator.append(DeprecatedString::formatted(" }}, {}", list.size()));
generator.append(ByteString::formatted(" }}, {}", list.size()));
};
generator.append(R"~~~(
static constexpr Array<SpecialCasing, @special_casing_size@> s_special_case { {)~~~");
for (auto const& casing : unicode_data.special_casing) {
generator.set("code_point", DeprecatedString::formatted("{:#x}", casing.code_point));
generator.set("code_point", ByteString::formatted("{:#x}", casing.code_point));
generator.append(R"~~~(
{ @code_point@)~~~");
@ -939,7 +939,7 @@ static constexpr Array<SpecialCasing, @special_casing_size@> s_special_case { {)
static constexpr Array<CaseFolding, @case_folding_size@> s_case_folding { {)~~~");
for (auto const& folding : unicode_data.case_folding) {
generator.set("code_point", DeprecatedString::formatted("{:#x}", folding.code_point));
generator.set("code_point", ByteString::formatted("{:#x}", folding.code_point));
generator.set("status", folding.status);
generator.append(R"~~~(
{ @code_point@, CaseFoldingStatus::@status@)~~~");
@ -1015,15 +1015,15 @@ struct CodePointBidiClassComparator : public CodePointRangeComparator {
)~~~");
generator.set("decomposition_mappings_size", DeprecatedString::number(unicode_data.decomposition_mappings.size()));
generator.set("decomposition_mappings_size", ByteString::number(unicode_data.decomposition_mappings.size()));
generator.append("\nstatic constexpr Array<u32, @decomposition_mappings_size@> s_decomposition_mappings_data { ");
generator.append(DeprecatedString::join(", "sv, unicode_data.decomposition_mappings, "{:#x}"sv));
generator.append(ByteString::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", DeprecatedString::number(size));
generator.set("size", ByteString::number(size));
generator.append(R"~~~(
static constexpr Array<@mapping_type@, @size@> s_@name@_mappings { {
@ -1046,16 +1046,16 @@ static constexpr Array<@mapping_type@, @size@> s_@name@_mappings { {
if (mappings_in_current_row++ > 0)
generator.append(" ");
generator.set("code_point", DeprecatedString::formatted("{:#x}", data.code_point));
generator.set("code_point", ByteString::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", DeprecatedString::formatted("{:#x}", *mapping));
generator.set("mapping", ByteString::formatted("{:#x}", *mapping));
generator.append(", @mapping@ },");
} else if constexpr (IsSame<decltype(mapping), Optional<CodePointDecomposition>>) {
generator.set("tag", mapping->tag);
generator.set("start", DeprecatedString::number(mapping->decomposition_index));
generator.set("size", DeprecatedString::number(mapping->decomposition_size));
generator.set("start", ByteString::number(mapping->decomposition_index));
generator.set("size", ByteString::number(mapping->decomposition_size));
generator.append(", CompatibilityFormattingTag::@tag@, @start@, @size@ },");
} else {
append_list_and_size(mapping, "&s_@name@[{}]"sv);
@ -1195,7 +1195,7 @@ static constexpr Array<@type@, @size@> @name@ { {
generator.set("type", type);
generator.set("name", name);
generator.set("size", DeprecatedString::number(display_names.size()));
generator.set("size", ByteString::number(display_names.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> @name@ { {
@ -1204,9 +1204,9 @@ static constexpr Array<@type@, @size@> @name@ { {
if (values_in_current_row++ > 0)
generator.append(", ");
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.set("first", ByteString::formatted("{:#x}", display_name.code_point_range.first));
generator.set("last", ByteString::formatted("{:#x}", display_name.code_point_range.last));
generator.set("name", ByteString::number(display_name.name));
generator.append("{ { @first@, @last@ }, @name@ }");
if (values_in_current_row == max_values_per_row) {
@ -1226,7 +1226,7 @@ static constexpr Array<@type@, @size@> @name@ { {
constexpr size_t max_bidi_classes_per_row = 20;
size_t bidi_classes_in_current_row = 0;
generator.set("size"sv, DeprecatedString::number(unicode_data.code_point_bidirectional_classes.size()));
generator.set("size"sv, ByteString::number(unicode_data.code_point_bidirectional_classes.size()));
generator.append(R"~~~(
static constexpr Array<BidiClassData, @size@> s_bidirectional_classes { {
)~~~");
@ -1234,8 +1234,8 @@ static constexpr Array<BidiClassData, @size@> s_bidirectional_classes { {
if (bidi_classes_in_current_row++ > 0)
generator.append(", ");
generator.set("first", DeprecatedString::formatted("{:#x}", data.code_point_range.first));
generator.set("last", DeprecatedString::formatted("{:#x}", data.code_point_range.last));
generator.set("first", ByteString::formatted("{:#x}", data.code_point_range.first));
generator.set("last", ByteString::formatted("{:#x}", data.code_point_range.last));
generator.set("bidi_class", data.bidi_class);
generator.append("{ { @first@, @last@ }, BidirectionalClass::@bidi_class@ }");
@ -1274,13 +1274,13 @@ ReadonlySpan<BlockName> block_display_names()
return display_names.span();
}
Optional<DeprecatedString> code_point_display_name(u32 code_point)
Optional<ByteString> 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 DeprecatedString::formatted(display_name, code_point);
return ByteString::formatted(display_name, code_point);
return display_name;
}
@ -1409,7 +1409,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)>, DeprecatedString>) {
if constexpr (IsSame<RemoveCVReference<decltype(prop)>, ByteString>) {
hashes.set(CaseInsensitiveASCIIStringViewTraits::hash(prop), prop);
options.sensitivity = CaseSensitivity::CaseInsensitive;
} else {

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Function.h>
#include <AK/HashFunctions.h>
#include <AK/HashMap.h>
@ -101,7 +101,7 @@ public:
{
generator.set("type"sv, type);
generator.set("name"sv, name);
generator.set("size"sv, DeprecatedString::number(m_storage.size()));
generator.set("size"sv, ByteString::number(m_storage.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@ + 1> @name@ { {
@ -113,10 +113,10 @@ static constexpr Array<@type@, @size@ + 1> @name@ { {
if (values_in_current_row++ > 0)
generator.append(", ");
if constexpr (IsSame<StorageType, DeprecatedString>)
generator.append(DeprecatedString::formatted("\"{}\"sv", value));
if constexpr (IsSame<StorageType, ByteString>)
generator.append(ByteString::formatted("\"{}\"sv", value));
else
generator.append(DeprecatedString::formatted("{}", value));
generator.append(ByteString::formatted("{}", value));
if (values_in_current_row == max_values_per_row) {
values_in_current_row = 0;
@ -138,8 +138,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, DeprecatedString::number(i));
generator.set("size"sv, DeprecatedString::number(list.size()));
generator.set("index"sv, ByteString::number(i));
generator.set("size"sv, ByteString::number(list.size()));
generator.append(R"~~~(
static constexpr Array<@type@, @size@> @name@@index@ { {)~~~");
@ -147,14 +147,14 @@ static constexpr Array<@type@, @size@> @name@@index@ { {)~~~");
bool first = true;
for (auto const& value : list) {
generator.append(first ? " "sv : ", "sv);
generator.append(DeprecatedString::formatted("{}", value));
generator.append(ByteString::formatted("{}", value));
first = false;
}
generator.append(" } };");
}
generator.set("size"sv, DeprecatedString::number(m_storage.size()));
generator.set("size"sv, ByteString::number(m_storage.size()));
generator.append(R"~~~(
@ -168,7 +168,7 @@ static constexpr Array<ReadonlySpan<@type@>, @size@ + 1> @name@ { {
if (values_in_current_row++ > 0)
generator.append(", ");
generator.set("index"sv, DeprecatedString::number(i));
generator.set("index"sv, ByteString::number(i));
generator.append("@name@@index@.span()");
if (values_in_current_row == max_values_per_row) {
@ -187,8 +187,8 @@ protected:
HashMap<StorageType, size_t> m_storage_indices;
};
class UniqueStringStorage : public UniqueStorage<DeprecatedString> {
using Base = UniqueStorage<DeprecatedString>;
class UniqueStringStorage : public UniqueStorage<ByteString> {
using Base = UniqueStorage<ByteString>;
public:
// The goal of the string table generator is to ensure the table is located within the read-only
@ -204,7 +204,7 @@ public:
if (values_in_current_row++ > 0)
generator.append(", ");
generator.append(DeprecatedString::formatted("{:#x}", value));
generator.append(ByteString::formatted("{:#x}", value));
if (values_in_current_row == max_values_per_row) {
values_in_current_row = 0;
@ -224,7 +224,7 @@ public:
next_index += string.length() + 2;
}
generator.set("size", DeprecatedString::number(next_index));
generator.set("size", ByteString::number(next_index));
generator.append(R"~~~(
static constexpr Array<u8, @size@> s_encoded_strings { {
)~~~");
@ -242,7 +242,7 @@ static constexpr Array<u8, @size@> s_encoded_strings { {
} };
)~~~");
generator.set("size", DeprecatedString::number(string_indices.size()));
generator.set("size", ByteString::number(string_indices.size()));
generator.append(R"~~~(
static constexpr Array<u32, @size@> s_encoded_string_indices { {
)~~~");
@ -276,8 +276,8 @@ static constexpr StringView decode_string(size_t index)
};
struct Alias {
DeprecatedString name;
DeprecatedString alias;
ByteString name;
ByteString alias;
};
struct CanonicalLanguageID {
@ -385,11 +385,11 @@ void generate_value_from_string(SourceGenerator& generator, StringView method_na
{
ensure_from_string_types_are_generated(generator);
generator.set("method_name", DeprecatedString::formatted(method_name_format, value_name));
generator.set("method_name", ByteString::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", DeprecatedString::number(hashes.size()));
generator.set("size", ByteString::number(hashes.size()));
generator.append(R"~~~(
Optional<@return_type@> @method_name@(StringView key)
@ -408,11 +408,11 @@ Optional<@return_type@> @method_name@(StringView key)
generator.append(" ");
if constexpr (IsIntegral<ValueType>)
generator.set("value"sv, DeprecatedString::number(hashes.get(hash_key).value()));
generator.set("value"sv, ByteString::number(hashes.get(hash_key).value()));
else
generator.set("value"sv, DeprecatedString::formatted("{}::{}", value_type, hashes.get(hash_key).value()));
generator.set("value"sv, ByteString::formatted("{}::{}", value_type, hashes.get(hash_key).value()));
generator.set("hash"sv, DeprecatedString::number(hash_key));
generator.set("hash"sv, ByteString::number(hash_key));
generator.append("{ @hash@U, @value@ },"sv);
if (values_in_current_row == max_values_per_row) {
@ -421,7 +421,7 @@ Optional<@return_type@> @method_name@(StringView key)
}
}
generator.set("return_statement", DeprecatedString::formatted(options.return_format, "value->value"sv));
generator.set("return_statement", ByteString::formatted(options.return_format, "value->value"sv));
generator.append(R"~~~(
} };
)~~~");
@ -445,9 +445,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, ReadonlySpan<DeprecatedString> values)
void generate_value_to_string(SourceGenerator& generator, StringView method_name_format, StringView value_type, StringView value_name, IdentifierFormatter&& format_identifier, ReadonlySpan<ByteString> values)
{
generator.set("method_name", DeprecatedString::formatted(method_name_format, value_name));
generator.set("method_name", ByteString::formatted(method_name_format, value_name));
generator.set("value_type", value_type);
generator.set("value_name", value_name);
@ -475,7 +475,7 @@ StringView @method_name@(@value_type@ @value_name@)
}
template<typename IdentifierFormatter>
void generate_enum(SourceGenerator& generator, IdentifierFormatter&& format_identifier, StringView name, StringView default_, Vector<DeprecatedString>& values, Vector<Alias> aliases = {})
void generate_enum(SourceGenerator& generator, IdentifierFormatter&& format_identifier, StringView name, StringView default_, Vector<ByteString>& 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(); });
@ -514,20 +514,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) {
DeprecatedString mapping_name;
ByteString mapping_name;
if constexpr (IsNullPointer<IdentifierFormatter>)
mapping_name = name.replace("-"sv, "_"sv, ReplaceMode::All);
else
mapping_name = format_identifier(type, name);
return DeprecatedString::formatted(format, mapping_name.to_lowercase());
return ByteString::formatted(format, mapping_name.to_lowercase());
};
Vector<DeprecatedString> mapping_names;
Vector<ByteString> mapping_names;
for (auto const& locale : locales) {
DeprecatedString mapping_name;
ByteString mapping_name;
if constexpr (requires { locale.key; }) {
mapping_name = format_mapping_name(format, locale.key);
@ -544,7 +544,7 @@ void generate_mapping(SourceGenerator& generator, LocalesType const& locales, St
generator.set("type", type);
generator.set("name", name);
generator.set("size", DeprecatedString::number(locales.size()));
generator.set("size", ByteString::number(locales.size()));
generator.append(R"~~~(
static constexpr Array<ReadonlySpan<@type@>, @size@> @name@ { {
)~~~");
@ -589,9 +589,9 @@ ReadonlySpan<StringView> @name@()
first = false;
if (auto it = aliases.find_if([&](auto const& alias) { return alias.alias == value; }); it != aliases.end())
generator.append(DeprecatedString::formatted("\"{}\"sv", it->name));
generator.append(ByteString::formatted("\"{}\"sv", it->name));
else
generator.append(DeprecatedString::formatted("\"{}\"sv", value));
generator.append(ByteString::formatted("\"{}\"sv", value));
}
generator.append(R"~~~( };

View file

@ -112,7 +112,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 DeprecatedString union_type_to_variant(UnionType const& union_type, Interface const& interface)
static ByteString union_type_to_variant(UnionType const& union_type, Interface const& interface)
{
StringBuilder builder;
builder.append("Variant<"sv);
@ -132,16 +132,16 @@ static DeprecatedString union_type_to_variant(UnionType const& union_type, Inter
builder.append(", Empty"sv);
builder.append('>');
return builder.to_deprecated_string();
return builder.to_byte_string();
}
CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
{
if (is_platform_object(type) || type.name() == "WindowProxy"sv)
return { .name = DeprecatedString::formatted("JS::Handle<{}>", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector };
return { .name = ByteString::formatted("JS::Handle<{}>", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector };
if (is_javascript_builtin(type))
return { .name = DeprecatedString::formatted("JS::Handle<JS::{}>", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector };
return { .name = ByteString::formatted("JS::Handle<JS::{}>", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector };
if (interface.callback_functions.contains(type.name()))
return { .name = "JS::Handle<WebIDL::CallbackType>", .sequence_storage_type = SequenceStorageType::MarkedVector };
@ -200,7 +200,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 = DeprecatedString::formatted("{}<{}>", storage_type_name, sequence_cpp_type.name), .sequence_storage_type = SequenceStorageType::Vector };
return { .name = ByteString::formatted("{}<{}>", storage_type_name, sequence_cpp_type.name), .sequence_storage_type = SequenceStorageType::Vector };
}
if (type.name() == "record") {
@ -210,7 +210,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 = DeprecatedString::formatted("OrderedHashMap<{}, {}>", record_key_cpp_type.name, record_value_cpp_type.name), .sequence_storage_type = SequenceStorageType::Vector };
return { .name = ByteString::formatted("OrderedHashMap<{}, {}>", record_key_cpp_type.name, record_value_cpp_type.name), .sequence_storage_type = SequenceStorageType::Vector };
}
if (is<UnionType>(type)) {
@ -229,13 +229,13 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
TODO();
}
static DeprecatedString make_input_acceptable_cpp(DeprecatedString const& input)
static ByteString make_input_acceptable_cpp(ByteString const& input)
{
if (input.is_one_of("class", "template", "for", "default", "char", "namespace", "delete", "inline")) {
StringBuilder builder;
builder.append(input);
builder.append('_');
return builder.to_deprecated_string();
return builder.to_byte_string();
}
return input.replace("-"sv, "_"sv, ReplaceMode::All);
@ -266,7 +266,7 @@ static void generate_include_for(auto& generator, auto& path)
}
LexicalPath include_path { path_string };
forked_generator.set("include.path", DeprecatedString::formatted("{}/{}.h", include_path.dirname(), include_path.title()));
forked_generator.set("include.path", ByteString::formatted("{}/{}.h", include_path.dirname(), include_path.title()));
forked_generator.append(R"~~~(
#include <@include.path@>
)~~~");
@ -275,7 +275,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<DeprecatedString> paths_imported;
HashTable<ByteString> paths_imported;
interfaces.enqueue(&interface);
@ -297,13 +297,13 @@ static void emit_includes_for_all_imports(auto& interface, auto& generator, bool
}
if (is_iterator) {
auto iterator_path = DeprecatedString::formatted("{}Iterator", interface.fully_qualified_name.replace("::"sv, "/"sv, ReplaceMode::All));
auto iterator_path = ByteString::formatted("{}Iterator", interface.fully_qualified_name.replace("::"sv, "/"sv, ReplaceMode::All));
generate_include_for_iterator(generator, iterator_path);
}
}
template<typename ParameterType>
static void generate_to_string(SourceGenerator& scoped_generator, ParameterType const& parameter, bool variadic, bool optional, Optional<DeprecatedString> const& optional_default_value)
static void generate_to_string(SourceGenerator& scoped_generator, ParameterType const& parameter, bool variadic, bool optional, Optional<ByteString> const& optional_default_value)
{
if (variadic) {
scoped_generator.append(R"~~~(
@ -363,7 +363,7 @@ static void generate_to_string(SourceGenerator& scoped_generator, ParameterType
}
template<typename ParameterType>
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)
static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter, ByteString const& js_name, ByteString const& js_suffix, ByteString const& cpp_name, IDL::Interface const& interface, bool legacy_null_to_empty_string = false, bool optional = false, Optional<ByteString> 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);
@ -698,7 +698,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", DeprecatedString::formatted("{}{}_string", enum_generator.get("js_name"sv), enum_generator.get("js_suffix"sv)));
enum_generator.set("js_name.as_string", ByteString::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@ };
)~~~");
@ -761,8 +761,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 = DeprecatedString::formatted("{}_value_{}", member_js_name, i);
auto member_property_value_name = DeprecatedString::formatted("{}_property_value_{}", member_js_name, i);
auto member_value_name = ByteString::formatted("{}_value_{}", member_js_name, i);
auto member_property_value_name = ByteString::formatted("{}_property_value_{}", member_js_name, i);
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);
@ -848,7 +848,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", DeprecatedString::number(recursion_depth));
sequence_generator.set("recursion_depth", ByteString::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.
@ -900,7 +900,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, DeprecatedString::formatted("{}{}", acceptable_cpp_name, optional ? "_non_optional" : ""), DeprecatedString::formatted("{}{}", js_name, js_suffix), DeprecatedString::formatted("iterator_method{}", recursion_depth), interface, recursion_depth + 1);
parameterized_type.generate_sequence_from_iterable(sequence_generator, ByteString::formatted("{}{}", acceptable_cpp_name, optional ? "_non_optional" : ""), ByteString::formatted("{}{}", js_name, js_suffix), ByteString::formatted("iterator_method{}", recursion_depth), interface, recursion_depth + 1);
if (optional) {
sequence_generator.append(R"~~~(
@ -913,7 +913,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", DeprecatedString::number(recursion_depth));
record_generator.set("recursion_depth", ByteString::number(recursion_depth));
// A record can only have two types: key type and value type.
VERIFY(parameterized_type.parameters().size() == 2);
@ -963,7 +963,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", DeprecatedString::number(recursion_depth), DeprecatedString::formatted("typed_key{}", recursion_depth), interface, false, false, {}, false, recursion_depth + 1);
generate_to_cpp(record_generator, key_parameter, "key", ByteString::number(recursion_depth), ByteString::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@));
@ -971,7 +971,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", DeprecatedString::number(recursion_depth), DeprecatedString::formatted("typed_value{}", recursion_depth), interface, false, false, {}, false, recursion_depth + 1);
generate_to_cpp(record_generator, value_parameter, "value", ByteString::number(recursion_depth), ByteString::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@);
@ -984,7 +984,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", DeprecatedString::number(recursion_depth));
union_generator.set("recursion_depth", ByteString::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.
@ -1036,9 +1036,9 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
to_variant_captures.append("&vm, &realm"sv);
if (dictionary_type)
to_variant_captures.append(DeprecatedString::formatted(", &{}{}_to_dictionary", js_name, js_suffix));
to_variant_captures.append(ByteString::formatted(", &{}{}_to_dictionary", js_name, js_suffix));
union_generator.set("to_variant_captures", to_variant_captures.to_deprecated_string());
union_generator.set("to_variant_captures", to_variant_captures.to_byte_string());
union_generator.append(R"~~~(
auto @js_name@@js_suffix@_to_variant = [@to_variant_captures@](JS::Value @js_name@@js_suffix@) -> JS::ThrowCompletionOr<@union_type@> {
@ -1211,7 +1211,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
if (method) {
)~~~");
sequence_type->generate_sequence_from_iterable(union_generator, acceptable_cpp_name, DeprecatedString::formatted("{}{}", js_name, js_suffix), "method", interface, recursion_depth + 1);
sequence_type->generate_sequence_from_iterable(union_generator, acceptable_cpp_name, ByteString::formatted("{}{}", js_name, js_suffix), "method", interface, recursion_depth + 1);
union_generator.append(R"~~~(
@ -1296,8 +1296,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 = 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);
IDL::Parameter parameter { .type = *numeric_type, .name = ByteString::empty(), .optional_default_value = {}, .extended_attributes = {} };
generate_to_cpp(union_generator, parameter, js_name, js_suffix, ByteString::formatted("{}{}_number", js_name, js_suffix), interface, false, false, {}, false, recursion_depth + 1);
union_generator.append(R"~~~(
return { @js_name@@js_suffix@_number };
@ -1361,8 +1361,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 = 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);
IDL::Parameter parameter { .type = *numeric_type, .name = ByteString::empty(), .optional_default_value = {}, .extended_attributes = {} };
generate_to_cpp(union_numeric_type_generator, parameter, "x", ByteString::empty(), "x_number", interface, false, false, {}, false, recursion_depth + 1);
union_numeric_type_generator.append(R"~~~(
return x_number;
@ -1372,8 +1372,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 = 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);
IDL::Parameter parameter { .type = *numeric_type, .name = ByteString::empty(), .optional_default_value = {}, .extended_attributes = {} };
generate_to_cpp(union_generator, parameter, js_name, js_suffix, ByteString::formatted("{}{}_number", js_name, js_suffix), interface, false, false, {}, false, recursion_depth + 1);
union_generator.append(R"~~~(
return { @js_name@@js_suffix@_number };
@ -1457,21 +1457,21 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
}
}
static void generate_argument_count_check(SourceGenerator& generator, DeprecatedString const& function_name, size_t argument_count)
static void generate_argument_count_check(SourceGenerator& generator, ByteString 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", DeprecatedString::number(argument_count));
argument_count_check_generator.set("function.nargs", ByteString::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", DeprecatedString::formatted(", \"{}\"", argument_count));
argument_count_check_generator.set(".arg_count_suffix", ByteString::formatted(", \"{}\"", argument_count));
}
argument_count_check_generator.append(R"~~~(
@ -1484,7 +1484,7 @@ static void generate_arguments(SourceGenerator& generator, Vector<IDL::Parameter
{
auto arguments_generator = generator.fork();
Vector<DeprecatedString> parameter_names;
Vector<ByteString> parameter_names;
size_t argument_index = 0;
for (auto& parameter : parameters) {
auto parameter_name = make_input_acceptable_cpp(parameter.name.to_snakecase());
@ -1492,18 +1492,18 @@ static void generate_arguments(SourceGenerator& generator, Vector<IDL::Parameter
if (parameter.variadic) {
// JS::MarkedVector is non-copyable, and the implementations likely want ownership of the
// list, so we move() it into the parameter list.
parameter_names.append(DeprecatedString::formatted("move({})", parameter_name));
parameter_names.append(ByteString::formatted("move({})", parameter_name));
} else {
parameter_names.append(move(parameter_name));
arguments_generator.set("argument.index", DeprecatedString::number(argument_index));
arguments_generator.set("argument.index", ByteString::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", DeprecatedString::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", ByteString::number(argument_index), parameter.name.to_snakecase(), interface, legacy_null_to_empty_string, parameter.optional, parameter.optional_default_value, parameter.variadic, 0);
++argument_index;
}
@ -1511,13 +1511,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, DeprecatedString const& cpp_name, DeprecatedString const& iterable_cpp_name, DeprecatedString const& iterator_method_cpp_name, IDL::Interface const& interface, size_t recursion_depth) const
void IDL::ParameterizedType::generate_sequence_from_iterable(SourceGenerator& generator, ByteString const& cpp_name, ByteString const& iterable_cpp_name, ByteString 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", DeprecatedString::number(recursion_depth));
sequence_generator.set("recursion_depth", ByteString::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));
@ -1558,7 +1558,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", DeprecatedString::number(recursion_depth), DeprecatedString::formatted("sequence_item{}", recursion_depth), interface, false, false, {}, false, recursion_depth);
generate_to_cpp(sequence_generator, parameter, "next_item", ByteString::number(recursion_depth), ByteString::formatted("sequence_item{}", recursion_depth), interface, false, false, {}, false, recursion_depth);
sequence_generator.append(R"~~~(
@cpp_name@.append(sequence_item@recursion_depth@);
@ -1571,13 +1571,13 @@ enum class WrappingReference {
Yes,
};
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)
static void generate_wrap_statement(SourceGenerator& generator, ByteString 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);
if (!libweb_interface_namespaces.span().contains_slow(type.name())) {
if (is_javascript_builtin(type))
scoped_generator.set("type", DeprecatedString::formatted("JS::{}", type.name()));
scoped_generator.set("type", ByteString::formatted("JS::{}", type.name()));
else
scoped_generator.set("type", type.name());
} else {
@ -1586,10 +1586,10 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString
builder.append(type.name());
builder.append("::"sv);
builder.append(type.name());
scoped_generator.set("type", builder.to_deprecated_string());
scoped_generator.set("type", builder.to_byte_string());
}
scoped_generator.set("result_expression", result_expression);
scoped_generator.set("recursion_depth", DeprecatedString::number(recursion_depth));
scoped_generator.set("recursion_depth", ByteString::number(recursion_depth));
if (type.name() == "undefined") {
scoped_generator.append(R"~~~(
@ -1665,7 +1665,7 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString
auto* wrapped_element@recursion_depth@ = &(*element@recursion_depth@);
)~~~");
} else {
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);
generate_wrap_statement(scoped_generator, ByteString::formatted("element{}", recursion_depth), sequence_generic_type.parameters().first(), interface, ByteString::formatted("auto wrapped_element{} =", recursion_depth), WrappingReference::Yes, recursion_depth + 1);
}
scoped_generator.append(R"~~~(
@ -1730,7 +1730,7 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString
)~~~");
// 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, DeprecatedString::formatted("visited_union_value{}", recursion_depth), current_union_type, interface, "return"sv, WrappingReference::No, recursion_depth + 1);
generate_wrap_statement(union_generator, ByteString::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.
@ -1760,7 +1760,7 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString
} else if (interface.enumerations.contains(type.name())) {
// Handle Enum? values, which were null-checked above
if (type.is_nullable())
scoped_generator.set("value", DeprecatedString::formatted("{}.value()", value));
scoped_generator.set("value", ByteString::formatted("{}.value()", value));
scoped_generator.append(R"~~~(
@result_expression@ JS::PrimitiveString::create(vm, Bindings::idl_enum_to_string(@value@));
)~~~");
@ -1796,18 +1796,18 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString
while (true) {
for (auto& member : current_dictionary->members) {
dictionary_generator.set("member_key", member.name);
auto member_key_js_name = DeprecatedString::formatted("{}{}", make_input_acceptable_cpp(member.name.to_snakecase()), recursion_depth);
auto member_key_js_name = ByteString::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 = DeprecatedString::formatted("{}_value", member_key_js_name);
auto member_value_js_name = ByteString::formatted("{}_value", member_key_js_name);
dictionary_generator.set("member_value", member_value_js_name);
auto wrapped_value_name = DeprecatedString::formatted("wrapped_{}", member_value_js_name);
auto wrapped_value_name = ByteString::formatted("wrapped_{}", member_value_js_name);
dictionary_generator.set("wrapped_value_name", wrapped_value_name);
dictionary_generator.append(R"~~~(
JS::Value @wrapped_value_name@;
)~~~");
generate_wrap_statement(dictionary_generator, DeprecatedString::formatted("{}.{}", value, member.name.to_snakecase()), member.type, interface, DeprecatedString::formatted("{} =", wrapped_value_name), WrappingReference::No, recursion_depth + 1);
generate_wrap_statement(dictionary_generator, ByteString::formatted("{}.{}", value, member.name.to_snakecase()), member.type, interface, ByteString::formatted("{} =", 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@));
@ -1856,23 +1856,23 @@ 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, DeprecatedString const& variable_name, IDL::Type const& value_type, DeprecatedString const& value_name, IDL::Interface const& interface)
static void generate_variable_statement(SourceGenerator& generator, ByteString const& variable_name, IDL::Type const& value_type, ByteString 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, DeprecatedString::formatted("{} = ", variable_name));
return generate_wrap_statement(generator, value_name, value_type, interface, ByteString::formatted("{} = ", variable_name));
}
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)
static void generate_function(SourceGenerator& generator, IDL::Function const& function, StaticFunction is_static_function, ByteString const& class_name, ByteString 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:snakecase", make_input_acceptable_cpp(function.name.to_snakecase()));
function_generator.set("overload_suffix", function.is_overloaded ? DeprecatedString::number(function.overload_index) : DeprecatedString::empty());
function_generator.set("overload_suffix", function.is_overloaded ? ByteString::number(function.overload_index) : ByteString::empty());
if (function.extended_attributes.contains("ImplementedAs")) {
auto implemented_as = function.extended_attributes.get("ImplementedAs").value();
@ -1941,7 +1941,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", DeprecatedString::formatted("vm, {}", arguments_builder.string_view()));
function_generator.set(".arguments", ByteString::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@); }));
@ -2082,7 +2082,7 @@ static Vector<EffectiveOverloadSet::Item> compute_the_effective_overload_set(aut
return overloads;
}
static DeprecatedString generate_constructor_for_idl_type(Type const& type)
static ByteString generate_constructor_for_idl_type(Type const& type)
{
auto append_type_list = [](auto& builder, auto const& type_list) {
bool first = true;
@ -2099,14 +2099,14 @@ static DeprecatedString generate_constructor_for_idl_type(Type const& type)
switch (type.kind()) {
case Type::Kind::Plain:
return DeprecatedString::formatted("make_ref_counted<IDL::Type>(\"{}\", {})", type.name(), type.is_nullable());
return ByteString::formatted("make_ref_counted<IDL::Type>(\"{}\", {})", type.name(), type.is_nullable());
case Type::Kind::Parameterized: {
auto const& parameterized_type = type.as_parameterized();
StringBuilder builder;
builder.appendff("make_ref_counted<IDL::ParameterizedType>(\"{}\", {}, Vector<NonnullRefPtr<IDL::Type const>> {{", type.name(), type.is_nullable());
append_type_list(builder, parameterized_type.parameters());
builder.append("})"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
case Type::Kind::Union: {
auto const& union_type = type.as_union();
@ -2114,7 +2114,7 @@ static DeprecatedString generate_constructor_for_idl_type(Type const& type)
builder.appendff("make_ref_counted<IDL::UnionType>(\"{}\", {}, Vector<NonnullRefPtr<IDL::Type const>> {{", type.name(), type.is_nullable());
append_type_list(builder, union_type.member_types());
builder.append("})"sv);
return builder.to_deprecated_string();
return builder.to_byte_string();
}
}
@ -2145,7 +2145,7 @@ static size_t resolve_distinguishing_argument_index(Interface const& interface,
VERIFY_NOT_REACHED();
}
static void generate_overload_arbiter(SourceGenerator& generator, auto const& overload_set, IDL::Interface const& interface, DeprecatedString const& class_name)
static void generate_overload_arbiter(SourceGenerator& generator, auto const& overload_set, IDL::Interface const& interface, ByteString const& class_name)
{
auto function_generator = generator.fork();
function_generator.set("class_name", class_name);
@ -2161,7 +2161,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", DeprecatedString::number(maximum_argument_count));
function_generator.set("max_argument_count", ByteString::number(maximum_argument_count));
function_generator.appendln(" switch (min(@max_argument_count@, vm.argument_count())) {");
// Generate the effective overload set for each argument count.
@ -2182,8 +2182,8 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@)
if (effective_overload_set.size() > 1)
distinguishing_argument_index = resolve_distinguishing_argument_index(interface, effective_overload_set, argument_count);
function_generator.set("current_argument_count", DeprecatedString::number(argument_count));
function_generator.set("overload_count", DeprecatedString::number(effective_overload_set.size()));
function_generator.set("current_argument_count", ByteString::number(argument_count));
function_generator.set("overload_count", ByteString::number(effective_overload_set.size()));
function_generator.appendln(R"~~~(
case @current_argument_count@: {
Vector<IDL::EffectiveOverloadSet::Item> overloads;
@ -2221,14 +2221,14 @@ JS_DEFINE_NATIVE_FUNCTION(@class_name@::@function.name:snakecase@)
types_builder.append("}"sv);
optionality_builder.append("}"sv);
function_generator.set("overload.callable_id", DeprecatedString::number(overload.callable_id));
function_generator.set("overload.types", types_builder.to_deprecated_string());
function_generator.set("overload.optionality_values", optionality_builder.to_deprecated_string());
function_generator.set("overload.callable_id", ByteString::number(overload.callable_id));
function_generator.set("overload.types", types_builder.to_byte_string());
function_generator.set("overload.optionality_values", optionality_builder.to_byte_string());
function_generator.appendln(" overloads.empend(@overload.callable_id@, @overload.types@, @overload.optionality_values@);");
}
function_generator.set("overload_set.distinguishing_argument_index", DeprecatedString::number(distinguishing_argument_index));
function_generator.set("overload_set.distinguishing_argument_index", ByteString::number(distinguishing_argument_index));
function_generator.append(R"~~~(
effective_overload_set.emplace(move(overloads), @overload_set.distinguishing_argument_index@);
break;
@ -2247,7 +2247,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", DeprecatedString::number(i));
function_generator.set("overload_id", ByteString::number(i));
function_generator.append(R"~~~(
case @overload_id@:
return @function.name:snakecase@@overload_id@(vm);
@ -2274,7 +2274,7 @@ static void generate_prototype_or_global_mixin_declarations(IDL::Interface const
)~~~");
if (overload_set.value.size() > 1) {
for (auto i = 0u; i < overload_set.value.size(); ++i) {
function_generator.set("overload_suffix", DeprecatedString::number(i));
function_generator.set("overload_suffix", ByteString::number(i));
function_generator.append(R"~~~(
JS_DECLARE_NATIVE_FUNCTION(@function.name:snakecase@@overload_suffix@);
)~~~");
@ -2420,7 +2420,7 @@ static void collect_attribute_values_of_an_inheritance_stack(SourceGenerator& fu
continue;
auto attribute_generator = function_generator.fork();
auto return_value_name = DeprecatedString::formatted("{}_retval", attribute.name.to_snakecase());
auto return_value_name = ByteString::formatted("{}_retval", attribute.name.to_snakecase());
attribute_generator.set("attribute.name", attribute.name);
attribute_generator.set("attribute.return_value_name", return_value_name);
@ -2466,7 +2466,7 @@ static void collect_attribute_values_of_an_inheritance_stack(SourceGenerator& fu
)~~~");
}
generate_wrap_statement(attribute_generator, return_value_name, attribute.type, interface_in_chain, DeprecatedString::formatted("auto {}_wrapped =", return_value_name));
generate_wrap_statement(attribute_generator, return_value_name, attribute.type, interface_in_chain, ByteString::formatted("auto {}_wrapped =", return_value_name));
attribute_generator.append(R"~~~(
MUST(result->create_data_property("@attribute.name@", @attribute.return_value_name@_wrapped));
@ -2477,7 +2477,7 @@ static void collect_attribute_values_of_an_inheritance_stack(SourceGenerator& fu
auto constant_generator = function_generator.fork();
constant_generator.set("constant.name", constant.name);
generate_wrap_statement(constant_generator, constant.value, constant.type, interface_in_chain, DeprecatedString::formatted("auto constant_{}_value =", constant.name));
generate_wrap_statement(constant_generator, constant.value, constant.type, interface_in_chain, ByteString::formatted("auto constant_{}_value =", constant.name));
constant_generator.append(R"~~~(
MUST(result->create_data_property("@constant.name@", constant_@constant.name@_value));
@ -2487,7 +2487,7 @@ static void collect_attribute_values_of_an_inheritance_stack(SourceGenerator& fu
}
// https://webidl.spec.whatwg.org/#default-tojson-steps
static void generate_default_to_json_function(SourceGenerator& generator, DeprecatedString const& class_name, IDL::Interface const& start_interface)
static void generate_default_to_json_function(SourceGenerator& generator, ByteString const& class_name, IDL::Interface const& start_interface)
{
// NOTE: This is done heavily out of order since the spec mixes parse time and run time type information together.
@ -2526,7 +2526,7 @@ static void generate_named_properties_object_declarations(IDL::Interface const&
{
SourceGenerator generator { builder };
generator.set("named_properties_class", DeprecatedString::formatted("{}Properties", interface.name));
generator.set("named_properties_class", ByteString::formatted("{}Properties", interface.name));
generator.append(R"~~~(
class @named_properties_class@ : public JS::Object {
@ -2557,7 +2557,7 @@ static void generate_named_properties_object_definitions(IDL::Interface const& i
generator.set("name", interface.name);
generator.set("parent_name", interface.parent_name);
generator.set("prototype_base_class", interface.prototype_base_class);
generator.set("named_properties_class", DeprecatedString::formatted("{}Properties", interface.name));
generator.set("named_properties_class", ByteString::formatted("{}Properties", interface.name));
// https://webidl.spec.whatwg.org/#create-a-named-properties-object
generator.append(R"~~~(
@ -2701,11 +2701,11 @@ static void generate_prototype_or_global_mixin_definitions(IDL::Interface const&
generator.set("prototype_name", interface.prototype_class); // Used for Global Mixin
if (interface.pair_iterator_types.has_value()) {
generator.set("iterator_name", DeprecatedString::formatted("{}Iterator", interface.name));
generator.set("iterator_name", ByteString::formatted("{}Iterator", interface.name));
}
if (is_global_interface) {
generator.set("named_properties_class", DeprecatedString::formatted("{}Properties", interface.name));
generator.set("named_properties_class", ByteString::formatted("{}Properties", interface.name));
// Doing this with macros is not super nice, but simplifies codegen a lot.
generator.append(R"~~~(
#define define_direct_property (object.define_direct_property)
@ -2785,7 +2785,7 @@ void @class_name@::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, DeprecatedString::formatted("auto constant_{}_value =", constant.name));
generate_wrap_statement(constant_generator, constant.value, constant.type, interface, ByteString::formatted("auto constant_{}_value =", constant.name));
constant_generator.append(R"~~~(
define_direct_property("@constant.name@", constant_@constant.name@_value, JS::Attribute::Enumerable);
@ -2797,7 +2797,7 @@ void @class_name@::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", DeprecatedString::number(get_shortest_function_length(overload_set.value)));
function_generator.set("function.length", ByteString::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"); })) {
@ -3351,7 +3351,7 @@ private:
)~~~");
if (overload_set.value.size() > 1) {
for (auto i = 0u; i < overload_set.value.size(); ++i) {
function_generator.set("overload_suffix", DeprecatedString::number(i));
function_generator.set("overload_suffix", ByteString::number(i));
function_generator.append(R"~~~(
JS_DECLARE_NATIVE_FUNCTION(@function.name:snakecase@@overload_suffix@);
)~~~");
@ -3451,7 +3451,7 @@ void @namespace_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", DeprecatedString::number(get_shortest_function_length(overload_set.value)));
function_generator.set("function.length", ByteString::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);
@ -3521,7 +3521,7 @@ private:
)~~~");
if (overload_set.value.size() > 1) {
for (auto i = 0u; i < overload_set.value.size(); ++i) {
function_generator.set("overload_suffix", DeprecatedString::number(i));
function_generator.set("overload_suffix", ByteString::number(i));
function_generator.append(R"~~~(
JS_DECLARE_NATIVE_FUNCTION(@function.name:snakecase@@overload_suffix@);
)~~~");
@ -3694,7 +3694,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> @constructor_class@::constru
}
}
generator.set("constructor.length", DeprecatedString::number(shortest_length));
generator.set("constructor.length", ByteString::number(shortest_length));
generator.append(R"~~~(
auto& vm = this->vm();
@ -3778,7 +3778,7 @@ JS::ThrowCompletionOr<JS::NonnullGCPtr<JS::Object>> @constructor_class@::constru
generator.set(".arg_count_suffix", "");
} else {
generator.set(".bad_arg_count", "JS::ErrorType::BadArgCountMany");
generator.set(".arg_count_suffix", DeprecatedString::formatted(", \"{}\"", shortest_length));
generator.set(".arg_count_suffix", ByteString::formatted(", \"{}\"", shortest_length));
}
generator.append(R"~~~(
@ -3943,7 +3943,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, DeprecatedString::formatted("auto constant_{}_value =", constant.name));
generate_wrap_statement(constant_generator, constant.value, constant.type, interface, ByteString::formatted("auto constant_{}_value =", constant.name));
constant_generator.append(R"~~~(
define_direct_property("@constant.name@", constant_@constant.name@_value, JS::Attribute::Enumerable);
@ -3955,7 +3955,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", DeprecatedString::number(get_shortest_function_length(overload_set.value)));
function_generator.set("function.length", ByteString::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);
@ -4172,7 +4172,7 @@ void @prototype_class@::initialize(JS::Realm& realm)
Base::initialize(realm);
)~~~");
if (interface.supports_named_properties()) {
generator.set("named_properties_class", DeprecatedString::formatted("{}Properties", interface.name));
generator.set("named_properties_class", ByteString::formatted("{}Properties", interface.name));
generator.set("namespaced_name", interface.namespaced_name);
generator.append(R"~~~(
define_direct_property(vm().well_known_symbol_to_string_tag(), JS::PrimitiveString::create(vm(), "@namespaced_name@"_string), JS::Attribute::Configurable);
@ -4198,7 +4198,7 @@ void generate_iterator_prototype_header(IDL::Interface const& interface, StringB
VERIFY(interface.pair_iterator_types.has_value());
SourceGenerator generator { builder };
generator.set("prototype_class", DeprecatedString::formatted("{}IteratorPrototype", interface.name));
generator.set("prototype_class", ByteString::formatted("{}IteratorPrototype", interface.name));
generator.append(R"~~~(
#pragma once
@ -4228,12 +4228,12 @@ void generate_iterator_prototype_implementation(IDL::Interface const& interface,
VERIFY(interface.pair_iterator_types.has_value());
SourceGenerator generator { builder };
generator.set("name", DeprecatedString::formatted("{}Iterator", interface.name));
generator.set("name", ByteString::formatted("{}Iterator", interface.name));
generator.set("parent_name", interface.parent_name);
generator.set("prototype_class", DeprecatedString::formatted("{}IteratorPrototype", interface.name));
generator.set("prototype_class", ByteString::formatted("{}IteratorPrototype", interface.name));
generator.set("prototype_base_class", interface.prototype_base_class);
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.set("fully_qualified_name", ByteString::formatted("{}Iterator", interface.fully_qualified_name));
generator.set("possible_include_path", ByteString::formatted("{}Iterator", interface.name.replace("::"sv, "/"sv, ReplaceMode::All)));
generator.append(R"~~~(
#include <AK/Function.h>

Some files were not shown because too many files have changed in this diff Show more