From 173c028dd43e8864df2973bfb6ac3ee2d813e989 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Sun, 18 Dec 2016 15:31:44 +0000 Subject: [PATCH] Add test and changes entry for Python -builtin %array_class fix Issue https://github.com/swig/swig/issues/446 --- CHANGES.current | 4 ++++ Examples/test-suite/li_carrays.i | 11 +++++++++++ Examples/test-suite/li_carrays_cpp.i | 11 +++++++++++ Examples/test-suite/php/li_carrays_cpp_runme.php | 4 ++-- Examples/test-suite/php/li_carrays_runme.php | 4 ++-- Examples/test-suite/php5/li_carrays_cpp_runme.php | 4 ++-- Examples/test-suite/php5/li_carrays_runme.php | 4 ++-- Examples/test-suite/python/li_carrays_cpp_runme.py | 9 +++++++++ Examples/test-suite/python/li_carrays_runme.py | 8 ++++++++ 9 files changed, 51 insertions(+), 8 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 81ea4ac7e..a72f31f31 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.11 (in progress) ============================ +2016-12-18: t-ikegami + [Python] Fix https://github.com/swig/swig/issues/446 + Python %array_class of carrays.i failed with -builtin option. + 2016-12-16: bcaine [Guile] Patch #744 Added support for Guile's native pointer functionality diff --git a/Examples/test-suite/li_carrays.i b/Examples/test-suite/li_carrays.i index 45c6537d5..a39f3a2c9 100644 --- a/Examples/test-suite/li_carrays.i +++ b/Examples/test-suite/li_carrays.i @@ -6,6 +6,7 @@ %array_functions(int,intArray); %array_class(double, doubleArray); +%array_class(short, shortArray); %inline %{ typedef struct { @@ -26,3 +27,13 @@ AB globalABArray[3]; %array_class(XY, XYArray) %array_functions(AB, ABArray) +%inline %{ +short sum_array(short x[5]) { + short sum = 0; + int i; + for (i=0; i<5; i++) { + sum = sum + x[i]; + } + return sum; +} +%} diff --git a/Examples/test-suite/li_carrays_cpp.i b/Examples/test-suite/li_carrays_cpp.i index c4743420e..2a80e7823 100644 --- a/Examples/test-suite/li_carrays_cpp.i +++ b/Examples/test-suite/li_carrays_cpp.i @@ -6,6 +6,7 @@ %array_functions(int,intArray); %array_class(double, doubleArray); +%array_class(short, shortArray); %inline %{ typedef struct { @@ -26,3 +27,13 @@ AB globalABArray[3]; %array_class(XY, XYArray) %array_functions(AB, ABArray) +%inline %{ +short sum_array(short x[5]) { + short sum = 0; + int i; + for (i=0; i<5; i++) { + sum = sum + x[i]; + } + return sum; +} +%} diff --git a/Examples/test-suite/php/li_carrays_cpp_runme.php b/Examples/test-suite/php/li_carrays_cpp_runme.php index 3be09ca8c..e0f9ffe92 100644 --- a/Examples/test-suite/php/li_carrays_cpp_runme.php +++ b/Examples/test-suite/php/li_carrays_cpp_runme.php @@ -3,11 +3,11 @@ require "tests.php"; require "li_carrays_cpp.php"; // Check functions. -check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem)); +check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem,shortarray_getitem,shortarray_setitem,shortarray_cast,shortarray_frompointer,sum_array)); // Check classes. // NB An "li_carrays_cpp" class is created as a mock namespace. -check::classes(array(li_carrays_cpp,doubleArray,AB,XY,XYArray)); +check::classes(array(li_carrays_cpp,doubleArray,AB,XY,XYArray,shortArray)); // Check global variables. check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray)); diff --git a/Examples/test-suite/php/li_carrays_runme.php b/Examples/test-suite/php/li_carrays_runme.php index fbe5cc793..40e82f9ea 100644 --- a/Examples/test-suite/php/li_carrays_runme.php +++ b/Examples/test-suite/php/li_carrays_runme.php @@ -3,11 +3,11 @@ require "tests.php"; require "li_carrays.php"; // Check functions. -check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem)); +check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem,shortarray_getitem,shortarray_setitem,shortarray_cast,shortarray_frompointer,sum_array)); // Check classes. // NB An "li_carrays" class is created as a mock namespace. -check::classes(array(li_carrays,doubleArray,AB,XY,XYArray)); +check::classes(array(li_carrays,doubleArray,AB,XY,XYArray,shortArray)); // Check global variables. check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray)); diff --git a/Examples/test-suite/php5/li_carrays_cpp_runme.php b/Examples/test-suite/php5/li_carrays_cpp_runme.php index 3be09ca8c..e0f9ffe92 100644 --- a/Examples/test-suite/php5/li_carrays_cpp_runme.php +++ b/Examples/test-suite/php5/li_carrays_cpp_runme.php @@ -3,11 +3,11 @@ require "tests.php"; require "li_carrays_cpp.php"; // Check functions. -check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem)); +check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem,shortarray_getitem,shortarray_setitem,shortarray_cast,shortarray_frompointer,sum_array)); // Check classes. // NB An "li_carrays_cpp" class is created as a mock namespace. -check::classes(array(li_carrays_cpp,doubleArray,AB,XY,XYArray)); +check::classes(array(li_carrays_cpp,doubleArray,AB,XY,XYArray,shortArray)); // Check global variables. check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray)); diff --git a/Examples/test-suite/php5/li_carrays_runme.php b/Examples/test-suite/php5/li_carrays_runme.php index fbe5cc793..40e82f9ea 100644 --- a/Examples/test-suite/php5/li_carrays_runme.php +++ b/Examples/test-suite/php5/li_carrays_runme.php @@ -3,11 +3,11 @@ require "tests.php"; require "li_carrays.php"; // Check functions. -check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem)); +check::functions(array(new_intarray,delete_intarray,intarray_getitem,intarray_setitem,doublearray_getitem,doublearray_setitem,doublearray_cast,doublearray_frompointer,xyarray_getitem,xyarray_setitem,xyarray_cast,xyarray_frompointer,delete_abarray,abarray_getitem,abarray_setitem,shortarray_getitem,shortarray_setitem,shortarray_cast,shortarray_frompointer,sum_array)); // Check classes. // NB An "li_carrays" class is created as a mock namespace. -check::classes(array(li_carrays,doubleArray,AB,XY,XYArray)); +check::classes(array(li_carrays,doubleArray,AB,XY,XYArray,shortArray)); // Check global variables. check::globals(array(xy_x,xy_y,globalxyarray,ab_a,ab_b,globalabarray)); diff --git a/Examples/test-suite/python/li_carrays_cpp_runme.py b/Examples/test-suite/python/li_carrays_cpp_runme.py index 54d79aa46..f6474a03c 100644 --- a/Examples/test-suite/python/li_carrays_cpp_runme.py +++ b/Examples/test-suite/python/li_carrays_cpp_runme.py @@ -7,3 +7,12 @@ d[5] = d[0] + 3 if d[5] + d[0] != 17: raise RuntimeError + +shorts = shortArray(5) + +for i in range(5): + shorts[i] = i + +sum = sum_array(shorts) +if sum != 0+1+2+3+4: + raise RuntimeError("incorrect sum, got: " + str(sum)) diff --git a/Examples/test-suite/python/li_carrays_runme.py b/Examples/test-suite/python/li_carrays_runme.py index ad48eab61..c390f89ea 100644 --- a/Examples/test-suite/python/li_carrays_runme.py +++ b/Examples/test-suite/python/li_carrays_runme.py @@ -7,3 +7,11 @@ d[5] = d[0] + 3 if d[5] + d[0] != 17: raise RuntimeError + +shorts = shortArray(5) +for i in range(5): + shorts[i] = i + +sum = sum_array(shorts) +if sum != 0+1+2+3+4: + raise RuntimeError("incorrect sum, got: " + str(sum))