Added initial caml4perl.
[perl4caml.git] / perl.ml
1 (* Interface to Perl from OCaml.
2  * Copyright (C) 2003 Merjis Ltd.
3  * $Id: perl.ml,v 1.1 2003-10-11 18:25:52 rich Exp $
4  *)
5
6 type t
7
8 type sv
9
10 exception PerlFailure of string
11
12 (* Perform some once-only initialization when the library is loaded. *)
13 external init : unit -> unit = "perl4caml_init"
14 let () = init ()
15
16 external create : ?args:string array -> unit -> t
17   = "perl4caml_create"
18
19 external destroy : t -> unit
20   = "perl4caml_destroy"
21
22 external set_context : t -> unit
23   = "perl4caml_set_context"
24
25 external int_of_sv : sv -> int = "perl4caml_int_of_sv"
26 external sv_of_int : int -> sv = "perl4caml_sv_of_int"
27 external float_of_sv : sv -> int = "perl4caml_float_of_sv"
28 external sv_of_float : int -> sv = "perl4caml_sv_of_float"
29 external string_of_sv : sv -> string = "perl4caml_string_of_sv"
30 external sv_of_string : string -> sv = "perl4caml_sv_of_string"
31
32 external call_scalar : string -> sv list -> sv
33   = "perl4caml_call_scalar"
34
35 (*
36 external call_array : string -> sv list -> sv list
37   = "perl4caml_call_array"
38
39 external call : string -> sv list -> unit
40   = "perl4caml_call"
41
42 external eval : string -> sv
43   = "perl4caml_eval"
44 *)