Add rvalue reference typemaps

This commit is contained in:
William S Fulton 2013-01-24 19:56:56 +00:00
commit 8bdfcda66e
2 changed files with 37 additions and 1 deletions

View file

@ -129,7 +129,7 @@
}
}
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
%typecheck(SWIG_TYPECHECK_POINTER) SWIGTYPE *, SWIGTYPE &, SWIGTYPE &&, SWIGTYPE [] {
void *ptr;
$1 = !caml_ptr_val_internal($input, &ptr,$descriptor);
}

View file

@ -34,11 +34,21 @@
$1 = ($ltype) caml_ptr_val($input,$1_descriptor);
}
%typemap(in) SWIGTYPE && {
/* %typemap(in) SWIGTYPE && */
$1 = ($ltype) caml_ptr_val($input,$1_descriptor);
}
%typemap(varin) SWIGTYPE & {
/* %typemap(varin) SWIGTYPE & */
$1 = *(($ltype) caml_ptr_val($input,$1_descriptor));
}
%typemap(varin) SWIGTYPE && {
/* %typemap(varin) SWIGTYPE && */
$1 = *(($ltype) caml_ptr_val($input,$1_descriptor));
}
%typemap(out) SWIGTYPE & {
/* %typemap(out) SWIGTYPE & */
CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
@ -49,6 +59,16 @@
}
}
%typemap(out) SWIGTYPE && {
/* %typemap(out) SWIGTYPE && */
CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
if( fromval ) {
$result = callback(*fromval,caml_val_ptr((void *) &$1,$1_descriptor));
} else {
$result = caml_val_ptr ((void *) &$1,$1_descriptor);
}
}
#if 0
%typemap(argout) SWIGTYPE & {
CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
@ -63,9 +83,23 @@
caml_val_ptr ((void *) $1,$1_descriptor));
}
}
%typemap(argout) SWIGTYPE && {
CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr");
if( fromval ) {
swig_result =
caml_list_append(swig_result,
callback(*fromval,caml_val_ptr((void *) $1,
$1_descriptor)));
} else {
swig_result =
caml_list_append(swig_result,
caml_val_ptr ((void *) $1,$1_descriptor));
}
}
#endif
%typemap(argout) const SWIGTYPE & { }
%typemap(argout) const SWIGTYPE && { }
%typemap(in) SWIGTYPE {
$1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ;
@ -101,6 +135,7 @@
}
%apply SWIGTYPE { const SWIGTYPE & };
%apply SWIGTYPE { const SWIGTYPE && };
#endif
@ -318,6 +353,7 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val);
/* Array reference typemaps */
%apply SWIGTYPE & { SWIGTYPE ((&)[ANY]) }
%apply SWIGTYPE && { SWIGTYPE ((&)[ANY]) }
/* const pointers */
%apply SWIGTYPE * { SWIGTYPE *const }