PageRenderTime 7ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

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

#
Swig | 33 lines | 25 code | 8 blank | 0 comment | 0 complexity | 0537bfe723c92fd56e6a99b44f674104 MD5 | raw file
 1%module funcptr_cpp
 2
 3%{
 4#if defined(__SUNPRO_CC)
 5#pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
 6#endif
 7%}
 8
 9%inline %{
10
11int addByValue(const int &a, int b) { return a+b; }
12int * addByPointer(const int &a, int b) { static int val; val = a+b; return &val; }
13int & addByReference(const int &a, int b) { static int val; val = a+b; return val; }
14
15int call1(int (*d)(const int &, int), int a, int b) { return d(a, b); }
16int call2(int * (*d)(const int &, int), int a, int b) { return *d(a, b); }
17int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); }
18%}
19
20%constant int (*ADD_BY_VALUE)(const int &, int) = addByValue;
21%constant int * (*ADD_BY_POINTER)(const int &, int) = addByPointer;
22%constant int & (*ADD_BY_REFERENCE)(const int &, int) = addByReference;
23
24
25%inline %{
26typedef int AddByValueTypedef(const int &a, int b);
27typedef int * AddByPointerTypedef(const int &a, int b);
28typedef int & AddByReferenceTypedef(const int &a, int b);
29void *typedef_call1(AddByValueTypedef *& precallback, AddByValueTypedef * postcallback) { return 0; }
30void *typedef_call2(AddByPointerTypedef *& precallback, AddByPointerTypedef * postcallback) { return 0; }
31void *typedef_call3(AddByReferenceTypedef *& precallback, AddByReferenceTypedef * postcallback) { return 0; }
32%}
33