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

LibIDL+WrapperGenerator: Move IDL code into a library

IDL function overload resolution requires knowing each IDL function's
parameters and their types at runtime. The simplest way to do that is
just to make the types the generator uses available to the runtime.

Parsing has moved to LibIDL, but code generation has not, since that is
very specific to WrapperGenerator.
This commit is contained in:
Sam Atkins 2022-08-22 14:50:06 +01:00 committed by Andreas Kling
parent 634a52b589
commit c4668053d1
9 changed files with 25 additions and 12 deletions

View file

@ -291,6 +291,13 @@ lagom_lib(TimeZone timezone
) )
target_compile_definitions(LibTimeZone PRIVATE ENABLE_TIME_ZONE_DATA=$<BOOL:${ENABLE_TIME_ZONE_DATABASE_DOWNLOAD}>) target_compile_definitions(LibTimeZone PRIVATE ENABLE_TIME_ZONE_DATA=$<BOOL:${ENABLE_TIME_ZONE_DATABASE_DOWNLOAD}>)
# LibIDL
# This is used by the WrapperGenerator so needs to always be built.
file(GLOB LIBIDL_SOURCES CONFIGURE_DEPENDS "../../Userland/Libraries/LibIDL/*.cpp")
lagom_lib(IDL idl
SOURCES ${LIBIDL_SOURCES}
)
# Manually install AK headers # Manually install AK headers
install( install(
DIRECTORY "${SERENITY_PROJECT_ROOT}/AK" DIRECTORY "${SERENITY_PROJECT_ROOT}/AK"
@ -548,7 +555,7 @@ if (BUILD_LAGOM)
lagom_lib(Web web lagom_lib(Web web
SOURCES ${LIBWEB_SOURCES} ${LIBWEB_SUBDIR_SOURCES} ${LIBWEB_SUBSUBDIR_SOURCES} ${LIBWEB_SUBSUBSUBDIR_SOURCES} ${LIBWEB_GENERATED_SOURCES} SOURCES ${LIBWEB_SOURCES} ${LIBWEB_SUBDIR_SOURCES} ${LIBWEB_SUBSUBDIR_SOURCES} ${LIBWEB_SUBSUBSUBDIR_SOURCES} ${LIBWEB_GENERATED_SOURCES}
LIBS LibMarkdown LibGemini LibGfx LibGL LibJS LibTextCodec LibWasm LibXML LIBS LibMarkdown LibGemini LibGfx LibGL LibIDL LibJS LibTextCodec LibWasm LibXML
) )
generate_js_wrappers(LibWeb) generate_js_wrappers(LibWeb)
endif() endif()

View file

@ -1,8 +1,7 @@
set(SOURCES "") set(SOURCES
lagom_tool(WrapperGenerator SOURCES
IDLGenerators.cpp IDLGenerators.cpp
IDLParser.cpp main.cpp
main.cpp) )
lagom_tool(WrapperGenerator LIBS LibIDL)
target_compile_options(WrapperGenerator PUBLIC -g) target_compile_options(WrapperGenerator PUBLIC -g)

View file

@ -7,10 +7,10 @@
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include "IDLTypes.h"
#include <AK/LexicalPath.h> #include <AK/LexicalPath.h>
#include <AK/Queue.h> #include <AK/Queue.h>
#include <AK/QuickSort.h> #include <AK/QuickSort.h>
#include <LibIDL/Types.h>
Vector<StringView> s_header_search_paths; Vector<StringView> s_header_search_paths;

View file

@ -7,12 +7,12 @@
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include "IDLParser.h"
#include "IDLTypes.h"
#include <AK/Debug.h> #include <AK/Debug.h>
#include <AK/LexicalPath.h> #include <AK/LexicalPath.h>
#include <LibCore/ArgsParser.h> #include <LibCore/ArgsParser.h>
#include <LibCore/File.h> #include <LibCore/File.h>
#include <LibIDL/IDLParser.h>
#include <LibIDL/Types.h>
extern Vector<StringView> s_header_search_paths; extern Vector<StringView> s_header_search_paths;

View file

@ -26,6 +26,7 @@ add_subdirectory(LibGL)
add_subdirectory(LibGPU) add_subdirectory(LibGPU)
add_subdirectory(LibGUI) add_subdirectory(LibGUI)
add_subdirectory(LibHTTP) add_subdirectory(LibHTTP)
add_subdirectory(LibIDL)
add_subdirectory(LibIMAP) add_subdirectory(LibIMAP)
add_subdirectory(LibImageDecoderClient) add_subdirectory(LibImageDecoderClient)
add_subdirectory(LibIPC) add_subdirectory(LibIPC)

View file

@ -0,0 +1,6 @@
set(SOURCES
IDLParser.cpp
)
serenity_lib(LibIDL idl)
target_link_libraries(LibIDL LibCore)

View file

@ -805,7 +805,7 @@ void Parser::parse_non_interface_entities(bool allow_interface, Interface& inter
consume_whitespace(); consume_whitespace();
} }
void resolve_typedef(Interface& interface, NonnullRefPtr<Type>& type, HashMap<String, String>* extended_attributes = {}) static void resolve_typedef(Interface& interface, NonnullRefPtr<Type>& type, HashMap<String, String>* extended_attributes = {})
{ {
if (is<ParameterizedType>(*type)) { if (is<ParameterizedType>(*type)) {
auto parameterized_type = static_ptr_cast<ParameterizedType>(type); auto parameterized_type = static_ptr_cast<ParameterizedType>(type);
@ -826,7 +826,7 @@ void resolve_typedef(Interface& interface, NonnullRefPtr<Type>& type, HashMap<St
for (auto& attribute : it->value.extended_attributes) for (auto& attribute : it->value.extended_attributes)
extended_attributes->set(attribute.key, attribute.value); extended_attributes->set(attribute.key, attribute.value);
} }
void resolve_parameters_typedefs(Interface& interface, Vector<Parameter>& parameters) static void resolve_parameters_typedefs(Interface& interface, Vector<Parameter>& parameters)
{ {
for (auto& parameter : parameters) for (auto& parameter : parameters)
resolve_typedef(interface, parameter.type, &parameter.extended_attributes); resolve_typedef(interface, parameter.type, &parameter.extended_attributes);

View file

@ -9,9 +9,9 @@
#pragma once #pragma once
#include "IDLTypes.h"
#include <AK/CharacterTypes.h> #include <AK/CharacterTypes.h>
#include <AK/GenericLexer.h> #include <AK/GenericLexer.h>
#include <LibIDL/Types.h>
namespace IDL { namespace IDL {