@@ -52,16 +52,25 @@ macro_rules! declare_TCFType {
52
52
(
53
53
$( #[ $doc: meta] ) *
54
54
$ty: ident, $raw: ident
55
+ ) => {
56
+ declare_TCFType!( $( #[ $doc] ) * $ty<>, $raw) ;
57
+ } ;
58
+
59
+ (
60
+ $( #[ $doc: meta] ) *
61
+ $ty: ident<$( $p: ident $( : $bound: path) * ) ,* >, $raw: ident
55
62
) => {
56
63
$( #[ $doc] ) *
57
- pub struct $ty( $ raw) ;
64
+ pub struct $ty<$ ( $p $ ( : $bound ) * ) , * > ( $ raw, $ ( :: std :: marker :: PhantomData <$p> ) , * ) ;
58
65
59
- impl Drop for $ty {
66
+ #[ allow( unused_imports) ]
67
+ impl <$( $p $( : $bound) * ) ,* > Drop for $ty<$( $p) ,* > {
60
68
fn drop( & mut self ) {
69
+ use $crate:: base:: TCFType ;
61
70
unsafe { $crate:: base:: CFRelease ( self . as_CFTypeRef( ) ) }
62
71
}
63
72
}
64
- }
73
+ } ;
65
74
}
66
75
67
76
/// Provide an implementation of the [`TCFType`] trait for the Rust
@@ -82,6 +91,7 @@ macro_rules! impl_TCFType {
82
91
impl <$( $p $( : $bound) * ) ,* > $crate:: base:: TCFType for $ty<$( $p) ,* > {
83
92
type Ref = $ty_ref;
84
93
94
+ #[ allow( non_snake_case) ]
85
95
#[ inline]
86
96
fn as_concrete_TypeRef( & self ) -> $ty_ref {
87
97
self . 0
@@ -94,6 +104,7 @@ macro_rules! impl_TCFType {
94
104
$crate:: base:: TCFType :: wrap_under_create_rule( reference)
95
105
}
96
106
107
+ #[ allow( non_snake_case) ]
97
108
#[ inline]
98
109
fn as_CFTypeRef( & self ) -> $crate:: base:: CFTypeRef {
99
110
self . as_concrete_TypeRef( ) as $crate:: base:: CFTypeRef
@@ -115,39 +126,46 @@ macro_rules! impl_TCFType {
115
126
}
116
127
}
117
128
118
- impl Clone for $ty {
129
+ #[ allow( unused_imports) ]
130
+ impl <$( $p $( : $bound) * ) ,* > Clone for $ty<$( $p) ,* > {
119
131
#[ inline]
120
- fn clone( & self ) -> $ty {
132
+ fn clone( & self ) -> Self {
133
+ use $crate:: base:: TCFType ;
121
134
unsafe {
122
135
$ty:: wrap_under_get_rule( self . 0 )
123
136
}
124
137
}
125
138
}
126
139
127
- impl PartialEq for $ty {
140
+ #[ allow( unused_imports) ]
141
+ impl <$( $p $( : $bound) * ) ,* > PartialEq for $ty<$( $p) ,* > {
128
142
#[ inline]
129
- fn eq( & self , other: & $ty) -> bool {
143
+ fn eq( & self , other: & Self ) -> bool {
144
+ use $crate:: base:: TCFType ;
130
145
self . as_CFType( ) . eq( & other. as_CFType( ) )
131
146
}
132
147
}
133
148
134
- impl Eq for $ty { }
149
+ impl <$ ( $p $ ( : $bound ) * ) , * > Eq for $ty<$ ( $p ) , * > { }
135
150
136
- unsafe impl <' a> $crate:: base:: ToVoid <$ty> for & ' a $ty {
151
+ #[ allow( unused_imports) ]
152
+ unsafe impl <' a, $( $p $( : $bound) * ) ,* > $crate:: base:: ToVoid <$ty<$( $p) ,* >> for & ' a $ty<$( $p) ,* > {
137
153
fn to_void( & self ) -> * const :: core:: ffi:: c_void {
138
- use $crate:: base:: TCFTypeRef ;
154
+ use $crate:: base:: { TCFType , TCFTypeRef } ;
139
155
self . as_concrete_TypeRef( ) . as_void_ptr( )
140
156
}
141
157
}
142
158
143
- unsafe impl $crate:: base:: ToVoid <$ty> for $ty {
159
+ #[ allow( unused_imports) ]
160
+ unsafe impl <$( $p $( : $bound) * ) ,* > $crate:: base:: ToVoid <$ty<$( $p) ,* >> for $ty<$( $p) ,* > {
144
161
fn to_void( & self ) -> * const :: core:: ffi:: c_void {
145
- use $crate:: base:: TCFTypeRef ;
162
+ use $crate:: base:: { TCFType , TCFTypeRef } ;
146
163
self . as_concrete_TypeRef( ) . as_void_ptr( )
147
164
}
148
165
}
149
166
150
- unsafe impl $crate:: base:: ToVoid <$ty> for $ty_ref {
167
+ #[ allow( unused_imports) ]
168
+ unsafe impl <$( $p $( : $bound) * ) ,* > $crate:: base:: ToVoid <$ty<$( $p) ,* >> for $ty_ref {
151
169
fn to_void( & self ) -> * const :: core:: ffi:: c_void {
152
170
use $crate:: base:: TCFTypeRef ;
153
171
self . as_void_ptr( )
@@ -178,8 +196,10 @@ macro_rules! impl_CFTypeDescription {
178
196
impl_CFTypeDescription!( $ty<>) ;
179
197
} ;
180
198
( $ty: ident<$( $p: ident $( : $bound: path) * ) ,* >) => {
199
+ #[ allow( unused_imports) ]
181
200
impl <$( $p $( : $bound) * ) ,* > :: std:: fmt:: Debug for $ty<$( $p) ,* > {
182
201
fn fmt( & self , f: & mut :: std:: fmt:: Formatter ) -> :: std:: fmt:: Result {
202
+ use $crate:: base:: TCFType ;
183
203
self . as_CFType( ) . fmt( f)
184
204
}
185
205
}
@@ -189,9 +209,12 @@ macro_rules! impl_CFTypeDescription {
189
209
#[ macro_export]
190
210
macro_rules! impl_CFComparison {
191
211
( $ty: ident, $compare: ident) => {
192
- impl PartialOrd for $ty {
212
+ impl_CFComparison!( $ty<>, $compare) ;
213
+ } ;
214
+ ( $ty: ident<$( $p: ident $( : $bound: path) * ) ,* >, $compare: ident) => {
215
+ impl <$( $p $( : $bound) * ) ,* > PartialOrd for $ty<$( $p) ,* > {
193
216
#[ inline]
194
- fn partial_cmp( & self , other: & $ty) -> Option <:: std:: cmp:: Ordering > {
217
+ fn partial_cmp( & self , other: & $ty<$ ( $p ) , * > ) -> Option <:: std:: cmp:: Ordering > {
195
218
unsafe {
196
219
Some (
197
220
$compare(
@@ -205,9 +228,9 @@ macro_rules! impl_CFComparison {
205
228
}
206
229
}
207
230
208
- impl Ord for $ty {
231
+ impl <$ ( $p $ ( : $bound ) * ) , * > Ord for $ty<$ ( $p ) , * > {
209
232
#[ inline]
210
- fn cmp( & self , other: & $ty) -> :: std:: cmp:: Ordering {
233
+ fn cmp( & self , other: & $ty<$ ( $p ) , * > ) -> :: std:: cmp:: Ordering {
211
234
self . partial_cmp( other) . unwrap( )
212
235
}
213
236
}
0 commit comments