more test cases, less cast operations

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@8266 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2006-01-07 00:57:44 +00:00
commit 4e05ba0554
3 changed files with 31 additions and 19 deletions

View file

@ -40,6 +40,10 @@ int get_value(int *x, int i) {
const Material * chitMat[Size];
Material hitMat_val[Size];
Material *hitMat[Size];
const Material * chitMat2[Size][Size];
Material hitMat_val2[Size][Size];
Material *hitMat2[Size][Size];
};
}

View file

@ -40,3 +40,22 @@ int get_2d_array(int (*array)[ARRAY_LEN_Y], int x, int y){
}
%}
#ifdef __cplusplus
%inline
{
struct Material
{
};
enum {
Size = 32
};
const Material * chitMat[Size][Size];
Material hitMat_val[Size][Size];
Material *hitMat[Size][Size];
}
#endif

View file

@ -154,16 +154,12 @@
/* memberin/globalin/varin, for fix double arrays. */
%typemap(memberin) SWIGTYPE [ANY][ANY] {
$basetype (*inp)[$dim1] = %static_cast($input, $basetype (*)[$dim1]);
if (inp) {
$basetype (*dest)[$dim1] = %static_cast($1, $basetype (*)[$dim1]);
if ($input) {
size_t ii = 0;
for (; ii < (size_t)$dim0; ++ii) {
$basetype *ip = inp[ii];
if (ip) {
$basetype *dp = dest[ii];
if ($input[ii]) {
size_t jj = 0;
for (; jj < (size_t)$dim1; ++jj) dp[jj] = ip[jj];
for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = $input[ii][jj];
} else {
%variable_nullref("$type","$name");
}
@ -174,16 +170,12 @@
}
%typemap(globalin) SWIGTYPE [ANY][ANY] {
$basetype (*inp)[$dim1] = %static_cast($input, $basetype (*)[$dim1]);
if (inp) {
$basetype (*dest)[$dim1] = %static_cast($1, $basetype (*)[$dim1]);
if ($input) {
size_t ii = 0;
for (; ii < (size_t)$dim0; ++ii) {
$basetype *ip = inp[ii];
if (ip) {
$basetype *dp = dest[ii];
if ($input[ii]) {
size_t jj = 0;
for (; jj < (size_t)$dim1; ++jj) dp[jj] = ip[jj];
for (; jj < (size_t)$dim1; ++jj) $1[ii][jj] = $input[ii][jj];
} else {
%variable_nullref("$type","$name");
}
@ -199,14 +191,11 @@
if (!SWIG_IsOK(res)) {
%variable_fail(SWIG_TypeError, "$type", "$name");
} else if (inp) {
$basetype (*dest)[$dim1] = %static_cast($1, $basetype (*)[$dim1]);
size_t ii = 0;
for (; ii < $dim0; ++ii) {
$basetype *ip = inp[ii];
if (ip) {
$basetype *dp = dest[ii];
if (inp[ii]) {
size_t jj = 0;
for (; jj < $dim1; ++jj) dp[jj] = ip[jj];
for (; jj < $dim1; ++jj) $1[ii][jj] = inp[ii][jj];
} else {
%variable_nullref("$type", "$name");
}