diff --git a/SWIG/Lib/swig.swg b/SWIG/Lib/swig.swg index eb2b6bc3e..3ec865450 100644 --- a/SWIG/Lib/swig.swg +++ b/SWIG/Lib/swig.swg @@ -402,4 +402,3 @@ static int NAME(TYPE x) { %} %enddef -%include unnamed.swg diff --git a/SWIG/Lib/unnamed.swg b/SWIG/Lib/unnamed.swg deleted file mode 100644 index 0f327b911..000000000 --- a/SWIG/Lib/unnamed.swg +++ /dev/null @@ -1,52 +0,0 @@ -/* - Auxiliary methods for assigning unnamed type C++ variables, where - swig doesn't know the casting type, but C++ can derived it: - - struct Foo { enum {Hi, Hello } hola; }; - - These are very specific macros, that could keep growing as more - compilers require especial support, or could vanish latter if the - enum mapping changes drastically. Therefore, better we put them in - this separate file, so swig.swg doesn't change every time we update - something here. - -*/ - -%insert("runtime") %{ -#ifdef __cplusplus -// here, the C++ compilers that do not accept unnamed template parameters -#if defined(_SGI_COMPILER_VERSION) -// -// Activate the following macro for compilers that do not support -// unnamed template parameters, but where memcpy works. -// -#define SWIG_UNNAMED_USE_MEMCPY -// -// -#ifdef SWIG_UNNAMED_USE_MEMCPY -// safe assigment, for enums it should work. -#define swig_assign_unnamed(eval, val) \ - if(sizeof(eval) == sizeof(val)) \ - memcpy(&(eval), &(val), sizeof(eval)); \ - else \ - printf("unnamed member assigment not supported\n") -#else -// much much safer choice :) -#define swig_assign_unnamed(eval, val) \ - printf("unnamed member assigment not supported\n") -#endif -#else /*** we have a 'good' compiler ***/ -// This is much safer, but some old compiler could not like it -template -inline -void swig_assign_unnamed(T& eval, const V& val) -{ - // it 'should' be: eval = static_cast(val); - // but just in case we found an old compiler - eval = (T)val; -} -#endif -#else -#define swig_assign_unnamed(eval, val) eval = val -#endif -%} diff --git a/SWIG/Source/Swig/cwrap.c b/SWIG/Source/Swig/cwrap.c index f9a4cfd0d..3c9a4e05a 100644 --- a/SWIG/Source/Swig/cwrap.c +++ b/SWIG/Source/Swig/cwrap.c @@ -409,10 +409,10 @@ Swig_cppconstructor_director_call(String_or_char *name, ParmList *parms) { /* ----------------------------------------------------------------------------- * Swig_cattr_search() * - * This function search for the class attribute 'attr' in the class + * This function searches for the class attribute 'attr' in the class * 'n' or recursively in its bases. * - * if you define SWIG_FAST_REC_SEARCH, the method will set the found + * If you define SWIG_FAST_REC_SEARCH, the method will set the found * 'attr' in io the target class 'n'. If not, the method will set the * 'noattr' one. This prevents of having to navigate the entire * hierarchy tree everytime, so, it is an O(1) method... or something @@ -423,7 +423,7 @@ Swig_cppconstructor_director_call(String_or_char *name, ParmList *parms) { * while searching. This could be slower for large projects with very * large hierarchy trees... or maybe not. But it will be cleaner. * - * Maybe latter a swig option can be added to switch at runtime. + * Maybe later a swig option can be added to switch at runtime. * * ----------------------------------------------------------------------------- */ @@ -556,12 +556,12 @@ Swig_cmemberset_call(String_or_char *name, SwigType *type, String_or_char *self) else self = NewString(self); Replaceall(self,"this",Swig_cparm_name(0,0)); if (SwigType_type(type) != T_ARRAY) { - if (!Strstr(type,"$unnamed")) { + if (!Strstr(type,"enum $unnamed")) { Printf(func,"if (%s) %s%s = %s",Swig_cparm_name(0,0), self,name, Swig_wrapped_var_deref(type, Swig_cparm_name(0,1))); } else { - Printf(func,"if (%s) swig_assign_unnamed(%s%s, %s)",Swig_cparm_name(0,0), self,name, - Swig_cparm_name(0,1)); + Printf(func,"if (%s && sizeof(int) == sizeof(%s%s)) *(int*)(void*)&(%s%s) = %s", + Swig_cparm_name(0,0), self, name, self, name, Swig_cparm_name(0,1)); } } Delete(self);