summaryrefslogtreecommitdiff
path: root/Lib/typemaps
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2013-01-24 20:23:54 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2013-01-24 20:27:29 +0000
commitac74c90fb03b9ce91db0c8d839d52afa3bbc3db8 (patch)
treee958297031abbf27e76c8b75dceb838f7b360df2 /Lib/typemaps
parentd3769a1fd42c8a54f178ed7a712fa1a513f57733 (diff)
downloadswig-ac74c90fb03b9ce91db0c8d839d52afa3bbc3db8.tar.gz
Add rvalue reference typemaps
Diffstat (limited to 'Lib/typemaps')
-rw-r--r--Lib/typemaps/enumint.swg15
-rw-r--r--Lib/typemaps/swigtype.swg95
2 files changed, 106 insertions, 4 deletions
diff --git a/Lib/typemaps/enumint.swg b/Lib/typemaps/enumint.swg
index 854d6f3e1..d048bb6bf 100644
--- a/Lib/typemaps/enumint.swg
+++ b/Lib/typemaps/enumint.swg
@@ -3,9 +3,20 @@
* ------------------------------------------------------------ */
%apply int { enum SWIGTYPE };
-%apply const int& { const enum SWIGTYPE& };
+%apply const int& { const enum SWIGTYPE & };
+%apply const int& { const enum SWIGTYPE && };
-%typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE& (int val, int ecode, $basetype temp) {
+%typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE & (int val, int ecode, $basetype temp) {
+ ecode = SWIG_AsVal(int)($input, &val);
+ if (!SWIG_IsOK(ecode)) {
+ %argument_fail(ecode, "$type", $symname, $argnum);
+ } else {
+ temp = %static_cast(val,$basetype);
+ $1 = &temp;
+ }
+}
+
+%typemap(in,fragment=SWIG_AsVal_frag(int),noblock=1) const enum SWIGTYPE && (int val, int ecode, $basetype temp) {
ecode = SWIG_AsVal(int)($input, &val);
if (!SWIG_IsOK(ecode)) {
%argument_fail(ecode, "$type", $symname, $argnum);
diff --git a/Lib/typemaps/swigtype.swg b/Lib/typemaps/swigtype.swg
index f57766962..6155a8abc 100644
--- a/Lib/typemaps/swigtype.swg
+++ b/Lib/typemaps/swigtype.swg
@@ -67,6 +67,41 @@
}
#endif
+/* Rvalue reference */
+%typemap(in, noblock=1) SWIGTYPE && (void *argp = 0, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ $1 = %reinterpret_cast(argp, $ltype);
+}
+%typemap(freearg) SWIGTYPE && "";
+
+#if defined(__cplusplus) && defined(%implicitconv_flag)
+%typemap(in,noblock=1,implicitconv=1) const SWIGTYPE && (void *argp = 0, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags | %implicitconv_flag);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ $1 = %reinterpret_cast(argp, $ltype);
+}
+%typemap(freearg,noblock=1,match="in",implicitconv=1) const SWIGTYPE &&
+{
+ if (SWIG_IsNewObj(res$argnum)) %delete($1);
+}
+#else
+%typemap(in,noblock=1) const SWIGTYPE && (void *argp, int res = 0) {
+ res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %argument_fail(res, "$type", $symname, $argnum);
+ }
+ if (!argp) { %argument_nullref("$type", $symname, $argnum); }
+ $1 = %reinterpret_cast(argp, $ltype);
+}
+#endif
+
/* By value */
#if defined(__cplusplus) && defined(%implicitconv_flag)
%typemap(in,implicitconv=1) SWIGTYPE (void *argp, int res = 0) {
@@ -102,7 +137,7 @@
* ----------------------------------------------------------------------------- */
/* Pointers, references */
-%typemap(out,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE[] {
+%typemap(out,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE[] {
%set_output(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, $owner | %newpointer_flags));
}
@@ -235,6 +270,18 @@
$1 = *(%reinterpret_cast(argp, $ltype));
}
+%typemap(varin,warning=SWIGWARN_TYPEMAP_SWIGTYPELEAK_MSG) SWIGTYPE && {
+ void *argp = 0;
+ int res = SWIG_ConvertPtr($input, &argp, $descriptor, %convertptr_flags);
+ if (!SWIG_IsOK(res)) {
+ %variable_fail(res, "$type", "$name");
+ }
+ if (!argp) {
+ %variable_nullref("$type", "$name");
+ }
+ $1 = *(%reinterpret_cast(argp, $ltype));
+}
+
#if defined(__cplusplus) && defined(%implicitconv_flag)
%typemap(varin,implicitconv=1) SWIGTYPE {
void *argp = 0;
@@ -284,6 +331,10 @@
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags));
}
+%typemap(varout, noblock=1) SWIGTYPE && {
+ %set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $descriptor, %newpointer_flags));
+}
+
/* Value */
%typemap(varout, noblock=1) SWIGTYPE {
%set_varoutput(SWIG_NewPointerObj(%as_voidptr(&$1), $&descriptor, %newpointer_flags));
@@ -311,12 +362,23 @@
$1 = SWIG_CheckState(res);
}
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE && {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
+ $1 = SWIG_CheckState(res);
+}
+
#if defined(__cplusplus) && defined(%implicitconv_flag)
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE & {
int res = SWIG_ConvertPtr($input, 0, $descriptor, %implicitconv_flag);
$1 = SWIG_CheckState(res);
}
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) const SWIGTYPE && {
+ int res = SWIG_ConvertPtr($input, 0, $descriptor, %implicitconv_flag);
+ $1 = SWIG_CheckState(res);
+}
+
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1,implicitconv=1) SWIGTYPE {
int res = SWIG_ConvertPtr($input, 0, $&descriptor, %implicitconv_flag);
$1 = SWIG_CheckState(res);
@@ -327,6 +389,11 @@
int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
$1 = SWIG_CheckState(res);
}
+%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) const SWIGTYPE && {
+ void *vptr = 0;
+ int res = SWIG_ConvertPtr($input, &vptr, $descriptor, 0);
+ $1 = SWIG_CheckState(res);
+}
%typemap(typecheck,precedence=SWIG_TYPECHECK_POINTER,noblock=1) SWIGTYPE {
void *vptr = 0;
@@ -355,6 +422,10 @@
$input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $descriptor, %newpointer_flags);
}
+%typemap(directorin,noblock=1) SWIGTYPE && {
+ $input = SWIG_NewPointerObj(%as_voidptr(&$1_name), $descriptor, %newpointer_flags);
+}
+
/* directorout */
#if defined(__cplusplus) && defined(%implicitconv_flag)
%typemap(directorout,noblock=1,implicitconv=1) SWIGTYPE (void * swig_argp, int swig_res = 0) {
@@ -406,6 +477,22 @@
}
}
+%typemap(directorout,noblock=1,warning=SWIGWARN_TYPEMAP_DIRECTOROUT_PTR_MSG)
+ SWIGTYPE &&(void *swig_argp, int swig_res, swig_owntype own) {
+ swig_res = SWIG_ConvertPtrAndOwn($input, &swig_argp, $descriptor, %convertptr_flags | SWIG_POINTER_DISOWN, &own);
+ if (!SWIG_IsOK(swig_res)) {
+ %dirout_fail(swig_res,"$type");
+ }
+ if (!swig_argp) { %dirout_nullref("$type"); }
+ $result = %reinterpret_cast(swig_argp, $ltype);
+ swig_acquire_ownership_obj(%as_voidptr($result), own /* & TODO: SWIG_POINTER_OWN */);
+}
+%typemap(directorfree,noblock=1,match="directorout") SWIGTYPE && {
+ if (director) {
+ SWIG_AcquirePtr($result, director->swig_release_ownership(%as_voidptr($input)));
+ }
+}
+
#endif /* SWIG_DIRECTOR_TYPEMAPS */
@@ -413,7 +500,7 @@
* --- Constants ---
* ------------------------------------------------------------ */
-%typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
+%typemap(constcode,noblock=1) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
%set_constant("$symname", SWIG_NewPointerObj(%as_voidptr($value),$descriptor,%newpointer_flags));
}
@@ -441,6 +528,10 @@
%raise(SWIG_NewPointerObj(%as_voidptr(&$1),$descriptor,0), "$type", $descriptor);
}
+%typemap(throws,noblock=1) SWIGTYPE && {
+ %raise(SWIG_NewPointerObj(%as_voidptr(&$1),$descriptor,0), "$type", $descriptor);
+}
+
%typemap(throws,noblock=1) (...) {
SWIG_exception_fail(SWIG_RuntimeError,"unknown exception");
}