diff options
author | Olly Betts <olly@survex.com> | 2021-04-15 12:50:32 +1200 |
---|---|---|
committer | Olly Betts <olly@survex.com> | 2021-04-15 12:50:32 +1200 |
commit | 97733543e2c267c1f54560a50ff61ffab4f15419 (patch) | |
tree | fb68fa24ff29699e3545a1e7e3c4ec9d21648a5a | |
parent | 451998f27ba9a89d1b2d9aadfecf914f8b55afb3 (diff) | |
download | swig-97733543e2c267c1f54560a50ff61ffab4f15419.tar.gz |
Fix directorout typemap for const TYPE &
Previous we were returning a pointer or reference to a local
variable.
-rw-r--r-- | Lib/php/utils.i | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/Lib/php/utils.i b/Lib/php/utils.i index ed6e08ff4..09507fc8b 100644 --- a/Lib/php/utils.i +++ b/Lib/php/utils.i @@ -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 |