File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed
SwiftCompilerSources/Sources/AST Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ public class Decl: CustomStringConvertible, Hashable {
2323 /// The module in which this declaration resides.
2424 public var parentModule : ModuleDecl { bridged. getModuleContext ( ) . getAs ( ModuleDecl . self) }
2525
26+ /// The parent DeclContext if it is a Decl.
27+ public var parent : Decl ? { bridged. getParent ( ) . decl }
28+
2629 // True if this declaration is imported from C/C++/ObjC.
2730 public var hasClangNode : Bool { bridged. hasClangNode ( ) }
2831
@@ -69,7 +72,9 @@ final public class ClassDecl: NominalTypeDecl {
6972 }
7073}
7174
72- final public class ProtocolDecl : NominalTypeDecl { }
75+ final public class ProtocolDecl : NominalTypeDecl {
76+ public var requiresClass : Bool { bridged. ProtocolDecl_requiresClass ( ) }
77+ }
7378
7479final public class BuiltinTupleDecl : NominalTypeDecl { }
7580
Original file line number Diff line number Diff line change @@ -379,6 +379,7 @@ struct BridgedDeclObj {
379379 BridgedOwnedString getDebugDescription () const ;
380380 BRIDGED_INLINE BridgedSourceLoc getLoc () const ;
381381 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj getModuleContext () const ;
382+ SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedDeclObj getParent () const ;
382383 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef Type_getName () const ;
383384 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedStringRef Value_getUserFacingName () const ;
384385 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSourceLoc Value_getNameLoc () const ;
@@ -391,6 +392,7 @@ struct BridgedDeclObj {
391392 BRIDGED_INLINE bool Struct_hasUnreferenceableStorage () const ;
392393 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType Class_getSuperclass () const ;
393394 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedDeclObj Class_getDestructor () const ;
395+ BRIDGED_INLINE bool ProtocolDecl_requiresClass () const ;
394396 BRIDGED_INLINE bool AbstractFunction_isOverridden () const ;
395397 BRIDGED_INLINE bool Destructor_isIsolated () const ;
396398};
Original file line number Diff line number Diff line change @@ -180,6 +180,10 @@ BridgedDeclObj BridgedDeclObj::getModuleContext() const {
180180 return {unbridged ()-> getModuleContext ()};
181181}
182182
183+ OptionalBridgedDeclObj BridgedDeclObj ::getParent () const {
184+ return {unbridged ()-> getDeclContext ()-> getAsDecl ()};
185+ }
186+
183187BridgedStringRef BridgedDeclObj ::Type_getName () const {
184188 return getAs < swift ::TypeDecl > ()-> getName ().str ();
185189}
@@ -228,6 +232,10 @@ BridgedDeclObj BridgedDeclObj::Class_getDestructor() const {
228232 return {getAs < swift ::ClassDecl > ( )-> getDestructor ()};
229233}
230234
235+ bool BridgedDeclObj ::ProtocolDecl_requiresClass () const {
236+ return getAs < swift ::ProtocolDecl > ( )-> requiresClass ();
237+ }
238+
231239bool BridgedDeclObj ::AbstractFunction_isOverridden () const {
232240 return getAs < swift ::AbstractFunctionDecl > ( )-> isOverridden ();
233241}
You can’t perform that action at this time.
0 commit comments