|
7 | 7 | /// example: `NSAutoreleasePool` does not have this). Finally the ownership
|
8 | 8 | /// must be correct for this class.
|
9 | 9 | macro_rules! object {
|
10 |
| - ($(#[$m:meta])* unsafe $v:vis struct $name:ident) => { |
11 |
| - object!($(#[$m])* unsafe $v struct<()> $name<> {}); |
| 10 | + ( |
| 11 | + $(#[$m:meta])* |
| 12 | + unsafe $v:vis struct $name:ident |
| 13 | + ) => { |
| 14 | + object!($(#[$m])* unsafe $v struct $name<> {}); |
12 | 15 | };
|
13 |
| - ($(#[$m:meta])* unsafe $v:vis struct<$($t:ident $(: $b:ident)?),+> $name:ident<$($t2:ident $(: $b2:ident)?),+> { |
14 |
| - $($p:ident: $pty:ty,)* |
15 |
| - }) => { |
16 |
| - object!($(#[$m])* unsafe $v struct<($($t $(: $b)?),+)> $name<$($t2 $(: $b2)?),+> { |
17 |
| - $($p: $pty,)* |
18 |
| - }); |
19 |
| - }; |
20 |
| - ($(#[$m:meta])* unsafe $v:vis struct<($($t:tt)*)> $name:ident<$($t2:ident $(: $b2:ident)?),*> { |
21 |
| - $($p:ident: $pty:ty,)* |
22 |
| - }) => { |
| 16 | + ( |
| 17 | + $(#[$m:meta])* |
| 18 | + unsafe $v:vis struct $name:ident<$($t:ident $(: $b:ident)?),*> { |
| 19 | + $($p:ident: $pty:ty,)* |
| 20 | + } |
| 21 | + $(impl where $($w:tt)+)? |
| 22 | + ) => { |
23 | 23 | // TODO: `extern type`
|
24 | 24 | $(#[$m])*
|
25 | 25 | #[repr(C)]
|
26 |
| - $v struct $name<$($t2 $(: $b2)?),*> { |
| 26 | + $v struct $name<$($t $(: $b)?),*> { |
27 | 27 | _private: [u8; 0],
|
28 | 28 | $($p: $pty),*
|
29 | 29 | }
|
30 | 30 |
|
31 |
| - unsafe impl<$($t)*> ::objc2::Message for $name<$($t2),*> { } |
| 31 | + unsafe impl<$($t $(: $b)?),*> ::objc2::Message for $name<$($t),*> { } |
32 | 32 |
|
33 |
| - unsafe impl<$($t)*> ::objc2::RefEncode for $name<$($t2),*> { |
| 33 | + unsafe impl<$($t $(: $b)?),*> ::objc2::RefEncode for $name<$($t),*> { |
34 | 34 | const ENCODING_REF: ::objc2::Encoding<'static> = ::objc2::Encoding::Object;
|
35 | 35 | }
|
36 | 36 |
|
37 |
| - unsafe impl<$($t)*> $crate::INSObject for $name<$($t2),*> { |
| 37 | + unsafe impl<$($t $(: $b)?),*> $crate::INSObject for $name<$($t),*> { |
38 | 38 | fn class() -> &'static ::objc2::runtime::Class {
|
39 | 39 | ::objc2::class!($name)
|
40 | 40 | }
|
41 | 41 | }
|
42 | 42 |
|
43 |
| - impl<$($t)*> ::core::cmp::PartialEq for $name<$($t2),*> { |
| 43 | + impl<$($t $(: $b)?),*> ::core::cmp::PartialEq for $name<$($t),*> { |
44 | 44 | fn eq(&self, other: &Self) -> bool {
|
45 | 45 | use $crate::INSObject;
|
46 | 46 | self.is_equal(other)
|
47 | 47 | }
|
48 | 48 | }
|
49 | 49 |
|
50 |
| - impl<$($t)*> ::core::cmp::Eq for $name<$($t2),*> {} |
| 50 | + impl<$($t $(: $b)?),*> ::core::cmp::Eq for $name<$($t),*> {} |
51 | 51 |
|
52 |
| - impl<$($t)*> ::core::hash::Hash for $name<$($t2),*> { |
| 52 | + impl<$($t $(: $b)?),*> ::core::hash::Hash for $name<$($t),*> { |
53 | 53 | fn hash<H: ::core::hash::Hasher>(&self, state: &mut H) {
|
54 | 54 | use $crate::INSObject;
|
55 | 55 | self.hash_code().hash(state);
|
56 | 56 | }
|
57 | 57 | }
|
58 | 58 |
|
59 |
| - impl<$($t)*> ::core::fmt::Debug for $name<$($t2),*> { |
| 59 | + impl<$($t $(: $b)?),*> ::core::fmt::Debug for $name<$($t),*> { |
60 | 60 | fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
61 | 61 | use $crate::{INSObject, INSString};
|
62 | 62 | ::objc2::rc::autoreleasepool(|pool| {
|
|
0 commit comments