merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@12011 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
75d2abfddb
21 changed files with 466 additions and 76 deletions
|
|
@ -21,7 +21,7 @@ below.
|
|||
static char *global_str = NULL;
|
||||
const int UINT_DIGITS = 10; // max unsigned int is 4294967295
|
||||
|
||||
bool check(const char *str, unsigned int number) {
|
||||
bool check(const char *const str, unsigned int number) {
|
||||
static char expected[256];
|
||||
sprintf(expected, "%s%d", OTHERLAND_MSG, number);
|
||||
bool matches = (strcmp(str, expected) == 0);
|
||||
|
|
@ -105,6 +105,18 @@ bool SetConstCharArrayStaticString(const char str[], unsigned int number) {
|
|||
return check(static_str, number);
|
||||
}
|
||||
|
||||
bool SetCharConstStaticString(char *const str, unsigned int number) {
|
||||
static char static_str[] = CPLUSPLUS_MSG;
|
||||
strcpy(static_str, str);
|
||||
return check(static_str, number);
|
||||
}
|
||||
|
||||
bool SetConstCharConstStaticString(const char *const str, unsigned int number) {
|
||||
static char static_str[] = CPLUSPLUS_MSG;
|
||||
strcpy(static_str, str);
|
||||
return check(static_str, number);
|
||||
}
|
||||
|
||||
// get set function
|
||||
char *CharPingPong(char *str) {
|
||||
return str;
|
||||
|
|
|
|||
|
|
@ -387,12 +387,14 @@ CPP_TEST_CASES += \
|
|||
typedef_scope \
|
||||
typedef_sizet \
|
||||
typedef_struct \
|
||||
typemap_delete \
|
||||
typemap_global_scope \
|
||||
typemap_namespace \
|
||||
typemap_ns_using \
|
||||
typemap_numinputs \
|
||||
typemap_template \
|
||||
typemap_out_optimal \
|
||||
typemap_qualifier_strip \
|
||||
typemap_variables \
|
||||
typemap_various \
|
||||
typename \
|
||||
|
|
|
|||
|
|
@ -76,6 +76,16 @@ public class char_strings_runme {
|
|||
throw new Exception("Test char set 6 failed, iteration " + i);
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
if (!char_strings.SetCharConstStaticString(OTHERLAND_MSG + i, i))
|
||||
throw new Exception("Test char set 7 failed, iteration " + i);
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
if (!char_strings.SetConstCharConstStaticString(OTHERLAND_MSG + i, i))
|
||||
throw new Exception("Test char set 8 failed, iteration " + i);
|
||||
}
|
||||
|
||||
// get set function
|
||||
for (i=0; i<count*10; i++) {
|
||||
string ping = OTHERLAND_MSG + i;
|
||||
|
|
|
|||
|
|
@ -14,8 +14,6 @@ public class runme {
|
|||
throw new Exception("test failed");
|
||||
if (special_variable_macros.testJim(name) != "multiname num")
|
||||
throw new Exception("test failed");
|
||||
if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123)
|
||||
throw new Exception("test failed");
|
||||
NewName newName = NewName.factory("factoryname");
|
||||
name = newName.getStoredName();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,6 +83,16 @@ public class char_strings_runme {
|
|||
throw new RuntimeException("Test char set 6 failed, iteration " + i);
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
if (!char_strings.SetCharConstStaticString(OTHERLAND_MSG + i, i))
|
||||
throw new RuntimeException("Test char set 7 failed, iteration " + i);
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
if (!char_strings.SetConstCharConstStaticString(OTHERLAND_MSG + i, i))
|
||||
throw new RuntimeException("Test char set 8 failed, iteration " + i);
|
||||
}
|
||||
|
||||
// get set function
|
||||
for (i=0; i<count; i++) {
|
||||
String ping = OTHERLAND_MSG + i;
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@ public class special_variable_macros_runme {
|
|||
throw new RuntimeException("test failed");
|
||||
if (!special_variable_macros.testJim(name).equals("multiname num"))
|
||||
throw new RuntimeException("test failed");
|
||||
if (special_variable_macros.testJohn(new PairIntBool(10, false)) != 123)
|
||||
throw new RuntimeException("test failed");
|
||||
NewName newName = NewName.factory("factoryname");
|
||||
name = newName.getStoredName();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,4 @@ if special_variable_macros.testMary(name) != "SWIGTYPE_p_NameWrap":
|
|||
raise "test failed"
|
||||
if special_variable_macros.testJim(name) != "multiname num":
|
||||
raise "test failed"
|
||||
if special_variable_macros.testJohn(special_variable_macros.PairIntBool(10, False)) != 123:
|
||||
raise "test failed"
|
||||
|
||||
|
|
|
|||
5
Examples/test-suite/python/typemap_delete_runme.py
Normal file
5
Examples/test-suite/python/typemap_delete_runme.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
import typemap_delete
|
||||
|
||||
r = typemap_delete.Rect(123)
|
||||
if r.val != 123:
|
||||
raise RuntimeError
|
||||
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
|
||||
|
||||
|
|
@ -88,7 +88,7 @@ const char * testMary(Name *mary) {
|
|||
%{
|
||||
/*%typemap(in) (Name *multiname, int num) start */
|
||||
temp_name = $*1_ltype("multiname num");
|
||||
temp_count = (int)strlen(temp_name.getNamePtr()->getName());
|
||||
temp_count = strlen(temp_name.getNamePtr()->getName());
|
||||
(void)$input;
|
||||
$1 = temp_name.getNamePtr();
|
||||
$2 = temp_count + 100;
|
||||
|
|
@ -103,7 +103,7 @@ $typemap(in, (Name *multiname, int num))
|
|||
|
||||
%inline %{
|
||||
const char * testJim(Name *jim, int count) {
|
||||
if (count != (int)strlen(jim->getNamePtr()->getName()) + 100)
|
||||
if (count != strlen(jim->getNamePtr()->getName()) + 100)
|
||||
return "size check failed";
|
||||
else
|
||||
return jim->getName();
|
||||
|
|
|
|||
16
Examples/test-suite/typemap_delete.i
Normal file
16
Examples/test-suite/typemap_delete.i
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
%module typemap_delete
|
||||
|
||||
%typemap(in) Rect* (Rect temp) {
|
||||
$1 = 0;
|
||||
will_not_compile
|
||||
}
|
||||
|
||||
%typemap(in) Rect*;
|
||||
|
||||
%inline %{
|
||||
struct Rect
|
||||
{
|
||||
int val;
|
||||
Rect(int v) : val(v) {}
|
||||
};
|
||||
%}
|
||||
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