diff options
author | William S Fulton <wsf@fultondesigns.co.uk> | 2019-02-15 19:06:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-15 19:06:05 +0000 |
commit | dd8c3e14668525d570cb3a514aae6126edac48c4 (patch) | |
tree | 755c59dde5cf8e106f845991f90224298a7d1f32 /Lib/ocaml | |
parent | e04da08093416cea4cdfb9ba64ff1ba02918cab7 (diff) | |
parent | b2d93665fe293508f2e9970198e09c5fd8d4d949 (diff) | |
download | swig-dd8c3e14668525d570cb3a514aae6126edac48c4.tar.gz |
Merge pull request #1461 from ZackerySpytz/OCaml-argout-typemaps-ref-types
[OCaml] Don't use argout typemaps by default for some reference types
Diffstat (limited to 'Lib/ocaml')
-rw-r--r-- | Lib/ocaml/ocaml.swg | 9 | ||||
-rw-r--r-- | Lib/ocaml/typemaps.i | 38 |
2 files changed, 18 insertions, 29 deletions
diff --git a/Lib/ocaml/ocaml.swg b/Lib/ocaml/ocaml.swg index 192a181cf..2da3fb769 100644 --- a/Lib/ocaml/ocaml.swg +++ b/Lib/ocaml/ocaml.swg @@ -459,15 +459,6 @@ extern "C" { } if( !Is_block(v) ) return -1; switch( SWIG_Tag_val(v) ) { - case C_int: - if( !caml_long_val( v ) ) { - *out = 0; - CAMLreturn_type(0); - } else { - *out = 0; - CAMLreturn_type(1); - } - break; case C_obj: if (!func_val) { func_val = caml_named_value("caml_obj_ptr"); diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index 4475707d6..af60d2422 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -52,10 +52,14 @@ $1 = *(($ltype) caml_ptr_val($input,$1_descriptor)); } -%typemap(out) SWIGTYPE &, SWIGTYPE && { +%typemap(varout) SWIGTYPE &, SWIGTYPE && { $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)&$1, $1_descriptor); } +%typemap(out) SWIGTYPE &, SWIGTYPE && { + $result = SWIG_Ocaml_ptr_to_val("create_$ntype_from_ptr", (void *)$1, $1_descriptor); +} + #if 0 %typemap(argout) SWIGTYPE & { CAML_VALUE *fromval = caml_named_value("create_$ntype_from_ptr"); @@ -85,9 +89,6 @@ } #endif -%typemap(argout) const SWIGTYPE & { } -%typemap(argout) const SWIGTYPE && { } - %typemap(in) SWIGTYPE { $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; } @@ -123,26 +124,26 @@ /* The SIMPLE_MAP macro below defines the whole set of typemaps needed for simple types. */ -%define SIMPLE_MAP(C_NAME, C_TO_MZ, MZ_TO_C) +%define SIMPLE_MAP(C_NAME, C_TO_OCAML, OCAML_TO_C) /* In */ %typemap(in) C_NAME { - $1 = MZ_TO_C($input); + $1 = OCAML_TO_C($input); } %typemap(varin) C_NAME { - $1 = MZ_TO_C($input); + $1 = OCAML_TO_C($input); } %typemap(in) C_NAME & ($*1_ltype temp) { - temp = ($*1_ltype) MZ_TO_C($input); + temp = ($*1_ltype) OCAML_TO_C($input); $1 = &temp; } %typemap(varin) C_NAME & { - $1 = MZ_TO_C($input); + $1 = OCAML_TO_C($input); } %typemap(directorout) C_NAME { - $1 = MZ_TO_C($input); + $1 = OCAML_TO_C($input); } %typemap(in) C_NAME *INPUT ($*1_ltype temp) { - temp = ($*1_ltype) MZ_TO_C($input); + temp = ($*1_ltype) OCAML_TO_C($input); $1 = &temp; } %typemap(in,numinputs=0) C_NAME *OUTPUT ($*1_ltype temp) { @@ -150,25 +151,22 @@ } /* Out */ %typemap(out) C_NAME { - $result = C_TO_MZ($1); + $result = C_TO_OCAML($1); } %typemap(varout) C_NAME { - $result = C_TO_MZ($1); + $result = C_TO_OCAML($1); } %typemap(varout) C_NAME & { - $result = C_TO_MZ($1); + $result = C_TO_OCAML($1); } %typemap(argout) C_NAME *OUTPUT { - swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); + swig_result = caml_list_append(swig_result, C_TO_OCAML((long)*$1)); } %typemap(out) C_NAME & { - $result = C_TO_MZ(*$1); -} -%typemap(argout) C_NAME & { - swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1)); + $result = C_TO_OCAML(*$1); } %typemap(directorin) C_NAME { - args = caml_list_append(args,C_TO_MZ($1)); + args = caml_list_append(args, C_TO_OCAML($1)); } %enddef |