diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2013-01-24 19:56:56 +0000 |
---|---|---|
committer | William S Fulton <wsf@fultondesigns.co.uk> | 2013-01-24 20:27:28 +0000 |
commit | 8bdfcda66ee58727097a9ff98d2f946e4da9a105 (patch) | |
tree | fedd501ef4f6f3949e88b07d8b783b088b2d591d | |
parent | 341a5366ddbbd2bc5747bdeb4c19b9e4ab3bb559 (diff) | |
download | swig-8bdfcda66ee58727097a9ff98d2f946e4da9a105.tar.gz |
Add rvalue reference typemaps
-rw-r--r-- | Lib/ocaml/typecheck.i | 2 | ||||
-rw-r--r-- | Lib/ocaml/typemaps.i | 36 |
2 files changed, 37 insertions, 1 deletions
diff --git a/Lib/ocaml/typecheck.i b/Lib/ocaml/typecheck.i index 4c3500690..a13e1552e 100644 --- a/Lib/ocaml/typecheck.i +++ b/Lib/ocaml/typecheck.i @@ -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); } diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index e5458a3e2..a729432d7 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -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 } |