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 +%} + +%include + +%feature("director") HandleBytes; + +%inline %{ + template class TwoTemplateParms {}; +%} + +%template(TT_int_double) TwoTemplateParms; + +%inline %{ + class HandleBytes { + public: + virtual void handle(const std::vector data) = 0; // Note: not instantiated with %template + virtual void handle2(TwoTemplateParms data) = 0; + virtual ~HandleBytes() {} + }; + + void bytes_wrapper(const std::vector 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 * {