1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 01:47:35 +00:00

LibWeb: Support interfaces with the [Global] extended attribute

These are treated differently as the interface members are placed on the
object itself, not its prototype.
As the object itself still needs to be hand-written code, and we can no
longer fully hide the gnarly generated code in the prototype object,
these now generate a 'mixin' class that is added to the actual object
through inheritance.

https://webidl.spec.whatwg.org/#Global
This commit is contained in:
Linus Groh 2023-03-05 15:50:56 +00:00
parent de83f5422d
commit 3316d247bf
5 changed files with 639 additions and 443 deletions

View file

@ -76,7 +76,7 @@ endfunction()
function (generate_js_bindings target)
set(LIBWEB_INPUT_FOLDER "${CMAKE_CURRENT_SOURCE_DIR}")
function(libweb_js_bindings class)
cmake_parse_arguments(PARSE_ARGV 1 LIBWEB_BINDINGS "ITERABLE" "" "")
cmake_parse_arguments(PARSE_ARGV 1 LIBWEB_BINDINGS "ITERABLE;GLOBAL" "" "")
get_filename_component(basename "${class}" NAME)
set(BINDINGS_SOURCES
"Bindings/${basename}Constructor.h"
@ -102,6 +102,19 @@ function (generate_js_bindings target)
iterator-prototype-implementation
)
endif()
# FIXME: Instead of requiring a manual declaration of global object bindings, we should ask BindingsGenerator if it's global
if(LIBWEB_BINDINGS_GLOBAL)
list(APPEND BINDINGS_SOURCES
"Bindings/${basename}GlobalMixin.h"
"Bindings/${basename}GlobalMixin.cpp"
)
list(APPEND BINDINGS_TYPES
global-mixin-header
global-mixin-implementation
)
endif()
target_sources(${target} PRIVATE ${BINDINGS_SOURCES})
# FIXME: cmake_minimum_required(3.17) for ZIP_LISTS
list(LENGTH BINDINGS_SOURCES num_bindings)