@@ -555,48 +555,57 @@ void IterableDeclContext_setParsedMembers(BridgedArrayRef bridgedMembers,
555
555
FingerprintAndMembers{llvm::None, ctx.AllocateCopy (members)});
556
556
}
557
557
558
- BridgedDeclContextAndDecl
559
- StructDecl_create (BridgedASTContext cContext, BridgedDeclContext cDeclContext,
560
- BridgedSourceLoc cStructKeywordLoc, BridgedIdentifier cName,
561
- BridgedSourceLoc cNameLoc,
562
- void *_Nullable opaqueGenericParamList,
563
- BridgedSourceRange cBraceRange) {
564
- ASTContext &context = convertASTContext (cContext);
565
-
566
- auto *decl = new (context)
567
- StructDecl (convertSourceLoc (cStructKeywordLoc), convertIdentifier (cName),
568
- convertSourceLoc (cNameLoc), {},
569
- static_cast <GenericParamList *>(opaqueGenericParamList),
570
- convertDeclContext (cDeclContext));
558
+ static SmallVector<InheritedEntry>
559
+ convertToInheritedEntries (BridgedArrayRef cInheritedTypes) {
560
+ SmallVector<InheritedEntry> inheritedEntries;
561
+ for (auto &repr : convertArrayRef<TypeRepr *>(cInheritedTypes)) {
562
+ inheritedEntries.emplace_back (repr);
563
+ }
564
+
565
+ return inheritedEntries;
566
+ }
567
+
568
+ BridgedDeclContextAndDecl StructDecl_create (
569
+ BridgedASTContext cContext, BridgedDeclContext cDeclContext,
570
+ BridgedSourceLoc cStructKeywordLoc, BridgedIdentifier cName,
571
+ BridgedSourceLoc cNameLoc, void *_Nullable opaqueGenericParamList,
572
+ BridgedArrayRef cInheritedTypes, BridgedSourceRange cBraceRange) {
573
+ ASTContext &context = convertASTContext (cContext);
574
+
575
+ auto *decl = new (context) StructDecl (
576
+ convertSourceLoc (cStructKeywordLoc), convertIdentifier (cName),
577
+ convertSourceLoc (cNameLoc),
578
+ context.AllocateCopy (convertToInheritedEntries (cInheritedTypes)),
579
+ static_cast <GenericParamList *>(opaqueGenericParamList),
580
+ convertDeclContext (cDeclContext));
571
581
decl->setBraces (convertSourceRange (cBraceRange));
572
582
573
583
return {bridgeDeclContext (decl), static_cast <Decl *>(decl)};
574
584
}
575
585
576
- BridgedDeclContextAndDecl
577
- ClassDecl_create (BridgedASTContext cContext, BridgedDeclContext cDeclContext,
578
- BridgedSourceLoc cClassKeywordLoc, BridgedIdentifier cName,
579
- BridgedSourceLoc cNameLoc,
580
- void *_Nullable opaqueGenericParamList,
581
- BridgedSourceRange cBraceRange) {
586
+ BridgedDeclContextAndDecl ClassDecl_create (
587
+ BridgedASTContext cContext, BridgedDeclContext cDeclContext,
588
+ BridgedSourceLoc cClassKeywordLoc, BridgedIdentifier cName,
589
+ BridgedSourceLoc cNameLoc, void *_Nullable opaqueGenericParamList,
590
+ BridgedArrayRef cInheritedTypes, BridgedSourceRange cBraceRange) {
582
591
ASTContext &context = convertASTContext (cContext);
583
592
584
- auto *decl = new (context)
585
- ClassDecl (convertSourceLoc (cClassKeywordLoc), convertIdentifier (cName),
586
- convertSourceLoc (cNameLoc), {},
587
- static_cast <GenericParamList *>(opaqueGenericParamList),
588
- convertDeclContext (cDeclContext), false );
593
+ auto *decl = new (context) ClassDecl (
594
+ convertSourceLoc (cClassKeywordLoc), convertIdentifier (cName),
595
+ convertSourceLoc (cNameLoc),
596
+ context.AllocateCopy (convertToInheritedEntries (cInheritedTypes)),
597
+ static_cast <GenericParamList *>(opaqueGenericParamList),
598
+ convertDeclContext (cDeclContext), false );
589
599
decl->setBraces (convertSourceRange (cBraceRange));
590
600
591
601
return {bridgeDeclContext (decl), static_cast <Decl *>(decl)};
592
602
}
593
603
594
- BridgedDeclContextAndDecl
595
- ProtocolDecl_create (BridgedASTContext cContext, BridgedDeclContext cDeclContext,
596
- BridgedSourceLoc cProtocolKeywordLoc,
597
- BridgedIdentifier cName, BridgedSourceLoc cNameLoc,
598
- BridgedArrayRef cPrimaryAssociatedTypeNames,
599
- BridgedSourceRange cBraceRange) {
604
+ BridgedDeclContextAndDecl ProtocolDecl_create (
605
+ BridgedASTContext cContext, BridgedDeclContext cDeclContext,
606
+ BridgedSourceLoc cProtocolKeywordLoc, BridgedIdentifier cName,
607
+ BridgedSourceLoc cNameLoc, BridgedArrayRef cPrimaryAssociatedTypeNames,
608
+ BridgedArrayRef cInheritedTypes, BridgedSourceRange cBraceRange) {
600
609
SmallVector<PrimaryAssociatedTypeName, 2 > primaryAssociatedTypeNames;
601
610
for (auto &pair : convertArrayRef<BridgedIdentifierAndSourceLoc>(
602
611
cPrimaryAssociatedTypeNames)) {
@@ -608,7 +617,9 @@ ProtocolDecl_create(BridgedASTContext cContext, BridgedDeclContext cDeclContext,
608
617
auto *decl = new (context) ProtocolDecl (
609
618
convertDeclContext (cDeclContext), convertSourceLoc (cProtocolKeywordLoc),
610
619
convertSourceLoc (cNameLoc), convertIdentifier (cName),
611
- context.AllocateCopy (primaryAssociatedTypeNames), {}, nullptr );
620
+ context.AllocateCopy (primaryAssociatedTypeNames),
621
+ context.AllocateCopy (convertToInheritedEntries (cInheritedTypes)),
622
+ nullptr );
612
623
decl->setBraces (convertSourceRange (cBraceRange));
613
624
614
625
return {bridgeDeclContext (decl), static_cast <Decl *>(decl)};
@@ -862,22 +873,24 @@ void *GenericParamList_create(BridgedASTContext cContext,
862
873
863
874
void *GenericTypeParamDecl_create (BridgedASTContext cContext,
864
875
BridgedDeclContext cDeclContext,
865
- BridgedIdentifier name,
876
+ BridgedSourceLoc cEachLoc,
877
+ BridgedIdentifier cName,
866
878
BridgedSourceLoc cNameLoc,
867
- BridgedSourceLoc cEachLoc, SwiftInt index,
868
- bool isParameterPack) {
869
- return GenericTypeParamDecl::createParsed (
870
- convertDeclContext (cDeclContext), convertIdentifier (name),
871
- convertSourceLoc (cNameLoc), convertSourceLoc (cEachLoc),
872
- /* index*/ index, isParameterPack);
873
- }
879
+ void *_Nullable opaqueInheritedType,
880
+ SwiftInt index) {
881
+ auto eachLoc = convertSourceLoc (cEachLoc);
882
+ auto *decl = GenericTypeParamDecl::createParsed (
883
+ convertDeclContext (cDeclContext), convertIdentifier (cName),
884
+ convertSourceLoc (cNameLoc), eachLoc, index,
885
+ /* isParameterPack*/ eachLoc.isValid ());
886
+
887
+ if (opaqueInheritedType) {
888
+ auto entry = InheritedEntry (static_cast <TypeRepr *>(opaqueInheritedType));
889
+ ASTContext &context = convertASTContext (cContext);
890
+ decl->setInherited (context.AllocateCopy (llvm::makeArrayRef (entry)));
891
+ }
874
892
875
- void GenericTypeParamDecl_setInheritedType (BridgedASTContext cContext,
876
- void *param, void *ty) {
877
- ASTContext &context = convertASTContext (cContext);
878
- auto entries = context.AllocateCopy (
879
- ArrayRef<InheritedEntry>{InheritedEntry{(TypeRepr *)ty}});
880
- ((GenericTypeParamDecl *)param)->setInherited (entries);
893
+ return decl;
881
894
}
882
895
883
896
void *ParameterList_create (BridgedASTContext cContext,
0 commit comments