|
| 1 | +#pragma once |
| 2 | + |
| 3 | +// FRT or SWIFT_SHARED_REFERENCE type |
| 4 | +struct FRTStruct { |
| 5 | +} \ |
| 6 | + __attribute__((swift_attr("import_reference"))) \ |
| 7 | + __attribute__((swift_attr("retain:retainFRTStruct"))) \ |
| 8 | + __attribute__((swift_attr("release:releaseFRTStruct"))); |
| 9 | + |
| 10 | +// Retain function for the FRT or SWIFT_SHARED_REFERENCE type FRTStruct |
| 11 | +void retainFRTStruct(FRTStruct * _Nonnull b) { |
| 12 | +} |
| 13 | + |
| 14 | +// Release function for the FRT or SWIFT_SHARED_REFERENCE type FRTStruct |
| 15 | +void releaseFRTStruct(FRTStruct * _Nonnull b) { |
| 16 | +} |
| 17 | + |
| 18 | +// Global/free C++ functions returning FRT without any attributes |
| 19 | +FRTStruct* _Nonnull global_function_returning_FRT(); |
| 20 | +FRTStruct* _Nonnull global_function_returning_copy(); |
| 21 | +FRTStruct* _Nonnull global_function_returning_create(); |
| 22 | +FRTStruct* _Nonnull global_function_returning_init(); |
| 23 | +FRTStruct* _Nonnull global_function_returning_clone(); |
| 24 | + |
| 25 | +// Global/free C++ functions returning FRT with attribute swift_attr("returns_retained") or SWIFT_RETURNS_RETAINED |
| 26 | +FRTStruct* _Nonnull global_function_returning_FRT_with_attr_returns_retained() __attribute__((swift_attr("returns_retained"))); |
| 27 | +FRTStruct* _Nonnull global_function_returning_copy_with_attr_returns_retained() __attribute__((swift_attr("returns_retained"))); |
| 28 | +FRTStruct* _Nonnull global_function_returning_create_with_attr_returns_retained() __attribute__((swift_attr("returns_retained"))); |
| 29 | +FRTStruct* _Nonnull global_function_returning_init_with_attr_returns_retained() __attribute__((swift_attr("returns_retained"))); |
| 30 | +FRTStruct* _Nonnull global_function_returning_clone_with_attr_returns_retained() __attribute__((swift_attr("returns_retained"))); |
| 31 | + |
| 32 | +// Global/free C++ functions returning FRT with attribute swift_attr("returns_unretained") or SWIFT_RETURNS_UNRETAINED |
| 33 | +FRTStruct* _Nonnull global_function_returning_FRT_with_attr_returns_unretained() __attribute__((swift_attr("returns_unretained"))); |
| 34 | +FRTStruct* _Nonnull global_function_returning_copy_with_attr_returns_unretained() __attribute__((swift_attr("returns_unretained"))); |
| 35 | +FRTStruct* _Nonnull global_function_returning_create_with_attr_returns_unretained() __attribute__((swift_attr("returns_unretained"))); |
| 36 | +FRTStruct* _Nonnull global_function_returning_init_with_attr_returns_unretained() __attribute__((swift_attr("returns_unretained"))); |
| 37 | +FRTStruct* _Nonnull global_function_returning_clone_with_attr_returns_unretained() __attribute__((swift_attr("returns_unretained"))); |
| 38 | + |
| 39 | +// Struct having static methods returning FRT without any attributes |
| 40 | +struct StructWithStaticMethodsReturningFRTWithoutAttributes { |
| 41 | + static FRTStruct* _Nonnull StaticMethodReturningFRT(); |
| 42 | + static FRTStruct* _Nonnull StaticMethodReturningFRT_copy(); |
| 43 | + static FRTStruct* _Nonnull StaticMethodReturningFRT_create(); |
| 44 | + static FRTStruct* _Nonnull StaticMethodReturningFRT_init(); |
| 45 | + static FRTStruct* _Nonnull StaticMethodReturningFRT_clone(); |
| 46 | +}; |
| 47 | + |
| 48 | +// Struct having static methods returning FRT with attribute swift_attr("returns_retained") or SWIFT_RETURNS_RETAINED |
| 49 | +struct StructWithStaticMethodsReturningFRTWithAttributeReturnsRetained { |
| 50 | + static FRTStruct* _Nonnull StaticMethodReturningFRT() __attribute__((swift_attr("returns_retained"))); |
| 51 | + static FRTStruct* _Nonnull StaticMethodReturningFRT_copy() __attribute__((swift_attr("returns_retained"))); |
| 52 | + static FRTStruct* _Nonnull StaticMethodReturningFRT_create() __attribute__((swift_attr("returns_retained"))); |
| 53 | + static FRTStruct* _Nonnull StaticMethodReturningFRT_init() __attribute__((swift_attr("returns_retained"))); |
| 54 | + static FRTStruct* _Nonnull StaticMethodReturningFRT_clone() __attribute__((swift_attr("returns_retained"))); |
| 55 | +}; |
| 56 | + |
| 57 | +// Struct having static methods returning FRT with attribute swift_attr("returns_unretained") or SWIFT_RETURNS_UNRETAINED |
| 58 | +struct StructWithStaticMethodsReturningFRTWithAttributeReturnsUnretained { |
| 59 | + static FRTStruct* _Nonnull StaticMethodReturningFRT() __attribute__((swift_attr("returns_unretained"))); |
| 60 | + static FRTStruct* _Nonnull StaticMethodReturningFRT_copy() __attribute__((swift_attr("returns_unretained"))); |
| 61 | + static FRTStruct* _Nonnull StaticMethodReturningFRT_create() __attribute__((swift_attr("returns_unretained"))); |
| 62 | + static FRTStruct* _Nonnull StaticMethodReturningFRT_init() __attribute__((swift_attr("returns_unretained"))); |
| 63 | + static FRTStruct* _Nonnull StaticMethodReturningFRT_clone() __attribute__((swift_attr("returns_unretained"))); |
| 64 | +}; |
| 65 | + |
| 66 | + |
| 67 | +// Global/free C++ functions returning FRT with both attributes swift_attr("returns_unretained") and swift_attr("returns_retained") |
| 68 | +FRTStruct* _Nonnull global_function_returning_FRT_with_both_attrs_returns_retained_returns_unretained() __attribute__((swift_attr("returns_retained"))) __attribute__((swift_attr("returns_unretained"))); |
| 69 | + |
| 70 | +// Struct having static method returning FRT with both attributes swift_attr("returns_unretained") and swift_attr("returns_retained") |
| 71 | +struct StructWithStaticMethodsReturningFRTWithBothAttributesReturnsRetainedAndReturnsUnretained { |
| 72 | + static FRTStruct* _Nonnull StaticMethodReturningFRT() __attribute__((swift_attr("returns_retained"))) __attribute__((swift_attr("returns_unretained"))); |
| 73 | +}; |
| 74 | + |
| 75 | +struct NonFRTStruct { |
| 76 | +}; |
| 77 | + |
| 78 | +// Global/free C++ functions returning non-FRT |
| 79 | +NonFRTStruct* _Nonnull global_function_returning_non_FRT(); |
| 80 | +NonFRTStruct* _Nonnull global_function_returning_non_FRT_with_attr_returns_retained() __attribute__((swift_attr("returns_retained"))); |
| 81 | +NonFRTStruct* _Nonnull global_function_returning_non_FRT_with_attr_returns_unretained() __attribute__((swift_attr("returns_unretained"))); |
| 82 | +NonFRTStruct* _Nonnull global_function_returning_non_FRT_create(); |
| 83 | +NonFRTStruct* _Nonnull global_function_returning_non_FRT_copy(); |
| 84 | + |
| 85 | + |
| 86 | +// Struct having static method returning non-FRT |
| 87 | +struct StructWithStaticMethodsReturningNonFRT { |
| 88 | + static NonFRTStruct* _Nonnull StaticMethodReturningNonFRT(); |
| 89 | + static NonFRTStruct* _Nonnull StaticMethodReturningNonFRTWithAttrReturnsRetained() __attribute__((swift_attr("returns_retained"))); |
| 90 | + static NonFRTStruct* _Nonnull StaticMethodReturningNonFRTWithAttrReturnsUnretained() __attribute__((swift_attr("returns_unretained"))); |
| 91 | + static NonFRTStruct* _Nonnull StaticMethodReturningNonFRT_create(); |
| 92 | + static NonFRTStruct* _Nonnull StaticMethodReturningNonFRT_copy(); |
| 93 | +}; |
| 94 | + |
0 commit comments