PageRenderTime 16ms CodeModel.GetById 9ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/trunk/Examples/test-suite/typedef_mptr.i

#
Swig | 41 lines | 33 code | 8 blank | 0 comment | 0 complexity | b843ca4f0a5c2dc269fdfd2ddb37b04b MD5 | raw file
 1// Tests typedef through member pointers
 2
 3%module typedef_mptr
 4
 5%{
 6#if defined(__SUNPRO_CC)
 7#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
 8#pragma error_messages (off, wbadinit) /* Using extern "C" ... to initialize ... */
 9#endif
10%}
11
12#if defined(SWIGPYTHON) || defined(SWIGOCAML)
13
14%inline %{
15
16class Foo {
17public:
18    int add(int x, int y) {
19        return x+y;
20    }
21    int sub(int x, int y) {
22        return x-y;
23    }
24    int do_op(int x, int y, int (Foo::*op)(int, int)) {
25	return (this->*op)(x,y);
26    }
27};
28
29typedef Foo FooObj;
30typedef int Integer;
31
32Integer do_op(Foo *f, Integer x, Integer y, Integer (FooObj::*op)(Integer, Integer)) {
33    return f->do_op(x,y,op);
34}
35%}
36#endif
37
38#if defined(SWIGPYTHON) || defined(SWIGOCAML)
39%constant int (Foo::*add)(int,int) = &Foo::add;
40%constant Integer (FooObj::*sub)(Integer,Integer) = &FooObj::sub;
41#endif