Fix getNamespacedName() and reuse it for enum

There doesn't seem to be any unit tests covering this, but the old code
was wrong because it didn't replace periods used as namespace separators
with underscores, which resulted in periods appearing in the output when
nested namespace were used.

Fix this and also reuse the now fixed getNamespacedName() in
getEnumName() which contained its own buggy version of the same code.
This commit is contained in:
Vadim Zeitlin 2019-08-05 02:03:58 +02:00
commit bd02ba19d8

View file

@ -155,10 +155,12 @@ public:
String *nspace = Getattr(n, "sym:nspace");
if (nspace) {
// FIXME: using namespace as class name is a hack.
proxyname = Swig_name_member(NULL, nspace, symname);
String *nspace_mangled = Copy(nspace);
Replaceall(nspace_mangled, ".", "_");
proxyname = NewStringf("%s_%s", nspace_mangled, symname);
Delete(nspace_mangled);
} else {
proxyname = Copy(symname);
proxyname = Copy(symname);
}
Setattr(n, "proxyname", proxyname);
@ -207,12 +209,7 @@ public:
Delete(proxyname);
} else {
// global enum or enum in a namespace
String *nspace = Getattr(n, "sym:nspace");
if (nspace) {
enumname = NewStringf("%s_%s", nspace, symname);
} else {
enumname = Copy(symname);
}
enumname = getNamespacedName(n);
}
Setattr(n, "enumname", enumname);
Delete(enumname);