mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:27:45 +00:00
LibWeb: Handle optional return values for getters returning new String
This commit is contained in:
parent
98705ecf71
commit
c0559e8a10
1 changed files with 16 additions and 2 deletions
|
@ -1487,11 +1487,19 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString
|
||||||
|
|
||||||
if (type.is_nullable() && !is<UnionType>(type)) {
|
if (type.is_nullable() && !is<UnionType>(type)) {
|
||||||
if (type.is_string()) {
|
if (type.is_string()) {
|
||||||
scoped_generator.append(R"~~~(
|
if (!interface.extended_attributes.contains("UseNewAKString")) {
|
||||||
|
scoped_generator.append(R"~~~(
|
||||||
if (@value@.is_null()) {
|
if (@value@.is_null()) {
|
||||||
@result_expression@ JS::js_null();
|
@result_expression@ JS::js_null();
|
||||||
} else {
|
} else {
|
||||||
)~~~");
|
)~~~");
|
||||||
|
} else {
|
||||||
|
scoped_generator.append(R"~~~(
|
||||||
|
if (!@value@.has_value()) {
|
||||||
|
@result_expression@ JS::js_null();
|
||||||
|
} else {
|
||||||
|
)~~~");
|
||||||
|
}
|
||||||
} else if (type.name() == "sequence") {
|
} else if (type.name() == "sequence") {
|
||||||
scoped_generator.append(R"~~~(
|
scoped_generator.append(R"~~~(
|
||||||
if (!@value@.has_value()) {
|
if (!@value@.has_value()) {
|
||||||
|
@ -1508,9 +1516,15 @@ static void generate_wrap_statement(SourceGenerator& generator, DeprecatedString
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type.is_string()) {
|
if (type.is_string()) {
|
||||||
scoped_generator.append(R"~~~(
|
if (type.is_nullable() && interface.extended_attributes.contains("UseNewAKString")) {
|
||||||
|
scoped_generator.append(R"~~~(
|
||||||
|
@result_expression@ JS::PrimitiveString::create(vm, @value@.release_value());
|
||||||
|
)~~~");
|
||||||
|
} else {
|
||||||
|
scoped_generator.append(R"~~~(
|
||||||
@result_expression@ JS::PrimitiveString::create(vm, @value@);
|
@result_expression@ JS::PrimitiveString::create(vm, @value@);
|
||||||
)~~~");
|
)~~~");
|
||||||
|
}
|
||||||
} else if (type.name() == "sequence") {
|
} else if (type.name() == "sequence") {
|
||||||
// https://webidl.spec.whatwg.org/#es-sequence
|
// https://webidl.spec.whatwg.org/#es-sequence
|
||||||
auto& sequence_generic_type = verify_cast<IDL::ParameterizedType>(type);
|
auto& sequence_generic_type = verify_cast<IDL::ParameterizedType>(type);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue