mirror of https://github.com/swig/swig
Ocaml - add STRING LENGTH multi-argument typemaps
This commit is contained in:
parent
29daa0fe34
commit
dcf69d3e0f
|
@ -20,7 +20,6 @@ top_builddir = @top_builddir@
|
|||
FAILING_CPP_TESTS = \
|
||||
allprotected \
|
||||
apply_strings \
|
||||
char_binary_rev_len \
|
||||
cpp11_decltype \
|
||||
cpp11_director_enums \
|
||||
cpp11_strongly_typed_enumerations \
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
open Swig
|
||||
open Char_binary_rev_len
|
||||
|
||||
let _ =
|
||||
let t = new_Test '() in
|
||||
assert (t -> strlen ("hile") as int = 4);
|
||||
assert (t -> strlen ("hil\x00") as int = 4);
|
||||
;;
|
|
@ -301,10 +301,23 @@ SIMPLE_MAP(unsigned long long,caml_val_ulong,caml_long_val);
|
|||
|
||||
/* String & length typemap */
|
||||
|
||||
%typemap(in) (char *STRING, int LENGTH), (char *STRING, size_t LENGTH) {
|
||||
%typemap(in) (const char *STRING, size_t LENGTH) {
|
||||
$1 = ($1_ltype) caml_string_val($input);
|
||||
$2 = ($2_ltype) caml_string_len($input);
|
||||
}
|
||||
%apply (const char *STRING, size_t LENGTH) { (const char *STRING, int LENGTH) }
|
||||
%apply (const char *STRING, size_t LENGTH) { (char *STRING, size_t LENGTH) }
|
||||
%apply (char *STRING, size_t LENGTH) { (char *STRING, int LENGTH) }
|
||||
|
||||
/* Length & string reverse order typemap */
|
||||
|
||||
%typemap(in) (size_t LENGTH, const char *STRING) {
|
||||
$2 = ($2_ltype) caml_string_val($input);
|
||||
$1 = ($1_ltype) caml_string_len($input);
|
||||
}
|
||||
%apply (size_t LENGTH, const char *STRING) { (int LENGTH, const char *STRING) }
|
||||
%apply (size_t LENGTH, const char *STRING) { (size_t LENGTH, char *STRING) }
|
||||
%apply (size_t LENGTH, char *STRING) { (int LENGTH, char *STRING) }
|
||||
|
||||
%typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
|
||||
swig_type_info *ty = SWIG_TypeDynamicCast($1_descriptor, (void **)&$1);
|
||||
|
|
Loading…
Reference in New Issue