/trunk/Examples/test-suite/funcptr_cpp.i
Swig | 33 lines | 25 code | 8 blank | 0 comment | 0 complexity | 0537bfe723c92fd56e6a99b44f674104 MD5 | raw file
Possible License(s): LGPL-2.1, Cube, GPL-3.0, 0BSD, GPL-2.0
- %module funcptr_cpp
- %{
- #if defined(__SUNPRO_CC)
- #pragma error_messages (off, badargtype2w) /* Formal argument ... is being passed extern "C" ... */
- #endif
- %}
- %inline %{
- int addByValue(const int &a, int b) { return a+b; }
- int * addByPointer(const int &a, int b) { static int val; val = a+b; return &val; }
- int & addByReference(const int &a, int b) { static int val; val = a+b; return val; }
- int call1(int (*d)(const int &, int), int a, int b) { return d(a, b); }
- int call2(int * (*d)(const int &, int), int a, int b) { return *d(a, b); }
- int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); }
- %}
- %constant int (*ADD_BY_VALUE)(const int &, int) = addByValue;
- %constant int * (*ADD_BY_POINTER)(const int &, int) = addByPointer;
- %constant int & (*ADD_BY_REFERENCE)(const int &, int) = addByReference;
- %inline %{
- typedef int AddByValueTypedef(const int &a, int b);
- typedef int * AddByPointerTypedef(const int &a, int b);
- typedef int & AddByReferenceTypedef(const int &a, int b);
- void *typedef_call1(AddByValueTypedef *& precallback, AddByValueTypedef * postcallback) { return 0; }
- void *typedef_call2(AddByPointerTypedef *& precallback, AddByPointerTypedef * postcallback) { return 0; }
- void *typedef_call3(AddByReferenceTypedef *& precallback, AddByReferenceTypedef * postcallback) { return 0; }
- %}