|
13 | 13 | #ifndef SWIFT_BASIC_BASICBRIDGING_H
|
14 | 14 | #define SWIFT_BASIC_BASICBRIDGING_H
|
15 | 15 |
|
16 |
| -#if !defined(COMPILED_WITH_SWIFT) || !defined(PURE_BRIDGING_MODE) |
17 |
| -#define USED_IN_CPP_SOURCE |
18 |
| -#endif |
19 |
| - |
20 | 16 | // Do not add other C++/llvm/swift header files here!
|
21 | 17 | // Function implementations should be placed into BasicBridging.cpp and required header files should be added there.
|
22 | 18 | //
|
23 | 19 | // Pure bridging mode does not permit including any C++/llvm/swift headers.
|
24 | 20 | // See also the comments for `BRIDGING_MODE` in the top-level CMakeLists.txt file.
|
25 | 21 | //
|
26 |
| -// |
27 |
| -// Note: On Windows ARM64, how a C++ struct/class value type is |
28 |
| -// returned is sensitive to conditions including whether a |
29 |
| -// user-defined constructor exists, etc. See |
30 |
| -// https://learn.microsoft.com/en-us/cpp/build/arm64-windows-abi-conventions?view=msvc-170#return-values |
31 |
| -// So, if a C++ struct/class type is returned as a value between Swift |
32 |
| -// and C++, we need to be careful to match the return convention |
33 |
| -// matches between the non-USED_IN_CPP_SOURCE (Swift) side and the |
34 |
| -// USE_IN_CPP_SOURCE (C++) side. |
35 |
| -// |
36 | 22 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
37 |
| -// !! Do not put any constructors inside an `#ifdef USED_IN_CPP_SOURCE` block !! |
| 23 | +// !! Do not put any constructors inside an !! |
| 24 | +// !! `#ifdef NOT_COMPILED_WITH_SWIFT_PURE_BRIDGING_MODE` block !! |
38 | 25 | // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
39 | 26 |
|
40 |
| -#include "swift/Basic/BridgedSwiftObject.h" |
| 27 | +/// This header defines `NOT_COMPILED_WITH_SWIFT_PURE_BRIDGING_MODE`, so it |
| 28 | +/// needs to be imported before the first use of the macro. |
41 | 29 | #include "swift/Basic/SwiftBridging.h"
|
42 | 30 |
|
| 31 | +#include "swift/Basic/BridgedSwiftObject.h" |
43 | 32 | #include <stddef.h>
|
44 | 33 | #include <stdint.h>
|
45 |
| -#ifdef USED_IN_CPP_SOURCE |
| 34 | + |
| 35 | +#ifdef NOT_COMPILED_WITH_SWIFT_PURE_BRIDGING_MODE |
46 | 36 | // Workaround to avoid a compiler error because `cas::ObjectRef` is not defined
|
47 | 37 | // when including VirtualFileSystem.h
|
48 | 38 | #include <cassert>
|
@@ -146,7 +136,7 @@ class BridgedArrayRef {
|
146 | 136 | BridgedArrayRef(const void *_Nullable data, size_t length)
|
147 | 137 | : Data(data), Length(length) {}
|
148 | 138 |
|
149 |
| -#ifdef USED_IN_CPP_SOURCE |
| 139 | +#ifdef NOT_COMPILED_WITH_SWIFT_PURE_BRIDGING_MODE |
150 | 140 | template <typename T>
|
151 | 141 | BridgedArrayRef(llvm::ArrayRef<T> arr)
|
152 | 142 | : Data(arr.data()), Length(arr.size()) {}
|
@@ -285,7 +275,7 @@ class BridgedOwnedString {
|
285 | 275 | };
|
286 | 276 | BRIDGED_OPTIONAL(SwiftInt, Int)
|
287 | 277 |
|
288 |
| -#ifdef USED_IN_CPP_SOURCE |
| 278 | +#ifdef NOT_COMPILED_WITH_SWIFT_PURE_BRIDGING_MODE |
289 | 279 | inline BridgedOptionalInt getFromAPInt(llvm::APInt i) {
|
290 | 280 | if (i.getSignificantBits() <=
|
291 | 281 | std::min(std::numeric_limits<SwiftInt>::digits, 64)) {
|
@@ -421,7 +411,7 @@ class BridgedCharSourceRangeVector {
|
421 | 411 | SWIFT_NAME("append(_:)")
|
422 | 412 | void push_back(BridgedCharSourceRange range);
|
423 | 413 |
|
424 |
| -#ifdef USED_IN_CPP_SOURCE |
| 414 | +#ifdef NOT_COMPILED_WITH_SWIFT_PURE_BRIDGING_MODE |
425 | 415 | /// Returns the `std::vector<swift::CharSourceRange>` that this
|
426 | 416 | /// `BridgedCharSourceRangeVector` represents and frees the memory owned by
|
427 | 417 | /// this `BridgedCharSourceRangeVector`.
|
|
0 commit comments