[OCaml] Don't use argout typemaps by default for some reference types
The OCaml module's typemaps.i supplied argout typemaps for some reference types (e.g. int &) by default, which was unintuitive and inconsistent when compared with other modules. The argout_ref example depended on this, so add a typemap to argout_ref/example.i. Add multiple runtime tests that deal with references.
This commit is contained in:
parent
940e32477d
commit
b2d93665fe
8 changed files with 130 additions and 29 deletions
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue