mirror of https://github.com/swig/swig
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:
parent
ac75e4ae53
commit
7ff0dfe426
|
@ -0,0 +1,7 @@
|
|||
# Compiled Source
|
||||
*.o
|
||||
*.class
|
||||
|
||||
# Local PCRE
|
||||
prce
|
||||
*.gz
|
|
@ -8,28 +8,31 @@ SWIG_JAVABODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
|
|||
%{
|
||||
#include <string>
|
||||
|
||||
namespace Bar
|
||||
namespace TopLevel
|
||||
{
|
||||
class FooBar {
|
||||
public:
|
||||
FooBar() {}
|
||||
FooBar(const FooBar&) {}
|
||||
virtual ~FooBar() {}
|
||||
namespace Bar
|
||||
{
|
||||
class FooBar {
|
||||
public:
|
||||
FooBar() {}
|
||||
FooBar(const FooBar&) {}
|
||||
virtual ~FooBar() {}
|
||||
|
||||
std::string FooBarDo() { return "Bar::Foo2::Foo2Bar()"; }
|
||||
};
|
||||
|
||||
std::string FooBarDo() { return "Bar::Foo2::Foo2Bar()"; }
|
||||
};
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping() { return "Bar::Foo::ping()"; }
|
||||
virtual std::string pong() { return "Bar::Foo::pong();" + ping(); }
|
||||
virtual std::string fooBar(FooBar* fb) { return fb->FooBarDo(); }
|
||||
virtual Foo makeFoo() { return Foo(); }
|
||||
virtual FooBar makeFooBar() { return FooBar(); }
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
virtual ~Foo() {}
|
||||
virtual std::string ping() { return "Bar::Foo::ping()"; }
|
||||
virtual std::string pong() { return "Bar::Foo::pong();" + ping(); }
|
||||
virtual std::string fooBar(FooBar* fb) { return fb->FooBarDo(); }
|
||||
virtual Foo makeFoo() { return Foo(); }
|
||||
virtual FooBar makeFooBar() { return FooBar(); }
|
||||
|
||||
static Foo* get_self(Foo *self_) {return self_;}
|
||||
};
|
||||
static Foo* get_self(Foo *self_) {return self_;}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
@ -38,36 +41,39 @@ namespace Bar
|
|||
|
||||
// nspace feature only supported by these languages
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGD)
|
||||
%nspace Bar::Foo;
|
||||
%nspace Bar::FooBar;
|
||||
%nspace TopLevel::Bar::Foo;
|
||||
%nspace TopLevel::Bar::FooBar;
|
||||
#else
|
||||
#warning nspace feature not yet supported in this target language
|
||||
#endif
|
||||
|
||||
%feature("director") Bar::Foo;
|
||||
%feature("director") TopLevel::Bar::Foo;
|
||||
|
||||
namespace Bar
|
||||
{
|
||||
class FooBar {
|
||||
public:
|
||||
FooBar();
|
||||
FooBar(const FooBar&);
|
||||
virtual ~FooBar();
|
||||
namespace TopLevel
|
||||
{
|
||||
namespace Bar
|
||||
{
|
||||
class FooBar {
|
||||
public:
|
||||
FooBar();
|
||||
FooBar(const FooBar&);
|
||||
virtual ~FooBar();
|
||||
|
||||
std::string FooBarDo();
|
||||
|
||||
};
|
||||
|
||||
std::string FooBarDo();
|
||||
|
||||
};
|
||||
|
||||
class Foo
|
||||
{
|
||||
public:
|
||||
virtual ~Foo();
|
||||
virtual std::string ping();
|
||||
virtual std::string pong();
|
||||
virtual std::string fooBar(FooBar* fb);
|
||||
virtual Foo makeFoo();
|
||||
virtual FooBar makeFooBar();
|
||||
|
||||
static Foo* get_self(Foo *self_);
|
||||
};
|
||||
class Foo
|
||||
{
|
||||
public:
|
||||
virtual ~Foo();
|
||||
virtual std::string ping();
|
||||
virtual std::string pong();
|
||||
virtual std::string fooBar(FooBar* fb);
|
||||
virtual Foo makeFoo();
|
||||
virtual FooBar makeFooBar();
|
||||
|
||||
static Foo* get_self(Foo *self_);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
public String ping() {
|
||||
|
@ -32,17 +32,17 @@ class director_nspace_MyBarFoo extends director_nspacePackage.Bar.Foo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String fooBar(director_nspacePackage.Bar.FooBar fooBar) {
|
||||
public String fooBar(director_nspacePackage.TopLevel.Bar.FooBar fooBar) {
|
||||
return fooBar.FooBarDo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public director_nspacePackage.Bar.Foo makeFoo() {
|
||||
return new director_nspacePackage.Bar.Foo();
|
||||
public director_nspacePackage.TopLevel.Bar.Foo makeFoo() {
|
||||
return new director_nspacePackage.TopLevel.Bar.Foo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public director_nspacePackage.Bar.FooBar makeFooBar() {
|
||||
return new director_nspacePackage.Bar.FooBar();
|
||||
public director_nspacePackage.TopLevel.Bar.FooBar makeFooBar() {
|
||||
return new director_nspacePackage.TopLevel.Bar.FooBar();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4253,8 +4253,13 @@ public:
|
|||
Wrapper *w = NewWrapper();
|
||||
|
||||
if (Len(package_path) > 0)
|
||||
if (Len(getNSpace()) > 0)
|
||||
if (Len(getNSpace()) > 0) {
|
||||
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
|
||||
internal_classname = NewStringf("%s/%s", package_path, classname);
|
||||
else
|
||||
|
|
Loading…
Reference in New Issue