mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 19:19:30 +00:00
IDLGenerators: Throw TypeError if IDL ByteString contains element > 255
This commit is contained in:
parent
6dc61f895d
commit
19a5780f0c
Notes:
github-actions[bot]
2024-11-21 20:51:11 +00:00
Author: https://github.com/tcl3
Commit: 19a5780f0c
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2485
Reviewed-by: https://github.com/trflynn89 ✅
3 changed files with 41 additions and 7 deletions
|
@ -342,10 +342,13 @@ static void emit_includes_for_all_imports(auto& interface, auto& generator, bool
|
|||
template<typename ParameterType>
|
||||
static void generate_to_string(SourceGenerator& scoped_generator, ParameterType const& parameter, bool variadic, bool optional, Optional<ByteString> const& optional_default_value)
|
||||
{
|
||||
if (parameter.type->name() == "USVString")
|
||||
scoped_generator.set("to_string", "to_well_formed_string"sv);
|
||||
else
|
||||
if (parameter.type->name() == "USVString") {
|
||||
scoped_generator.set("to_string", "to_usv_string"sv);
|
||||
} else if (parameter.type->name() == "ByteString") {
|
||||
scoped_generator.set("to_string", "to_byte_string"sv);
|
||||
} else {
|
||||
scoped_generator.set("to_string", "to_string"sv);
|
||||
}
|
||||
|
||||
if (variadic) {
|
||||
scoped_generator.append(R"~~~(
|
||||
|
@ -355,7 +358,7 @@ static void generate_to_string(SourceGenerator& scoped_generator, ParameterType
|
|||
@cpp_name@.ensure_capacity(vm.argument_count() - @js_suffix@);
|
||||
|
||||
for (size_t i = @js_suffix@; i < vm.argument_count(); ++i) {
|
||||
auto to_string_result = TRY(vm.argument(i).@to_string@(vm));
|
||||
auto to_string_result = TRY(WebIDL::@to_string@(vm, vm.argument(i)));
|
||||
@cpp_name@.unchecked_append(move(to_string_result));
|
||||
}
|
||||
}
|
||||
|
@ -365,14 +368,14 @@ static void generate_to_string(SourceGenerator& scoped_generator, ParameterType
|
|||
scoped_generator.append(R"~~~(
|
||||
@string_type@ @cpp_name@;
|
||||
if (!@legacy_null_to_empty_string@ || !@js_name@@js_suffix@.is_null()) {
|
||||
@cpp_name@ = TRY(@js_name@@js_suffix@.@to_string@(vm));
|
||||
@cpp_name@ = TRY(WebIDL::@to_string@(vm, @js_name@@js_suffix@));
|
||||
}
|
||||
)~~~");
|
||||
} else {
|
||||
scoped_generator.append(R"~~~(
|
||||
Optional<@string_type@> @cpp_name@;
|
||||
if (!@js_name@@js_suffix@.is_nullish())
|
||||
@cpp_name@ = TRY(@js_name@@js_suffix@.@to_string@(vm));
|
||||
@cpp_name@ = TRY(WebIDL::@to_string@(vm, @js_name@@js_suffix@));
|
||||
)~~~");
|
||||
}
|
||||
} else {
|
||||
|
@ -390,7 +393,7 @@ static void generate_to_string(SourceGenerator& scoped_generator, ParameterType
|
|||
scoped_generator.append(R"~~~(
|
||||
if (!@js_name@@js_suffix@.is_undefined()) {
|
||||
if (!@legacy_null_to_empty_string@ || !@js_name@@js_suffix@.is_null())
|
||||
@cpp_name@ = TRY(@js_name@@js_suffix@.@to_string@(vm));
|
||||
@cpp_name@ = TRY(WebIDL::@to_string@(vm, @js_name@@js_suffix@));
|
||||
})~~~");
|
||||
if (!may_be_null) {
|
||||
scoped_generator.append(R"~~~( else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue