[OCaml] Fix the wrapmacro test
Add a typecheck typemap for size_t and const size_t &. Add the const qualifier to the typemaps for primitive reference types. Add multiple runtime tests.
This commit is contained in:
parent
6522afe90a
commit
10d62aecd5
10 changed files with 58 additions and 10 deletions
|
|
@ -1,13 +1,13 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
|
||||
%typemap(argout) (int &x, int &y) {
|
||||
%typemap(argout) (const int &x, const int &y) {
|
||||
swig_result = caml_list_append(swig_result, caml_val_int(*$1));
|
||||
swig_result = caml_list_append(swig_result, caml_val_int(*$2));
|
||||
}
|
||||
|
||||
%{
|
||||
extern "C" void factor(int &x, int &y);
|
||||
extern "C" void factor(const int &x, const int &y);
|
||||
%}
|
||||
|
||||
extern "C" void factor(int &x, int &y);
|
||||
extern "C" void factor(const int &x, const int &y);
|
||||
|
|
|
|||
15
Examples/test-suite/ocaml/global_vars_runme.ml
Normal file
15
Examples/test-suite/ocaml/global_vars_runme.ml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
open Swig
|
||||
open Global_vars
|
||||
|
||||
_init '()
|
||||
|
||||
let _ =
|
||||
assert (_b '() as string = "string b");
|
||||
assert (_b '("a string value") as string = "a string value");
|
||||
assert (_b '() as string = "a string value");
|
||||
assert (_x '() as int = 1234);
|
||||
assert (_x '(9876) as int = 9876);
|
||||
assert (_x '() as int = 9876);
|
||||
assert (_Hi '() as int = 0);
|
||||
assert (_Hola '() as int = 1);
|
||||
;;
|
||||
|
|
@ -22,7 +22,7 @@ let _ =
|
|||
|
||||
let _ = _var_short (_createref_short (C_short 10)) in
|
||||
assert (_value_short (_var_short '()) as int = 10);
|
||||
|
||||
|
||||
let _ = _var_unsigned_short (_createref_unsigned_short (C_ushort 10)) in
|
||||
assert (_value_unsigned_short (_var_unsigned_short '()) as int = 10);
|
||||
|
||||
|
|
|
|||
10
Examples/test-suite/ocaml/sizet_runme.ml
Normal file
10
Examples/test-suite/ocaml/sizet_runme.ml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
open Swig
|
||||
open Sizet
|
||||
|
||||
let _ =
|
||||
let s = C_int64 2000L in
|
||||
assert (_test1 '(s) as int = 2000);
|
||||
assert (_test2 '(s) as int = 2000);
|
||||
assert (_test3 '(s) as int = 2000);
|
||||
assert (_test4 '(s) as int = 2000);
|
||||
;;
|
||||
11
Examples/test-suite/ocaml/typedef_reference_runme.ml
Normal file
11
Examples/test-suite/ocaml/typedef_reference_runme.ml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
open Swig
|
||||
open Typedef_reference
|
||||
|
||||
let _ =
|
||||
let i = _copy_intp '(2) in
|
||||
assert (_somefunc '(i) as int = 2);
|
||||
assert (_delete_intp '(i) = C_void);
|
||||
let i = _copy_intp '(3) in
|
||||
assert (_otherfunc '(i) as int = 3);
|
||||
assert (_delete_intp '(i) = C_void);
|
||||
;;
|
||||
10
Examples/test-suite/ocaml/wrapmacro_runme.ml
Normal file
10
Examples/test-suite/ocaml/wrapmacro_runme.ml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
open Swig
|
||||
open Wrapmacro
|
||||
|
||||
let _ =
|
||||
let args = C_list [ C_int64 2L ; C_int64 1L ] in
|
||||
assert (_maximum '(args) as int = 2);
|
||||
let args = C_list [ C_double (2. /. 7.) ; C_double 256. ] in
|
||||
assert (_maximum '(args) as float = 256.);
|
||||
assert (_GUINT16_SWAP_LE_BE_CONSTANT '(0x1234) as int = 0x3412);
|
||||
;;
|
||||
Loading…
Add table
Add a link
Reference in a new issue