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:
parent
18cede40d2
commit
8f1bde9d81
6 changed files with 67 additions and 8 deletions
|
|
@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
|
||||||
Version 2.0.2 (in progress)
|
Version 2.0.2 (in progress)
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
|
2010-12-14: wsfulton
|
||||||
|
Fix $basemangle expansion in array typemaps. For example if type is int *[3],
|
||||||
|
$basemangle expands to _p_int.
|
||||||
|
|
||||||
2010-12-07: iant
|
2010-12-07: iant
|
||||||
Check that we are using a sufficiently new version of the
|
Check that we are using a sufficiently new version of the
|
||||||
6g or 8g Go compiler during configure time. If not, disable Go.
|
6g or 8g Go compiler during configure time. If not, disable Go.
|
||||||
|
|
|
||||||
|
|
@ -397,6 +397,7 @@ CPP_TEST_CASES += \
|
||||||
typedef_scope \
|
typedef_scope \
|
||||||
typedef_sizet \
|
typedef_sizet \
|
||||||
typedef_struct \
|
typedef_struct \
|
||||||
|
typemap_arrays \
|
||||||
typemap_delete \
|
typemap_delete \
|
||||||
typemap_global_scope \
|
typemap_global_scope \
|
||||||
typemap_namespace \
|
typemap_namespace \
|
||||||
|
|
|
||||||
19
Examples/test-suite/java/typemap_arrays_runme.java
Normal file
19
Examples/test-suite/java/typemap_arrays_runme.java
Normal 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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
5
Examples/test-suite/python/typemap_arrays_runme.py
Normal file
5
Examples/test-suite/python/typemap_arrays_runme.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
from typemap_arrays import *
|
||||||
|
|
||||||
|
if sumA(None) != 60:
|
||||||
|
raise RuntimeError, "Sum is wrong"
|
||||||
|
|
||||||
30
Examples/test-suite/typemap_arrays.i
Normal file
30
Examples/test-suite/typemap_arrays.i
Normal 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;
|
||||||
|
}
|
||||||
|
%}
|
||||||
|
|
@ -963,7 +963,7 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
|
||||||
{
|
{
|
||||||
SwigType *star_type, *amp_type, *base_type, *lex_type;
|
SwigType *star_type, *amp_type, *base_type, *lex_type;
|
||||||
SwigType *ltype, *star_ltype, *amp_ltype;
|
SwigType *ltype, *star_ltype, *amp_ltype;
|
||||||
String *mangle, *star_mangle, *amp_mangle, *base_mangle, *base_name;
|
String *mangle, *star_mangle, *amp_mangle, *base_mangle, *base_name, *base_type_str;
|
||||||
String *descriptor, *star_descriptor, *amp_descriptor;
|
String *descriptor, *star_descriptor, *amp_descriptor;
|
||||||
String *ts;
|
String *ts;
|
||||||
char *sc;
|
char *sc;
|
||||||
|
|
@ -1132,21 +1132,20 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
|
||||||
|
|
||||||
/* Base type */
|
/* Base type */
|
||||||
if (SwigType_isarray(type)) {
|
if (SwigType_isarray(type)) {
|
||||||
SwigType *bt = Copy(type);
|
base_type = Copy(type);
|
||||||
Delete(SwigType_pop_arrays(bt));
|
Delete(SwigType_pop_arrays(base_type));
|
||||||
base_type = SwigType_str(bt, 0);
|
|
||||||
Delete(bt);
|
|
||||||
} else {
|
} else {
|
||||||
base_type = SwigType_base(type);
|
base_type = SwigType_base(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
base_name = SwigType_namestr(base_type);
|
base_type_str = SwigType_str(base_type, 0);
|
||||||
|
base_name = SwigType_namestr(base_type_str);
|
||||||
if (index == 1) {
|
if (index == 1) {
|
||||||
Replace(s, "$basetype", base_name, DOH_REPLACE_ANY);
|
Replace(s, "$basetype", base_name, DOH_REPLACE_ANY);
|
||||||
replace_local_types(locals, "$basetype", base_name);
|
replace_local_types(locals, "$basetype", base_name);
|
||||||
}
|
}
|
||||||
strcpy(varname, "basetype");
|
strcpy(varname, "basetype");
|
||||||
Replace(s, var, base_type, DOH_REPLACE_ANY);
|
Replace(s, var, base_type_str, DOH_REPLACE_ANY);
|
||||||
replace_local_types(locals, var, base_name);
|
replace_local_types(locals, var, base_name);
|
||||||
|
|
||||||
base_mangle = SwigType_manglestr(base_type);
|
base_mangle = SwigType_manglestr(base_type);
|
||||||
|
|
@ -1155,8 +1154,9 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
|
||||||
strcpy(varname, "basemangle");
|
strcpy(varname, "basemangle");
|
||||||
Replace(s, var, base_mangle, DOH_REPLACE_ANY);
|
Replace(s, var, base_mangle, DOH_REPLACE_ANY);
|
||||||
Delete(base_mangle);
|
Delete(base_mangle);
|
||||||
Delete(base_type);
|
|
||||||
Delete(base_name);
|
Delete(base_name);
|
||||||
|
Delete(base_type_str);
|
||||||
|
Delete(base_type);
|
||||||
|
|
||||||
lex_type = SwigType_base(rtype);
|
lex_type = SwigType_base(rtype);
|
||||||
if (index == 1)
|
if (index == 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue