1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:17:44 +00:00

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -48,7 +48,7 @@ JS::NonnullGCPtr<JS::PromiseCapability> Body::fully_read_as_promise() const
// FIXME: Implement the streams spec - this is completely made up for now :^)
if (auto const* byte_buffer = m_source.get_pointer<ByteBuffer>()) {
auto result = String::copy(*byte_buffer);
auto result = DeprecatedString::copy(*byte_buffer);
return WebIDL::create_resolved_promise(realm, JS::js_string(vm, move(result)));
}
// Empty, Blob, FormData

View file

@ -86,7 +86,7 @@ ErrorOr<Optional<ByteBuffer>> HeaderList::get(ReadonlyBytes name) const
}
// https://fetch.spec.whatwg.org/#concept-header-list-get-decode-split
ErrorOr<Optional<Vector<String>>> HeaderList::get_decode_and_split(ReadonlyBytes name) const
ErrorOr<Optional<Vector<DeprecatedString>>> HeaderList::get_decode_and_split(ReadonlyBytes name) const
{
// To get, decode, and split a header name name from header list list, run these steps:
@ -95,7 +95,7 @@ ErrorOr<Optional<Vector<String>>> HeaderList::get_decode_and_split(ReadonlyBytes
// 2. If initialValue is null, then return null.
if (!initial_value.has_value())
return Optional<Vector<String>> {};
return Optional<Vector<DeprecatedString>> {};
// 3. Let input be the result of isomorphic decoding initialValue.
auto input = StringView { *initial_value };
@ -104,7 +104,7 @@ ErrorOr<Optional<Vector<String>>> HeaderList::get_decode_and_split(ReadonlyBytes
auto lexer = GenericLexer { input };
// 5. Let values be a list of strings, initially empty.
Vector<String> values;
Vector<DeprecatedString> values;
// 6. Let value be the empty string.
StringBuilder value_builder;
@ -273,10 +273,10 @@ ErrorOr<Vector<Header>> HeaderList::sort_and_combine() const
Optional<MimeSniff::MimeType> HeaderList::extract_mime_type() const
{
// 1. Let charset be null.
Optional<String> charset;
Optional<DeprecatedString> charset;
// 2. Let essence be null.
Optional<String> essence;
Optional<DeprecatedString> essence;
// 3. Let mimeType be null.
Optional<MimeSniff::MimeType> mime_type;

View file

@ -7,11 +7,11 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/Error.h>
#include <AK/Forward.h>
#include <AK/HashTable.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibJS/Forward.h>
#include <LibJS/Heap/Cell.h>
@ -44,7 +44,7 @@ public:
[[nodiscard]] bool contains(ReadonlyBytes) const;
[[nodiscard]] ErrorOr<Optional<ByteBuffer>> get(ReadonlyBytes) const;
[[nodiscard]] ErrorOr<Optional<Vector<String>>> get_decode_and_split(ReadonlyBytes) const;
[[nodiscard]] ErrorOr<Optional<Vector<DeprecatedString>>> get_decode_and_split(ReadonlyBytes) const;
[[nodiscard]] ErrorOr<void> append(Header);
void delete_(ReadonlyBytes name);
[[nodiscard]] ErrorOr<void> set(Header);

View file

@ -177,7 +177,7 @@ bool Request::has_redirect_tainted_origin() const
}
// https://fetch.spec.whatwg.org/#serializing-a-request-origin
String Request::serialize_origin() const
DeprecatedString Request::serialize_origin() const
{
// 1. If request has a redirect-tainted origin, then return "null".
if (has_redirect_tainted_origin())
@ -260,14 +260,14 @@ ErrorOr<void> Request::add_range_header(u64 first, Optional<u64> const& last)
auto range_value = MUST(ByteBuffer::copy("bytes"sv.bytes()));
// 3. Serialize and isomorphic encode first, and append the result to rangeValue.
TRY(range_value.try_append(String::number(first).bytes()));
TRY(range_value.try_append(DeprecatedString::number(first).bytes()));
// 4. Append 0x2D (-) to rangeValue.
TRY(range_value.try_append('-'));
// 5. If last is given, then serialize and isomorphic encode it, and append the result to rangeValue.
if (last.has_value())
TRY(range_value.try_append(String::number(*last).bytes()));
TRY(range_value.try_append(DeprecatedString::number(*last).bytes()));
// 6. Append (`Range`, rangeValue) to requests header list.
auto header = Header {

View file

@ -7,10 +7,10 @@
#pragma once
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/Error.h>
#include <AK/Forward.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <AK/URL.h>
#include <AK/Variant.h>
#include <AK/Vector.h>
@ -185,8 +185,8 @@ public:
[[nodiscard]] ReservedClientType& reserved_client() { return m_reserved_client; }
void set_reserved_client(ReservedClientType reserved_client) { m_reserved_client = move(reserved_client); }
[[nodiscard]] String const& replaces_client_id() const { return m_replaces_client_id; }
void set_replaces_client_id(String replaces_client_id) { m_replaces_client_id = move(replaces_client_id); }
[[nodiscard]] DeprecatedString const& replaces_client_id() const { return m_replaces_client_id; }
void set_replaces_client_id(DeprecatedString replaces_client_id) { m_replaces_client_id = move(replaces_client_id); }
[[nodiscard]] WindowType const& window() const { return m_window; }
void set_window(WindowType window) { m_window = move(window); }
@ -233,11 +233,11 @@ public:
[[nodiscard]] RedirectMode redirect_mode() const { return m_redirect_mode; }
void set_redirect_mode(RedirectMode redirect_mode) { m_redirect_mode = redirect_mode; }
[[nodiscard]] String const& integrity_metadata() const { return m_integrity_metadata; }
void set_integrity_metadata(String integrity_metadata) { m_integrity_metadata = move(integrity_metadata); }
[[nodiscard]] DeprecatedString const& integrity_metadata() const { return m_integrity_metadata; }
void set_integrity_metadata(DeprecatedString integrity_metadata) { m_integrity_metadata = move(integrity_metadata); }
[[nodiscard]] String const& cryptographic_nonce_metadata() const { return m_cryptographic_nonce_metadata; }
void set_cryptographic_nonce_metadata(String cryptographic_nonce_metadata) { m_cryptographic_nonce_metadata = move(cryptographic_nonce_metadata); }
[[nodiscard]] DeprecatedString const& cryptographic_nonce_metadata() const { return m_cryptographic_nonce_metadata; }
void set_cryptographic_nonce_metadata(DeprecatedString cryptographic_nonce_metadata) { m_cryptographic_nonce_metadata = move(cryptographic_nonce_metadata); }
[[nodiscard]] Optional<ParserMetadata> const& parser_metadata() const { return m_parser_metadata; }
void set_parser_metadata(Optional<ParserMetadata> parser_metadata) { m_parser_metadata = move(parser_metadata); }
@ -293,7 +293,7 @@ public:
[[nodiscard]] bool has_redirect_tainted_origin() const;
[[nodiscard]] String serialize_origin() const;
[[nodiscard]] DeprecatedString serialize_origin() const;
[[nodiscard]] ErrorOr<ByteBuffer> byte_serialize_origin() const;
[[nodiscard]] WebIDL::ExceptionOr<JS::NonnullGCPtr<Request>> clone(JS::VM&) const;
@ -351,7 +351,7 @@ private:
// https://fetch.spec.whatwg.org/#concept-request-replaces-client-id
// A request has an associated replaces client id (a string). Unless stated otherwise it is the empty string.
String m_replaces_client_id { String::empty() };
DeprecatedString m_replaces_client_id { DeprecatedString::empty() };
// https://fetch.spec.whatwg.org/#concept-request-window
// A request has an associated window ("no-window", "client", or an environment settings object whose global object
@ -443,12 +443,12 @@ private:
// https://fetch.spec.whatwg.org/#concept-request-integrity-metadata
// A request has associated integrity metadata (a string). Unless stated otherwise, it is the empty string.
String m_integrity_metadata { String::empty() };
DeprecatedString m_integrity_metadata { DeprecatedString::empty() };
// https://fetch.spec.whatwg.org/#concept-request-nonce-metadata
// A request has associated cryptographic nonce metadata (a string). Unless stated otherwise, it is the empty
// string.
String m_cryptographic_nonce_metadata { String::empty() };
DeprecatedString m_cryptographic_nonce_metadata { DeprecatedString::empty() };
// https://fetch.spec.whatwg.org/#concept-request-parser-metadata
// A request has associated parser metadata which is the empty string, "parser-inserted", or

View file

@ -43,7 +43,7 @@ JS::NonnullGCPtr<Response> Response::aborted_network_error(JS::VM& vm)
return response;
}
JS::NonnullGCPtr<Response> Response::network_error(JS::VM& vm, String message)
JS::NonnullGCPtr<Response> Response::network_error(JS::VM& vm, DeprecatedString message)
{
dbgln_if(WEB_FETCH_DEBUG, "Fetch: Creating network error response with message: {}", message);
auto response = Response::create(vm);
@ -93,7 +93,7 @@ Optional<AK::URL const&> Response::url() const
}
// https://fetch.spec.whatwg.org/#concept-response-location-url
ErrorOr<Optional<AK::URL>> Response::location_url(Optional<String> const& request_fragment) const
ErrorOr<Optional<AK::URL>> Response::location_url(Optional<DeprecatedString> const& request_fragment) const
{
// The location URL of a response response, given null or an ASCII string requestFragment, is the value returned by the following steps. They return null, failure, or a URL.

View file

@ -50,7 +50,7 @@ public:
[[nodiscard]] static JS::NonnullGCPtr<Response> create(JS::VM&);
[[nodiscard]] static JS::NonnullGCPtr<Response> aborted_network_error(JS::VM&);
[[nodiscard]] static JS::NonnullGCPtr<Response> network_error(JS::VM&, String message);
[[nodiscard]] static JS::NonnullGCPtr<Response> network_error(JS::VM&, DeprecatedString message);
[[nodiscard]] static JS::NonnullGCPtr<Response> appropriate_network_error(JS::VM&, FetchParams const&);
virtual ~Response() = default;
@ -103,12 +103,12 @@ public:
[[nodiscard]] bool is_network_error() const;
[[nodiscard]] Optional<AK::URL const&> url() const;
[[nodiscard]] ErrorOr<Optional<AK::URL>> location_url(Optional<String> const& request_fragment) const;
[[nodiscard]] ErrorOr<Optional<AK::URL>> location_url(Optional<DeprecatedString> const& request_fragment) const;
[[nodiscard]] WebIDL::ExceptionOr<JS::NonnullGCPtr<Response>> clone(JS::VM&) const;
// Non-standard
Optional<String> const& network_error_message() const { return m_network_error_message; }
Optional<DeprecatedString> const& network_error_message() const { return m_network_error_message; }
protected:
explicit Response(JS::NonnullGCPtr<HeaderList>);
@ -176,7 +176,7 @@ private:
bool m_has_cross_origin_redirects { false };
// Non-standard
Optional<String> m_network_error_message;
Optional<DeprecatedString> m_network_error_message;
};
// https://fetch.spec.whatwg.org/#concept-filtered-response