Typedef_mptr test (with runme).
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@4871 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
a1ffa6afda
commit
d2cd68c7cc
3 changed files with 41 additions and 14 deletions
15
SWIG/Examples/test-suite/ocaml/typedef_mptr_runme.ml
Normal file
15
SWIG/Examples/test-suite/ocaml/typedef_mptr_runme.ml
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
open Typedef_mptr
|
||||
|
||||
let soci x = (string_of_int (get_int x))
|
||||
|
||||
let x = new_Foo C_void
|
||||
let add_res = _do_op (C_list [ x ; C_int 2 ; C_int 1 ; _add ])
|
||||
and sub_res = _do_op (C_list [ x ; C_int 2 ; C_int 1 ; _sub ])
|
||||
let _ =
|
||||
if add_res <> (C_int 3) || sub_res <> (C_int 1) then
|
||||
raise (Failure ("Bad result:" ^
|
||||
" (add " ^ (soci add_res) ^ ") " ^
|
||||
" (sub " ^ (soci sub_res) ^ ")"))
|
||||
let _ = Printf.printf "2 + 1 = %d, 2 - 1 = %d\n"
|
||||
(get_int add_res)
|
||||
(get_int sub_res)
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
%module typedef_mptr
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
#if defined(SWIGPYTHON) || defined(SWIGOCAML)
|
||||
|
||||
%inline %{
|
||||
|
||||
|
|
@ -28,7 +28,7 @@ Integer do_op(Foo *f, Integer x, Integer y, Integer (FooObj::*op)(Integer, Integ
|
|||
%}
|
||||
#endif
|
||||
|
||||
#ifdef SWIGPYTHON
|
||||
#if defined(SWIGPYTHON) || defined(SWIGOCAML)
|
||||
%constant int (Foo::*add)(int,int) = &Foo::add;
|
||||
%constant Integer (FooObj::*sub)(Integer,Integer) = &FooObj::sub;
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue