swigp4-ified examples.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@5232 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
78fd2cb821
commit
25d0e88ee7
4 changed files with 21 additions and 15 deletions
|
|
@ -21,6 +21,12 @@ static::
|
|||
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
|
||||
ocaml_static
|
||||
|
||||
toplevel::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' MLFILE='$(MLFILE)' \
|
||||
PROGFILE='$(PROGFILE)' OBJS='$(OBJS)' \
|
||||
ocaml_static_toplevel
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile MLFILE='$(MLFILE)' ocaml_clean
|
||||
|
||||
|
|
|
|||
|
|
@ -7,26 +7,21 @@ open Example
|
|||
|
||||
exception NoReturn
|
||||
|
||||
let single_int x =
|
||||
match x with C_int a -> a | _ -> raise NoReturn
|
||||
let get_float x =
|
||||
match x with C_float f -> f | C_double f -> f | _ -> raise NoReturn
|
||||
|
||||
let x = 42
|
||||
let y = 105
|
||||
let g = single_int (_gcd (C_list [ C_int x ; C_int y ]))
|
||||
let _ = Printf.printf "The gcd of %d and %d is %d\n" x y g
|
||||
let x = 42 to int
|
||||
let y = 105 to int
|
||||
let g = _gcd '(x,y) as int
|
||||
let _ = Printf.printf "The gcd of %d and %d is %d\n" (x as int) (y as int) g
|
||||
|
||||
(* Manipulate the Foo global variable *)
|
||||
|
||||
(* Output its current value *)
|
||||
let _ = Printf.printf "Foo = %f\n" (get_float (_Foo C_void))
|
||||
let _ = Printf.printf "Foo = %f\n" (_Foo '() as float)
|
||||
|
||||
(* Change its value *)
|
||||
let _ = _Foo (C_float 3.1415926)
|
||||
let _ = _Foo '(3.1415926)
|
||||
|
||||
(* See if the change took effect *)
|
||||
let _ = Printf.printf "Foo = %f\n" (get_float (_Foo C_void))
|
||||
let _ = Printf.printf "Foo = %f\n" (_Foo '() as float)
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,11 @@ dynamic::
|
|||
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
ocaml_static_cpp
|
||||
|
||||
toplevel::
|
||||
$(MAKE) -f $(TOP)/Makefile SRCS='$(SRCS)' SWIG='$(SWIG)' \
|
||||
PROGFILE='$(PROGFILE)' TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' \
|
||||
ocaml_static_cpp_toplevel
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile TARGET='$(TARGET)' ocaml_clean
|
||||
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
open Swig
|
||||
open Example
|
||||
|
||||
let v = new_StringVector C_void
|
||||
let v = new_StringVector '()
|
||||
|
||||
let _ =
|
||||
for i = 0 to (Array.length Sys.argv) - 1 do
|
||||
(invoke v) "push_back" (C_string Sys.argv.(i))
|
||||
let str = (Sys.argv.(i)) to string in v -> push_back (str)
|
||||
done
|
||||
|
||||
let _ = _vec_write v
|
||||
let _ = _vec_write '(v)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue