@@ -176,6 +176,7 @@ message_args_impl!(a: A, b: B, c: C, d: D, e: E, f: F, g: G, h: H, i: I, j: J, k
176
176
177
177
#[ doc( hidden) ]
178
178
#[ inline( always) ]
179
+ #[ cfg( not( feature = "verify_message" ) ) ]
179
180
pub unsafe fn send_message < T , A , R > ( obj : * const T , sel : Sel , args : A )
180
181
-> Result < R , String >
181
182
where T : Message , A : MessageArguments , R : Any {
@@ -184,12 +185,51 @@ pub unsafe fn send_message<T, A, R>(obj: *const T, sel: Sel, args: A)
184
185
185
186
#[ doc( hidden) ]
186
187
#[ inline( always) ]
188
+ #[ cfg( feature = "verify_message" ) ]
189
+ pub unsafe fn send_message < T , A , R > ( obj : * const T , sel : Sel , args : A )
190
+ -> Result < R , String >
191
+ where T : Message , A : MessageArguments + :: verify:: EncodeArguments ,
192
+ R : Any + :: Encode {
193
+ use verify:: verify_message_signature;
194
+
195
+ let cls = if obj. is_null ( ) {
196
+ return Err ( format ! ( "Messaging {:?} to nil" , sel) ) ;
197
+ } else {
198
+ ( * ( obj as * const Object ) ) . class ( )
199
+ } ;
200
+
201
+ verify_message_signature :: < A , R > ( cls, sel) . map ( |_| {
202
+ args. send ( obj as * mut T , sel)
203
+ } )
204
+ }
205
+
206
+ #[ doc( hidden) ]
207
+ #[ inline( always) ]
208
+ #[ cfg( not( feature = "verify_message" ) ) ]
187
209
pub unsafe fn send_super_message < T , A , R > ( obj : * const T , superclass : & Class ,
188
210
sel : Sel , args : A ) -> Result < R , String >
189
211
where T : Message , A : MessageArguments , R : Any {
190
212
Ok ( args. send_super ( obj as * mut T , superclass, sel) )
191
213
}
192
214
215
+ #[ doc( hidden) ]
216
+ #[ inline( always) ]
217
+ #[ cfg( feature = "verify_message" ) ]
218
+ pub unsafe fn send_super_message < T , A , R > ( obj : * const T , superclass : & Class ,
219
+ sel : Sel , args : A ) -> Result < R , String >
220
+ where T : Message , A : MessageArguments + :: verify:: EncodeArguments ,
221
+ R : Any + :: Encode {
222
+ use verify:: verify_message_signature;
223
+
224
+ if obj. is_null ( ) {
225
+ return Err ( format ! ( "Messaging {:?} to nil" , sel) ) ;
226
+ }
227
+
228
+ verify_message_signature :: < A , R > ( superclass, sel) . map ( |_| {
229
+ args. send_super ( obj as * mut T , superclass, sel)
230
+ } )
231
+ }
232
+
193
233
#[ cfg( test) ]
194
234
mod tests {
195
235
use runtime:: Object ;
0 commit comments