diff --git a/CHANGES.current b/CHANGES.current index 97fe740d1..ea34b0c81 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -5,6 +5,12 @@ See the RELEASENOTES file for a summary of changes in each release. Version 3.0.1 (in progress) =========================== +2014-04-08: wsfulton + [Java C#] Enums which have been ignored via %ignore and are subsequently + used are handled slightly differently. Type wrapper classes are now generated + which are effectively a wrapper of an empty enum. Previously in Java uncompilable + code was generated and in C# an int was used. + 2014-04-04: wsfulton Fix regression in 3.0.0 where legal code following an operator<< definition might give a syntax error. SF Bug #1365. diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk index 67f99b0b1..afc4752c7 100644 --- a/Examples/test-suite/common.mk +++ b/Examples/test-suite/common.mk @@ -197,6 +197,7 @@ CPP_TEST_CASES += \ disown \ dynamic_cast \ empty \ + enum_ignore \ enum_plus \ enum_rename \ enum_scope_template \ diff --git a/Examples/test-suite/enum_ignore.i b/Examples/test-suite/enum_ignore.i new file mode 100644 index 000000000..6d11f6a97 --- /dev/null +++ b/Examples/test-suite/enum_ignore.i @@ -0,0 +1,20 @@ +%module enum_ignore + +// Similar to enum_missing C test, but with namespaces and using %ignore + +%ignore N::C; + +%inline %{ + namespace N { + enum C { Red, Green, Blue }; + + struct Draw { + void DrawBW() {} + void DrawC(C c) {} + void DrawC_Ptr(C* c) {} + void DrawC_ConstRef(C const& c) {} + }; + } +%} + + diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index e0d4a1ab1..3e34e7f91 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -3175,8 +3175,8 @@ public: if (anonymous_enum) { replacementname = NewString("int"); } else { - // An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition) - replacementname = SwigType_base(classnametype); + // An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition) or an ignored enum + replacementname = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype)); Replace(replacementname, "enum ", "", DOH_REPLACE_ANY); Setattr(swig_types_hash, replacementname, classnametype); } diff --git a/Source/Modules/go.cxx b/Source/Modules/go.cxx index a6a74ccac..c2d3948d4 100644 --- a/Source/Modules/go.cxx +++ b/Source/Modules/go.cxx @@ -4514,10 +4514,12 @@ private: } else if (Strcmp(t, "enum ") == 0) { ret = NewString("int"); } else { - // An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition) - ret = SwigType_base(t); - Replace(ret, "enum ", "", DOH_REPLACE_ANY); + // An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition) or an ignored enum + String *tt = Copy(t); + Replace(tt, "enum ", "", DOH_REPLACE_ANY); + ret = exportedName(tt); Setattr(undefined_enum_types, t, ret); + Delete(tt); } } else if (SwigType_isfunctionpointer(type) || SwigType_isfunction(type)) { ret = NewString("_swig_fnptr"); diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index 53f856749..eda3ba7c8 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -3090,8 +3090,8 @@ public: if (anonymous_enum) { replacementname = NewString("int"); } else { - // An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition) - replacementname = SwigType_base(classnametype); + // An unknown enum - one that has not been parsed (neither a C enum forward reference nor a definition) or an ignored enum + replacementname = NewStringf("SWIGTYPE%s", SwigType_manglestr(classnametype)); Replace(replacementname, "enum ", "", DOH_REPLACE_ANY); Setattr(swig_types_hash, replacementname, classnametype); }