Typemap matching rules enhancement for non-default typemaps. Previously all qualifiers were stripped in one step, now they are stripped one at a time starting with the left most qualifier.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12007 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
58a7e2c3d6
commit
efd200ffe2
10 changed files with 398 additions and 38 deletions
|
|
@ -393,6 +393,7 @@ CPP_TEST_CASES += \
|
|||
typemap_numinputs \
|
||||
typemap_template \
|
||||
typemap_out_optimal \
|
||||
typemap_qualifier_strip \
|
||||
typemap_variables \
|
||||
typemap_various \
|
||||
typename \
|
||||
|
|
|
|||
54
Examples/test-suite/python/typemap_qualifier_strip_runme.py
Normal file
54
Examples/test-suite/python/typemap_qualifier_strip_runme.py
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
import typemap_qualifier_strip
|
||||
|
||||
val = typemap_qualifier_strip.create_int(111)
|
||||
if typemap_qualifier_strip.testA1(val) != 1234:
|
||||
raise RuntimeError
|
||||
|
||||
if typemap_qualifier_strip.testA2(val) != 1234:
|
||||
raise RuntimeError
|
||||
|
||||
if typemap_qualifier_strip.testA3(val) != 1234:
|
||||
raise RuntimeError
|
||||
|
||||
if typemap_qualifier_strip.testA4(val) != 1234:
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
if typemap_qualifier_strip.testB1(val) != 111:
|
||||
raise RuntimeError
|
||||
|
||||
if typemap_qualifier_strip.testB2(val) != 111:
|
||||
raise RuntimeError
|
||||
|
||||
if typemap_qualifier_strip.testB3(val) != 111:
|
||||
raise RuntimeError
|
||||
|
||||
if typemap_qualifier_strip.testB4(val) != 111:
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
if typemap_qualifier_strip.testC1(val) != 5678:
|
||||
raise RuntimeError
|
||||
|
||||
if typemap_qualifier_strip.testC2(val) != 111:
|
||||
raise RuntimeError
|
||||
|
||||
if typemap_qualifier_strip.testC3(val) != 5678:
|
||||
raise RuntimeError
|
||||
|
||||
if typemap_qualifier_strip.testC4(val) != 111:
|
||||
raise RuntimeError
|
||||
|
||||
|
||||
if typemap_qualifier_strip.testD1(val) != 111:
|
||||
raise RuntimeError
|
||||
|
||||
if typemap_qualifier_strip.testD2(val) != 3456:
|
||||
raise RuntimeError
|
||||
|
||||
if typemap_qualifier_strip.testD3(val) != 111:
|
||||
raise RuntimeError
|
||||
|
||||
if typemap_qualifier_strip.testD4(val) != 111:
|
||||
raise RuntimeError
|
||||
|
||||
76
Examples/test-suite/typemap_qualifier_strip.i
Normal file
76
Examples/test-suite/typemap_qualifier_strip.i
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
%module typemap_qualifier_strip
|
||||
|
||||
%typemap(in) int *ptr {
|
||||
int temp = 1234;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) int *const ptrConst {
|
||||
int temp = 5678;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%typemap(in) int const* constPtr {
|
||||
int temp = 3456;
|
||||
$1 = &temp;
|
||||
}
|
||||
|
||||
%inline %{
|
||||
int *create_int(int newval) {
|
||||
static int val = 0;
|
||||
val = newval;
|
||||
return &val;
|
||||
}
|
||||
int testA1(int const*const ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
int testA2(int const* ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
int testA3(int *const ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
int testA4(int * ptr) {
|
||||
return *ptr;
|
||||
}
|
||||
|
||||
int testB1(int const*const p) {
|
||||
return *p;
|
||||
}
|
||||
int testB2(int const* p) {
|
||||
return *p;
|
||||
}
|
||||
int testB3(int *const p) {
|
||||
return *p;
|
||||
}
|
||||
int testB4(int * p) {
|
||||
return *p;
|
||||
}
|
||||
|
||||
int testC1(int const*const ptrConst) {
|
||||
return *ptrConst;
|
||||
}
|
||||
int testC2(int const* ptrConst) {
|
||||
return *ptrConst;
|
||||
}
|
||||
int testC3(int *const ptrConst) {
|
||||
return *ptrConst;
|
||||
}
|
||||
int testC4(int * ptrConst) {
|
||||
return *ptrConst;
|
||||
}
|
||||
|
||||
int testD1(int const*const constPtr) {
|
||||
return *constPtr;
|
||||
}
|
||||
int testD2(int const* constPtr) {
|
||||
return *constPtr;
|
||||
}
|
||||
int testD3(int *const constPtr) {
|
||||
return *constPtr;
|
||||
}
|
||||
int testD4(int * constPtr) {
|
||||
return *constPtr;
|
||||
}
|
||||
%}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue