mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-27 20:58:16 +00:00
LibWeb/Bindings: Generate undefined in a union as 'Empty'
This can only ever be undefined, and no other JS value, so it makes sense to use undefined to represent this case.
This commit is contained in:
parent
fef1f62ecc
commit
dfdcfc8e88
Notes:
github-actions[bot]
2025-01-12 18:40:27 +00:00
Author: https://github.com/shannonbooth
Commit: dfdcfc8e88
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3233
Reviewed-by: https://github.com/tcl3 ✅
5 changed files with 13 additions and 7 deletions
|
@ -231,9 +231,15 @@ CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
|
|||
if (type.name() == "long" && !type.is_nullable())
|
||||
return { .name = "WebIDL::Long", .sequence_storage_type = SequenceStorageType::Vector };
|
||||
|
||||
if (type.name() == "any" || type.name() == "undefined")
|
||||
if (type.name() == "any")
|
||||
return { .name = "JS::Value", .sequence_storage_type = SequenceStorageType::RootVector };
|
||||
|
||||
// NOTE: undefined is a somewhat special case that may be used in a union to represent the javascript 'undefined' (and
|
||||
// only ever js_undefined). Therefore, we say that the type is Empty here, so that a union of (T, undefined) is
|
||||
// generated as Variant<T, Empty>, which is then returned in the Variant's visit as undefined if it is Empty.
|
||||
if (type.name() == "undefined")
|
||||
return { .name = "Empty", .sequence_storage_type = SequenceStorageType::RootVector };
|
||||
|
||||
if (type.name() == "object")
|
||||
return { .name = "GC::Root<JS::Object>", .sequence_storage_type = SequenceStorageType::Vector };
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue