Changed swigtype.swg to use static_cast's instead of

reinterpret_cast's.
This fixes a potentially subtle problem with director
classes using reinterpret casts in their casts
and when casting class that have multiple inheritance. 
The code currently generated by swig actually works
find under most compilers but was, afaik, not truly 
C++ conformant.



git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9942 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Gonzalo Garramuno 2007-09-19 09:00:59 +00:00
commit 7a3c9a08a2

View file

@ -7,7 +7,7 @@
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
}
$1 = %reinterpret_cast(argp, $ltype);
$1 = %static_cast(argp, $ltype);
}
%typemap(freearg) SWIGTYPE * "";
@ -16,7 +16,7 @@
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$type", $symname, $argnum);
}
$1 = %reinterpret_cast(argp, $ltype);
$1 = %static_cast(argp, $ltype);
}
%typemap(freearg) SWIGTYPE [] "";
@ -26,7 +26,7 @@
if (!SWIG_IsOK(res)) {
%argument_fail(res, "$*ltype", $symname, $argnum);
}
temp = %reinterpret_cast(argp, $*ltype);
temp = %static_cast(argp, $*ltype);
$1 = &temp;
}
%typemap(freearg) SWIGTYPE* const& "";
@ -39,7 +39,7 @@
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
$1 = %reinterpret_cast(argp, $ltype);
$1 = %static_cast(argp, $ltype);
}
%typemap(freearg) SWIGTYPE & "";
@ -50,7 +50,7 @@
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
$1 = %reinterpret_cast(argp, $ltype);
$1 = %static_cast(argp, $ltype);
}
%typemap(freearg,noblock=1,match="in",implicitconv=1) const SWIGTYPE &
{
@ -63,7 +63,7 @@
%argument_fail(res, "$type", $symname, $argnum);
}
if (!argp) { %argument_nullref("$type", $symname, $argnum); }
$1 = %reinterpret_cast(argp, $ltype);
$1 = %static_cast(argp, $ltype);
}
#endif
@ -77,7 +77,7 @@
if (!argp) {
%argument_nullref("$type", $symname, $argnum);
} else {
$&ltype temp = %reinterpret_cast(argp, $&ltype);
$&ltype temp = %static_cast(argp, $&ltype);
$1 = *temp;
if (SWIG_IsNewObj(res)) %delete(temp);
}
@ -91,7 +91,7 @@
if (!argp) {
%argument_nullref("$type", $symname, $argnum);
} else {
$1 = *(%reinterpret_cast(argp, $&ltype));
$1 = *(%static_cast(argp, $&ltype));
}
}
#endif
@ -215,7 +215,7 @@
if (!SWIG_IsOK(res)) {
%variable_fail(res, "$type", "$name");
}
$1 = %reinterpret_cast(argp, $ltype);
$1 = %static_cast(argp, $ltype);
}
%typemap(varin,noblock=1,warning="462:Unable to set dimensionless array variable") SWIGTYPE []
@ -232,7 +232,7 @@
if (!argp) {
%variable_nullref("$type", "$name");
}
$1 = *(%reinterpret_cast(argp, $ltype));
$1 = *(%static_cast(argp, $ltype));
}
#if defined(__cplusplus) && defined(%implicitconv_flag)
@ -246,7 +246,7 @@
%variable_nullref("$type", "$name");
} else {
$&type temp;
temp = %reinterpret_cast(argp, $&type);
temp = %static_cast(argp, $&type);
$1 = *temp;
if (SWIG_IsNewObj(res)) %delete(temp);
}
@ -261,7 +261,7 @@
if (!argp) {
%variable_nullref("$type", "$name");
} else {
$1 = *(%reinterpret_cast(argp, $&type));
$1 = *(%static_cast(argp, $&type));
}
}
#endif
@ -356,8 +356,8 @@
if (!SWIG_IsOK(swig_res)) {
%dirout_fail(swig_res,"$type");
}
$result = *(%reinterpret_cast(swig_argp, $&ltype));
if (SWIG_IsNewObj(swig_res)) %delete(%reinterpret_cast(swig_argp, $&ltype));
$result = *(%static_cast(swig_argp, $&ltype));
if (SWIG_IsNewObj(swig_res)) %delete(%static_cast(swig_argp, $&ltype));
}
#else
%typemap(directorout,noblock=1) SWIGTYPE (void * swig_argp, int swig_res = 0) {
@ -365,7 +365,7 @@
if (!SWIG_IsOK(swig_res)) {
%dirout_fail(swig_res,"$type");
}
$result = *(%reinterpret_cast(swig_argp, $&ltype));
$result = *(%static_cast(swig_argp, $&ltype));
}
#endif
@ -375,7 +375,7 @@
if (!SWIG_IsOK(swig_res)) {
%dirout_fail(swig_res,"$type");
}
$result = %reinterpret_cast(swig_argp, $ltype);
$result = %static_cast(swig_argp, $ltype);
swig_acquire_ownership_obj(%as_voidptr($result), own);
}
%typemap(directorfree,noblock=1,match="directorout") SWIGTYPE * {
@ -391,7 +391,7 @@
%dirout_fail(swig_res,"$type");
}
if (!swig_argp) { %dirout_nullref("$type"); }
$result = %reinterpret_cast(swig_argp, $ltype);
$result = %static_cast(swig_argp, $ltype);
swig_acquire_ownership_obj(%as_voidptr($result), own);
}
%typemap(directorfree,noblock=1,match="directorout") SWIGTYPE & {