diff --git a/SWIG/Examples/test-suite/director_protected.i b/SWIG/Examples/test-suite/director_protected.i index cb59264f3..d3f670837 100644 --- a/SWIG/Examples/test-suite/director_protected.i +++ b/SWIG/Examples/test-suite/director_protected.i @@ -123,6 +123,7 @@ class FooBar : private Foo virtual ~AA() {}; protected: virtual void draw() {}; + virtual void plot() {}; }; class BB : public AA { @@ -132,6 +133,9 @@ class FooBar : private Foo protected: void draw() {}; void draw(int arg1) {}; + + void plot(int arg1) {}; + void plot() {}; }; %} diff --git a/SWIG/Examples/test-suite/python/director_abstract_runme.py b/SWIG/Examples/test-suite/python/director_abstract_runme.py index df8a2fa44..7e03beb9f 100644 --- a/SWIG/Examples/test-suite/python/director_abstract_runme.py +++ b/SWIG/Examples/test-suite/python/director_abstract_runme.py @@ -60,3 +60,9 @@ try: except: error = 0 if (error): raise RuntimeError + + +try: + f = director_abstract.A.f +except: + raise RuntimeError diff --git a/SWIG/Source/Modules/lang.cxx b/SWIG/Source/Modules/lang.cxx index dfb081655..6e3effafe 100644 --- a/SWIG/Source/Modules/lang.cxx +++ b/SWIG/Source/Modules/lang.cxx @@ -765,9 +765,17 @@ int Language::cDeclaration(Node *n) { if (!isfriend ) { /* we check what director needs. If the method is pure virtual, it is always needed. */ - if (!(directorsEnabled() && Getattr(n,"director")) ) { + if (!(directorsEnabled() && is_member_director(CurrentClass,n) && need_nonpublic_member(n))) { return SWIG_NOWRAP; } + /* prevent wrapping the method twice due to overload */ + String *wrapname = NewStringf("nonpublic_%s%s",Getattr(n,"sym:name"), Getattr(n,"sym:overname")); + if (Getattr(CurrentClass,wrapname)) { + Delete(wrapname); + return SWIG_NOWRAP; + } + SetFlag(CurrentClass,wrapname); + Delete(wrapname); } } @@ -2305,8 +2313,7 @@ int Language::classHandler(Node *n) { if (Strcmp(type,"cdecl") !=0 ) continue; String* methodname = Getattr(method,"sym:name"); String* wrapname = NewStringf("%s_%s", symname,methodname); - if (!Getattr(symbols,wrapname) - && (!is_public(method))) { + if (!Getattr(symbols,wrapname) && (!is_public(method))) { Node* m = Copy(method); Setattr(m, "director", "1"); Setattr(m,"parentNode", n);