@@ -17,10 +17,12 @@ inline llvm::ArrayRef<T> getArrayRef(BridgedArrayRef bridged) {
17
17
}
18
18
19
19
BridgedIdentifier
20
- SwiftASTContext_getIdentifier (void *ctx, const char *_Nullable str, long len) {
21
- return static_cast <ASTContext *>(ctx)
22
- ->getIdentifier (StringRef{str, size_t (len)})
23
- .get ();
20
+ SwiftASTContext_getIdentifier (void *ctx, const uint8_t *_Nullable str, long len) {
21
+ return const_cast <void *>(
22
+ static_cast <ASTContext *>(ctx)
23
+ ->getIdentifier (
24
+ StringRef{reinterpret_cast <const char *>(str), size_t (len)})
25
+ .getAsOpaquePointer ());
24
26
}
25
27
26
28
void *SwiftImportDecl_create (void *ctx, void *dc, void *importLoc, char kind,
@@ -101,40 +103,43 @@ void *SwiftFunctionCallExpr_create(void *ctx, void *fn, void *args) {
101
103
/* implicit*/ false );
102
104
}
103
105
104
- void *SwiftIdentifierExpr_create (void *ctx, const char * base, void *loc) {
106
+ void *SwiftIdentifierExpr_create (void *ctx, BridgedIdentifier base, void *loc) {
105
107
ASTContext &Context = *static_cast <ASTContext *>(ctx);
106
108
auto name = DeclNameRef{
107
- swift::Identifier::getFromOpaquePointer (const_cast < char *>( base) )};
109
+ swift::Identifier::getFromOpaquePointer (base)};
108
110
Expr *E = new (Context) UnresolvedDeclRefExpr (
109
111
name, DeclRefKind::Ordinary, DeclNameLoc{*(SourceLoc *)&loc});
110
112
return E;
111
113
}
112
114
113
- void *SwiftStringLiteralExpr_create (void *ctx, const char *_Nullable string,
114
- long len, void *TokenLoc) {
115
+ void *SwiftStringLiteralExpr_create (
116
+ void *ctx, const uint8_t *_Nullable string,
117
+ long len, void *TokenLoc) {
115
118
ASTContext &Context = *static_cast <ASTContext *>(ctx);
116
- return new (Context) StringLiteralExpr (StringRef{string, size_t (len)},
117
- *(SourceLoc *)&TokenLoc);
119
+ return new (Context) StringLiteralExpr (
120
+ StringRef{reinterpret_cast <const char *>(string), size_t (len)},
121
+ *(SourceLoc *)&TokenLoc);
118
122
}
119
123
120
- void *SwiftIntegerLiteralExpr_create (void *ctx, const char *_Nullable string,
121
- long len, void *TokenLoc) {
124
+ void *SwiftIntegerLiteralExpr_create (
125
+ void *ctx, const uint8_t *_Nullable string, long len, void *TokenLoc) {
122
126
ASTContext &Context = *static_cast <ASTContext *>(ctx);
123
- return new (Context) IntegerLiteralExpr (StringRef{string, size_t (len)},
124
- *(SourceLoc *)&TokenLoc);
127
+ return new (Context) IntegerLiteralExpr (
128
+ StringRef{reinterpret_cast <const char *>(string), size_t (len)},
129
+ *(SourceLoc *)&TokenLoc);
125
130
}
126
131
127
132
void *SwiftBooleanLiteralExpr_create (void *ctx, bool value, void *TokenLoc) {
128
133
ASTContext &Context = *static_cast <ASTContext *>(ctx);
129
134
return new (Context) BooleanLiteralExpr (value, *(SourceLoc *)&TokenLoc);
130
135
}
131
136
132
- void *SwiftVarDecl_create (void *ctx, const char * _Nullable nameId,
137
+ void *SwiftVarDecl_create (void *ctx, BridgedIdentifier _Nullable nameId,
133
138
void *loc, bool isStatic, bool isLet, void *dc) {
134
139
ASTContext &Context = *static_cast <ASTContext *>(ctx);
135
140
return new (Context) VarDecl (isStatic,
136
141
isLet ? VarDecl::Introducer::Let : VarDecl::Introducer::Var,
137
- *(SourceLoc *)&loc, Identifier::getFromOpaquePointer (( void *) nameId),
142
+ *(SourceLoc *)&loc, Identifier::getFromOpaquePointer (nameId),
138
143
reinterpret_cast <DeclContext *>(dc));
139
144
}
140
145
@@ -164,10 +169,11 @@ void *BraceStmt_createStmt(void *ctx, void *lbloc, BridgedArrayRef elements, voi
164
169
*(SourceLoc *)&rbloc);
165
170
}
166
171
167
- void *ParamDecl_create (void *ctx, void *loc,
168
- void *_Nullable argLoc, void *_Nullable argName,
169
- void *_Nullable paramLoc, void *_Nullable paramName,
170
- void *declContext) {
172
+ void *ParamDecl_create (
173
+ void *ctx, void *loc,
174
+ void *_Nullable argLoc, BridgedIdentifier _Nullable argName,
175
+ void *_Nullable paramLoc, BridgedIdentifier _Nullable paramName,
176
+ void *declContext) {
171
177
ASTContext &Context = *static_cast <ASTContext *>(ctx);
172
178
return new (Context) ParamDecl (*(SourceLoc *)&loc, *(SourceLoc *)&argLoc,
173
179
Identifier::getFromOpaquePointer (argName),
@@ -177,7 +183,7 @@ void *ParamDecl_create(void *ctx, void *loc,
177
183
}
178
184
179
185
void *FuncDecl_create (void *ctx, void *staticLoc, bool isStatic, void *funcLoc,
180
- const char * name, void *nameLoc,
186
+ BridgedIdentifier name, void *nameLoc,
181
187
bool isAsync, void *_Nullable asyncLoc,
182
188
bool throws, void *_Nullable throwsLoc,
183
189
void *paramLLoc, BridgedArrayRef params, void *paramRLoc,
@@ -188,7 +194,7 @@ void *FuncDecl_create(void *ctx, void *staticLoc, bool isStatic, void *funcLoc,
188
194
getArrayRef<ParamDecl *>(params), *(SourceLoc *)¶mRLoc);
189
195
auto declName =
190
196
DeclName (*static_cast <ASTContext *>(ctx),
191
- Identifier::getFromOpaquePointer (( void *) name), paramList);
197
+ Identifier::getFromOpaquePointer (name), paramList);
192
198
auto *out = FuncDecl::create (
193
199
*static_cast <ASTContext *>(ctx), *(SourceLoc *)&staticLoc,
194
200
isStatic ? StaticSpellingKind::KeywordStatic : StaticSpellingKind::None,
@@ -200,16 +206,18 @@ void *FuncDecl_create(void *ctx, void *staticLoc, bool isStatic, void *funcLoc,
200
206
return static_cast <Decl *>(out);
201
207
}
202
208
203
- void *SimpleIdentTypeRepr_create (void *ctx, void *loc, const char * id) {
209
+ void *SimpleIdentTypeRepr_create (void *ctx, void *loc, BridgedIdentifier id) {
204
210
ASTContext &Context = *static_cast <ASTContext *>(ctx);
205
211
return new (Context) SimpleIdentTypeRepr (DeclNameLoc (*(SourceLoc *)&loc),
206
- DeclNameRef (Identifier::getFromOpaquePointer (( void *) id)));
212
+ DeclNameRef (Identifier::getFromOpaquePointer (id)));
207
213
}
208
214
209
- void *UnresolvedDotExpr_create (void *ctx, void *base, void *dotLoc, const char *name, void *nameLoc) {
215
+ void *UnresolvedDotExpr_create (
216
+ void *ctx, void *base, void *dotLoc, BridgedIdentifier name,
217
+ void *nameLoc) {
210
218
ASTContext &Context = *static_cast <ASTContext *>(ctx);
211
219
return new (Context) UnresolvedDotExpr ((Expr *)base, *(SourceLoc *)&dotLoc,
212
- DeclNameRef (Identifier::getFromOpaquePointer (( void *) name)),
220
+ DeclNameRef (Identifier::getFromOpaquePointer (name)),
213
221
DeclNameLoc (*(SourceLoc *)&nameLoc), false );
214
222
}
215
223
@@ -235,23 +243,23 @@ void NominalTypeDecl_setMembers(void *decl, BridgedArrayRef members) {
235
243
((NominalTypeDecl *)decl)->addMember (m);
236
244
}
237
245
238
- DeclContextAndDecl StructDecl_create (void *ctx, void *loc, const char *name, void *nameLoc,
239
- void *dc) {
246
+ DeclContextAndDecl StructDecl_create (
247
+ void *ctx, void *loc, BridgedIdentifier name, void *nameLoc, void *dc) {
240
248
ASTContext &Context = *static_cast <ASTContext *>(ctx);
241
249
auto *out = new (Context) StructDecl (SourceLoc (), // *(SourceLoc *)&loc,
242
- Identifier::getFromOpaquePointer (( void *) name),
250
+ Identifier::getFromOpaquePointer (name),
243
251
SourceLoc (), // *(SourceLoc *)&nameLoc,
244
252
{}, nullptr ,
245
253
(DeclContext *)dc);
246
254
out->setImplicit (); // TODO: remove this.
247
255
return {(DeclContext *)out, (NominalTypeDecl *)out, (Decl *)out};
248
256
}
249
257
250
- DeclContextAndDecl ClassDecl_create (void *ctx, void *loc, const char *name, void *nameLoc,
251
- void *dc) {
258
+ DeclContextAndDecl ClassDecl_create (
259
+ void *ctx, void *loc, BridgedIdentifier name, void *nameLoc, void *dc) {
252
260
ASTContext &Context = *static_cast <ASTContext *>(ctx);
253
261
auto *out = new (Context) ClassDecl (SourceLoc (), // *(SourceLoc *)&loc,
254
- Identifier::getFromOpaquePointer (( void *) name),
262
+ Identifier::getFromOpaquePointer (name),
255
263
SourceLoc (), // *(SourceLoc *)&nameLoc,
256
264
{}, nullptr ,
257
265
(DeclContext *)dc, false );
@@ -263,4 +271,4 @@ void TopLevelCodeDecl_dump(void *decl) { ((TopLevelCodeDecl *)decl)->dump(); }
263
271
264
272
void Expr_dump (void *expr) { ((Expr *)expr)->dump (); }
265
273
void Decl_dump (void *expr) { ((Decl *)expr)->dump (); }
266
- void Stmt_dump (void *expr) { ((Stmt *)expr)->dump (); }
274
+ void Stmt_dump (void *expr) { ((Stmt *)expr)->dump (); }
0 commit comments