summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2009-01-13 07:09:27 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2009-01-13 07:09:27 +0000
commitd029d0a6275b3968ee7bed3098998d75484b982f (patch)
tree16c12bf8d061f94d82f3bbb23b11dc21efe44cbe
parente604e46b17213ae0ab64af04000ef8e7246e4d5a (diff)
downloadswig-d029d0a6275b3968ee7bed3098998d75484b982f.tar.gz
Fix compilation error when using directors on protected virtual overloaded methods reported by Sam Hendley.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11062 626c5289-ae23-0410-ae9c-e8d60b6d4f22
-rw-r--r--CHANGES.current8
-rw-r--r--Examples/test-suite/common.mk1
-rw-r--r--Examples/test-suite/director_protected_overloaded.i21
-rw-r--r--Source/Modules/lang.cxx13
4 files changed, 37 insertions, 6 deletions
diff --git a/CHANGES.current b/CHANGES.current
index 9410e51bd..ef8b9d798 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -3,8 +3,12 @@ Version 1.3.37 (30 December 2008)
2009-01-13: mgossage
[Lua] Added contract support for requiring that unsigned numbers are >=0
- Rewrote much of Examples/Lua/embed3.
- Added a lot of to the Lua documentation.
+ Rewrote much of Examples/Lua/embed3.
+ Added a lot to the Lua documentation.
+
+2009-01-13: wsfulton
+ Fix compilation error when using directors on protected virtual overloaded
+ methods reported by Sam Hendley.
2009-01-12: drjoe
Fixed handling of integer arrays
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 90eca082a..bca58e75b 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -166,6 +166,7 @@ CPP_TEST_CASES += \
director_overload \
director_primitives \
director_protected \
+ director_protected_overloaded \
director_redefined \
director_thread \
director_unroll \
diff --git a/Examples/test-suite/director_protected_overloaded.i b/Examples/test-suite/director_protected_overloaded.i
new file mode 100644
index 000000000..a9f786fc7
--- /dev/null
+++ b/Examples/test-suite/director_protected_overloaded.i
@@ -0,0 +1,21 @@
+%module(directors="1",dirprot="1") director_protected_overloaded
+
+%director IDataObserver;
+%director DerivedDataObserver;
+
+// protected overloaded methods
+%inline %{
+ class IDataObserver
+ {
+ public:
+ virtual ~IDataObserver(){}
+
+ protected:
+ virtual void notoverloaded() = 0;
+ virtual void isoverloaded() = 0;
+ virtual void isoverloaded(int i) = 0;
+ virtual void isoverloaded(int i, double d) = 0;
+ };
+ class DerivedDataObserver : public IDataObserver {
+ };
+%}
diff --git a/Source/Modules/lang.cxx b/Source/Modules/lang.cxx
index db8923074..39ede8243 100644
--- a/Source/Modules/lang.cxx
+++ b/Source/Modules/lang.cxx
@@ -830,9 +830,8 @@ int Language::cDeclaration(Node *n) {
if (!(directorsEnabled() && ((is_member_director(CurrentClass, n) && need_nonpublic_member(n)) || is_non_virtual_protected_access(n)))) {
return SWIG_NOWRAP;
}
-#if 0
-// I don't see why this is needed - WSF
- /* prevent wrapping the method twice due to overload */
+ // Prevent wrapping protected overloaded director methods more than once -
+ // This bit of code is only needed due to the cDeclaration call in classHandler()
String *wrapname = NewStringf("nonpublic_%s%s", symname, Getattr(n, "sym:overname"));
if (Getattr(CurrentClass, wrapname)) {
Delete(wrapname);
@@ -840,7 +839,6 @@ int Language::cDeclaration(Node *n) {
}
SetFlag(CurrentClass, wrapname);
Delete(wrapname);
-#endif
}
}
@@ -2476,6 +2474,13 @@ int Language::classHandler(Node *n) {
Node *m = Copy(method);
Setattr(m, "director", "1");
Setattr(m, "parentNode", n);
+ /*
+ * There is a bug that needs fixing still...
+ * This area of code is creating methods which have not been overidden in a derived class (director methods that are protected in the base)
+ * If the method is overloaded, then Swig_overload_dispatch() incorrectly generates a call to the base wrapper, _wrap_xxx method
+ * See director_protected_overloaded.i - Possibly sym:overname needs correcting here.
+ Printf(stdout, "new method: %s::%s(%s)\n", Getattr(parentNode(m), "name"), Getattr(m, "name"), ParmList_str_defaultargs(Getattr(m, "parms")));
+ */
cDeclaration(m);
Delete(m);
}