(* Interface to Perl from OCaml.
* Copyright (C) 2003 Merjis Ltd.
- * $Id: perl.ml,v 1.5 2003-10-14 16:05:21 rich Exp $
+ * $Id: perl.ml,v 1.6 2003-10-15 16:51:12 rich Exp $
*)
type t
exception Perl_failure of string
+external create : ?args:string array -> unit -> t
+ = "perl4caml_create"
+
+(* Initialization. This must happen first, otherwise other parts of the
+ * program will segfault because of a missing interpreter.
+ *)
external c_init : unit -> unit = "perl4caml_init"
-let init () =
+let () =
+ (* Leave this debugging message in for now until init support in OCaml
+ * is debugged.
+ *)
+ prerr_endline "perl_init: Initialising Perl support ...";
Callback.register_exception "perl4caml_perl_failure" (Perl_failure "");
- c_init () (* Initialise C code. *)
+ c_init (); (* Initialise C code. *)
+ (* Create the default interpreter. *)
+ create ~args:[| ""; "-w"; "-e"; "0" |] ();
+ ()
-external destroy : unit -> unit
- = "perl4caml_destroy"
+external current_interpreter : unit -> t
+ = "perl4caml_current_interpreter"
-external create : ?args:string array -> unit -> t
- = "perl4caml_create"
+external destroy : t -> unit
+ = "perl4caml_destroy"
external set_context : t -> unit
= "perl4caml_set_context"