Fix for SourceForge Bug #1278

* Modify test-suite to test Java directors with multi-level namespaces.
* Path java module to correctly generate method descriptors when multilevel namespaces are used.
This commit is contained in:
Brant K. Kyser 2013-01-02 15:07:56 -06:00
commit 7ff0dfe426
4 changed files with 70 additions and 52 deletions

7
.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
# Compiled Source
*.o
*.class
# Local PCRE
prce
*.gz

View file

@ -8,6 +8,8 @@ SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
%{ %{
#include <string> #include <string>
namespace TopLevel
{
namespace Bar namespace Bar
{ {
class FooBar { class FooBar {
@ -31,6 +33,7 @@ namespace Bar
static Foo* get_self(Foo *self_) {return self_;} static Foo* get_self(Foo *self_) {return self_;}
}; };
} }
}
%} %}
@ -38,14 +41,16 @@ namespace Bar
// nspace feature only supported by these languages // nspace feature only supported by these languages
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD) #if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
%nspace Bar::Foo; %nspace TopLevel::Bar::Foo;
%nspace Bar::FooBar; %nspace TopLevel::Bar::FooBar;
#else #else
#warning nspace feature not yet supported in this target language #warning nspace feature not yet supported in this target language
#endif #endif
%feature("director") Bar::Foo; %feature("director") TopLevel::Bar::Foo;
namespace TopLevel
{
namespace Bar namespace Bar
{ {
class FooBar { class FooBar {
@ -71,3 +76,4 @@ namespace Bar
static Foo* get_self(Foo *self_); static Foo* get_self(Foo *self_);
}; };
} }
}

View file

@ -19,7 +19,7 @@ public class director_nspace_runme {
} }
class director_nspace_MyBarFoo extends director_nspacePackage.Bar.Foo { class director_nspace_MyBarFoo extends director_nspacePackage.TopLevel.Bar.Foo {
@Override @Override
public String ping() { public String ping() {
@ -32,17 +32,17 @@ class director_nspace_MyBarFoo extends director_nspacePackage.Bar.Foo {
} }
@Override @Override
public String fooBar(director_nspacePackage.Bar.FooBar fooBar) { public String fooBar(director_nspacePackage.TopLevel.Bar.FooBar fooBar) {
return fooBar.FooBarDo(); return fooBar.FooBarDo();
} }
@Override @Override
public director_nspacePackage.Bar.Foo makeFoo() { public director_nspacePackage.TopLevel.Bar.Foo makeFoo() {
return new director_nspacePackage.Bar.Foo(); return new director_nspacePackage.TopLevel.Bar.Foo();
} }
@Override @Override
public director_nspacePackage.Bar.FooBar makeFooBar() { public director_nspacePackage.TopLevel.Bar.FooBar makeFooBar() {
return new director_nspacePackage.Bar.FooBar(); return new director_nspacePackage.TopLevel.Bar.FooBar();
} }
} }

View file

@ -4253,8 +4253,13 @@ public:
Wrapper *w = NewWrapper(); Wrapper *w = NewWrapper();
if (Len(package_path) > 0) if (Len(package_path) > 0)
if (Len(getNSpace()) > 0) if (Len(getNSpace()) > 0) {
internal_classname = NewStringf("%s/%s/%s", package_path, getNSpace(), classname); internal_classname = NewStringf("%s/%s/%s", package_path, getNSpace(), classname);
// If the namespace is multiple levels, the result of getNSpace() will have inserted
// .'s to delimit namespaces, so we need to replace those with /'s
Replace(internal_classname, ".", "/", DOH_REPLACE_ANY);
}
else else
internal_classname = NewStringf("%s/%s", package_path, classname); internal_classname = NewStringf("%s/%s", package_path, classname);
else else