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
This commit is contained in:
William S Fulton 2022-10-10 19:51:08 +01:00
parent 0239ba5536
commit 2268d6ee96
5 changed files with 36 additions and 2 deletions

View File

@ -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.

View File

@ -216,6 +216,7 @@ CPP_TEST_CASES += \
director_ref \
director_simple \
director_smartptr \
director_template \
director_thread \
director_unroll \
director_unwrap_result \

View File

@ -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);
}
%}

View File

@ -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 ""

View File

@ -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 * {