Fix assert handling enums with same name in different namespaces.

This commit is contained in:
William S Fulton 2024-02-03 07:40:48 +00:00
parent dc11837c64
commit e6846ac8f3
3 changed files with 37 additions and 32 deletions

View File

@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.2.1 (in progress) Version 4.2.1 (in progress)
=========================== ===========================
2024-02-03: wsfulton
#1897 [C#, Java] Fix crash handling enums with same name in different
namespaces.
2024-02-01: wsfulton 2024-02-01: wsfulton
#2781 Correctly report line number warnings/errors for base classes that #2781 Correctly report line number warnings/errors for base classes that
are templates. are templates.
@ -20,7 +24,7 @@ Version 4.2.1 (in progress)
functype: ssizeobjargproc and ternaryfunc. functype: ssizeobjargproc and ternaryfunc.
2024-01-31: olly 2024-01-31: olly
[java] #2766 Fix segfault trying to wrap a constant whose type is unknown [Java] #2766 Fix segfault trying to wrap a constant whose type is unknown
to SWIG with "%javaconst(1);" enabled. to SWIG with "%javaconst(1);" enabled.
2024-01-31: wsfulton 2024-01-31: wsfulton
@ -53,7 +57,7 @@ Version 4.2.1 (in progress)
#2749 Fix seg fault handling friend constructor/destructor declarations. #2749 Fix seg fault handling friend constructor/destructor declarations.
2024-01-12: olly 2024-01-12: olly
[Ruby,Tcl] #2751 Fix -external-runtime output to define [Ruby, Tcl] #2751 Fix -external-runtime output to define
SWIG_snprintf (bug introduced in 4.2.0). SWIG_snprintf (bug introduced in 4.2.0).
2024-01-12: olly 2024-01-12: olly

View File

@ -1176,21 +1176,6 @@ public:
return SWIG_NOWRAP; return SWIG_NOWRAP;
String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call
if (proxy_flag && !is_wrapping_class()) {
// Global enums / enums in a namespace
assert(!full_imclass_name);
if (!nspace) {
full_imclass_name = NewStringf("%s", imclass_name);
} else {
if (namespce) {
full_imclass_name = NewStringf("%s.%s", namespce, imclass_name);
} else {
full_imclass_name = NewStringf("%s", imclass_name);
}
}
}
enum_code = NewString(""); enum_code = NewString("");
String *symname = Getattr(n, "sym:name"); String *symname = Getattr(n, "sym:name");
String *constants_code = (proxy_flag && is_wrapping_class())? proxy_class_constants_code : module_class_constants_code; String *constants_code = (proxy_flag && is_wrapping_class())? proxy_class_constants_code : module_class_constants_code;
@ -1243,9 +1228,29 @@ public:
Printf(constants_code, " // %s \n", symname); Printf(constants_code, " // %s \n", symname);
} }
if (proxy_flag && !is_wrapping_class()) {
// Global enums / enums in a namespace
assert(!full_imclass_name);
if (!nspace) {
full_imclass_name = NewStringf("%s", imclass_name);
} else {
if (namespce) {
full_imclass_name = NewStringf("%s.%s", namespce, imclass_name);
} else {
full_imclass_name = NewStringf("%s", imclass_name);
}
}
}
// Emit each enum item // Emit each enum item
Language::enumDeclaration(n); Language::enumDeclaration(n);
if (proxy_flag && !is_wrapping_class()) {
Delete(full_imclass_name);
full_imclass_name = 0;
}
if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) { if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) {
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum
// Finish the enum declaration // Finish the enum declaration
@ -1297,11 +1302,6 @@ public:
Delete(enum_code); Delete(enum_code);
enum_code = NULL; enum_code = NULL;
if (proxy_flag && !is_wrapping_class()) {
Delete(full_imclass_name);
full_imclass_name = 0;
}
} }
return SWIG_OK; return SWIG_OK;
} }

View File

@ -1245,11 +1245,6 @@ public:
return SWIG_NOWRAP; return SWIG_NOWRAP;
String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call String *nspace = Getattr(n, "sym:nspace"); // NSpace/getNSpace() only works during Language::enumDeclaration call
if (proxy_flag && !is_wrapping_class()) {
// Global enums / enums in a namespace
assert(!full_imclass_name);
constructIntermediateClassName(n);
}
enum_code = NewString(""); enum_code = NewString("");
String *symname = Getattr(n, "sym:name"); String *symname = Getattr(n, "sym:name");
@ -1300,9 +1295,20 @@ public:
} }
} }
if (proxy_flag && !is_wrapping_class()) {
// Global enums / enums in a namespace
assert(!full_imclass_name);
constructIntermediateClassName(n);
}
// Emit each enum item // Emit each enum item
Language::enumDeclaration(n); Language::enumDeclaration(n);
if (proxy_flag && !is_wrapping_class()) {
Delete(full_imclass_name);
full_imclass_name = 0;
}
if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) { if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) {
// Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum
// Finish the enum declaration // Finish the enum declaration
@ -1369,11 +1375,6 @@ public:
Delete(enum_code); Delete(enum_code);
enum_code = NULL; enum_code = NULL;
if (proxy_flag && !is_wrapping_class()) {
Delete(full_imclass_name);
full_imclass_name = 0;
}
} }
return SWIG_OK; return SWIG_OK;
} }