Fix directorout typemap for const TYPE &

Previous we were returning a pointer or reference to a local
variable.
This commit is contained in:
Olly Betts 2021-04-15 12:50:32 +12:00
commit 97733543e2

View file

@ -79,12 +79,21 @@
CONVERT_IN($result, $1_ltype, *$input);
}
%}
%typemap(directorout) const TYPE & ($*1_ltype temp)
%typemap(directorout) const TYPE &
%{
$*1_ltype swig_val;
if (!EG(exception)) {
CONVERT_IN(temp, $*1_ltype, *$input);
CONVERT_IN(swig_val, $*1_ltype, *$input);
$1_ltype temp = new $*1_ltype(($*1_ltype)swig_val);
swig_acquire_ownership(temp);
$result = temp;
}
%}
%typemap(directorfree) const TYPE &
%{
if (director) {
director->swig_release_ownership(%as_voidptr($input));
}
$result = &temp;
%}
%enddef