Fix expansion in array typemaps

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12347 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2010-12-14 21:38:36 +00:00
commit 8f1bde9d81
6 changed files with 67 additions and 8 deletions

View file

@ -397,6 +397,7 @@ CPP_TEST_CASES += \
typedef_scope \
typedef_sizet \
typedef_struct \
typemap_arrays \
typemap_delete \
typemap_global_scope \
typemap_namespace \

View file

@ -0,0 +1,19 @@
import typemap_arrays.*;
public class typemap_arrays_runme {
static {
try {
System.loadLibrary("typemap_arrays");
} catch (UnsatisfiedLinkError e) {
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
System.exit(1);
}
}
public static void main(String argv[]) {
if (typemap_arrays.sumA(null) != 60)
throw new RuntimeException("Sum is wrong");
}
}

View file

@ -0,0 +1,5 @@
from typemap_arrays import *
if sumA(None) != 60:
raise RuntimeError, "Sum is wrong"

View file

@ -0,0 +1,30 @@
%module typemap_arrays
// Test that previously non-working array typemaps special variables are working
%typemap(in) SWIGTYPE[ANY] {
_should_not_be_used_and_will_not_compile_
}
// Check $basemangle expands to _p_int and $basetype expands to int *
%typemap(in) int *nums[3] (int *temp[3]) {
$basetype var1$basemangle = new int(10);
$basetype var2$basemangle = new int(20);
$basetype var3$basemangle = new int(30);
temp[0] = var1_p_int;
temp[1] = var2_p_int;
temp[2] = var3_p_int;
$1 = temp;
}
%inline %{
int sumA(int *nums[3]) {
int sum = 0;
for (int i=0; i<3; ++i) {
int *p = nums[i];
if (p)
sum += *p;
}
return sum;
}
%}