2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / objc / execute / IMP.m
blob99f619339263ffc5c6c1b9ad7b0268bd1a857952
1 /* Contributed by Nicola Pero - Fri Mar  9 19:39:15 CET 2001 */
2 #include <objc/objc.h>
3 #include <objc/objc-api.h>
5 #include "next_mapping.h"
7 /* Test getting and calling the IMP of a method */
9 @interface TestClass
11   Class isa;
13 - (int) next: (int)a;
14 @end
16 @implementation TestClass
17 - (int) next: (int)a
19   return a + 1;
21 @end
24 int main (void)
26   Class class;
27   SEL selector;
28   int (* imp) (id, SEL, int);
29   
30   class = objc_get_class ("TestClass");
31   selector = @selector (next:);
32   imp = (int (*)(id, SEL, int))method_get_imp 
33     (class_get_class_method (class, selector));
34   
35   if (imp (class, selector, 5) != 6)
36     {
37       abort ();
38     }
40   return 0;