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