diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2022-03-28 09:16:46 +0100 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2022-03-28 19:25:17 +0100 |
commit | e1e4e4df285bfdb2de3de49cf2409783de4ae79a (patch) | |
tree | a5af06131ed8511c4b6cc29d8936241be3aa880d /Lib/d | |
parent | 2ded25d138ba51152087aebde9ab5c2d685519fc (diff) | |
download | swig-e1e4e4df285bfdb2de3de49cf2409783de4ae79a.tar.gz |
Add rvalue reference typemaps for D
Diffstat (limited to 'Lib/d')
-rw-r--r-- | Lib/d/dswigtype.swg | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/Lib/d/dswigtype.swg b/Lib/d/dswigtype.swg index f0d604b6f..1d97cb089 100644 --- a/Lib/d/dswigtype.swg +++ b/Lib/d/dswigtype.swg @@ -20,6 +20,10 @@ %typemap(imtype) SWIGTYPE & "void*" %typemap(dtype, nativepointer="$dtype") SWIGTYPE & "$dclassname" +%typemap(ctype) SWIGTYPE && "void *" +%typemap(imtype) SWIGTYPE && "void*" +%typemap(dtype, nativepointer="$dtype") SWIGTYPE && "$dclassname" + %typemap(ctype) SWIGTYPE *const& "void *" %typemap(imtype) SWIGTYPE *const& "void*" %typemap(dtype) SWIGTYPE *const& "$*dclassname" @@ -28,6 +32,7 @@ SWIGTYPE, SWIGTYPE *, SWIGTYPE &, + SWIGTYPE &&, SWIGTYPE [], SWIGTYPE *const& "" @@ -149,6 +154,43 @@ /* + * Rvalue reference conversion typemaps. + */ + +%typemap(in, canthrow=1) SWIGTYPE && %{ $1 = ($1_ltype)$input; + if (!$1) { + SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "$1_type type is null"); + return $null; + } %} +%typemap(out) SWIGTYPE && "$result = (void *)$1;" + +%typemap(directorin) SWIGTYPE && + "$input = ($1_ltype) &$1;" +%typemap(directorout, warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG) SWIGTYPE && +%{ if (!$input) { + SWIG_DSetPendingException(SWIG_DIllegalArgumentException, "Unexpected null return for type $1_type"); + return $null; + } + $result = ($1_ltype)$input; %} + +%typemap(ddirectorin, + nativepointer="cast($dtype)$winput" +) SWIGTYPE && "new $dclassname($winput, false)" +%typemap(ddirectorout, + nativepointer="cast(void*)$dcall" +) SWIGTYPE && "$dclassname.swigGetCPtr($dcall)" + +%typemap(din, + nativepointer="cast(void*)$dinput" +) SWIGTYPE && "$dclassname.swigGetCPtr($dinput)" +%typemap(dout, excode=SWIGEXCODE, + nativepointer="{\n auto ret = cast($dtype)$imcall;$excode\n return ret;\n}") SWIGTYPE && { + $dclassname ret = new $dclassname($imcall, $owner);$excode + return ret; +} + + +/* * Array conversion typemaps. */ @@ -164,6 +206,7 @@ // Treat references to arrays like references to a single element. %apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) } +%apply SWIGTYPE && { SWIGTYPE ((&&)[ANY]) } /* |