@@ -7,8 +7,7 @@ macro_rules! __inner_declare_class {
7
7
@$output_type: ident
8
8
@$builder: ident
9
9
10
- $( #[ $m: meta] ) *
11
- @sel( $( $sel: tt) +)
10
+ $( #[ $( $m: tt) * ] ) *
12
11
fn $name: ident( $( $args: tt) * ) $( -> $ret: ty) ? $body: block
13
12
14
13
$( $rest: tt) *
@@ -21,8 +20,7 @@ macro_rules! __inner_declare_class {
21
20
// it as a function argument
22
21
( $( $args) * )
23
22
24
- $( #[ $m] ) *
25
- @sel( $( $sel) +)
23
+ $( #[ $( $m) * ] ) *
26
24
fn $name( $( $args) * ) $( -> $ret) ? $body
27
25
}
28
26
@@ -42,8 +40,7 @@ macro_rules! __inner_declare_class {
42
40
@$builder: ident
43
41
( & mut self $( $__rest_args: tt) * )
44
42
45
- $( #[ $m: meta] ) *
46
- @sel( $( $sel: tt) +)
43
+ $( #[ $( $m: tt) * ] ) *
47
44
fn $name: ident(
48
45
& mut $self: ident
49
46
$( , $( $rest_args: tt) * ) ?
@@ -52,12 +49,11 @@ macro_rules! __inner_declare_class {
52
49
$crate:: __inner_declare_class! {
53
50
@$output_type
54
51
@instance_method
55
- @sel( $( $sel) * )
56
52
@$name
57
53
@$builder
58
54
@( $( $( $rest_args) * ) ?)
59
55
60
- $( #[ $m ] ) *
56
+ $( #[ $( $m ) * ] ) *
61
57
extern "C" fn $name(
62
58
& mut $self,
63
59
_: $crate:: objc2:: runtime:: Sel ,
@@ -71,8 +67,7 @@ macro_rules! __inner_declare_class {
71
67
@$builder: ident
72
68
( & self $( $__rest_args: tt) * )
73
69
74
- $( #[ $m: meta] ) *
75
- @sel( $( $sel: tt) +)
70
+ $( #[ $( $m: tt) * ] ) *
76
71
fn $name: ident(
77
72
& $self: ident
78
73
$( , $( $rest_args: tt) * ) ?
@@ -81,12 +76,11 @@ macro_rules! __inner_declare_class {
81
76
$crate:: __inner_declare_class! {
82
77
@$output_type
83
78
@instance_method
84
- @sel( $( $sel) * )
85
79
@$name
86
80
@$builder
87
81
@( $( $( $rest_args) * ) ?)
88
82
89
- $( #[ $m ] ) *
83
+ $( #[ $( $m ) * ] ) *
90
84
extern "C" fn $name(
91
85
& $self,
92
86
_: $crate:: objc2:: runtime:: Sel ,
@@ -103,8 +97,7 @@ macro_rules! __inner_declare_class {
103
97
$( , $( $__rest_args: tt) * ) ?
104
98
)
105
99
106
- $( #[ $m: meta] ) *
107
- @sel( $( $sel: tt) +)
100
+ $( #[ $( $m: tt) * ] ) *
108
101
fn $name: ident(
109
102
mut $self: ident: $self_ty: ty
110
103
$( , $( $rest_args: tt) * ) ?
@@ -113,12 +106,11 @@ macro_rules! __inner_declare_class {
113
106
$crate:: __inner_declare_class! {
114
107
@$output_type
115
108
@instance_method
116
- @sel( $( $sel) * )
117
109
@$name
118
110
@$builder
119
111
@( $( $( $rest_args) * ) ?)
120
112
121
- $( #[ $m ] ) *
113
+ $( #[ $( $m ) * ] ) *
122
114
extern "C" fn $name(
123
115
mut $self: $self_ty,
124
116
_: $crate:: objc2:: runtime:: Sel ,
@@ -135,8 +127,7 @@ macro_rules! __inner_declare_class {
135
127
$( , $( $__rest_args: tt) * ) ?
136
128
)
137
129
138
- $( #[ $m: meta] ) *
139
- @sel( $( $sel: tt) +)
130
+ $( #[ $( $m: tt) * ] ) *
140
131
fn $name: ident(
141
132
$self: ident: $self_ty: ty
142
133
$( , $( $rest_args: tt) * ) ?
@@ -145,12 +136,11 @@ macro_rules! __inner_declare_class {
145
136
$crate:: __inner_declare_class! {
146
137
@$output_type
147
138
@instance_method
148
- @sel( $( $sel) * )
149
139
@$name
150
140
@$builder
151
141
@( $( $( $rest_args) * ) ?)
152
142
153
- $( #[ $m ] ) *
143
+ $( #[ $( $m ) * ] ) *
154
144
extern "C" fn $name(
155
145
$self: $self_ty,
156
146
_: $crate:: objc2:: runtime:: Sel ,
@@ -166,21 +156,19 @@ macro_rules! __inner_declare_class {
166
156
@$builder: ident
167
157
( $( $__args: tt) * )
168
158
169
- $( #[ $m: meta] ) *
170
- @sel( $( $sel: tt) +)
159
+ $( #[ $( $m: tt) * ] ) *
171
160
fn $name: ident(
172
161
$( $args: tt) *
173
162
) $( -> $ret: ty) ? $body: block
174
163
} => {
175
164
$crate:: __inner_declare_class! {
176
165
@$output_type
177
166
@class_method
178
- @sel( $( $sel) * )
179
167
@$name
180
168
@$builder
181
169
@( $( $args) * )
182
170
183
- $( #[ $m ] ) *
171
+ $( #[ $( $m ) * ] ) *
184
172
extern "C" fn $name(
185
173
_: & $crate:: objc2:: runtime:: Class ,
186
174
_: $crate:: objc2:: runtime:: Sel ,
@@ -192,27 +180,35 @@ macro_rules! __inner_declare_class {
192
180
{
193
181
@method_out
194
182
@$method_type: ident
195
- @sel( $( $sel: tt) * )
196
- @$name: ident
183
+ @$_name: ident
197
184
@$builder: ident
198
185
@( $( $builder_args: tt) * )
199
186
200
- $method: item
187
+ $( #[ $( $m: tt) * ] ) *
188
+ extern "C" fn $( $fn: tt) *
201
189
} => {
202
- $method
190
+ $crate:: __attribute_helper! {
191
+ @strip_sel
192
+ $( @[ $( $m) * ] ) *
193
+ ( extern "C" fn $( $fn) * )
194
+ }
203
195
} ;
196
+
204
197
{
205
198
@register_out
206
199
@class_method
207
- @sel( $( $sel: tt) * )
208
200
@$name: ident
209
201
@$builder: ident
210
202
@( $( $builder_args: tt) * )
211
203
212
- $method: item
204
+ $( #[ $( $m: tt) * ] ) *
205
+ extern "C" fn $( $fn: tt) *
213
206
} => {
214
207
$builder. add_class_method(
215
- $crate:: objc2:: sel!( $( $sel) * ) ,
208
+ $crate:: __attribute_helper! {
209
+ @extract_sel
210
+ $( #[ $( $m) * ] ) *
211
+ } ,
216
212
$crate:: __inner_declare_class! {
217
213
@cast_extern_fn
218
214
@$name
@@ -223,15 +219,18 @@ macro_rules! __inner_declare_class {
223
219
{
224
220
@register_out
225
221
@instance_method
226
- @sel( $( $sel: tt) * )
227
222
@$name: ident
228
223
@$builder: ident
229
224
@( $( $builder_args: tt) * )
230
225
231
- $method: item
226
+ $( #[ $( $m: tt) * ] ) *
227
+ extern "C" fn $( $fn: tt) *
232
228
} => {
233
229
$builder. add_method(
234
- $crate:: objc2:: sel!( $( $sel) * ) ,
230
+ $crate:: __attribute_helper! {
231
+ @extract_sel
232
+ $( #[ $( $m) * ] ) *
233
+ } ,
235
234
$crate:: __inner_declare_class! {
236
235
@cast_extern_fn
237
236
@$name
@@ -454,8 +453,8 @@ macro_rules! __inner_declare_class {
454
453
/// particular, if you use `self` your method will be registered as an
455
454
/// instance method, and if you don't it will be registered as a class method.
456
455
///
457
- /// The desired selector can be specified using a special `@ sel(my:selector:)`
458
- /// directive directly before the function definition .
456
+ /// The desired selector can be specified using the `#[ sel(my:selector:)] `
457
+ /// attribute .
459
458
///
460
459
/// A transformation step is performed on the functions (to make them have the
461
460
/// correct ABI) and hence they shouldn't really be called manually. (You
@@ -520,7 +519,7 @@ macro_rules! __inner_declare_class {
520
519
/// }
521
520
///
522
521
/// unsafe impl {
523
- /// @ sel(initWithFoo:)
522
+ /// #[ sel(initWithFoo:)]
524
523
/// fn init_with(&mut self, foo: u8) -> Option<&mut Self> {
525
524
/// let this: Option<&mut Self> = unsafe {
526
525
/// msg_send![super(self, NSObject::class()), init]
@@ -535,19 +534,19 @@ macro_rules! __inner_declare_class {
535
534
/// })
536
535
/// }
537
536
///
538
- /// @ sel(foo)
537
+ /// #[ sel(foo)]
539
538
/// fn __get_foo(&self) -> u8 {
540
539
/// *self.foo
541
540
/// }
542
541
///
543
- /// @ sel(myClassMethod)
542
+ /// #[ sel(myClassMethod)]
544
543
/// fn __my_class_method() -> Bool {
545
544
/// Bool::YES
546
545
/// }
547
546
/// }
548
547
///
549
548
/// unsafe impl protocol NSCopying {
550
- /// @ sel(copyWithZone:)
549
+ /// #[ sel(copyWithZone:)]
551
550
/// fn copy_with_zone(&self, _zone: *const NSZone) -> *mut Self {
552
551
/// let mut obj = Self::new(*self.foo);
553
552
/// *obj.bar = *self.bar;
0 commit comments