Преглед на файлове

LibWeb: Add support for WindowProxy in IDL -> CPP, unions, constructors

Luke Wilde преди 1 година
родител
ревизия
34cd69e623
променени са 1 файла, в които са добавени 17 реда и са изтрити 1 реда
  1. 17 1
      Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp

+ 17 - 1
Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp

@@ -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>
 
 )~~~");