From b03b13b720b455e84205c3628e3d6d5cebdb5edf Mon Sep 17 00:00:00 2001 From: Andrew Kaster Date: Sat, 17 Aug 2024 20:13:54 -0600 Subject: [PATCH] AK+LibGfx+LibWebView: Add wrapper header around swift/bridging When using a configuration without a swift compiler, we need to no-op the swift annotations. Other, cleverer solutions beyond the has include all fell flat in the face of the clang modules implementation used by swift to parse-once use-everywhere each module. --- AK/Swift.h | 21 +++++++++++++++++++++ Userland/Libraries/LibGfx/Color.cpp | 2 +- Userland/Libraries/LibWebView/Application.h | 7 +------ 3 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 AK/Swift.h diff --git a/AK/Swift.h b/AK/Swift.h new file mode 100644 index 00000000000..be81fdb4cab --- /dev/null +++ b/AK/Swift.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024, Andrew Kaster + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#if __has_include() +# include +#else +# define SWIFT_SELF_CONTAINED +# define SWIFT_RETURNS_INDEPENDENT_VALUE +# define SWIFT_SHARED_REFERENCE(retain, release) +# define SWIFT_IMMORTAL_REFERENCE +# define SWIFT_UNSAFE_REFERENCE +# define SWIFT_NAME(name) +# define SWIFT_CONFORMS_TO_PROTOCOL(protocol) +# define SWIFT_COMPUTED_PROPERTY +# define SWIFT_MUTATING +#endif diff --git a/Userland/Libraries/LibGfx/Color.cpp b/Userland/Libraries/LibGfx/Color.cpp index ce6a630089f..9417e8d6899 100644 --- a/Userland/Libraries/LibGfx/Color.cpp +++ b/Userland/Libraries/LibGfx/Color.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -18,7 +19,6 @@ #ifdef LIBGFX_USE_SWIFT # include -# include #endif namespace Gfx { diff --git a/Userland/Libraries/LibWebView/Application.h b/Userland/Libraries/LibWebView/Application.h index 7f261568ca2..d9b228b932f 100644 --- a/Userland/Libraries/LibWebView/Application.h +++ b/Userland/Libraries/LibWebView/Application.h @@ -7,6 +7,7 @@ #pragma once #include +#include #include #include #include @@ -14,12 +15,6 @@ #include #include -#ifdef __swift__ -# include -#else -# define SWIFT_IMMORTAL_REFERENCE -#endif - namespace WebView { class Application {