LibWeb: Add support for WindowProxy in IDL -> CPP, unions, constructors
This commit is contained in:
parent
280199fb08
commit
34cd69e623
Notes:
sideshowbarker
2024-07-16 20:31:50 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/34cd69e623 Pull-request: https://github.com/SerenityOS/serenity/pull/21823 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/shannonbooth Reviewed-by: https://github.com/trflynn89
1 changed files with 17 additions and 1 deletions
|
@ -133,7 +133,7 @@ static DeprecatedString union_type_to_variant(UnionType const& union_type, Inter
|
|||
|
||||
CppType idl_type_name_to_cpp_type(Type const& type, Interface const& interface)
|
||||
{
|
||||
if (is_platform_object(type))
|
||||
if (is_platform_object(type) || type.name() == "WindowProxy"sv)
|
||||
return { .name = DeprecatedString::formatted("JS::Handle<{}>", type.name()), .sequence_storage_type = SequenceStorageType::MarkedVector };
|
||||
|
||||
if (is_javascript_builtin(type))
|
||||
|
@ -1103,6 +1103,21 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter
|
|||
)~~~");
|
||||
}
|
||||
|
||||
bool includes_window_proxy = false;
|
||||
for (auto& type : types) {
|
||||
if (type->name() == "WindowProxy"sv) {
|
||||
includes_window_proxy = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (includes_window_proxy) {
|
||||
union_generator.append(R"~~~(
|
||||
if (is<WindowProxy>(@js_name@@js_suffix@_object))
|
||||
return JS::make_handle(static_cast<WindowProxy&>(@js_name@@js_suffix@_object));
|
||||
)~~~");
|
||||
}
|
||||
|
||||
// 6. If Type(V) is Object and V has an [[ArrayBufferData]] internal slot, then
|
||||
// 1. If types includes ArrayBuffer, then return the result of converting V to ArrayBuffer.
|
||||
for (auto& type : types) {
|
||||
|
@ -3514,6 +3529,7 @@ void generate_constructor_implementation(IDL::Interface const& interface, String
|
|||
#elif __has_include(<LibWeb/URL/@name@.h>)
|
||||
# include <LibWeb/URL/@name@.h>
|
||||
#endif
|
||||
#include <LibWeb/HTML/WindowProxy.h>
|
||||
#include <LibWeb/WebIDL/CallbackType.h>
|
||||
|
||||
)~~~");
|
||||
|
|
Loading…
Add table
Reference in a new issue