Fixes to remove "dereferencing type-punned pointer will break strict-aliasing rules" warnings in C wrappers when compiling C code with 'gcc -Wall -fstrict-aliasing'. Patch from Michael Cahill.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7192 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
9bd7f1ec9a
commit
94e6c86d06
6 changed files with 33 additions and 24 deletions
|
|
@ -576,7 +576,7 @@
|
|||
|
||||
/* Default handling. Object passed by value. Convert to a pointer */
|
||||
%typemap(in) SWIGTYPE ($&1_type argp)
|
||||
%{ argp = *($&1_ltype*)&$input;
|
||||
%{ argp = *($&1_ltype*)(void *)&$input;
|
||||
if (!argp) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
|
|
@ -584,7 +584,7 @@
|
|||
$1 = *argp; %}
|
||||
|
||||
%typemap(directorout) SWIGTYPE ($1_ltype argp)
|
||||
%{ argp = *($&1_ltype)&$input;
|
||||
%{ argp = *($&1_ltype)(void *)&$input;
|
||||
if (!argp) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "Attempt to dereference null $1_type");
|
||||
return $null;
|
||||
|
|
@ -593,45 +593,45 @@
|
|||
|
||||
%typemap(out) SWIGTYPE
|
||||
#ifdef __cplusplus
|
||||
%{*($&1_ltype*)&$result = new $1_ltype(($1_ltype &)$1); %}
|
||||
%{*($&1_ltype*)(void *)&$result = new $1_ltype(($1_ltype &)$1); %}
|
||||
#else
|
||||
{
|
||||
$&1_ltype $1ptr = ($&1_ltype) malloc(sizeof($1_ltype));
|
||||
memmove($1ptr, &$1, sizeof($1_type));
|
||||
*($&1_ltype*)&$result = $1ptr;
|
||||
*($&1_ltype*)(void *)&$result = $1ptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
%typemap(directorin,descriptor="L$packagepath/$&javaclassname;") SWIGTYPE "*(($&1_type)&$input) = &$1;"
|
||||
%typemap(directorin,descriptor="L$packagepath/$&javaclassname;") SWIGTYPE "*(($&1_type)(void *)&$input) = &$1;"
|
||||
%typemap(javadirectorin) SWIGTYPE "new $&javaclassname($jniinput, false)"
|
||||
%typemap(javadirectorout) SWIGTYPE "$&javaclassname.getCPtr($javacall)"
|
||||
|
||||
/* Generic pointers and references */
|
||||
%typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)&$input; %}
|
||||
%typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)&$input;
|
||||
%typemap(in) SWIGTYPE *, SWIGTYPE (CLASS::*) %{ $1 = *($&1_ltype)(void *)&$input; %}
|
||||
%typemap(in) SWIGTYPE & %{ $1 = *($&1_ltype)(void *)&$input;
|
||||
if(!$1) {
|
||||
SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, "$1_type reference is null");
|
||||
return $null;
|
||||
} %}
|
||||
%typemap(out) SWIGTYPE *, SWIGTYPE (CLASS::*)
|
||||
%{ *($&1_ltype)&$result = $1; %}
|
||||
%{ *($&1_ltype)(void *)&$result = $1; %}
|
||||
%typemap(out) SWIGTYPE &
|
||||
%{ *($&1_ltype)&$result = $1; %}
|
||||
%{ *($&1_ltype)(void *)&$result = $1; %}
|
||||
|
||||
%typemap(directorout) SWIGTYPE *, SWIGTYPE (CLASS::*)
|
||||
%{ $1 = *($&1_ltype)&$input; %}
|
||||
%{ $1 = *($&1_ltype)(void *)&$input; %}
|
||||
%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE *, SWIGTYPE (CLASS::*)
|
||||
%{ *(($&1_ltype)&$input) = ($1_ltype) $1; %}
|
||||
%{ *(($&1_ltype)(void *)&$input) = ($1_ltype) $1; %}
|
||||
|
||||
%typemap(directorin,descriptor="L$packagepath/$javaclassname;") SWIGTYPE &
|
||||
%{ *($&1_ltype)&$input = ($1_ltype) &$1; %}
|
||||
%{ *($&1_ltype)(void *)&$input = ($1_ltype) &$1; %}
|
||||
|
||||
%typemap(javadirectorin) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, const SWIGTYPE & "new $javaclassname($jniinput, false)"
|
||||
%typemap(javadirectorout) SWIGTYPE *, SWIGTYPE (CLASS::*), SWIGTYPE &, const SWIGTYPE & "$javaclassname.getCPtr($javacall)"
|
||||
|
||||
/* Default array handling */
|
||||
%typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)&$input; %}
|
||||
%typemap(out) SWIGTYPE [] %{ *($&1_ltype)&$result = $1; %}
|
||||
%typemap(in) SWIGTYPE [] %{ $1 = *($&1_ltype)(void *)&$input; %}
|
||||
%typemap(out) SWIGTYPE [] %{ *($&1_ltype)(void *)&$result = $1; %}
|
||||
%typemap(freearg) SWIGTYPE [ANY], SWIGTYPE [] ""
|
||||
|
||||
/* char arrays - treat as String */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue