Skip to content

Commit b9c7277

Browse files
committed
Mark FlutterELinuxEngine, FlutterELinuxView and FlutterELinuxTextureRegistrar
as unsafe references for importing into Swift, consolidating Swift annotation macro wrappers into flutter_export.h. This patch allows the importing of C++ engine APIs into Swift, using the Swift C++ bridging layer. Signed-off-by: Luke Howard <[email protected]>
1 parent 61b90d5 commit b9c7277

File tree

7 files changed

+14
-11
lines changed

7 files changed

+14
-11
lines changed

Diff for: src/flutter/shell/platform/common/client_wrapper/include/flutter/texture_registrar.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ class TextureRegistrar {
136136
// Unregisters an existing texture object.
137137
// DEPRECATED: Use UnregisterTexture(texture_id, optional_callback) instead.
138138
virtual bool UnregisterTexture(int64_t texture_id) = 0;
139-
};
139+
} SWIFT_UNSAFE_REFERENCE;
140140

141141
} // namespace flutter
142142

Diff for: src/flutter/shell/platform/common/public/flutter_export.h

+9
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,13 @@
2525

2626
#endif // FLUTTER_DESKTOP_LIBRARY
2727

28+
#if __has_include(<swift/bridging>)
29+
#include <swift/bridging>
30+
#else
31+
#define SWIFT_UNSAFE_REFERENCE
32+
#define SWIFT_SHARED_REFERENCE(_retain, _release)
33+
#define SWIFT_RETURNS_RETAINED
34+
#define SWIFT_RETURNS_UNRETAINED
35+
#endif
36+
2837
#endif // FLUTTER_SHELL_PLATFORM_COMMON_PUBLIC_FLUTTER_EXPORT_H_

Diff for: src/flutter/shell/platform/common/public/flutter_plugin_registrar.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typedef void (*FlutterDesktopOnPluginRegistrarDestroyed)(
2424
FlutterDesktopPluginRegistrarRef);
2525

2626
// Returns the engine messenger associated with this registrar.
27-
FLUTTER_EXPORT FlutterDesktopMessengerRef
27+
FLUTTER_EXPORT SWIFT_RETURNS_UNRETAINED FlutterDesktopMessengerRef
2828
FlutterDesktopPluginRegistrarGetMessenger(
2929
FlutterDesktopPluginRegistrarRef registrar);
3030

Diff for: src/flutter/shell/platform/linux_embedded/flutter_elinux_engine.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ class FlutterELinuxEngine {
195195
std::unique_ptr<VsyncWaiter> vsync_waiter_;
196196

197197
bool enable_impeller_ = false;
198-
};
198+
} SWIFT_UNSAFE_REFERENCE;
199199

200200
} // namespace flutter
201201

Diff for: src/flutter/shell/platform/linux_embedded/flutter_elinux_state.h

-6
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@
99
#include <memory>
1010
#include <mutex>
1111

12-
#if __has_include(<swift/bridging>)
13-
#include <swift/bridging>
14-
#else
15-
#define SWIFT_SHARED_REFERENCE(_retain, _release)
16-
#endif
17-
1812
#include "flutter/shell/platform/common/client_wrapper/include/flutter/plugin_registrar.h"
1913
#include "flutter/shell/platform/common/incoming_message_dispatcher.h"
2014
#include "flutter/shell/platform/embedder/embedder.h"

Diff for: src/flutter/shell/platform/linux_embedded/flutter_elinux_view.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ class FlutterELinuxView : public WindowBindingHandlerDelegate {
318318
// Current view rotation (FlutterTransformation).
319319
FlutterTransformation view_rotation_transformation_ = {
320320
1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0};
321-
};
321+
} SWIFT_UNSAFE_REFERENCE;
322322

323323
} // namespace flutter
324324

Diff for: src/flutter/shell/platform/linux_embedded/public/flutter_elinux.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ FLUTTER_EXPORT FlutterDesktopViewRef FlutterDesktopPluginRegistrarGetView(
216216
FlutterDesktopPluginRegistrarRef registrar);
217217

218218
// Returns the messenger associated with the engine.
219-
FLUTTER_EXPORT FlutterDesktopMessengerRef
219+
FLUTTER_EXPORT SWIFT_RETURNS_UNRETAINED FlutterDesktopMessengerRef
220220
FlutterDesktopEngineGetMessenger(FlutterDesktopEngineRef engine);
221221

222222
// Returns the texture registrar associated with the engine.

0 commit comments

Comments
 (0)