mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:37:34 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -22,7 +22,7 @@ TESTJS_GLOBAL_FUNCTION(is_strict_mode, isStrictMode, 0)
|
|||
|
||||
TESTJS_GLOBAL_FUNCTION(can_parse_source, canParseSource)
|
||||
{
|
||||
auto source = TRY(vm.argument(0).to_deprecated_string(vm));
|
||||
auto source = TRY(vm.argument(0).to_byte_string(vm));
|
||||
auto parser = JS::Parser(JS::Lexer(source));
|
||||
(void)parser.parse_program();
|
||||
return JS::Value(!parser.has_errors());
|
||||
|
@ -65,14 +65,14 @@ TESTJS_GLOBAL_FUNCTION(mark_as_garbage, markAsGarbage)
|
|||
return execution_context->lexical_environment != nullptr;
|
||||
});
|
||||
if (!outer_environment.has_value())
|
||||
return vm.throw_completion<JS::ReferenceError>(JS::ErrorType::UnknownIdentifier, variable_name.deprecated_string());
|
||||
return vm.throw_completion<JS::ReferenceError>(JS::ErrorType::UnknownIdentifier, variable_name.byte_string());
|
||||
|
||||
auto reference = TRY(vm.resolve_binding(variable_name.deprecated_string(), outer_environment.value()->lexical_environment));
|
||||
auto reference = TRY(vm.resolve_binding(variable_name.byte_string(), outer_environment.value()->lexical_environment));
|
||||
|
||||
auto value = TRY(reference.get_value(vm));
|
||||
|
||||
if (!can_be_held_weakly(value))
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::CannotBeHeldWeakly, DeprecatedString::formatted("Variable with name {}", variable_name.deprecated_string()));
|
||||
return vm.throw_completion<JS::TypeError>(JS::ErrorType::CannotBeHeldWeakly, ByteString::formatted("Variable with name {}", variable_name.byte_string()));
|
||||
|
||||
vm.heap().uproot_cell(&value.as_cell());
|
||||
TRY(reference.delete_(vm));
|
||||
|
@ -111,7 +111,7 @@ TESTJS_GLOBAL_FUNCTION(set_time_zone, setTimeZone)
|
|||
return current_time_zone;
|
||||
}
|
||||
|
||||
TESTJS_RUN_FILE_FUNCTION(DeprecatedString const& test_file, JS::Realm& realm, JS::ExecutionContext&)
|
||||
TESTJS_RUN_FILE_FUNCTION(ByteString const& test_file, JS::Realm& realm, JS::ExecutionContext&)
|
||||
{
|
||||
if (!test262_parser_tests)
|
||||
return Test::JS::RunFileHookResult::RunAsNormal;
|
||||
|
@ -146,8 +146,8 @@ TESTJS_RUN_FILE_FUNCTION(DeprecatedString const& test_file, JS::Realm& realm, JS
|
|||
parse_succeeded = !Test::JS::parse_script(test_file, realm).is_error();
|
||||
|
||||
bool test_passed = true;
|
||||
DeprecatedString message;
|
||||
DeprecatedString expectation_string;
|
||||
ByteString message;
|
||||
ByteString expectation_string;
|
||||
|
||||
switch (expectation) {
|
||||
case Early:
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/JsonObject.h>
|
||||
|
@ -107,7 +107,7 @@ static StringView emoji_for_result(TestResult result)
|
|||
|
||||
static constexpr StringView total_test_emoji = "🧪"sv;
|
||||
|
||||
static ErrorOr<HashMap<size_t, TestResult>> run_test_files(Span<DeprecatedString> files, size_t offset, StringView command, char const* const arguments[])
|
||||
static ErrorOr<HashMap<size_t, TestResult>> run_test_files(Span<ByteString> files, size_t offset, StringView command, char const* const arguments[])
|
||||
{
|
||||
HashMap<size_t, TestResult> results {};
|
||||
TRY(results.try_ensure_capacity(files.size()));
|
||||
|
@ -133,12 +133,12 @@ static ErrorOr<HashMap<size_t, TestResult>> run_test_files(Span<DeprecatedString
|
|||
}
|
||||
|
||||
auto output_or_error = runner_process->read_all();
|
||||
DeprecatedString output;
|
||||
ByteString output;
|
||||
|
||||
if (output_or_error.is_error())
|
||||
warnln("Got error: {} while reading runner output", output_or_error.error());
|
||||
else
|
||||
output = DeprecatedString(output_or_error.release_value().standard_error.bytes(), Chomp);
|
||||
output = ByteString(output_or_error.release_value().standard_error.bytes(), Chomp);
|
||||
|
||||
auto status_or_error = runner_process->status();
|
||||
bool failed = false;
|
||||
|
@ -162,7 +162,7 @@ static ErrorOr<HashMap<size_t, TestResult>> run_test_files(Span<DeprecatedString
|
|||
auto result_object_or_error = parser.parse();
|
||||
if (!result_object_or_error.is_error() && result_object_or_error.value().is_object()) {
|
||||
auto& result_object = result_object_or_error.value().as_object();
|
||||
if (auto result_string = result_object.get_deprecated_string("result"sv); result_string.has_value()) {
|
||||
if (auto result_string = result_object.get_byte_string("result"sv); result_string.has_value()) {
|
||||
auto const& view = result_string.value();
|
||||
// Timeout and assert fail already are the result of the stopping test
|
||||
if (view == "timeout"sv || view == "assert_fail"sv) {
|
||||
|
@ -190,7 +190,7 @@ static ErrorOr<HashMap<size_t, TestResult>> run_test_files(Span<DeprecatedString
|
|||
return results;
|
||||
}
|
||||
|
||||
void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<DeprecatedString> const& paths, StringView per_file_name, double time_taken_in_ms);
|
||||
void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<ByteString> const& paths, StringView per_file_name, double time_taken_in_ms);
|
||||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
|
@ -213,12 +213,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
args_parser.parse(arguments);
|
||||
|
||||
// Normalize the path to ensure filenames are consistent
|
||||
Vector<DeprecatedString> paths;
|
||||
Vector<ByteString> paths;
|
||||
|
||||
if (!FileSystem::is_directory(test_directory)) {
|
||||
paths.append(test_directory);
|
||||
} else {
|
||||
Test::iterate_directory_recursively(LexicalPath::canonicalized_path(test_directory), [&](DeprecatedString const& file_path) {
|
||||
Test::iterate_directory_recursively(LexicalPath::canonicalized_path(test_directory), [&](ByteString const& file_path) {
|
||||
if (file_path.contains("_FIXTURE"sv))
|
||||
return;
|
||||
// FIXME: Add ignored file set
|
||||
|
@ -230,7 +230,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
outln("Found {} tests", paths.size());
|
||||
|
||||
auto parameters = pass_through_parameters.split_view(' ');
|
||||
Vector<DeprecatedString> args;
|
||||
Vector<ByteString> args;
|
||||
args.ensure_capacity(parameters.size() + 2);
|
||||
args.append(runner_command);
|
||||
if (!dont_disable_core_dump)
|
||||
|
@ -301,7 +301,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<DeprecatedString> const& paths, StringView per_file_name, double time_taken_in_ms)
|
||||
void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<ByteString> const& paths, StringView per_file_name, double time_taken_in_ms)
|
||||
{
|
||||
|
||||
auto file_or_error = Core::File::open(per_file_name, Core::File::OpenMode::Write);
|
||||
|
@ -320,7 +320,7 @@ void write_per_file(HashMap<size_t, TestResult> const& result_map, Vector<Deprec
|
|||
complete_results.set("duration", time_taken_in_ms / 1000.);
|
||||
complete_results.set("results", result_object);
|
||||
|
||||
if (file->write_until_depleted(complete_results.to_deprecated_string().bytes()).is_error())
|
||||
if (file->write_until_depleted(complete_results.to_byte_string().bytes()).is_error())
|
||||
warnln("Failed to write per-file");
|
||||
file->close();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/Result.h>
|
||||
|
@ -32,9 +32,9 @@
|
|||
# include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
static DeprecatedString s_current_test = "";
|
||||
static ByteString s_current_test = "";
|
||||
static bool s_parse_only = false;
|
||||
static DeprecatedString s_harness_file_directory;
|
||||
static ByteString s_harness_file_directory;
|
||||
static bool s_automatic_harness_detection_mode = false;
|
||||
|
||||
enum class NegativePhase {
|
||||
|
@ -46,9 +46,9 @@ enum class NegativePhase {
|
|||
|
||||
struct TestError {
|
||||
NegativePhase phase { NegativePhase::ParseOrEarly };
|
||||
DeprecatedString type;
|
||||
DeprecatedString details;
|
||||
DeprecatedString harness_file;
|
||||
ByteString type;
|
||||
ByteString details;
|
||||
ByteString harness_file;
|
||||
};
|
||||
|
||||
using ScriptOrModuleProgram = Variant<JS::NonnullGCPtr<JS::Script>, JS::NonnullGCPtr<JS::SourceTextModule>>;
|
||||
|
@ -61,7 +61,7 @@ static Result<ScriptOrModuleProgram, TestError> parse_program(JS::Realm& realm,
|
|||
return TestError {
|
||||
NegativePhase::ParseOrEarly,
|
||||
"SyntaxError",
|
||||
script_or_error.error()[0].to_deprecated_string(),
|
||||
script_or_error.error()[0].to_byte_string(),
|
||||
""
|
||||
};
|
||||
}
|
||||
|
@ -92,39 +92,39 @@ static Result<void, TestError> run_program(InterpreterT& interpreter, ScriptOrMo
|
|||
|
||||
auto name = object.get_without_side_effects("name");
|
||||
if (!name.is_empty() && !name.is_accessor()) {
|
||||
error.type = name.to_string_without_side_effects().to_deprecated_string();
|
||||
error.type = name.to_string_without_side_effects().to_byte_string();
|
||||
} else {
|
||||
auto constructor = object.get_without_side_effects("constructor");
|
||||
if (constructor.is_object()) {
|
||||
name = constructor.as_object().get_without_side_effects("name");
|
||||
if (!name.is_undefined())
|
||||
error.type = name.to_string_without_side_effects().to_deprecated_string();
|
||||
error.type = name.to_string_without_side_effects().to_byte_string();
|
||||
}
|
||||
}
|
||||
|
||||
auto message = object.get_without_side_effects("message");
|
||||
if (!message.is_empty() && !message.is_accessor())
|
||||
error.details = message.to_string_without_side_effects().to_deprecated_string();
|
||||
error.details = message.to_string_without_side_effects().to_byte_string();
|
||||
}
|
||||
if (error.type.is_empty())
|
||||
error.type = error_value.to_string_without_side_effects().to_deprecated_string();
|
||||
error.type = error_value.to_string_without_side_effects().to_byte_string();
|
||||
return error;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
static HashMap<DeprecatedString, DeprecatedString> s_cached_harness_files;
|
||||
static HashMap<ByteString, ByteString> s_cached_harness_files;
|
||||
|
||||
static Result<StringView, TestError> read_harness_file(StringView harness_file)
|
||||
{
|
||||
auto cache = s_cached_harness_files.find(harness_file);
|
||||
if (cache == s_cached_harness_files.end()) {
|
||||
auto file_or_error = Core::File::open(DeprecatedString::formatted("{}{}", s_harness_file_directory, harness_file), Core::File::OpenMode::Read);
|
||||
auto file_or_error = Core::File::open(ByteString::formatted("{}{}", s_harness_file_directory, harness_file), Core::File::OpenMode::Read);
|
||||
if (file_or_error.is_error()) {
|
||||
return TestError {
|
||||
NegativePhase::Harness,
|
||||
"filesystem",
|
||||
DeprecatedString::formatted("Could not open file: {}", harness_file),
|
||||
ByteString::formatted("Could not open file: {}", harness_file),
|
||||
harness_file
|
||||
};
|
||||
}
|
||||
|
@ -134,13 +134,13 @@ static Result<StringView, TestError> read_harness_file(StringView harness_file)
|
|||
return TestError {
|
||||
NegativePhase::Harness,
|
||||
"filesystem",
|
||||
DeprecatedString::formatted("Could not read file: {}", harness_file),
|
||||
ByteString::formatted("Could not read file: {}", harness_file),
|
||||
harness_file
|
||||
};
|
||||
}
|
||||
|
||||
StringView contents_view = contents_or_error.value();
|
||||
s_cached_harness_files.set(harness_file, contents_view.to_deprecated_string());
|
||||
s_cached_harness_files.set(harness_file, contents_view.to_byte_string());
|
||||
cache = s_cached_harness_files.find(harness_file);
|
||||
VERIFY(cache != s_cached_harness_files.end());
|
||||
}
|
||||
|
@ -206,7 +206,7 @@ static Result<void, TestError> run_test(StringView source, StringView filepath,
|
|||
return TestError {
|
||||
NegativePhase::ParseOrEarly,
|
||||
"SyntaxError",
|
||||
parser.errors()[0].to_deprecated_string(),
|
||||
parser.errors()[0].to_byte_string(),
|
||||
""
|
||||
};
|
||||
}
|
||||
|
@ -250,14 +250,14 @@ static Result<void, TestError> run_test(StringView source, StringView filepath,
|
|||
return run_program(vm->bytecode_interpreter(), program_or_error.value());
|
||||
}
|
||||
|
||||
static Result<TestMetadata, DeprecatedString> extract_metadata(StringView source)
|
||||
static Result<TestMetadata, ByteString> extract_metadata(StringView source)
|
||||
{
|
||||
auto lines = source.lines();
|
||||
|
||||
TestMetadata metadata;
|
||||
|
||||
bool parsing_negative = false;
|
||||
DeprecatedString failed_message;
|
||||
ByteString failed_message;
|
||||
|
||||
auto parse_list = [&](StringView line) {
|
||||
auto start = line.find('[');
|
||||
|
@ -268,7 +268,7 @@ static Result<TestMetadata, DeprecatedString> extract_metadata(StringView source
|
|||
|
||||
auto end = line.find_last(']');
|
||||
if (!end.has_value() || end.value() <= start.value()) {
|
||||
failed_message = DeprecatedString::formatted("Can't parse list in '{}'", line);
|
||||
failed_message = ByteString::formatted("Can't parse list in '{}'", line);
|
||||
return items;
|
||||
}
|
||||
|
||||
|
@ -281,7 +281,7 @@ static Result<TestMetadata, DeprecatedString> extract_metadata(StringView source
|
|||
auto second_word = [&](StringView line) {
|
||||
auto separator = line.find(' ');
|
||||
if (!separator.has_value() || separator.value() >= (line.length() - 1u)) {
|
||||
failed_message = DeprecatedString::formatted("Can't parse value after space in '{}'", line);
|
||||
failed_message = ByteString::formatted("Can't parse value after space in '{}'", line);
|
||||
return ""sv;
|
||||
}
|
||||
return line.substring_view(separator.value() + 1);
|
||||
|
@ -335,7 +335,7 @@ static Result<TestMetadata, DeprecatedString> extract_metadata(StringView source
|
|||
metadata.phase = NegativePhase::Runtime;
|
||||
} else {
|
||||
has_phase = false;
|
||||
failed_message = DeprecatedString::formatted("Unknown negative phase: {}", phase);
|
||||
failed_message = ByteString::formatted("Unknown negative phase: {}", phase);
|
||||
break;
|
||||
}
|
||||
} else if (line.starts_with("type:"sv)) {
|
||||
|
@ -392,7 +392,7 @@ static Result<TestMetadata, DeprecatedString> extract_metadata(StringView source
|
|||
}
|
||||
|
||||
if (failed_message.is_empty())
|
||||
failed_message = DeprecatedString::formatted("Never reached end of comment '---*/'");
|
||||
failed_message = ByteString::formatted("Never reached end of comment '---*/'");
|
||||
|
||||
return failed_message;
|
||||
}
|
||||
|
@ -416,7 +416,7 @@ static bool verify_test(Result<void, TestError>& result, TestMetadata const& met
|
|||
}
|
||||
|
||||
if (metadata.is_async && output.has("output"sv)) {
|
||||
auto output_messages = output.get_deprecated_string("output"sv);
|
||||
auto output_messages = output.get_byte_string("output"sv);
|
||||
VERIFY(output_messages.has_value());
|
||||
if (output_messages->contains("AsyncTestFailure:InternalError: TODO("sv)) {
|
||||
output.set("todo_error", true);
|
||||
|
@ -467,7 +467,7 @@ static bool verify_test(Result<void, TestError>& result, TestMetadata const& met
|
|||
|
||||
JsonObject expected_error_object;
|
||||
expected_error_object.set("phase", phase_to_string(metadata.phase));
|
||||
expected_error_object.set("type", metadata.type.to_deprecated_string());
|
||||
expected_error_object.set("type", metadata.type.to_byte_string());
|
||||
|
||||
expected_error = expected_error_object;
|
||||
|
||||
|
@ -506,7 +506,7 @@ static bool verify_test(Result<void, TestError>& result, TestMetadata const& met
|
|||
return error.phase == metadata.phase && error.type == metadata.type;
|
||||
}
|
||||
|
||||
static bool extract_harness_directory(DeprecatedString const& test_file_path)
|
||||
static bool extract_harness_directory(ByteString const& test_file_path)
|
||||
{
|
||||
auto test_directory_index = test_file_path.find("test/"sv);
|
||||
if (!test_directory_index.has_value()) {
|
||||
|
@ -514,7 +514,7 @@ static bool extract_harness_directory(DeprecatedString const& test_file_path)
|
|||
return false;
|
||||
}
|
||||
|
||||
s_harness_file_directory = DeprecatedString::formatted("{}harness/", test_file_path.substring_view(0, test_directory_index.value()));
|
||||
s_harness_file_directory = ByteString::formatted("{}harness/", test_file_path.substring_view(0, test_directory_index.value()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -532,7 +532,7 @@ static bool g_in_assert = false;
|
|||
assert_fail_result.set("assert_fail", true);
|
||||
assert_fail_result.set("result", "assert_fail");
|
||||
assert_fail_result.set("output", assert_failed_message);
|
||||
outln(saved_stdout_fd, "RESULT {}{}", assert_fail_result.to_deprecated_string(), '\0');
|
||||
outln(saved_stdout_fd, "RESULT {}{}", assert_fail_result.to_byte_string(), '\0');
|
||||
// (Attempt to) Ensure that messages are written before quitting.
|
||||
fflush(saved_stdout_fd);
|
||||
fflush(stderr);
|
||||
|
@ -555,7 +555,7 @@ extern "C" __attribute__((__noreturn__)) void __assert_fail(char const* assertio
|
|||
extern "C" __attribute__((__noreturn__)) void __assert_fail(char const* assertion, char const* file, unsigned int line, char const* function)
|
||||
# endif
|
||||
{
|
||||
auto full_message = DeprecatedString::formatted("{}:{}: {}: Assertion `{}' failed.", file, line, function, assertion);
|
||||
auto full_message = ByteString::formatted("{}:{}: {}: Assertion `{}' failed.", file, line, function, assertion);
|
||||
handle_failed_assert(full_message.characters());
|
||||
}
|
||||
#endif
|
||||
|
@ -598,7 +598,7 @@ int main(int argc, char** argv)
|
|||
if (s_harness_file_directory.is_empty()) {
|
||||
s_automatic_harness_detection_mode = true;
|
||||
} else if (!s_harness_file_directory.ends_with('/')) {
|
||||
s_harness_file_directory = DeprecatedString::formatted("{}/", s_harness_file_directory);
|
||||
s_harness_file_directory = ByteString::formatted("{}/", s_harness_file_directory);
|
||||
}
|
||||
|
||||
if (timeout <= 0) {
|
||||
|
@ -651,10 +651,10 @@ int main(int argc, char** argv)
|
|||
auto collect_output = [&] {
|
||||
fflush(stdout);
|
||||
auto nread = read(stdout_pipe[0], buffer, BUFFER_SIZE);
|
||||
Optional<DeprecatedString> value;
|
||||
Optional<ByteString> value;
|
||||
|
||||
if (nread > 0) {
|
||||
value = DeprecatedString { buffer, static_cast<size_t>(nread) };
|
||||
value = ByteString { buffer, static_cast<size_t>(nread) };
|
||||
while (nread > 0) {
|
||||
nread = read(stdout_pipe[0], buffer, BUFFER_SIZE);
|
||||
}
|
||||
|
@ -707,7 +707,7 @@ int main(int argc, char** argv)
|
|||
|
||||
count++;
|
||||
|
||||
DeprecatedString source_with_strict;
|
||||
ByteString source_with_strict;
|
||||
static StringView use_strict = "'use strict';\n"sv;
|
||||
static size_t strict_length = use_strict.length();
|
||||
|
||||
|
@ -721,7 +721,7 @@ int main(int argc, char** argv)
|
|||
StringBuilder builder { contents.size() + strict_length };
|
||||
builder.append(use_strict);
|
||||
builder.append(contents);
|
||||
source_with_strict = builder.to_deprecated_string();
|
||||
source_with_strict = builder.to_byte_string();
|
||||
}
|
||||
|
||||
StringView with_strict = source_with_strict.view();
|
||||
|
@ -731,7 +731,7 @@ int main(int argc, char** argv)
|
|||
result_object.set("test", path);
|
||||
|
||||
ScopeGuard output_guard = [&] {
|
||||
outln(saved_stdout_fd, "RESULT {}{}", result_object.to_deprecated_string(), '\0');
|
||||
outln(saved_stdout_fd, "RESULT {}{}", result_object.to_byte_string(), '\0');
|
||||
fflush(saved_stdout_fd);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue