mirror of https://github.com/swig/swig
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:
parent
0239ba5536
commit
2268d6ee96
|
@ -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)
|
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
|
2022-10-10: treitmayr, wsfulton
|
||||||
[Python, Ruby] #1811 #1823 Fix invalid code generated in some cases when
|
[Python, Ruby] #1811 #1823 Fix invalid code generated in some cases when
|
||||||
returning a pointer or reference to a director-enabled class instance.
|
returning a pointer or reference to a director-enabled class instance.
|
||||||
|
|
|
@ -216,6 +216,7 @@ CPP_TEST_CASES += \
|
||||||
director_ref \
|
director_ref \
|
||||||
director_simple \
|
director_simple \
|
||||||
director_smartptr \
|
director_smartptr \
|
||||||
|
director_template \
|
||||||
director_thread \
|
director_thread \
|
||||||
director_unroll \
|
director_unroll \
|
||||||
director_unwrap_result \
|
director_unwrap_result \
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
%}
|
|
@ -473,7 +473,7 @@
|
||||||
%typemap(directorin) SWIGTYPE
|
%typemap(directorin) SWIGTYPE
|
||||||
%{
|
%{
|
||||||
ZVAL_UNDEF($input);
|
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 ""
|
%typemap(out, phptype="void") void ""
|
||||||
|
|
|
@ -390,7 +390,7 @@
|
||||||
/* directorin */
|
/* directorin */
|
||||||
|
|
||||||
%typemap(directorin,noblock=1) SWIGTYPE {
|
%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 * {
|
%typemap(directorin,noblock=1) SWIGTYPE * {
|
||||||
|
|
Loading…
Reference in New Issue