Fix directorout typemaps which were causing undefined behaviour when returning pointers by reference.
Closes #1167
This commit is contained in:
parent
224bb9e023
commit
e86c881a70
6 changed files with 24 additions and 7 deletions
|
|
@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/
|
|||
Version 4.0.0 (in progress)
|
||||
===========================
|
||||
|
||||
2017-12-13: wsfulton
|
||||
Issue #1167 Fix directorout typemaps which were causing undefined behaviour when
|
||||
returning pointers by reference.
|
||||
|
||||
2017-12-08: olly
|
||||
[PHP] Use ZEND_MODULE_GLOBALS_ACCESSOR to access globals - this
|
||||
should make the generated code work with PHP 7.2.0.
|
||||
|
|
|
|||
|
|
@ -857,8 +857,10 @@ SWIGINTERN const char * SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
%{ $result = (void *)*$1; %}
|
||||
%typemap(directorin) SWIGTYPE *const&
|
||||
%{ $input = (void *) $1; %}
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *const&
|
||||
%{ $result = ($1_ltype)&$input; %}
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) SWIGTYPE *const&
|
||||
%{ static $*1_ltype swig_temp;
|
||||
swig_temp = ($*1_ltype)$input;
|
||||
$result = &swig_temp; %}
|
||||
%typemap(csdirectorin) SWIGTYPE *const& "($iminput == global::System.IntPtr.Zero) ? null : new $*csclassname($iminput, false)"
|
||||
%typemap(csdirectorout) SWIGTYPE *const& "$*csclassname.getCPtr($cscall).Handle"
|
||||
|
||||
|
|
|
|||
|
|
@ -185,7 +185,9 @@
|
|||
%typemap(directorin) SWIGTYPE *const&
|
||||
"$input = (void *) $1;"
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *const&
|
||||
"$result = ($1_ltype)&$input;"
|
||||
%{ static $*1_ltype swig_temp;
|
||||
swig_temp = ($*1_ltype)$input;
|
||||
$result = &swig_temp; %}
|
||||
%typemap(ddirectorin,
|
||||
nativepointer="cast($dtype)$winput"
|
||||
) SWIGTYPE *const& "($winput is null) ? null : new $*dclassname($winput, false)"
|
||||
|
|
|
|||
|
|
@ -380,6 +380,11 @@
|
|||
%typemap(directorout) SWIGTYPE &
|
||||
%{ *($&1_ltype)&$result = $input; %}
|
||||
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *const&
|
||||
%{ static $*1_ltype swig_temp;
|
||||
swig_temp = *($1_ltype)&$input;
|
||||
$result = &swig_temp; %}
|
||||
|
||||
%typemap(gotype) SWIGTYPE &&
|
||||
%{$gotypename%}
|
||||
|
||||
|
|
|
|||
|
|
@ -1183,8 +1183,10 @@ Swig::LocalRefGuard $1_refguard(jenv, $input); }
|
|||
%{ *($1_ltype)&$result = *$1; %}
|
||||
%typemap(directorin,descriptor="L$packagepath/$*javaclassname;") SWIGTYPE *const&
|
||||
%{ *(($1_ltype)&$input) = ($*1_ltype) $1; %}
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE *const&
|
||||
%{ $result = ($1_ltype)&$input; %}
|
||||
%typemap(directorout, warning=SWIGWARN_TYPEMAP_THREAD_UNSAFE_MSG) SWIGTYPE *const&
|
||||
%{ static $*1_ltype swig_temp;
|
||||
swig_temp = *($1_ltype)&$input;
|
||||
$result = &swig_temp; %}
|
||||
%typemap(javadirectorin) SWIGTYPE *const& "($jniinput == 0) ? null : new $*javaclassname($jniinput, false)"
|
||||
%typemap(javadirectorout) SWIGTYPE *const& "$*javaclassname.getCPtr($javacall)"
|
||||
|
||||
|
|
|
|||
|
|
@ -431,6 +431,7 @@
|
|||
}
|
||||
|
||||
/* directorout */
|
||||
|
||||
#if defined(__cplusplus) && defined(%implicitconv_flag)
|
||||
%typemap(directorout,noblock=1,implicitconv=1) SWIGTYPE (void * swig_argp, int swig_res = 0) {
|
||||
swig_res = SWIG_ConvertPtr($input,&swig_argp,$&descriptor, %convertptr_flags | %implicitconv_flag);
|
||||
|
|
@ -471,8 +472,9 @@
|
|||
if (!SWIG_IsOK(swig_res)) {
|
||||
%dirout_fail(swig_res,"$type");
|
||||
}
|
||||
$result = %reinterpret_cast(&swig_argp, $ltype);
|
||||
swig_acquire_ownership_obj(%as_voidptr(*$result), own /* & TODO: SWIG_POINTER_OWN */);
|
||||
$1_ltype swig_temp = new $*1_ltype(($*1_ltype)swig_argp);
|
||||
swig_acquire_ownership(swig_temp);
|
||||
$result = swig_temp;
|
||||
}
|
||||
%typemap(directorfree,noblock=1,match="directorout") SWIGTYPE *const& {
|
||||
if (director) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue