1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 12:07:35 +00:00
serenity/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator
Shannon Booth f991e40d7f LibWeb: Support [Reflect] on IDL String attributes that may return null
This change allows IDL interfaces to be compiled using new AK String
which have a attribute in the interface that may return null.

Without this change we would run into a compile error from code such as
the following example:

```
auto retval = impl->deprecated_attribute(HTML::AttributeNames::ref);

if (!retval.has_value()) {
    return JS::js_null();
 }
 return JS::PrimitiveString::create(vm, retval.release_value());
```

As `deprecated_attribute` returns a `DeprecatedString` instead of an
`Optional<String>`. Fix that by using the non-deprecated attribute
implementation, and falling back to the empty string for where we cannot
return null.

Also add a test here to cover a regression I almost introduced here
which was not previously covered by our test suite.

Ideally, all of this should actually just be calling
Element::get_attribute_value, but I'm not entirely sure at this stage
what the behavioral change would be to test for here. Since this
implementation preserves the previous behavior, stick with it, and add a
FIXME for now.
2023-09-05 20:36:09 -04:00
..
CMakeLists.txt BindingsGenerator: Write generated code to disk instead of stdout 2022-12-13 11:31:24 +01:00
IDLGenerators.cpp LibWeb: Support [Reflect] on IDL String attributes that may return null 2023-09-05 20:36:09 -04:00
main.cpp BindingsGenerator: Only truncate generated files if they have changed 2023-08-04 10:06:41 -06:00
Namespaces.h LibWeb: Add MathML Namespace to IDL Generator 2023-08-12 07:59:23 +01:00