1 (* Interface to Perl from OCaml.
2 * Copyright (C) 2003 Merjis Ltd.
3 * $Id: perl.ml,v 1.3 2003-10-12 11:56:26 rich Exp $
10 exception Perl_failure of string
12 external init : unit -> unit = "perl4caml_init"
14 Callback.register_exception "perl4caml_perl_failure" (Perl_failure "");
15 init () (* Initialise C code. *)
17 external create : ?args:string array -> unit -> t
20 external destroy : t -> unit
23 external set_context : t -> unit
24 = "perl4caml_set_context"
26 external int_of_sv : sv -> int = "perl4caml_int_of_sv"
27 external sv_of_int : int -> sv = "perl4caml_sv_of_int"
28 external float_of_sv : sv -> int = "perl4caml_float_of_sv"
29 external sv_of_float : int -> sv = "perl4caml_sv_of_float"
30 external string_of_sv : sv -> string = "perl4caml_string_of_sv"
31 external sv_of_string : string -> sv = "perl4caml_sv_of_string"
32 external sv_is_true : sv -> bool = "perl4caml_sv_is_true"
33 external sv_is_undef : sv -> bool = "perl4caml_sv_is_undef"
34 external sv_get_undef : unit -> sv = "perl4caml_sv_get_undef"
35 external sv_get_yes : unit -> sv = "perl4caml_sv_get_yes"
36 external sv_get_no : unit -> sv = "perl4caml_sv_get_no"
38 let sv_undef = sv_get_undef ()
39 let sv_true = sv_get_yes ()
40 let sv_false = sv_get_no ()
42 external get_sv : ?create:bool -> string -> sv = "perl4caml_get_sv"
44 external call : ?sv:sv -> ?fn:string -> sv list -> sv
46 external call_array : ?sv:sv -> ?fn:string -> sv list -> sv list
47 = "perl4caml_call_array"
48 external call_void : ?sv:sv -> ?fn:string -> sv list -> unit
49 = "perl4caml_call_void"
51 external eval : string -> sv
54 external call_method : sv -> string -> sv list -> sv
55 = "perl4caml_call_method"
56 external call_method_array : sv -> string -> sv list -> sv list
57 = "perl4caml_call_method_array"
58 external call_method_void : sv -> string -> sv list -> unit
59 = "perl4caml_call_method_void"
60 external call_class_method : string -> string -> sv list -> sv
61 = "perl4caml_call_class_method"
62 external call_class_method_array : string -> string -> sv list -> sv list
63 = "perl4caml_call_class_method_array"
64 external call_class_method_void : string -> string -> sv list -> unit
65 = "perl4caml_call_class_method_void"