diff --git a/Source/CParse/parser.y b/Source/CParse/parser.y index 40d853387..c6fe56b70 100644 --- a/Source/CParse/parser.y +++ b/Source/CParse/parser.y @@ -2676,7 +2676,8 @@ template_directive: SWIGTEMPLATE LPAREN idstringopt RPAREN idcolonnt LESSTHAN va Setattr(templnode,"sym:typename","1"); } /* for now, nested %template is allowed only in the same scope as the template declaration */ - if ($3 && !(currentOuterClass && (currentOuterClass != Getattr(nn, "nested:outer")))) { + if ($3 && !((currentOuterClass && (currentOuterClass != Getattr(nn, "nested:outer"))) + ||(extendmode && current_class && (current_class != Getattr(nn, "nested:outer"))))) { /* Comment this out for 1.3.28. We need to re-enable it later but first we need to diff --git a/Source/Modules/csharp.cxx b/Source/Modules/csharp.cxx index 3c765835e..1713e6f3f 100644 --- a/Source/Modules/csharp.cxx +++ b/Source/Modules/csharp.cxx @@ -1107,6 +1107,30 @@ public: return ret; } + + String *getCurrentScopeName(String *nspace) + { + String *scope = 0; + if (nspace || getCurrentClass()) { + scope = NewString(""); + if (nspace) + Printf(scope, "%s", nspace); + if (Node* cls = getCurrentClass()) + { + if (Node *outer = Getattr(cls, "nested:outer")) { + String *outerClassesPrefix = Copy(Getattr(outer, "sym:name")); + for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) { + Push(outerClassesPrefix, "."); + Push(outerClassesPrefix, Getattr(outer, "sym:name")); + } + Printv(scope, nspace ? "." : "", outerClassesPrefix, ".", proxy_class_name, NIL); + Delete(outerClassesPrefix); + } else + Printv(scope, nspace ? "." : "", proxy_class_name, NIL); + } + } + return scope; + } /* ---------------------------------------------------------------------- * enumDeclaration() @@ -1150,14 +1174,7 @@ public: if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) { // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper C# enum - String *scope = 0; - if (nspace || proxy_class_name) { - scope = NewString(""); - if (nspace) - Printf(scope, "%s", nspace); - if (proxy_class_name) - Printv(scope, nspace ? "." : "", proxy_class_name, NIL); - } + String *scope = getCurrentScopeName(nspace); if (!addSymbol(symname, n, scope)) return SWIG_ERROR; @@ -1305,12 +1322,11 @@ public: scope = Copy(module_class_name); } } else { - scope = NewString(""); - if (nspace) - Printf(scope, "%s.", nspace); - if (proxy_class_name) - Printf(scope, "%s.", proxy_class_name); - Printf(scope, "%s",Getattr(parent, "sym:name")); + scope = getCurrentScopeName(nspace); + if (!scope) + scope = Copy(Getattr(parent, "sym:name")); + else + Printf(scope, ".%s", Getattr(parent, "sym:name")); } if (!addSymbol(name, n, scope)) return SWIG_ERROR; diff --git a/Source/Modules/java.cxx b/Source/Modules/java.cxx index d378a02f3..c47dd3e48 100644 --- a/Source/Modules/java.cxx +++ b/Source/Modules/java.cxx @@ -1194,6 +1194,30 @@ public: return ret; } + String *getCurrentScopeName(String *nspace) + { + String *scope = 0; + if (nspace || getCurrentClass()) { + scope = NewString(""); + if (nspace) + Printf(scope, "%s", nspace); + if (Node* cls = getCurrentClass()) + { + if (Node *outer = Getattr(cls, "nested:outer")) { + String *outerClassesPrefix = Copy(Getattr(outer, "sym:name")); + for (outer = Getattr(outer, "nested:outer"); outer != 0; outer = Getattr(outer, "nested:outer")) { + Push(outerClassesPrefix, "."); + Push(outerClassesPrefix, Getattr(outer, "sym:name")); + } + Printv(scope, nspace ? "." : "", outerClassesPrefix, ".", proxy_class_name, NIL); + Delete(outerClassesPrefix); + } else + Printv(scope, nspace ? "." : "", proxy_class_name, NIL); + } + } + return scope; + } + /* ---------------------------------------------------------------------- * enumDeclaration() * @@ -1227,14 +1251,7 @@ public: if ((enum_feature != SimpleEnum) && symname && typemap_lookup_type) { // Wrap (non-anonymous) C/C++ enum within a typesafe, typeunsafe or proper Java enum - String *scope = 0; - if (nspace || proxy_class_name) { - scope = NewString(""); - if (nspace) - Printf(scope, "%s", nspace); - if (proxy_class_name) - Printv(scope, nspace ? "." : "", proxy_class_name, NIL); - } + String *scope = getCurrentScopeName(nspace); if (!addSymbol(symname, n, scope)) return SWIG_ERROR; @@ -1389,12 +1406,11 @@ public: scope = Copy(constants_interface_name); } } else { - scope = NewString(""); - if (nspace) - Printf(scope, "%s.", nspace); - if (proxy_class_name) - Printf(scope, "%s.", proxy_class_name); - Printf(scope, "%s",Getattr(parent, "sym:name")); + scope = getCurrentScopeName(nspace); + if (!scope) + scope = Copy(Getattr(parent, "sym:name")); + else + Printf(scope, ".%s", Getattr(parent, "sym:name")); } if (!addSymbol(name, n, scope)) return SWIG_ERROR; diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx index 795b9edb8..c3c148fa5 100644 --- a/Source/Modules/lang.cxx +++ b/Source/Modules/lang.cxx @@ -3620,4 +3620,3 @@ Language *Language::instance() { Hash *Language::getClassHash() const { return classhash; } -