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.
This commit is contained in:
Andrew Kaster 2024-08-17 20:13:54 -06:00 committed by Andreas Kling
parent d105b1d4f8
commit b03b13b720
Notes: github-actions[bot] 2024-08-19 10:57:55 +00:00
3 changed files with 23 additions and 7 deletions

21
AK/Swift.h Normal file
View file

@ -0,0 +1,21 @@
/*
* Copyright (c) 2024, Andrew Kaster <andrew@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#if __has_include(<swift/bridging>)
# include <swift/bridging>
#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

View file

@ -9,6 +9,7 @@
#include <AK/ByteString.h>
#include <AK/FloatingPointStringConversions.h>
#include <AK/Optional.h>
#include <AK/Swift.h>
#include <AK/Vector.h>
#include <LibGfx/Color.h>
#include <LibGfx/SystemTheme.h>
@ -18,7 +19,6 @@
#ifdef LIBGFX_USE_SWIFT
# include <LibGfx-Swift.h>
# include <swift/bridging>
#endif
namespace Gfx {

View file

@ -7,6 +7,7 @@
#pragma once
#include <AK/Badge.h>
#include <AK/Swift.h>
#include <LibCore/EventLoop.h>
#include <LibMain/Main.h>
#include <LibURL/URL.h>
@ -14,12 +15,6 @@
#include <LibWebView/Process.h>
#include <LibWebView/ProcessManager.h>
#ifdef __swift__
# include <swift/bridging>
#else
# define SWIFT_IMMORTAL_REFERENCE
#endif
namespace WebView {
class Application {