|
22 | 22 | #include "swift/Basic/BasicBridging.h"
|
23 | 23 |
|
24 | 24 | #ifdef USED_IN_CPP_SOURCE
|
| 25 | +#include "swift/AST/Attr.h" |
25 | 26 | #include "swift/AST/DiagnosticConsumer.h"
|
26 | 27 | #include "swift/AST/DiagnosticEngine.h"
|
27 | 28 | #include "swift/AST/Stmt.h"
|
@@ -279,6 +280,15 @@ namespace swift {
|
279 | 280 | BridgedPattern Bridged##Id##Pattern_asPattern(Bridged##Id##Pattern pattern);
|
280 | 281 | #include "swift/AST/PatternNodes.def"
|
281 | 282 |
|
| 283 | +// Declare `.asDeclAttribute` on each BridgedXXXAttr type, which upcasts a |
| 284 | +// wrapper for a DeclAttribute subclass to a BridgedDeclAttribute. |
| 285 | +#define SIMPLE_DECL_ATTR(...) |
| 286 | +#define DECL_ATTR(_, Id, ...) \ |
| 287 | + SWIFT_NAME("getter:Bridged" #Id "Attr.asDeclAttribute(self:)") \ |
| 288 | + BridgedDeclAttribute Bridged##Id##Attr_asDeclAttribute( \ |
| 289 | + Bridged##Id##Attr attr); |
| 290 | +#include "swift/AST/Attr.def" |
| 291 | + |
282 | 292 | struct BridgedPatternBindingEntry {
|
283 | 293 | BridgedPattern pattern;
|
284 | 294 | BridgedSourceLoc equalLoc;
|
@@ -407,10 +417,286 @@ SWIFT_NAME("getter:BridgedPatternBindingInitializer.asDeclContext(self:)")
|
407 | 417 | BridgedDeclContext BridgedPatternBindingInitializer_asDeclContext(
|
408 | 418 | BridgedPatternBindingInitializer cInit);
|
409 | 419 |
|
| 420 | +//===----------------------------------------------------------------------===// |
| 421 | +// MARK: DeclAttributes |
| 422 | +//===----------------------------------------------------------------------===// |
| 423 | + |
| 424 | +enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedDeclAttrKind { |
| 425 | +#define DECL_ATTR(_, Id, ...) BridgedDeclAttrKind##Id, |
| 426 | +#include "swift/AST/Attr.def" |
| 427 | + BridgedDeclAttrKindNone, |
| 428 | +}; |
| 429 | + |
| 430 | +SWIFT_NAME("BridgedDeclAttrKind.init(from:)") |
| 431 | +BridgedDeclAttrKind BridgedDeclAttrKind_fromString(BridgedStringRef cStr); |
| 432 | + |
| 433 | +struct BridgedDeclAttributes { |
| 434 | + BridgedNullableDeclAttribute chain; |
| 435 | + |
| 436 | + BridgedDeclAttributes() : chain(nullptr){}; |
| 437 | + |
| 438 | +#ifdef USED_IN_CPP_SOURCE |
| 439 | + BridgedDeclAttributes(swift::DeclAttributes attrs) |
| 440 | + : chain(attrs.getRawAttributeChain()) {} |
| 441 | + |
| 442 | + swift::DeclAttributes unbridged() const { |
| 443 | + swift::DeclAttributes attrs; |
| 444 | + attrs.setRawAttributeChain(chain.unbridged()); |
| 445 | + return attrs; |
| 446 | + } |
| 447 | +#endif |
| 448 | +}; |
| 449 | + |
| 450 | +SWIFT_NAME("BridgedDeclAttributes.add(self:_:)") |
| 451 | +void BridgedDeclAttributes_add(BridgedDeclAttributes *_Nonnull attrs, |
| 452 | + BridgedDeclAttribute add); |
| 453 | + |
| 454 | +SWIFT_NAME("BridgedDeclAttribute.createSimple(_:kind:atLoc:nameLoc:)") |
| 455 | +BridgedDeclAttribute BridgedDeclAttribute_createSimple( |
| 456 | + BridgedASTContext cContext, BridgedDeclAttrKind cKind, |
| 457 | + BridgedSourceLoc cAtLoc, BridgedSourceLoc cNameLoc); |
| 458 | + |
| 459 | +enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedAccessLevel { |
| 460 | + BridgedAccessLevelPrivate, |
| 461 | + BridgedAccessLevelFilePrivate, |
| 462 | + BridgedAccessLevelInternal, |
| 463 | + BridgedAccessLevelPackage, |
| 464 | + BridgedAccessLevelPublic, |
| 465 | + BridgedAccessLevelOpen, |
| 466 | +}; |
| 467 | + |
| 468 | +SWIFT_NAME("BridgedAccessControlAttr.createParsed(_:range:accessLevel:)") |
| 469 | +BridgedAccessControlAttr |
| 470 | +BridgedAccessControlAttr_createParsed(BridgedASTContext cContext, |
| 471 | + BridgedSourceRange cRange, |
| 472 | + BridgedAccessLevel cAccessLevel); |
| 473 | + |
| 474 | +SWIFT_NAME("BridgedAlignmentAttr.createParsed(_:atLoc:range:value:)") |
| 475 | +BridgedAlignmentAttr |
| 476 | +BridgedAlignmentAttr_createParsed(BridgedASTContext cContext, |
| 477 | + BridgedSourceLoc cAtLoc, |
| 478 | + BridgedSourceRange cRange, size_t cValue); |
| 479 | + |
| 480 | +SWIFT_NAME("BridgedCDeclAttr.createParsed(_:atLoc:range:name:)") |
| 481 | +BridgedCDeclAttr BridgedCDeclAttr_createParsed(BridgedASTContext cContext, |
| 482 | + BridgedSourceLoc cAtLoc, |
| 483 | + BridgedSourceRange cRange, |
| 484 | + BridgedStringRef cName); |
| 485 | + |
| 486 | +SWIFT_NAME( |
| 487 | + "BridgedDynamicReplacementAttr.createParsed(_:atLoc:attrNameLoc:lParenLoc:" |
| 488 | + "replacedFunction:rParenLoc:)") |
| 489 | +BridgedDynamicReplacementAttr BridgedDynamicReplacementAttr_createParsed( |
| 490 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 491 | + BridgedSourceLoc cAttrNameLoc, BridgedSourceLoc cLParenLoc, |
| 492 | + BridgedDeclNameRef cReplacedFunction, BridgedSourceLoc cRParenLoc); |
| 493 | + |
| 494 | +enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedEffectsKind { |
| 495 | + BridgedEffectsKindReadNone, |
| 496 | + BridgedEffectsKindReadOnly, |
| 497 | + BridgedEffectsKindReleaseNone, |
| 498 | + BridgedEffectsKindReadWrite, |
| 499 | + BridgedEffectsKindUnspecified, |
| 500 | + BridgedEffectsKindCustom, |
| 501 | +}; |
| 502 | + |
| 503 | +SWIFT_NAME("BridgedEffectsAttr.createParsed(_:atLoc:range:effectKind:)") |
| 504 | +BridgedEffectsAttr BridgedEffectsAttr_createParsed( |
| 505 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 506 | + BridgedSourceRange cRange, BridgedEffectsKind cEffectKind); |
| 507 | + |
| 508 | +SWIFT_NAME("BridgedEffectsAttr.createParsed(_:atLoc:range:customString:" |
| 509 | + "customStringLoc:)") |
| 510 | +BridgedEffectsAttr BridgedEffectsAttr_createParsed( |
| 511 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 512 | + BridgedSourceRange cRange, BridgedStringRef cCustomString, |
| 513 | + BridgedSourceLoc cCustomStringLoc); |
| 514 | + |
| 515 | +enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedExclusivityAttrMode { |
| 516 | + BridgedExclusivityAttrModeChecked, |
| 517 | + BridgedExclusivityAttrModeUnchecked, |
| 518 | +}; |
| 519 | + |
| 520 | +SWIFT_NAME("BridgedExclusivityAttr.createParsed(_:atLoc:range:mode:)") |
| 521 | +BridgedExclusivityAttr BridgedExclusivityAttr_createParsed( |
| 522 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 523 | + BridgedSourceRange cRange, BridgedExclusivityAttrMode cMode); |
| 524 | + |
| 525 | +enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedExposureKind { |
| 526 | + BridgedExposureKindCxx, |
| 527 | + BridgedExposureKindWasm, |
| 528 | +}; |
| 529 | + |
| 530 | +SWIFT_NAME("BridgedExposeAttr.createParsed(_:atLoc:range:name:kind:)") |
| 531 | +BridgedExposeAttr BridgedExposeAttr_createParsed(BridgedASTContext cContext, |
| 532 | + BridgedSourceLoc cAtLoc, |
| 533 | + BridgedSourceRange cRange, |
| 534 | + BridgedStringRef cName, |
| 535 | + BridgedExposureKind cKind); |
| 536 | + |
| 537 | +enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedExternKind { |
| 538 | + BridgedExternKindC, |
| 539 | + BridgedExternKindWasm, |
| 540 | +}; |
| 541 | + |
| 542 | +SWIFT_NAME("BridgedExternAttr.createParsed(_:atLoc:range:lParenLoc:rParenLoc:" |
| 543 | + "kind:moduleName:name:)") |
| 544 | +BridgedExternAttr BridgedExternAttr_createParsed( |
| 545 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 546 | + BridgedSourceRange cRange, BridgedSourceLoc cLParenLoc, |
| 547 | + BridgedSourceLoc cRParenLoc, BridgedExternKind cKind, |
| 548 | + BridgedStringRef cModuleName, BridgedStringRef cName); |
| 549 | + |
| 550 | +SWIFT_NAME("BridgedImplementsAttr.createParsed(_:atLoc:range:protocolType:" |
| 551 | + "memberName:memberNameLoc:)") |
| 552 | +BridgedImplementsAttr BridgedImplementsAttr_createParsed( |
| 553 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 554 | + BridgedSourceRange cRange, BridgedTypeRepr cProtocolType, |
| 555 | + BridgedDeclNameRef cMemberName, BridgedDeclNameLoc cMemberNameLoc); |
| 556 | + |
| 557 | +enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedInlineKind { |
| 558 | + BridgedInlineKindNever, |
| 559 | + BridgedInlineKindAlways, |
| 560 | +}; |
| 561 | + |
| 562 | +SWIFT_NAME("BridgedInlineAttr.createParsed(_:atLoc:range:kind:)") |
| 563 | +BridgedInlineAttr BridgedInlineAttr_createParsed(BridgedASTContext cContext, |
| 564 | + BridgedSourceLoc cAtLoc, |
| 565 | + BridgedSourceRange cRange, |
| 566 | + BridgedInlineKind cKind); |
| 567 | + |
| 568 | +SWIFT_NAME("BridgedMainTypeAttr.createParsed(_:atLoc:nameLoc:)") |
| 569 | +BridgedMainTypeAttr BridgedMainTypeAttr_createParsed(BridgedASTContext cContext, |
| 570 | + BridgedSourceLoc cAtLoc, |
| 571 | + BridgedSourceLoc cNameLoc); |
| 572 | + |
| 573 | +SWIFT_NAME( |
| 574 | + "BridgedSwiftNativeObjCRuntimeBaseAttr.createParsed(_:atLoc:range:name:)") |
| 575 | +BridgedSwiftNativeObjCRuntimeBaseAttr |
| 576 | +BridgedSwiftNativeObjCRuntimeBaseAttr_createParsed(BridgedASTContext cContext, |
| 577 | + BridgedSourceLoc cAtLoc, |
| 578 | + BridgedSourceRange cRange, |
| 579 | + BridgedIdentifier cName); |
| 580 | + |
| 581 | +enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedNonSendableKind { |
| 582 | + BridgedNonSendableKindSpecific, |
| 583 | + BridgedNonSendableKindAssumed, |
| 584 | +}; |
| 585 | + |
| 586 | +SWIFT_NAME("BridgedNonSendableAttr.createParsed(_:atLoc:range:kind:)") |
| 587 | +BridgedNonSendableAttr BridgedNonSendableAttr_createParsed( |
| 588 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 589 | + BridgedSourceRange cRange, BridgedNonSendableKind cKind); |
| 590 | + |
| 591 | +SWIFT_NAME("BridgedObjCAttr.createParsedUnnamed(_:atLoc:attrNameLoc:)") |
| 592 | +BridgedObjCAttr |
| 593 | +BridgedObjCAttr_createParsedUnnamed(BridgedASTContext cContext, |
| 594 | + BridgedSourceLoc cAtLoc, |
| 595 | + BridgedSourceLoc cAttrNameLoc); |
| 596 | + |
| 597 | +SWIFT_NAME("BridgedObjCAttr.createParsedNullary(_:atLoc:attrNameLoc:lParenLoc:" |
| 598 | + "nameLoc:name:rParenLoc:)") |
| 599 | +BridgedObjCAttr BridgedObjCAttr_createParsedNullary( |
| 600 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 601 | + BridgedSourceLoc cAttrNameLoc, BridgedSourceLoc cLParenLoc, |
| 602 | + BridgedSourceLoc cNameLoc, BridgedIdentifier cName, |
| 603 | + BridgedSourceLoc cRParenLoc); |
| 604 | + |
| 605 | +SWIFT_NAME("BridgedObjCAttr.createParsedSelector(_:atLoc:attrNameLoc:lParenLoc:" |
| 606 | + "nameLocs:names:rParenLoc:)") |
| 607 | +BridgedObjCAttr BridgedObjCAttr_createParsedSelector( |
| 608 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 609 | + BridgedSourceLoc cAttrNameLoc, BridgedSourceLoc cLParenLoc, |
| 610 | + BridgedArrayRef cNameLocs, BridgedArrayRef cNames, |
| 611 | + BridgedSourceLoc cRParenLoc); |
| 612 | + |
| 613 | +SWIFT_NAME("BridgedObjCImplementationAttr.createParsed(_:atLoc:range:name:)") |
| 614 | +BridgedObjCImplementationAttr BridgedObjCImplementationAttr_createParsed( |
| 615 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 616 | + BridgedSourceRange cRange, BridgedIdentifier cName); |
| 617 | + |
| 618 | +SWIFT_NAME("BridgedObjCRuntimeNameAttr.createParsed(_:atLoc:range:name:)") |
| 619 | +BridgedObjCRuntimeNameAttr BridgedObjCRuntimeNameAttr_createParsed( |
| 620 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 621 | + BridgedSourceRange cRange, BridgedIdentifier cName); |
| 622 | + |
| 623 | +enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedOptimizationMode { |
| 624 | + BridgedOptimizationModeForSpeed, |
| 625 | + BridgedOptimizationModeForSize, |
| 626 | + BridgedOptimizationModeNoOptimization, |
| 627 | +}; |
| 628 | + |
| 629 | +SWIFT_NAME("BridgedOptimizeAttr.createParsed(_:atLoc:range:mode:)") |
| 630 | +BridgedOptimizeAttr BridgedOptimizeAttr_createParsed( |
| 631 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 632 | + BridgedSourceRange cRange, BridgedOptimizationMode cMode); |
| 633 | + |
| 634 | +SWIFT_NAME("BridgedPrivateImportAttr.createParsed(_:atLoc:attrNameLoc:" |
| 635 | + "lParenLoc:fileName:rParenLoc:)") |
| 636 | +BridgedPrivateImportAttr BridgedPrivateImportAttr_createParsed( |
| 637 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 638 | + BridgedSourceLoc cAttrNameLoc, BridgedSourceLoc cLParenLoc, |
| 639 | + BridgedStringRef cFileName, BridgedSourceLoc cRParenLoc); |
| 640 | + |
| 641 | +SWIFT_NAME( |
| 642 | + "BridgedProjectedValuePropertyAttr.createParsed(_:atLoc:range:name:)") |
| 643 | +BridgedProjectedValuePropertyAttr |
| 644 | +BridgedProjectedValuePropertyAttr_createParsed(BridgedASTContext cContext, |
| 645 | + BridgedSourceLoc cAtLoc, |
| 646 | + BridgedSourceRange cRange, |
| 647 | + BridgedIdentifier cName); |
| 648 | + |
| 649 | +SWIFT_NAME("BridgedRawDocCommentAttr.createParsed(_:range:)") |
| 650 | +BridgedRawDocCommentAttr |
| 651 | +BridgedRawDocCommentAttr_createParsed(BridgedASTContext cContext, |
| 652 | + BridgedCharSourceRange cRange); |
| 653 | + |
| 654 | +enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedReferenceOwnership { |
| 655 | + BridgedReferenceOwnershipWeak, |
| 656 | + BridgedReferenceOwnershipUnowned, |
| 657 | + BridgedReferenceOwnershipUnmanaged, |
| 658 | +}; |
| 659 | + |
| 660 | +SWIFT_NAME("BridgedReferenceOwnershipAttr.createParsed(_:atLoc:range:kind:)") |
| 661 | +BridgedReferenceOwnershipAttr BridgedReferenceOwnershipAttr_createParsed( |
| 662 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 663 | + BridgedSourceRange cRange, BridgedReferenceOwnership cKind); |
| 664 | + |
| 665 | +SWIFT_NAME("BridgedSectionAttr.createParsed(_:atLoc:range:name:)") |
| 666 | +BridgedSectionAttr BridgedSectionAttr_createParsed(BridgedASTContext cContext, |
| 667 | + BridgedSourceLoc cAtLoc, |
| 668 | + BridgedSourceRange cRange, |
| 669 | + BridgedStringRef cName); |
| 670 | + |
| 671 | +SWIFT_NAME("BridgedSemanticsAttr.createParsed(_:atLoc:range:value:)") |
| 672 | +BridgedSemanticsAttr BridgedSemanticsAttr_createParsed( |
| 673 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 674 | + BridgedSourceRange cRange, BridgedStringRef cValue); |
| 675 | + |
| 676 | +SWIFT_NAME("BridgedSetterAccessAttr.createParsed(_:range:accessLevel:)") |
| 677 | +BridgedSetterAccessAttr |
| 678 | +BridgedSetterAccessAttr_createParsed(BridgedASTContext cContext, |
| 679 | + BridgedSourceRange cRange, |
| 680 | + BridgedAccessLevel cAccessLevel); |
| 681 | + |
| 682 | +SWIFT_NAME( |
| 683 | + "BridgedSPIAccessControlAttr.createParsed(_:atLoc:range:spiGroupName:)") |
| 684 | +BridgedSPIAccessControlAttr BridgedSPIAccessControlAttr_createParsed( |
| 685 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 686 | + BridgedSourceRange cRange, BridgedIdentifier cSPIGroupName); |
| 687 | + |
| 688 | +SWIFT_NAME("BridgedSILGenNameAttr.createParsed(_:atLoc:range:name:isRaw:)") |
| 689 | +BridgedSILGenNameAttr BridgedSILGenNameAttr_createParsed( |
| 690 | + BridgedASTContext cContext, BridgedSourceLoc cAtLoc, |
| 691 | + BridgedSourceRange cRange, BridgedStringRef cName, bool isRaw); |
| 692 | + |
410 | 693 | //===----------------------------------------------------------------------===//
|
411 | 694 | // MARK: Decls
|
412 | 695 | //===----------------------------------------------------------------------===//
|
413 | 696 |
|
| 697 | +SWIFT_NAME("BridgedDecl.setAttrs(self:_:)") |
| 698 | +void BridgedDecl_setAttrs(BridgedDecl decl, BridgedDeclAttributes attrs); |
| 699 | + |
414 | 700 | enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedStaticSpelling {
|
415 | 701 | BridgedStaticSpellingNone,
|
416 | 702 | BridgedStaticSpellingStatic,
|
@@ -466,15 +752,15 @@ SWIFT_NAME("BridgedDestructorDecl.setParsedBody(self:_:)")
|
466 | 752 | void BridgedDestructorDecl_setParsedBody(BridgedDestructorDecl decl,
|
467 | 753 | BridgedBraceStmt body);
|
468 | 754 |
|
469 |
| -SWIFT_NAME( |
470 |
| - "BridgedFuncDecl.createParsed(_:declContext:staticLoc:funcKeywordLoc:" |
471 |
| - "name:nameLoc:genericParamList:parameterList:asyncSpecifierLoc:" |
472 |
| - "throwsSpecifierLoc:thrownType:returnType:genericWhereClause:)") |
| 755 | +SWIFT_NAME("BridgedFuncDecl.createParsed(_:declContext:staticLoc:" |
| 756 | + "staticSpelling:funcKeywordLoc:" |
| 757 | + "name:nameLoc:genericParamList:parameterList:asyncSpecifierLoc:" |
| 758 | + "throwsSpecifierLoc:thrownType:returnType:genericWhereClause:)") |
473 | 759 | BridgedFuncDecl BridgedFuncDecl_createParsed(
|
474 | 760 | BridgedASTContext cContext, BridgedDeclContext cDeclContext,
|
475 |
| - BridgedSourceLoc cStaticLoc, BridgedSourceLoc cFuncKeywordLoc, |
476 |
| - BridgedIdentifier cName, BridgedSourceLoc cNameLoc, |
477 |
| - BridgedNullableGenericParamList genericParamList, |
| 761 | + BridgedSourceLoc cStaticLoc, BridgedStaticSpelling cStaticSpelling, |
| 762 | + BridgedSourceLoc cFuncKeywordLoc, BridgedIdentifier cName, |
| 763 | + BridgedSourceLoc cNameLoc, BridgedNullableGenericParamList genericParamList, |
478 | 764 | BridgedParameterList parameterList, BridgedSourceLoc cAsyncLoc,
|
479 | 765 | BridgedSourceLoc cThrowsLoc, BridgedNullableTypeRepr thrownType,
|
480 | 766 | BridgedNullableTypeRepr returnType,
|
|
0 commit comments