mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-27 05:05:32 +03:00
LibWeb: Support nullable integral IDL types
We currently support optional integral types, but not nullable types. So if an IDL contains e.g. "long?", passing null will be coerced to 0. This will be used by the Inspector, but will also eventually be used by real IDL interfaces (e.g. HTMLInputElement's selectionStart).
This commit is contained in:
parent
1cb450e9a3
commit
939779cad3
Notes:
sideshowbarker
2024-07-17 06:46:15 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/939779cad3 Pull-request: https://github.com/SerenityOS/serenity/pull/23251 Issue: https://github.com/SerenityOS/serenity/issues/23241
@ -396,7 +396,7 @@ static void generate_to_integral(SourceGenerator& scoped_generator, ParameterTyp
|
||||
VERIFY(it != idl_type_map.end());
|
||||
scoped_generator.set("cpp_type"sv, it->cpp_type);
|
||||
|
||||
if (!optional || optional_default_value.has_value()) {
|
||||
if ((!optional && !parameter.type->is_nullable()) || optional_default_value.has_value()) {
|
||||
scoped_generator.append(R"~~~(
|
||||
@cpp_type@ @cpp_name@;
|
||||
)~~~");
|
||||
@ -406,7 +406,11 @@ static void generate_to_integral(SourceGenerator& scoped_generator, ParameterTyp
|
||||
)~~~");
|
||||
}
|
||||
|
||||
if (optional) {
|
||||
if (parameter.type->is_nullable()) {
|
||||
scoped_generator.append(R"~~~(
|
||||
if (!@js_name@@js_suffix@.is_null() && !@js_name@@js_suffix@.is_undefined())
|
||||
)~~~");
|
||||
} else if (optional) {
|
||||
scoped_generator.append(R"~~~(
|
||||
if (!@js_name@@js_suffix@.is_undefined())
|
||||
)~~~");
|
||||
|
Loading…
Reference in New Issue
Block a user