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

LibWeb: Add partial support for IDL Iterable declarations

This currently only supports pair iterables (i.e. iterable<key, value>)
support for value iterables (i.e. iterable<value>) is left as TODO().

Since currently our cmake setup calls the WrapperGenerator separately
and unconditionally for each (hard-coded) output file iterable wrappers
have to be explicitly marked so in the CMakeLists.txt declaration, we
could likely improve this in the future by querying WrapperGenerator
for the outputs based on the IDL.
This commit is contained in:
Idan Horowitz 2021-09-27 23:45:29 +03:00 committed by Andreas Kling
parent 2fab43ba5d
commit cdde3ba5c5
2 changed files with 474 additions and 0 deletions

View file

@ -271,6 +271,7 @@ serenity_lib(LibWeb web)
target_link_libraries(LibWeb LibCore LibJS LibMarkdown LibGemini LibGUI LibGfx LibTextCodec LibProtocol LibImageDecoderClient LibWasm)
function(libweb_js_wrapper class)
cmake_parse_arguments(PARSE_ARGV 1 LIBWEB_WRAPPER "ITERABLE" "" "")
get_filename_component(basename "${class}" NAME)
set(BINDINGS_SOURCES
"Bindings/${basename}Wrapper.h"
@ -288,6 +289,21 @@ function(libweb_js_wrapper class)
prototype-header
prototype-implementation
)
# FIXME: Instead of requiring a manual declaration of iterable wrappers, we should ask WrapperGenerator if it's iterable
if(LIBWEB_WRAPPER_ITERABLE)
list(APPEND BINDINGS_SOURCES
"Bindings/${basename}IteratorWrapper.h"
"Bindings/${basename}IteratorWrapper.cpp"
"Bindings/${basename}IteratorPrototype.h"
"Bindings/${basename}IteratorPrototype.cpp"
)
list(APPEND BINDINGS_TYPES
iterator-header
iterator-implementation
iterator-prototype-header
iterator-prototype-implementation
)
endif()
target_sources(LibWeb PRIVATE ${BINDINGS_SOURCES})
# FIXME: cmake_minimum_required(3.17) for ZIP_LISTS
list(LENGTH BINDINGS_SOURCES num_bindings)