|
3 | 3 | #define SWIFT_NAME(name) __attribute__((__swift_name__(name)))
|
4 | 4 | #define SWIFT_ASYNC_NAME(name) __attribute__((__swift_async_name__(name)))
|
5 | 5 |
|
6 |
| -typedef struct { |
7 |
| - float x, y, z; |
8 |
| -} Point3D; |
9 |
| - |
10 |
| -__attribute__((__swift_name__("PType"))) |
11 | 6 | @protocol P
|
12 | 7 | @end
|
13 | 8 |
|
14 |
| -__attribute__((__swift_name__("IClass"))) |
15 |
| -@interface I<P> |
16 |
| -- (instancetype)init SWIFT_NAME("init()"); |
17 |
| -- (instancetype)initWithValue:(int)value SWIFT_NAME("iWithValue(_:)"); |
18 |
| - |
19 |
| -+ (void)refresh SWIFT_NAME("refresh()"); |
20 |
| - |
21 |
| -- (instancetype)i SWIFT_NAME("i()"); |
22 |
| - |
23 |
| -- (I *)iWithValue:(int)value SWIFT_NAME("i(value:)"); |
24 |
| -- (I *)iWithValue:(int)value value:(int)value2 SWIFT_NAME("i(value:extra:)"); |
25 |
| -- (I *)iWithValueConvertingValue:(int)value value:(int)value2 SWIFT_NAME("i(_:extra:)"); |
26 |
| - |
27 |
| -+ (I *)iWithOtheValue:(int)value SWIFT_NAME("init"); |
28 |
| -// expected-warning@-1 {{'__swift_name__' attribute argument must be a string literal specifying a Swift function name}} |
29 |
| - |
30 |
| -+ (I *)iWithAnotherValue:(int)value SWIFT_NAME("i()"); |
31 |
| -// expected-warning@-1 {{too few parameters in the signature specified by the '__swift_name__' attribute (expected 1; got 0)}} |
32 |
| - |
33 |
| -+ (I *)iWithYetAnotherValue:(int)value SWIFT_NAME("i(value:extra:)"); |
34 |
| -// expected-warning@-1 {{too many parameters in the signature specified by the '__swift_name__' attribute (expected 1; got 2}} |
35 |
| - |
36 |
| -+ (I *)iAndReturnErrorCode:(int *)errorCode SWIFT_NAME("i()"); // no-warning |
37 |
| -+ (I *)iWithValue:(int)value andReturnErrorCode:(int *)errorCode SWIFT_NAME("i(value:)"); // no-warning |
38 |
| - |
39 |
| -+ (I *)iFromErrorCode:(const int *)errorCode SWIFT_NAME("i()"); |
40 |
| -// expected-warning@-1 {{too few parameters in the signature specified by the '__swift_name__' attribute (expected 1; got 0)}} |
41 |
| - |
42 |
| -+ (I *)iWithPointerA:(int *)value andReturnErrorCode:(int *)errorCode SWIFT_NAME("i()"); // no-warning |
43 |
| -+ (I *)iWithPointerB:(int *)value andReturnErrorCode:(int *)errorCode SWIFT_NAME("i(pointer:)"); // no-warning |
44 |
| -+ (I *)iWithPointerC:(int *)value andReturnErrorCode:(int *)errorCode SWIFT_NAME("i(pointer:errorCode:)"); // no-warning |
45 |
| - |
46 |
| -+ (I *)iWithOtherI:(I *)other SWIFT_NAME("i()"); |
47 |
| -// expected-warning@-1 {{too few parameters in the signature specified by the '__swift_name__' attribute (expected 1; got 0)}} |
48 |
| - |
49 |
| -+ (instancetype)specialI SWIFT_NAME("init(options:)"); |
50 |
| -+ (instancetype)specialJ SWIFT_NAME("init(options:extra:)"); |
51 |
| -// expected-warning@-1 {{too many parameters in the signature specified by the '__swift_name__' attribute (expected 0; got 2)}} |
52 |
| -+ (instancetype)specialK SWIFT_NAME("init(_:)"); |
53 |
| -// expected-warning@-1 {{too many parameters in the signature specified by the '__swift_name__' attribute (expected 0; got 1)}} |
54 |
| -+ (instancetype)specialL SWIFT_NAME("i(options:)"); |
55 |
| -// expected-warning@-1 {{too many parameters in the signature specified by the '__swift_name__' attribute (expected 0; got 1)}} |
56 |
| - |
57 |
| -+ (instancetype)trailingParen SWIFT_NAME("foo("); |
58 |
| -// expected-warning@-1 {{'__swift_name__' attribute argument must be a string literal specifying a Swift function name}} |
59 |
| -+ (instancetype)trailingColon SWIFT_NAME("foo:"); |
60 |
| -// expected-warning@-1 {{'__swift_name__' attribute argument must be a string literal specifying a Swift function name}} |
61 |
| -+ (instancetype)initialIgnore:(int)value SWIFT_NAME("_(value:)"); |
62 |
| -// expected-warning@-1 {{'__swift_name__' attribute has invalid identifier for the base name}} |
63 |
| -+ (instancetype)middleOmitted:(int)value SWIFT_NAME("i(:)"); |
64 |
| -// expected-warning@-1 {{'__swift_name__' attribute has invalid identifier for the parameter name}} |
65 |
| - |
66 |
| -@property(strong) id someProp SWIFT_NAME("prop"); |
67 |
| -@end |
68 |
| - |
69 |
| -enum SWIFT_NAME("E") E { |
70 |
| - value1, |
71 |
| - value2, |
72 |
| - value3 SWIFT_NAME("three"), |
73 |
| - value4 SWIFT_NAME("four()"), // expected-warning {{'__swift_name__' attribute has invalid identifier for the base name}} |
74 |
| -}; |
75 |
| - |
76 |
| -struct SWIFT_NAME("TStruct") SStruct { |
77 |
| - int i, j, k SWIFT_NAME("kay"); |
78 |
| -}; |
79 |
| - |
80 |
| -int i SWIFT_NAME("g_i"); |
81 |
| - |
82 |
| -void f0(int i) SWIFT_NAME("f_0"); |
83 |
| -// expected-warning@-1 {{'__swift_name__' attribute argument must be a string literal specifying a Swift function name}} |
84 |
| - |
85 |
| -void f1(int i) SWIFT_NAME("f_1()"); |
86 |
| -// expected-warning@-1 {{too few parameters in the signature specified by the '__swift_name__' attribute (expected 1; got 0)}} |
87 |
| - |
88 |
| -void f2(int i) SWIFT_NAME("f_2(a:b:)"); |
89 |
| -// expected-warning@-1 {{too many parameters in the signature specified by the '__swift_name__' attribute (expected 1; got 2)}} |
90 |
| - |
91 |
| -void f3(int x, int y) SWIFT_NAME("fWithX(_:y:)"); |
92 |
| -void f4(int x, int *error) SWIFT_NAME("fWithX(_:)"); |
93 |
| - |
94 |
| -typedef int int_t SWIFT_NAME("IntType"); |
95 |
| - |
96 |
| -struct Point3D createPoint3D(float x, float y, float z) SWIFT_NAME("Point3D.init(x:y:z:)"); |
97 |
| -struct Point3D rotatePoint3D(Point3D point, float radians) SWIFT_NAME("Point3D.rotate(self:radians:)"); |
98 |
| -struct Point3D badRotatePoint3D(Point3D point, float radians) SWIFT_NAME("Point3D.rotate(radians:)"); |
99 |
| -// expected-warning@-1 {{too few parameters in the signature specified by the '__swift_name__' attribute (expected 2; got 1)}} |
100 |
| - |
101 |
| -extern struct Point3D identityPoint SWIFT_NAME("Point3D.identity"); |
102 |
| - |
103 |
| -float Point3DGetMagnitude(Point3D point) SWIFT_NAME("getter:Point3D.magnitude(self:)"); |
104 |
| -float Point3DGetMagnitudeAndSomethingElse(Point3D point, float f) SWIFT_NAME("getter:Point3D.magnitude(self:f:)"); |
105 |
| -// expected-warning@-1 {{'__swift_name__' attribute for getter must not have any parameters besides 'self:'}} |
106 |
| - |
107 |
| -float Point3DGetRadius(Point3D point) SWIFT_NAME("getter:Point3D.radius(self:)"); |
108 |
| -void Point3DSetRadius(Point3D point, float radius) SWIFT_NAME("setter:Point3D.radius(self:newValue:)"); |
109 |
| - |
110 |
| -float Point3DPreGetRadius(Point3D point) SWIFT_NAME("getter:Point3D.preRadius(self:)"); |
111 |
| -void Point3DPreSetRadius(float radius, Point3D point) SWIFT_NAME("setter:Point3D.preRadius(newValue:self:)"); |
112 |
| - |
113 |
| -void Point3DSetRadiusAndSomethingElse(Point3D point, float radius, float f) SWIFT_NAME("setter:Point3D.radius(self:newValue:f:)"); |
114 |
| -// expected-warning@-1 {{'__swift_name__' attribute for setter must have one parameter for new value}} |
115 |
| - |
116 |
| -float Point3DGetComponent(Point3D point, unsigned index) SWIFT_NAME("getter:Point3D.subscript(self:_:)"); |
117 |
| -float Point3DSetComponent(Point3D point, unsigned index, float value) SWIFT_NAME("setter:Point3D.subscript(self:_:newValue:)"); |
118 |
| - |
119 |
| -float Point3DGetMatrixComponent(Point3D point, unsigned x, unsigned y) SWIFT_NAME("getter:Point3D.subscript(self:x:y:)"); |
120 |
| -void Point3DSetMatrixComponent(Point3D point, unsigned x, float value, unsigned y) SWIFT_NAME("setter:Point3D.subscript(self:x:newValue:y:)"); |
121 |
| - |
122 |
| -float Point3DSetWithoutNewValue(Point3D point, unsigned x, unsigned y) SWIFT_NAME("setter:Point3D.subscript(self:x:y:)"); |
123 |
| -// expected-warning@-1 {{'__swift_name__' attribute for 'subscript' setter must have a 'newValue:' parameter}} |
124 |
| - |
125 |
| -float Point3DSubscriptButNotGetterSetter(Point3D point, unsigned x) SWIFT_NAME("Point3D.subscript(self:_:)"); |
126 |
| -// expected-warning@-1 {{'__swift_name__' attribute for 'subscript' must be a getter or setter}} |
127 |
| - |
128 |
| -void Point3DSubscriptSetterTwoNewValues(Point3D point, unsigned x, float a, float b) SWIFT_NAME("setter:Point3D.subscript(self:_:newValue:newValue:)"); |
129 |
| -// expected-warning@-1 {{'__swift_name__' attribute for 'subscript' setter cannot have multiple 'newValue:' parameters}} |
130 |
| - |
131 |
| -float Point3DSubscriptGetterNewValue(Point3D point, unsigned x, float a, float b) SWIFT_NAME("getter:Point3D.subscript(self:_:newValue:newValue:)"); |
132 |
| -// expected-warning@-1 {{'__swift_name__' attribute for 'subscript' getter cannot have a 'newValue:' parameter}} |
133 |
| - |
134 |
| -void Point3DMethodWithNewValue(Point3D point, float newValue) SWIFT_NAME("Point3D.method(self:newValue:)"); |
135 |
| -void Point3DMethodWithNewValues(Point3D point, float newValue, float newValueB) SWIFT_NAME("Point3D.method(self:newValue:newValue:)"); |
136 |
| - |
137 |
| -float Point3DStaticSubscript(unsigned x) SWIFT_NAME("getter:Point3D.subscript(_:)"); |
138 |
| -// expected-warning@-1 {{'__swift_name__' attribute for 'subscript' must have a 'self:' parameter}} |
139 |
| - |
140 |
| -float Point3DStaticSubscriptNoArgs(void) SWIFT_NAME("getter:Point3D.subscript()"); |
141 |
| -// expected-warning@-1 {{'__swift_name__' attribute for 'subscript' must have at least one parameter}} |
142 |
| - |
143 |
| -float Point3DPreGetComponent(Point3D point, unsigned index) SWIFT_NAME("getter:Point3D.subscript(self:_:)"); |
144 |
| - |
145 |
| -Point3D getCurrentPoint3D(void) SWIFT_NAME("getter:currentPoint3D()"); |
146 |
| - |
147 |
| -void setCurrentPoint3D(Point3D point) SWIFT_NAME("setter:currentPoint3D(newValue:)"); |
148 |
| - |
149 |
| -Point3D getLastPoint3D(void) SWIFT_NAME("getter:lastPoint3D()"); |
150 |
| - |
151 |
| -void setLastPoint3D(Point3D point) SWIFT_NAME("setter:lastPoint3D(newValue:)"); |
152 |
| - |
153 |
| -Point3D getZeroPoint(void) SWIFT_NAME("getter:Point3D.zero()"); |
154 |
| -void setZeroPoint(Point3D point) SWIFT_NAME("setter:Point3D.zero(newValue:)"); |
155 |
| -Point3D getZeroPointNoPrototype() SWIFT_NAME("getter:Point3D.zeroNoPrototype()"); |
156 |
| -// expected-warning@-1 {{'__swift_name__' attribute only applies to non-K&R-style functions}} |
157 |
| - |
158 |
| -Point3D badGetter1(int x) SWIFT_NAME("getter:bad1(_:)"); |
159 |
| -// expected-warning@-1 {{'__swift_name__' attribute for getter must not have any parameters besides 'self:'}} |
160 |
| - |
161 |
| -void badSetter1(void) SWIFT_NAME("getter:bad1())"); |
162 |
| -// expected-warning@-1 {{'__swift_name__' attribute argument must be a string literal specifying a Swift function name}} |
163 |
| - |
164 |
| -Point3D badGetter2(Point3D point) SWIFT_NAME("getter:bad2(_:))"); |
165 |
| -// expected-warning@-1 {{'__swift_name__' attribute argument must be a string literal specifying a Swift function name}} |
166 |
| - |
167 |
| -void badSetter2(Point3D point) SWIFT_NAME("setter:bad2(self:))"); |
168 |
| -// expected-warning@-1 {{'__swift_name__' attribute argument must be a string literal specifying a Swift function name}} |
169 |
| - |
170 |
| -void g(int i) SWIFT_NAME("function(int:)"); |
171 |
| -// expected-note@-1 {{conflicting attribute is here}} |
172 |
| - |
173 |
| -// expected-error@+1 {{'swift_name' and 'swift_name' attributes are not compatible}} |
174 |
| -void g(int i) SWIFT_NAME("function(_:)") { |
175 |
| -} |
176 |
| - |
177 | 9 | typedef int (^CallbackTy)(void);
|
178 | 10 |
|
179 | 11 | @interface AsyncI<P>
|
|
0 commit comments