diff --git a/SWIG/CHANGES.current b/SWIG/CHANGES.current index bc56d85d9..e9583e2f9 100644 --- a/SWIG/CHANGES.current +++ b/SWIG/CHANGES.current @@ -1,6 +1,14 @@ Version 1.3.25 (In progress) ============================ +05/13/2005: wsfulton + [Java] 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. This modifies many of the casts slightly, for example + arg1 = *(DB_ENV **)&jarg1; + to + arg1 = *(DB_ENV **)(void *)&jarg1; + 05/12/2005: wsfulton [C#] Support for C# attributes. C# attributes can be generated: 1) On a C/C++ type basis by specifying an inattributes and/or outattributes typemap attribute diff --git a/SWIG/Examples/java/native/example.i b/SWIG/Examples/java/native/example.i index 65710f2bc..cb561b2e6 100644 --- a/SWIG/Examples/java/native/example.i +++ b/SWIG/Examples/java/native/example.i @@ -35,7 +35,7 @@ JNIEXPORT jstring JNICALL Java_exampleJNI_point_1toString2(JNIEnv *jenv, jclass (void)jcls; - p = *(Point **)&jpoint; + p = *(Point **)(void *)&jpoint; sprintf(buf, "[%d,%d]", p->x, p->y); result = (*jenv)->NewStringUTF(jenv, buf); diff --git a/SWIG/Lib/java/arrays_java.i b/SWIG/Lib/java/arrays_java.i index 0a2f451de..944fc5256 100644 --- a/SWIG/Lib/java/arrays_java.i +++ b/SWIG/Lib/java/arrays_java.i @@ -262,7 +262,7 @@ JAVA_ARRAYS_TYPEMAPS(double, double, jdouble, Double, "[D") /* double[ANY] * return $null; } for (i=0; iNewWeakGlobalRef(jself); weak_global_ = true; } - } else { /* Java releses ownership of C++ object's lifetime */ + } else { /* Java releases ownership of C++ object's lifetime */ if (weak_global_) { jenv->DeleteWeakGlobalRef(jthis_); jthis_ = jenv->NewGlobalRef(jself); diff --git a/SWIG/Lib/java/java.swg b/SWIG/Lib/java/java.swg index ccd2961d5..b016cd9c7 100644 --- a/SWIG/Lib/java/java.swg +++ b/SWIG/Lib/java/java.swg @@ -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 */ diff --git a/SWIG/Source/Modules/java.cxx b/SWIG/Source/Modules/java.cxx index b6964bba6..2740304ee 100644 --- a/SWIG/Source/Modules/java.cxx +++ b/SWIG/Source/Modules/java.cxx @@ -1122,6 +1122,7 @@ class JAVA : public Language { // Add extra indentation Replaceall(enum_code, "\n", "\n "); + Replaceall(enum_code, " \n", "\n"); Printv(proxy_class_constants_code, " ", enum_code, "\n\n", NIL); } else { @@ -1623,7 +1624,7 @@ class JAVA : public Language { " jlong baseptr = 0;\n" " (void)jenv;\n" " (void)jcls;\n" - " *($cbaseclass **)&baseptr = *($cclass **)&jarg1;\n" + " *($cbaseclass **)(void *)&baseptr = *($cclass **)(void *)&jarg1;\n" " return baseptr;\n" "}\n", "\n", @@ -1723,7 +1724,7 @@ class JAVA : public Language { jnipackage, jni_imclass_name, jni_class_name); Printf(dcast_wrap->code, " Swig::Director *director = (Swig::Director *) 0;\n"); Printf(dcast_wrap->code, " jobject jresult = (jobject) 0;\n"); - Printf(dcast_wrap->code, " %s *obj = *((%s **) &jCPtrBase);\n", norm_name, norm_name); + Printf(dcast_wrap->code, " %s *obj = *((%s **)(void *)&jCPtrBase);\n", norm_name, norm_name); Printf(dcast_wrap->code, " if (obj) director = dynamic_cast(obj);\n"); Printf(dcast_wrap->code, " if (director) jresult = director->swig_get_self(jenv);\n"); Printf(dcast_wrap->code, " return jresult;\n"); @@ -2760,7 +2761,7 @@ class JAVA : public Language { "JNIEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jswig_mem_own, " "jboolean jweak_global) {\n", jnipackage, jni_imclass_name, swig_director_connect_jni); - Printf(code_wrap->code, " %s *obj = *((%s **) &objarg);\n", norm_name, norm_name); + Printf(code_wrap->code, " %s *obj = *((%s **)(void *)&objarg);\n", norm_name, norm_name); Printf(code_wrap->code, " (void)jcls;\n"); Printf(code_wrap->code, " SwigDirector_%s *director = dynamic_cast(obj);\n", sym_name, sym_name); @@ -2787,7 +2788,7 @@ class JAVA : public Language { Printf(code_wrap->def, "JNIEXPORT void JNICALL Java_%s%s_%s(JNIEnv *jenv, jclass jcls, jobject jself, jlong objarg, jboolean jtake_or_release) {\n", jnipackage, jni_imclass_name, changeown_jnimethod_name); - Printf(code_wrap->code, " %s *obj = *((%s **) &objarg);\n", norm_name, norm_name); + Printf(code_wrap->code, " %s *obj = *((%s **)(void *)&objarg);\n", norm_name, norm_name); Printf(code_wrap->code, " SwigDirector_%s *director = dynamic_cast(obj);\n", sym_name, sym_name); Printf(code_wrap->code, " (void)jcls;\n");