summaryrefslogtreecommitdiff
path: root/Examples
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2017-10-06 21:57:04 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2017-10-06 21:57:04 +0100
commit4a7976a5d89452be2d908ee6b4328e386a9b6064 (patch)
tree120f17eb2818180c474e4b25ade5765a1aa6248c /Examples
parentac8331648feee4c06c27f41fe01551ff2bbd3b0e (diff)
downloadswig-4a7976a5d89452be2d908ee6b4328e386a9b6064.tar.gz
Fix platorm inconsistency in Python default argument handling.
32 bit and 64 bit compiled versions of SWIG generated different Python files when default arguments were outside the range of 32 bit signed integers. The default arguments specified in Python are now only those that are in the range of a 32 bit signed integer, otherwise the default is obtained from C/C++ code. Closes #1108
Diffstat (limited to 'Examples')
-rw-r--r--Examples/test-suite/default_args.i8
-rw-r--r--Examples/test-suite/python/default_args_runme.py18
2 files changed, 26 insertions, 0 deletions
diff --git a/Examples/test-suite/default_args.i b/Examples/test-suite/default_args.i
index 1f7183f47..1401cd576 100644
--- a/Examples/test-suite/default_args.i
+++ b/Examples/test-suite/default_args.i
@@ -28,6 +28,14 @@
int value_perm(int first, int mode = 0640 | 0004) { return mode; }
int value_m01(int first, int val = -01) { return val; }
bool booltest2(bool x = 0 | 1) { return x; }
+ int max_32bit_int1(int a = 0x7FFFFFFF) { return a; }
+ int max_32bit_int2(int a = 2147483647) { return a; }
+ int min_32bit_int1(int a = -0x80000000) { return a; }
+ int min_32bit_int2(int a = -2147483648) { return a; }
+ long long too_big_32bit_int1(long long a = 0x80000000) { return a; }
+ long long too_big_32bit_int2(long long a = 2147483648LL) { return a; }
+ long long too_small_32bit_int1(long long a = -0x80000001) { return a; }
+ long long too_small_32bit_int2(long long a = -2147483649LL) { return a; }
};
void doublevalue1(int first, double num = 0.0e-1) {}
diff --git a/Examples/test-suite/python/default_args_runme.py b/Examples/test-suite/python/default_args_runme.py
index ddaf2cd4f..d745cae10 100644
--- a/Examples/test-suite/python/default_args_runme.py
+++ b/Examples/test-suite/python/default_args_runme.py
@@ -139,6 +139,24 @@ def run(module_name):
print "booltest2 failed"
tricky_failure = True
+ if tricky.max_32bit_int1() != 0x7FFFFFFF:
+ print "max_32bit_int1 failed"
+ tricky_failure = True
+ if tricky.min_32bit_int1() != -2147483648:
+ print "min_32bit_int1 failed"
+ tricky_failure = True
+ if tricky.max_32bit_int2() != 0x7FFFFFFF:
+ print "max_32bit_int2 failed"
+ tricky_failure = True
+ if tricky.min_32bit_int2() != -2147483648:
+ print "min_32bit_int2 failed"
+ tricky_failure = True
+
+ tricky.too_big_32bit_int1()
+ tricky.too_small_32bit_int1()
+ tricky.too_big_32bit_int2()
+ tricky.too_small_32bit_int2()
+
if tricky_failure:
raise RuntimeError