handle const pointers to functions

This commit is contained in:
Paweł Tomulik 2016-03-23 16:11:15 +01:00
commit 350d43d988
6 changed files with 9 additions and 2 deletions

View file

@ -20,7 +20,7 @@ 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;
%constant int (* const ADD_BY_VALUE_C)(const int &, int) = addByValue;
%inline %{
typedef int AddByValueTypedef(const int &a, int b);

View file

@ -16,3 +16,4 @@ assert(fc.addByValue(5,10) == 15)
assert(fc.call1(fc.ADD_BY_VALUE, 5, 10) == 15)
assert(fc.call2(fc.ADD_BY_POINTER, 7, 9) == 16)
assert(fc.call3(fc.ADD_BY_REFERENCE, 8, 9) == 17)
assert(fc.call1(fc.ADD_BY_VALUE_C, 2, 3) == 5)

View file

@ -6,3 +6,5 @@ if call2(ADD_BY_POINTER, 12, 13) != 25:
raise RuntimeError
if call3(ADD_BY_REFERENCE, 14, 15) != 29:
raise RuntimeError
if call1(ADD_BY_VALUE_C, 2, 3) != 5:
raise RuntimeError

View file

@ -3,5 +3,6 @@ exec("swigtest.start", -1);
checkequal(call1(ADD_BY_VALUE_get(), 10, 11), 21, "ADD_BY_VALUE");
checkequal(call2(ADD_BY_POINTER_get(), 12, 13), 25, "ADD_BY_POINTER");
checkequal(call3(ADD_BY_REFERENCE_get(), 14, 15), 29, "ADD_BY_REFERENCE");
checkequal(call1(ADD_BY_VALUE_C_get(), 2, 3), 5, "ADD_BY_VALUE_C");
exec("swigtest.quit", -1);