mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:07:35 +00:00
LibWeb: Add new code generator for creating exposed interface helpers
This new code generator takes all the .idl files in LibWeb, looks for each top level interface in there with an [Exposed=Foo] attribute, and adds code to add the constructor and prototype for each of those exposed interfaces to the realm of the relevant global object we're initialzing. It will soon replace WindowObjectHelper as the way that web interfaces are added to the Window object, and will be used in the future for creating proper WorkerGlobalScope objects for dedicated and shared workers.
This commit is contained in:
parent
067a53b7e7
commit
2acff8d853
3 changed files with 340 additions and 0 deletions
|
@ -158,8 +158,36 @@ function (generate_js_bindings target)
|
|||
add_dependencies(all_generated generate_${basename}Prototype.h)
|
||||
add_custom_target(generate_${basename}Prototype.cpp DEPENDS ${LIBWEB_OUTPUT_FOLDER}Bindings/${basename}Prototype.cpp)
|
||||
add_dependencies(all_generated generate_${basename}Prototype.cpp)
|
||||
|
||||
list(APPEND LIBWEB_ALL_IDL_FILES "${LIBWEB_INPUT_FOLDER}/${class}.idl")
|
||||
set(LIBWEB_ALL_IDL_FILES ${LIBWEB_ALL_IDL_FILES} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(generate_exposed_interface_files)
|
||||
set(exposed_interface_sources DedicatedWorkerExposedInterfaces.cpp DedicatedWorkerExposedInterfaces.h
|
||||
SharedWorkerExposedInterfaces.cpp SharedWorkerExposedInterfaces.h
|
||||
WindowExposedInterfaces.cpp WindowExposedInterfaces.h)
|
||||
list(TRANSFORM exposed_interface_sources PREPEND "${LIBWEB_OUTPUT_FOLDER}Bindings/")
|
||||
add_custom_command(
|
||||
OUTPUT ${exposed_interface_sources}
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "tmp"
|
||||
COMMAND $<TARGET_FILE:Lagom::GenerateWindowOrWorkerInterfaces> -o "${CMAKE_CURRENT_BINARY_DIR}/tmp" -b "${LIBWEB_INPUT_FOLDER}" ${LIBWEB_ALL_IDL_FILES}
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different tmp/DedicatedWorkerExposedInterfaces.h "${LIBWEB_OUTPUT_FOLDER}Bindings/DedicatedWorkerExposedInterfaces.h"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different tmp/DedicatedWorkerExposedInterfaces.cpp "${LIBWEB_OUTPUT_FOLDER}Bindings/DedicatedWorkerExposedInterfaces.cpp"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different tmp/SharedWorkerExposedInterfaces.h "${LIBWEB_OUTPUT_FOLDER}Bindings/SharedWorkerExposedInterfaces.h"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different tmp/SharedWorkerExposedInterfaces.cpp "${LIBWEB_OUTPUT_FOLDER}Bindings/SharedWorkerExposedInterfaces.cpp"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different tmp/WindowExposedInterfaces.h "${LIBWEB_OUTPUT_FOLDER}Bindings/WindowExposedInterfaces.h"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different tmp/WindowExposedInterfaces.cpp "${LIBWEB_OUTPUT_FOLDER}Bindings/WindowExposedInterfaces.cpp"
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove_directory "${CMAKE_CURRENT_BINARY_DIR}/tmp"
|
||||
VERBATIM
|
||||
DEPENDS Lagom::GenerateWindowOrWorkerInterfaces ${LIBWEB_ALL_IDL_FILES}
|
||||
)
|
||||
target_sources(${target} PRIVATE ${exposed_interface_sources})
|
||||
add_custom_target("generate_${LIBWEB_META_PREFIX}exposed_interfaces" DEPENDS ${exposed_interface_sources})
|
||||
add_dependencies(all_generated "generate_${LIBWEB_META_PREFIX}exposed_interfaces")
|
||||
endfunction()
|
||||
|
||||
include("${LIBWEB_INPUT_FOLDER}/idl_files.cmake")
|
||||
generate_exposed_interface_files()
|
||||
|
||||
endfunction()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue