mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 13:30:31 +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:
parent
634a52b589
commit
c4668053d1
Notes:
sideshowbarker
2024-07-17 10:08:28 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/c4668053d1 Pull-request: https://github.com/SerenityOS/serenity/pull/15170
9 changed files with 25 additions and 12 deletions
|
@ -291,6 +291,13 @@ lagom_lib(TimeZone timezone
|
|||
)
|
||||
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
|
||||
install(
|
||||
DIRECTORY "${SERENITY_PROJECT_ROOT}/AK"
|
||||
|
@ -548,7 +555,7 @@ if (BUILD_LAGOM)
|
|||
|
||||
lagom_lib(Web web
|
||||
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)
|
||||
endif()
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
set(SOURCES "")
|
||||
|
||||
lagom_tool(WrapperGenerator SOURCES
|
||||
set(SOURCES
|
||||
IDLGenerators.cpp
|
||||
IDLParser.cpp
|
||||
main.cpp)
|
||||
main.cpp
|
||||
)
|
||||
|
||||
lagom_tool(WrapperGenerator LIBS LibIDL)
|
||||
target_compile_options(WrapperGenerator PUBLIC -g)
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "IDLTypes.h"
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/Queue.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <LibIDL/Types.h>
|
||||
|
||||
Vector<StringView> s_header_search_paths;
|
||||
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "IDLParser.h"
|
||||
#include "IDLTypes.h"
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibIDL/IDLParser.h>
|
||||
#include <LibIDL/Types.h>
|
||||
|
||||
extern Vector<StringView> s_header_search_paths;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@ add_subdirectory(LibGL)
|
|||
add_subdirectory(LibGPU)
|
||||
add_subdirectory(LibGUI)
|
||||
add_subdirectory(LibHTTP)
|
||||
add_subdirectory(LibIDL)
|
||||
add_subdirectory(LibIMAP)
|
||||
add_subdirectory(LibImageDecoderClient)
|
||||
add_subdirectory(LibIPC)
|
||||
|
|
6
Userland/Libraries/LibIDL/CMakeLists.txt
Normal file
6
Userland/Libraries/LibIDL/CMakeLists.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
set(SOURCES
|
||||
IDLParser.cpp
|
||||
)
|
||||
|
||||
serenity_lib(LibIDL idl)
|
||||
target_link_libraries(LibIDL LibCore)
|
|
@ -805,7 +805,7 @@ void Parser::parse_non_interface_entities(bool allow_interface, Interface& inter
|
|||
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)) {
|
||||
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)
|
||||
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)
|
||||
resolve_typedef(interface, parameter.type, ¶meter.extended_attributes);
|
|
@ -9,9 +9,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "IDLTypes.h"
|
||||
#include <AK/CharacterTypes.h>
|
||||
#include <AK/GenericLexer.h>
|
||||
#include <LibIDL/Types.h>
|
||||
|
||||
namespace IDL {
|
||||
|
Loading…
Reference in a new issue