mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 00:17:46 +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
|
@ -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>
|
||||
|
|
|
@ -78,7 +78,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
builder.append(namespace_);
|
||||
builder.append("::"sv);
|
||||
builder.append(interface.name);
|
||||
interface.fully_qualified_name = builder.to_deprecated_string();
|
||||
interface.fully_qualified_name = builder.to_byte_string();
|
||||
} else {
|
||||
interface.fully_qualified_name = interface.name;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue