Added to typemaps: reference type in/out

Strings <=> std::string by value
std::wstring accessible from Ocaml.  The string example converts a multibyte
japanese EUC sequence to a single wchar_t sequence if you have the ja_JP.EUC-JP
locale, or similar.
Better handling of reference in types
Corrected problems with & * mismatch in type verifier.
Type verifier now really functional.  No more type errors in places they
wouldn't be allowed in C++, unless you work at it.
Added argout_ref example for argout_ref.
Init code now effective (called from let _ = f_<module>_init ())


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4412 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Art Yerkes 2003-02-27 07:09:12 +00:00
commit b8490f9c18
10 changed files with 190 additions and 58 deletions

View file

@ -44,28 +44,28 @@
}
%typemap(ocaml,in) SWIGTYPE * {
$1 = ($ltype)caml_ptr_val($input,$descriptor);
$1 = ($ltype)caml_ptr_val($input,$*1_descriptor);
}
%typemap(ocaml,out) SWIGTYPE * {
value *fromval = caml_named_value("create_$ntype_from_ptr");
if( fromval ) {
$result = callback(*fromval,caml_val_ptr((void *)$1,$descriptor));
$result = callback(*fromval,caml_val_ptr((void *)$1,$*1_descriptor));
} else {
$result = caml_val_ptr ((void *)$1,$descriptor);
$result = caml_val_ptr ((void *)$1,$*1_descriptor);
}
}
%typemap(ocaml,varin) SWIGTYPE * {
$1 = ($ltype)caml_ptr_val($input,$descriptor);
$1 = ($ltype)caml_ptr_val($input,$*1_descriptor);
}
%typemap(ocaml,varout) SWIGTYPE * {
value *fromval = caml_named_value("create_$ntype_from_ptr");
if( fromval ) {
$result = callback(*fromval,caml_val_ptr((void *)$1,$descriptor));
$result = callback(*fromval,caml_val_ptr((void *)$1,$*1_descriptor));
} else {
$result = caml_val_ptr ((void *)$1,$descriptor);
$result = caml_val_ptr ((void *)$1,$*1_descriptor);
}
}
@ -74,15 +74,29 @@
#ifdef __cplusplus
%typemap(ocaml,in) SWIGTYPE & {
$1 = ($ltype) caml_ptr_val($input,$descriptor);
$1 = ($ltype) caml_ptr_val($input,$*1_descriptor);
}
%typemap(ocaml,out) SWIGTYPE & {
value *fromval = caml_named_value("create_$ntype_from_ptr");
if( fromval ) {
$result = callback(*fromval,caml_val_ptr((void *) $1,$descriptor));
$result = callback(*fromval,caml_val_ptr((void *) $1,$*1_descriptor));
} else {
$result = caml_val_ptr ((void *) $1,$descriptor);
$result = caml_val_ptr ((void *) $1,$*1_descriptor);
}
}
%typemap(ocaml,argout) SWIGTYPE & {
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));
}
}
@ -118,6 +132,8 @@
}
}
%apply SWIGTYPE { const SWIGTYPE & };
#endif
/* Arrays */
@ -158,7 +174,14 @@
$1 = &temp;
}
%typemap(argout) C_NAME *OUTPUT {
caml_list_append(swig_result,(long)*$1);
swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1));
}
%typemap(in) C_NAME & (C_NAME temp) {
temp = (C_NAME) MZ_TO_C($input);
$1 = &temp;
}
%typemap(argout) C_NAME & {
swig_result = caml_list_append(swig_result,C_TO_MZ((long)*$1));
}
%enddef