fixed the problem with 'using' and protected mebers. now it seems to be safe to generate the protected members as protected again. all the test are running and the director_protected_runme.rb now test for the right access control

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5526 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2003-12-09 23:46:39 +00:00
commit f7e02f46fc
3 changed files with 33 additions and 22 deletions

View file

@ -21,14 +21,11 @@ public:
} }
protected: protected:
#if defined(SWIGPYTHON) || defined(SWIGRUBY) \
|| defined(SWIGJAVA) || defined(SWIGOCAML)
virtual std::string ping() = 0; virtual std::string ping() = 0;
#else
virtual std::string ping() { return "";};
#endif
void hellom() {} void hellom() {}
virtual void used() {}
}; };
class Bar : public Foo class Bar : public Foo
@ -45,6 +42,8 @@ public:
int hello; int hello;
using Foo::used;
protected: protected:
std::string ping() { std::string ping() {
return "Bar::ping();"; return "Bar::ping();";

View file

@ -9,13 +9,26 @@ class FooBar < Director_protected::Bar
end end
end end
class Hello < FooBar
public
def pang
ping
end
end
b = Director_protected::Bar.new b = Director_protected::Bar.new
fb = FooBar.new fb = FooBar.new
p = 0
begin begin
fb.ping b.ping
p = 1
rescue NoProtectedError rescue NoProtectedError
end end
h = Hello.new
raise RuntimeError if p == 1
raise RuntimeError if b.pong != "Bar::pong();Foo::pong();Bar::ping();" raise RuntimeError if b.pong != "Bar::pong();Foo::pong();Bar::ping();"
raise RuntimeError if fb.pong != "Bar::pong();Foo::pong();FooBar::ping();" raise RuntimeError if fb.pong != "Bar::pong();Foo::pong();FooBar::ping();"
raise RuntimeError if h.pang != "FooBar::ping();"

View file

@ -13,6 +13,7 @@
char cvsroot_ruby_cxx[] = "$Header$"; char cvsroot_ruby_cxx[] = "$Header$";
#include "swigmod.h" #include "swigmod.h"
#define SWIG_PROTECTED_TARGET_METHODS 1
#ifndef MACSWIG #ifndef MACSWIG
#include "swigconfig.h" #include "swigconfig.h"
@ -599,23 +600,21 @@ public:
switch (current) { switch (current) {
case MEMBER_FUNC: case MEMBER_FUNC:
if (multipleInheritance) { {
/* #ifdef SWIG_PROTECTED_TARGET_METHODS
const char* rb_define_method = !is_protected(n) ? const char* rb_define_method = is_protected(n) ?
"rb_define_method" : "rb_define_protected_method"; "rb_define_protected_method" : "rb_define_method";
*/ #else
const char* rb_define_method = "rb_define_method"; const char* rb_define_method = "rb_define_method";
Printv(klass->init, tab4, rb_define_method,"(", klass->mImpl, ", \"", #endif
iname, "\", ", wname, ", -1);\n", NIL); if (multipleInheritance) {
} else { Printv(klass->init, tab4, rb_define_method,"(", klass->mImpl, ", \"",
/* iname, "\", ", wname, ", -1);\n", NIL);
const char* rb_define_method = !is_protected(n) ? } else {
"rb_define_method" : "rb_define_protected_method"; Printv(klass->init, tab4, rb_define_method, "(", klass->vname, ", \"",
*/ iname, "\", ", wname, ", -1);\n", NIL);
const char* rb_define_method = "rb_define_method"; }
Printv(klass->init, tab4, rb_define_method, "(", klass->vname, ", \"", }
iname, "\", ", wname, ", -1);\n", NIL);
}
break; break;
case CONSTRUCTOR_ALLOCATE: case CONSTRUCTOR_ALLOCATE:
Printv(s, tab4, "rb_define_alloc_func(", klass->vname, ", ", alloc_func, ");\n", NIL); Printv(s, tab4, "rb_define_alloc_func(", klass->vname, ", ", alloc_func, ");\n", NIL);