@@ -29,6 +29,10 @@ public class Decl: CustomStringConvertible, Hashable {
2929 // True if this declaration is imported from C/C++/ObjC.
3030 public var hasClangNode : Bool { bridged. hasClangNode ( ) }
3131
32+ public var declContext : DeclContext { bridgedDecl. declContext }
33+
34+ var bridgedDecl : BridgedDecl { BridgedDecl ( raw: bridged. obj) }
35+
3236 public static func == ( lhs: Decl , rhs: Decl ) -> Bool { lhs === rhs }
3337
3438 public func hash( into hasher: inout Hasher ) {
@@ -39,7 +43,7 @@ public class Decl: CustomStringConvertible, Hashable {
3943public class ValueDecl : Decl {
4044 final public var nameLoc : SourceLoc ? { SourceLoc ( bridged: bridged. Value_getNameLoc ( ) ) }
4145 final public var userFacingName : StringRef { StringRef ( bridged: bridged. Value_getUserFacingName ( ) ) }
42- final public var baseIdentifier : swift . Identifier { bridged. Value_getBaseIdentifier ( ) }
46+ final public var baseIdentifier : Identifier { bridged. Value_getBaseIdentifier ( ) }
4347 final public var isObjC : Bool { bridged. Value_isObjC ( ) }
4448}
4549
@@ -58,8 +62,8 @@ public class NominalTypeDecl: GenericTypeDecl {
5862 bridged. NominalType_getValueTypeDestructor ( ) . getAs ( DestructorDecl . self)
5963 }
6064
61- public var declaredInterfaceType : AST . ` Type` {
62- AST . ` Type` ( bridged: bridged. NominalType_getDeclaredInterfaceType ( ) )
65+ public var declaredInterfaceType : Type {
66+ Type ( bridged: bridged. NominalType_getDeclaredInterfaceType ( ) )
6367 }
6468}
6569
@@ -123,8 +127,8 @@ final public class MacroDecl: ValueDecl {}
123127
124128final public class EnumElementDecl : ValueDecl {
125129 public var hasAssociatedValues : Bool { bridged. EnumElementDecl_hasAssociatedValues ( ) }
126- public var parameterList : BridgedParameterList { bridged. EnumElementDecl_getParameterList ( ) }
127- public var nameStr : StringRef { StringRef ( bridged: bridged. EnumElementDecl_getNameStr ( ) ) }
130+ public var parameterList : ParameterList { bridged. EnumElementDecl_getParameterList ( ) }
131+ public var name : StringRef { StringRef ( bridged: bridged. EnumElementDecl_getNameStr ( ) ) }
128132}
129133
130134final public class ExtensionDecl : Decl { }
@@ -172,3 +176,150 @@ extension Optional where Wrapped == Decl {
172176 OptionalBridgedDeclObj ( self ? . bridged. obj)
173177 }
174178}
179+
180+ public typealias Identifier = swift . Identifier
181+
182+ public typealias GenericTypeParamKind = swift . GenericTypeParamKind
183+
184+ public typealias ASTContext = BridgedASTContext
185+
186+ public typealias DeclContext = BridgedDeclContext
187+
188+ public typealias Expr = BridgedExpr
189+
190+ public typealias ParameterList = BridgedParameterList
191+
192+ public typealias SourceFile = BridgedSourceFile
193+
194+ public typealias FileUnit = BridgedFileUnit
195+
196+ public typealias GenericParamList = BridgedGenericParamList
197+
198+ public typealias TrailingWhereClause = BridgedTrailingWhereClause
199+
200+ public typealias BridgedParamDecl = ASTBridging . BridgedParamDecl
201+
202+ public typealias BridgedGenericTypeParamDecl = ASTBridging . BridgedGenericTypeParamDecl
203+
204+ public typealias BridgedEnumDecl = ASTBridging . BridgedEnumDecl
205+
206+ public typealias BridgedEnumElementDecl = ASTBridging . BridgedEnumElementDecl
207+
208+ extension ParameterList {
209+ public subscript( _ index: Int ) -> BridgedParamDecl {
210+ return get ( index)
211+ }
212+
213+ public static func createParsed(
214+ _ astContext: ASTContext , leftParenLoc: SourceLoc ? , parameters: [ BridgedParamDecl ] ,
215+ rightParenLoc: SourceLoc ?
216+ ) -> ParameterList {
217+ parameters. withBridgedArrayRef {
218+ ParameterList . createParsed (
219+ astContext, leftParenLoc: leftParenLoc. bridgedLocation, parameters: $0,
220+ rightParenLoc: rightParenLoc. bridgedLocation)
221+ }
222+ }
223+ }
224+
225+ extension GenericParamList {
226+ public static func createParsed(
227+ _ astContext: ASTContext , leftAngleLoc: SourceLoc ? , parameters: [ BridgedGenericTypeParamDecl ] ,
228+ genericWhereClause: TrailingWhereClause ? ,
229+ rightAngleLoc: SourceLoc ?
230+ ) -> GenericParamList {
231+ return parameters. withBridgedArrayRef {
232+ GenericParamList . createParsed (
233+ astContext, leftAngleLoc: leftAngleLoc. bridgedLocation, parameters: $0,
234+ genericWhereClause: genericWhereClause. bridged, rightAngleLoc: rightAngleLoc. bridgedLocation
235+ )
236+ }
237+ }
238+ }
239+
240+ extension BridgedDecl {
241+ public var declObj : BridgedDeclObj {
242+ BridgedDeclObj ( SwiftObject ( raw. bindMemory ( to: BridgedSwiftObject . self, capacity: 1 ) ) )
243+ }
244+ public var decl : Decl { declObj. decl }
245+ }
246+
247+ extension BridgedEnumDecl {
248+ public static func createParsed(
249+ _ astContext: ASTContext , declContext: DeclContext , enumKeywordLoc: SourceLoc ? , name: String ,
250+ nameLoc: SourceLoc ? , genericParamList: GenericParamList ? , inheritedTypes: [ Type ] ,
251+ genericWhereClause: TrailingWhereClause ? , braceRange: SourceRange
252+ ) -> BridgedEnumDecl {
253+ return name. withCString { strPtr in
254+ inheritedTypes. withBridgedArrayRef { types in
255+ BridgedEnumDecl . createParsed (
256+ astContext, declContext: declContext,
257+ enumKeywordLoc: enumKeywordLoc. bridgedLocation,
258+ name: astContext. getIdentifier ( BridgedStringRef ( data: strPtr, count: name. count) ) ,
259+ nameLoc: nameLoc. bridgedLocation,
260+ genericParamList: genericParamList. bridged,
261+ inheritedTypes: types,
262+ genericWhereClause: genericWhereClause. bridged,
263+ braceRange: braceRange. bridged)
264+ }
265+ }
266+ }
267+ }
268+
269+ extension BridgedEnumElementDecl {
270+ public static func createParsed(
271+ _ astContext: ASTContext , declContext: DeclContext ,
272+ name: Identifier , nameLoc: SourceLoc ? ,
273+ parameterList: ParameterList ? ,
274+ equalsLoc: SourceLoc ? , rawValue: Expr ?
275+ ) -> BridgedEnumElementDecl {
276+ BridgedEnumElementDecl . createParsed (
277+ astContext, declContext: declContext,
278+ name: name, nameLoc: nameLoc. bridgedLocation,
279+ parameterList: parameterList. bridged,
280+ equalsLoc: equalsLoc. bridgedLocation, rawValue: rawValue. bridged)
281+ }
282+ }
283+
284+ extension SourceFile {
285+ public init ? ( bridged: BridgedNullableSourceFile ) {
286+ guard let raw = bridged. raw else {
287+ return nil
288+ }
289+ self . init ( raw: raw)
290+ }
291+ }
292+
293+ extension FileUnit {
294+ public var asSourceFile : SourceFile ? { SourceFile ( bridged: self . castToSourceFile ( ) ) }
295+ }
296+
297+ extension BridgedParamDecl {
298+ public func setInterfaceType( type: Type ) {
299+ self . setInterfaceType ( type. bridged)
300+ }
301+ }
302+
303+ extension ParameterList ? {
304+ public var bridged : BridgedNullableParameterList {
305+ BridgedNullableParameterList ( raw: self ? . raw)
306+ }
307+ }
308+
309+ extension GenericParamList ? {
310+ public var bridged : BridgedNullableGenericParamList {
311+ BridgedNullableGenericParamList ( raw: self ? . raw)
312+ }
313+ }
314+
315+ extension Expr ? {
316+ public var bridged : BridgedNullableExpr {
317+ BridgedNullableExpr ( raw: self ? . raw)
318+ }
319+ }
320+
321+ extension TrailingWhereClause ? {
322+ public var bridged : BridgedNullableTrailingWhereClause {
323+ BridgedNullableTrailingWhereClause ( raw: self ? . raw)
324+ }
325+ }
0 commit comments