summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2022-10-10 19:51:08 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2022-10-10 19:51:08 +0100
commit2268d6ee96a380f628169e364711cf38d3db1460 (patch)
treef52c7140ed5c19ebdd2f8997851ebc8ccddf3ca3
parent0239ba5536105bec1ac4c2386b10a300e9a483cd (diff)
downloadswig-2268d6ee96a380f628169e364711cf38d3db1460.tar.gz
Fix compile error when using directors
Fix when using templates with more than one template parameter and used as an input parameter in a virtual method in a director class (problem affecting most of the scripting languages). Fixes #2160
-rw-r--r--CHANGES.current5
-rw-r--r--Examples/test-suite/common.mk1
-rw-r--r--Examples/test-suite/director_template.i28
-rw-r--r--Lib/php/php.swg2
-rw-r--r--Lib/typemaps/swigtype.swg2
5 files changed, 36 insertions, 2 deletions
diff --git a/CHANGES.current b/CHANGES.current
index bc9f386d8..27caf2c1a 100644
--- a/CHANGES.current
+++ b/CHANGES.current
@@ -7,6 +7,11 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
Version 4.1.0 (in progress)
===========================
+2022-10-10: wsfulton
+ #2160 Fix compile error when using templates with more than one template
+ parameter and used as an input parameter in a virtual method in a
+ director class (problem affecting most of the scripting languages).
+
2022-10-10: treitmayr, wsfulton
[Python, Ruby] #1811 #1823 Fix invalid code generated in some cases when
returning a pointer or reference to a director-enabled class instance.
diff --git a/Examples/test-suite/common.mk b/Examples/test-suite/common.mk
index 2808763c7..1c70ece4c 100644
--- a/Examples/test-suite/common.mk
+++ b/Examples/test-suite/common.mk
@@ -216,6 +216,7 @@ CPP_TEST_CASES += \
director_ref \
director_simple \
director_smartptr \
+ director_template \
director_thread \
director_unroll \
director_unwrap_result \
diff --git a/Examples/test-suite/director_template.i b/Examples/test-suite/director_template.i
new file mode 100644
index 000000000..fdc5bfbd1
--- /dev/null
+++ b/Examples/test-suite/director_template.i
@@ -0,0 +1,28 @@
+%module(directors="1") director_template
+
+%{
+#include <vector>
+%}
+
+%include <std_vector.i>
+
+%feature("director") HandleBytes;
+
+%inline %{
+ template <typename X, typename Y> class TwoTemplateParms {};
+%}
+
+%template(TT_int_double) TwoTemplateParms<int, double>;
+
+%inline %{
+ class HandleBytes {
+ public:
+ virtual void handle(const std::vector<unsigned char> data) = 0; // Note: not instantiated with %template
+ virtual void handle2(TwoTemplateParms<int, double> data) = 0;
+ virtual ~HandleBytes() {}
+ };
+
+ void bytes_wrapper(const std::vector<unsigned char> data, HandleBytes *handler) {
+ handler->handle(data);
+ }
+%}
diff --git a/Lib/php/php.swg b/Lib/php/php.swg
index b22166593..e14401236 100644
--- a/Lib/php/php.swg
+++ b/Lib/php/php.swg
@@ -473,7 +473,7 @@
%typemap(directorin) SWIGTYPE
%{
ZVAL_UNDEF($input);
- SWIG_SetPointerZval($input, SWIG_as_voidptr(new $1_ltype(SWIG_STD_MOVE($1))), $&1_descriptor, 1);
+ SWIG_SetPointerZval($input, (new $1_ltype(SWIG_STD_MOVE($1))), $&1_descriptor, 1);
%}
%typemap(out, phptype="void") void ""
diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg
index 42c9c54eb..69f83794d 100644
--- a/Lib/typemaps/swigtype.swg
+++ b/Lib/typemaps/swigtype.swg
@@ -390,7 +390,7 @@
/* directorin */
%typemap(directorin,noblock=1) SWIGTYPE {
- $input = SWIG_NewPointerObj(%as_voidptr(new $1_ltype(SWIG_STD_MOVE($1))), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags);
+ $input = SWIG_NewPointerObj((new $1_ltype(SWIG_STD_MOVE($1))), $&descriptor, SWIG_POINTER_OWN | %newpointer_flags);
}
%typemap(directorin,noblock=1) SWIGTYPE * {