22
22
#include " swift/Basic/BasicBridging.h"
23
23
24
24
#ifdef USED_IN_CPP_SOURCE
25
- #include " swift/AST/ArgumentList.h"
26
25
#include " swift/AST/Attr.h"
27
26
#include " swift/AST/Decl.h"
28
- #include " swift/AST/DiagnosticConsumer.h"
29
- #include " swift/AST/DiagnosticEngine.h"
30
- #include " swift/AST/IfConfigClauseRangeInfo.h"
31
- #include " swift/AST/Stmt.h"
32
27
#endif
33
28
34
29
SWIFT_BEGIN_NULLABILITY_ANNOTATIONS
35
30
36
31
namespace swift {
32
+ class Argument ;
37
33
class ASTContext ;
34
+ struct ASTNode ;
35
+ class DeclAttributes ;
36
+ class DeclBaseName ;
37
+ class DeclNameLoc ;
38
+ class DeclNameRef ;
38
39
class DiagnosticArgument ;
39
40
class DiagnosticEngine ;
41
+ class Identifier ;
42
+ class IfConfigClauseRangeInfo ;
43
+ struct LabeledStmtInfo ;
44
+ class ProtocolConformanceRef ;
40
45
class Type ;
41
46
class CanType ;
42
47
class TypeBase ;
48
+ class StmtConditionElement ;
43
49
class SubstitutionMap ;
44
50
}
45
51
@@ -62,14 +68,9 @@ class BridgedIdentifier {
62
68
SWIFT_NAME (" init(raw:)" )
63
69
BridgedIdentifier (const void *_Nullable raw) : Raw(raw) {}
64
70
65
- #ifdef USED_IN_CPP_SOURCE
66
- BridgedIdentifier (swift::Identifier ident)
67
- : Raw(ident.getAsOpaquePointer()) {}
71
+ BRIDGED_INLINE BridgedIdentifier (swift::Identifier ident);
68
72
69
- swift::Identifier unbridged () const {
70
- return swift::Identifier::getFromOpaquePointer (Raw);
71
- }
72
- #endif
73
+ BRIDGED_INLINE swift::Identifier unbridged () const ;
73
74
};
74
75
75
76
SWIFT_NAME (" getter:BridgedIdentifier.raw(self:)" )
@@ -89,17 +90,9 @@ class BridgedDeclBaseName {
89
90
BridgedIdentifier Ident;
90
91
91
92
public:
92
- // Ensure that this struct value type will be indirectly returned on
93
- // Windows ARM64
94
- BridgedDeclBaseName () : Ident() {}
95
-
96
- #ifdef USED_IN_CPP_SOURCE
97
- BridgedDeclBaseName (swift::DeclBaseName baseName) : Ident(baseName.Ident) {}
93
+ BRIDGED_INLINE BridgedDeclBaseName (swift::DeclBaseName baseName);
98
94
99
- swift::DeclBaseName unbridged () const {
100
- return swift::DeclBaseName (Ident.unbridged ());
101
- }
102
- #endif
95
+ BRIDGED_INLINE swift::DeclBaseName unbridged () const ;
103
96
};
104
97
105
98
SWIFT_NAME (" BridgedDeclBaseName.createConstructor()" )
@@ -119,17 +112,9 @@ class BridgedDeclNameRef {
119
112
void *_Nonnull opaque;
120
113
121
114
public:
122
- // Ensure that this struct value type will be indirectly returned on
123
- // Windows ARM64
124
- BridgedDeclNameRef () : opaque() {}
115
+ BRIDGED_INLINE BridgedDeclNameRef (swift::DeclNameRef name);
125
116
126
- #ifdef USED_IN_CPP_SOURCE
127
- BridgedDeclNameRef (swift::DeclNameRef name) : opaque(name.getOpaqueValue()) {}
128
-
129
- swift::DeclNameRef unbridged () const {
130
- return swift::DeclNameRef::getFromOpaqueValue (opaque);
131
- }
132
- #endif
117
+ BRIDGED_INLINE swift::DeclNameRef unbridged () const ;
133
118
};
134
119
135
120
SWIFT_NAME (" BridgedDeclNameRef.createParsed(_:baseName:argumentLabels:)" )
@@ -149,15 +134,9 @@ class BridgedDeclNameLoc {
149
134
public:
150
135
BridgedDeclNameLoc () : LocationInfo(nullptr ), NumArgumentLabels(0 ) {}
151
136
152
- #ifdef USED_IN_CPP_SOURCE
153
- BridgedDeclNameLoc (swift::DeclNameLoc loc)
154
- : LocationInfo(loc.LocationInfo),
155
- NumArgumentLabels(loc.NumArgumentLabels) {}
137
+ BRIDGED_INLINE BridgedDeclNameLoc (swift::DeclNameLoc loc);
156
138
157
- swift::DeclNameLoc unbridged () const {
158
- return swift::DeclNameLoc (LocationInfo, NumArgumentLabels);
159
- }
160
- #endif
139
+ BRIDGED_INLINE swift::DeclNameLoc unbridged () const ;
161
140
};
162
141
163
142
SWIFT_NAME (" BridgedDeclNameLoc.createParsed(_:baseNameLoc:lParenLoc:"
@@ -179,17 +158,11 @@ class BridgedASTContext {
179
158
swift::ASTContext * _Nonnull Ctx;
180
159
181
160
public:
182
- // Ensure that this struct value type will be indirectly returned on
183
- // Windows ARM64
184
- BridgedASTContext () : Ctx() {}
185
-
186
- #ifdef USED_IN_CPP_SOURCE
187
161
SWIFT_UNAVAILABLE (" Use init(raw:) instead" )
188
- BridgedASTContext(swift::ASTContext &ctx) : Ctx(&ctx) {}
162
+ BRIDGED_INLINE BridgedASTContext (swift::ASTContext &ctx);
189
163
190
164
SWIFT_UNAVAILABLE (" Use '.raw' instead" )
191
- swift::ASTContext &unbridged() const { return *Ctx; }
192
- #endif
165
+ BRIDGED_INLINE swift::ASTContext &unbridged () const ;
193
166
};
194
167
195
168
SWIFT_NAME (" getter:BridgedASTContext.raw(self:)" )
@@ -343,18 +316,7 @@ struct BridgedASTNode {
343
316
SWIFT_NAME (" kind" )
344
317
ASTNodeKind Kind;
345
318
346
- #ifdef USED_IN_CPP_SOURCE
347
- swift::ASTNode unbridged () const {
348
- switch (Kind) {
349
- case ASTNodeKindExpr:
350
- return swift::ASTNode (static_cast <swift::Expr *>(Raw));
351
- case ASTNodeKindStmt:
352
- return swift::ASTNode (static_cast <swift::Stmt *>(Raw));
353
- case ASTNodeKindDecl:
354
- return swift::ASTNode (static_cast <swift::Decl *>(Raw));
355
- }
356
- }
357
- #endif
319
+ BRIDGED_INLINE swift::ASTNode unbridged () const ;
358
320
};
359
321
360
322
// Forward declare the underlying AST node type for each wrapper.
@@ -453,39 +415,16 @@ class BridgedDiagnosticArgument {
453
415
int64_t storage[3 ];
454
416
455
417
public:
456
- // Ensure that this struct value type will be indirectly returned on
457
- // Windows ARM64
458
- BridgedDiagnosticArgument () {}
459
-
460
- #ifdef USED_IN_CPP_SOURCE
461
- BridgedDiagnosticArgument (const swift::DiagnosticArgument &arg) {
462
- *reinterpret_cast <swift::DiagnosticArgument *>(&storage) = arg;
463
- }
464
- const swift::DiagnosticArgument &unbridged () const {
465
- return *reinterpret_cast <const swift::DiagnosticArgument *>(&storage);
466
- }
467
- #endif
418
+ BRIDGED_INLINE BridgedDiagnosticArgument (const swift::DiagnosticArgument &arg);
419
+ BRIDGED_INLINE const swift::DiagnosticArgument &unbridged () const ;
468
420
469
421
BridgedDiagnosticArgument (SwiftInt i);
470
422
BridgedDiagnosticArgument (BridgedStringRef s);
471
423
};
472
424
473
425
class BridgedDiagnosticFixIt {
474
- int64_t storage[7 ];
475
-
476
426
public:
477
- // Ensure that this struct value type will be indirectly returned on
478
- // Windows ARM64
479
- BridgedDiagnosticFixIt () {}
480
-
481
- #ifdef USED_IN_CPP_SOURCE
482
- BridgedDiagnosticFixIt (const swift::DiagnosticInfo::FixIt &fixit){
483
- *reinterpret_cast <swift::DiagnosticInfo::FixIt *>(&storage) = fixit;
484
- }
485
- const swift::DiagnosticInfo::FixIt &unbridged () const {
486
- return *reinterpret_cast <const swift::DiagnosticInfo::FixIt *>(&storage);
487
- }
488
- #endif
427
+ int64_t storage[7 ];
489
428
490
429
BridgedDiagnosticFixIt (BridgedSourceLoc start, uint32_t length, BridgedStringRef text);
491
430
};
@@ -585,16 +524,9 @@ struct BridgedDeclAttributes {
585
524
586
525
BridgedDeclAttributes () : chain(nullptr ){};
587
526
588
- #ifdef USED_IN_CPP_SOURCE
589
- BridgedDeclAttributes (swift::DeclAttributes attrs)
590
- : chain(attrs.getRawAttributeChain()) {}
527
+ BRIDGED_INLINE BridgedDeclAttributes (swift::DeclAttributes attrs);
591
528
592
- swift::DeclAttributes unbridged () const {
593
- swift::DeclAttributes attrs;
594
- attrs.setRawAttributeChain (chain.unbridged ());
595
- return attrs;
596
- }
597
- #endif
529
+ BRIDGED_INLINE swift::DeclAttributes unbridged () const ;
598
530
};
599
531
600
532
SWIFT_NAME (" BridgedDeclAttributes.add(self:_:)" )
@@ -1209,12 +1141,7 @@ struct BridgedCallArgument {
1209
1141
BridgedIdentifier label;
1210
1142
BridgedExpr argExpr;
1211
1143
1212
- #ifdef USED_IN_CPP_SOURCE
1213
- swift::Argument unbridged () const {
1214
- return swift::Argument (labelLoc.unbridged (), label.unbridged (),
1215
- argExpr.unbridged ());
1216
- }
1217
- #endif
1144
+ BRIDGED_INLINE swift::Argument unbridged () const ;
1218
1145
};
1219
1146
1220
1147
SWIFT_NAME (" BridgedArgumentList.createImplicitUnlabeled(_:exprs:)" )
@@ -1528,29 +1455,16 @@ struct BridgedLabeledStmtInfo {
1528
1455
SWIFT_NAME (" loc" )
1529
1456
BridgedSourceLoc Loc;
1530
1457
1531
- #ifdef USED_IN_CPP_SOURCE
1532
- swift::LabeledStmtInfo unbridged () const {
1533
- return {Name.unbridged (), Loc.unbridged ()};
1534
- }
1535
- #endif
1458
+ BRIDGED_INLINE swift::LabeledStmtInfo unbridged () const ;
1536
1459
};
1537
1460
1538
1461
class BridgedStmtConditionElement {
1539
1462
void *_Nonnull Raw;
1540
1463
1541
1464
public:
1542
- // Ensure that this struct value type will be indirectly returned on
1543
- // Windows ARM64
1544
- BridgedStmtConditionElement () {}
1545
-
1546
- #ifdef USED_IN_CPP_SOURCE
1547
- BridgedStmtConditionElement (swift::StmtConditionElement elem)
1548
- : Raw(elem.getOpaqueValue()) {}
1465
+ BRIDGED_INLINE BridgedStmtConditionElement (swift::StmtConditionElement elem);
1549
1466
1550
- swift::StmtConditionElement unbridged () const {
1551
- return swift::StmtConditionElement::fromOpaqueValue (Raw);
1552
- }
1553
- #endif
1467
+ BRIDGED_INLINE swift::StmtConditionElement unbridged () const ;
1554
1468
};
1555
1469
1556
1470
SWIFT_NAME (" BridgedStmtConditionElement.createBoolean(expr:)" )
@@ -2099,14 +2013,8 @@ class BridgedCanType {
2099
2013
struct BridgedConformance {
2100
2014
void * _Nullable opaqueValue;
2101
2015
2102
- #ifdef USED_IN_CPP_SOURCE
2103
- BridgedConformance (swift::ProtocolConformanceRef conformance)
2104
- : opaqueValue(conformance.getOpaqueValue()) {}
2105
-
2106
- swift::ProtocolConformanceRef unbridged () const {
2107
- return swift::ProtocolConformanceRef::getFromOpaqueValue (opaqueValue);
2108
- }
2109
- #endif
2016
+ BRIDGED_INLINE BridgedConformance (swift::ProtocolConformanceRef conformance);
2017
+ BRIDGED_INLINE swift::ProtocolConformanceRef unbridged () const ;
2110
2018
2111
2019
BridgedOwnedString getDebugDescription () const ;
2112
2020
BRIDGED_INLINE bool isConcrete () const ;
@@ -2122,15 +2030,6 @@ struct BridgedConformance {
2122
2030
struct BridgedConformanceArray {
2123
2031
BridgedArrayRef pcArray;
2124
2032
2125
- #ifdef USED_IN_CPP_SOURCE
2126
- BridgedConformanceArray (llvm::ArrayRef<swift::ProtocolConformanceRef> conformances)
2127
- : pcArray(conformances) {}
2128
-
2129
- llvm::ArrayRef<swift::ProtocolConformanceRef> unbridged () const {
2130
- return pcArray.unbridged <swift::ProtocolConformanceRef>();
2131
- }
2132
- #endif
2133
-
2134
2033
SwiftInt getCount () const { return SwiftInt (pcArray.Length ); }
2135
2034
2136
2035
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE
@@ -2168,29 +2067,7 @@ struct BridgedIfConfigClauseRangeInfo {
2168
2067
BridgedSourceLoc endLoc;
2169
2068
BridgedIfConfigClauseKind kind;
2170
2069
2171
- #ifdef USED_IN_CPP_SOURCE
2172
- swift::IfConfigClauseRangeInfo unbridged () const {
2173
- swift::IfConfigClauseRangeInfo::ClauseKind clauseKind;
2174
- switch (kind) {
2175
- case IfConfigActive:
2176
- clauseKind = swift::IfConfigClauseRangeInfo::ActiveClause;
2177
- break ;
2178
-
2179
- case IfConfigInactive:
2180
- clauseKind = swift::IfConfigClauseRangeInfo::InactiveClause;
2181
- break ;
2182
-
2183
- case IfConfigEnd:
2184
- clauseKind = swift::IfConfigClauseRangeInfo::EndDirective;
2185
- break ;
2186
- }
2187
-
2188
- return swift::IfConfigClauseRangeInfo (directiveLoc.unbridged (),
2189
- bodyLoc.unbridged (),
2190
- endLoc.unbridged (),
2191
- clauseKind);
2192
- }
2193
- #endif
2070
+ BRIDGED_INLINE swift::IfConfigClauseRangeInfo unbridged () const ;
2194
2071
};
2195
2072
2196
2073
// ===----------------------------------------------------------------------===//
0 commit comments