From d6cd52f5863bdb6494fa91b7d4ffa9dddca17cd3 Mon Sep 17 00:00:00 2001 From: William S Fulton Date: Fri, 11 Jan 2019 19:31:37 +0000 Subject: [PATCH] Fix OCAML typemap warnings wrapping C code Fixes: Lib/ocaml/typemaps.i:366: Warning 453: Can't apply (SWIGTYPE &). No typemaps are defined. Lib/ocaml/typemaps.i:367: Warning 453: Can't apply (SWIGTYPE &&). No typemaps are defined. Lib/ocaml/typemaps.i:372: Warning 453: Can't apply (SWIGTYPE &). No typemaps are defined. --- Lib/ocaml/typemaps.i | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/Lib/ocaml/typemaps.i b/Lib/ocaml/typemaps.i index b70b78928..3e0233ffa 100644 --- a/Lib/ocaml/typemaps.i +++ b/Lib/ocaml/typemaps.i @@ -27,7 +27,16 @@ $result = caml_val_ptr($1,$descriptor); } -#ifdef __cplusplus +%typemap(in) char *& (char *temp) { + /* %typemap(in) char *& */ + temp = (char*)caml_val_ptr($1,$descriptor); + $1 = &temp; +} + +%typemap(argout) char *& { + /* %typemap(argout) char *& */ + swig_result = caml_list_append(swig_result,caml_val_string_len(*$1, strlen(*$1))); +} %typemap(in) SWIGTYPE & { /* %typemap(in) SWIGTYPE & */ @@ -105,6 +114,8 @@ $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; } +#ifdef __cplusplus + %typemap(out) SWIGTYPE { /* %typemap(out) SWIGTYPE */ $&1_ltype temp = new $ltype((const $1_ltype &) $1); @@ -116,23 +127,8 @@ } } -%typemap(in) char *& (char *temp) { - /* %typemap(in) char *& */ - temp = (char*)caml_val_ptr($1,$descriptor); - $1 = &temp; -} - -%typemap(argout) char *& { - /* %typemap(argout) char *& */ - swig_result = caml_list_append(swig_result,caml_val_string_len(*$1, strlen(*$1))); -} - #else -%typemap(in) SWIGTYPE { - $1 = *(($&1_ltype) caml_ptr_val($input,$&1_descriptor)) ; -} - %typemap(out) SWIGTYPE { /* %typemap(out) SWIGTYPE */ void *temp = calloc(1,sizeof($ltype)); @@ -145,9 +141,6 @@ } } -%apply SWIGTYPE { const SWIGTYPE & }; -%apply SWIGTYPE { const SWIGTYPE && }; - #endif /* The SIMPLE_MAP macro below defines the whole set of typemaps needed