Blame support/slave.ml

Packit bd2e5d
(***********************************************************************)
Packit bd2e5d
(*                                                                     *)
Packit bd2e5d
(*                 MLTk, Tcl/Tk interface of OCaml                     *)
Packit bd2e5d
(*                                                                     *)
Packit bd2e5d
(*    Francois Rouaix, Francois Pessaux, Jun Furuse and Pierre Weis    *)
Packit bd2e5d
(*               projet Cristal, INRIA Rocquencourt                    *)
Packit bd2e5d
(*            Jacques Garrigue, Kyoto University RIMS                  *)
Packit bd2e5d
(*                                                                     *)
Packit bd2e5d
(*  Copyright 2002 Institut National de Recherche en Informatique et   *)
Packit bd2e5d
(*  en Automatique and Kyoto University.  All rights reserved.         *)
Packit bd2e5d
(*  This file is distributed under the terms of the GNU Library        *)
Packit bd2e5d
(*  General Public License, with the special exception on linking      *)
Packit bd2e5d
(*  described in file LICENSE found in the OCaml source tree.          *)
Packit bd2e5d
(*                                                                     *)
Packit bd2e5d
(***********************************************************************)
Packit bd2e5d
Packit bd2e5d
(* $Id$ *)
Packit bd2e5d
Packit bd2e5d
(* The code run on initialisation, in addition to normal Tk code
Packit bd2e5d
 * NOTE: camltk has not fully been initialised yet
Packit bd2e5d
 *)
Packit bd2e5d
external tcl_eval : string -> string
Packit bd2e5d
        =  "camltk_tcl_eval"
Packit bd2e5d
let tcl_command s = ignore (tcl_eval s);;
Packit bd2e5d
open Printf
Packit bd2e5d
Packit bd2e5d
let dynload args =
Packit bd2e5d
  List.iter Dynlink.loadfile args
Packit bd2e5d
Packit bd2e5d
(* Default modules include everything from
Packit bd2e5d
let default_modules = []
Packit bd2e5d
*)
Packit bd2e5d
Packit bd2e5d
(* [caml::run foo.cmo .. bar.cmo] is now available from Tcl *)
Packit bd2e5d
let init () =
Packit bd2e5d
  Dynlink.init();
Packit bd2e5d
  (* Make it unsafe by default, with everything available *)
Packit bd2e5d
  Dynlink.allow_unsafe_modules true;
Packit bd2e5d
  Dynlink.add_interfaces [] [];
Packit bd2e5d
  let s = register_callback Widget.dummy dynload in
Packit bd2e5d
  tcl_command (sprintf "proc caml::run {l} {camlcb %s l}" s)
Packit bd2e5d
Packit bd2e5d
let _ =
Packit bd2e5d
  Printexc.print init ()
Packit bd2e5d
Packit bd2e5d
(* A typical master program would then
Packit bd2e5d
 *   caml::run foo.cmo
Packit bd2e5d
 *     # during initialisation, "foo" was registered as a tcl procedure
Packit bd2e5d
 *   foo x y z
Packit bd2e5d
 *     # proceed with some Tcl code calling foo
Packit bd2e5d
 *)