summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacques Garrigue <garrigue at math.nagoya-u.ac.jp>2000-01-20 03:00:50 +0000
committerJacques Garrigue <garrigue at math.nagoya-u.ac.jp>2000-01-20 03:00:50 +0000
commita928f5cd699efe6c46d15958572848ce90d44478 (patch)
treed63275938f81544cabe1827bc5da7f84be97691d
parenta3ee3353a62353be9836e3a6a04af1f20e686982 (diff)
from bazar-ocaml/camltk41
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2760 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
-rw-r--r--otherlibs/labltk/support/slave.ml49
1 files changed, 49 insertions, 0 deletions
diff --git a/otherlibs/labltk/support/slave.ml b/otherlibs/labltk/support/slave.ml
new file mode 100644
index 000000000..2539e2426
--- /dev/null
+++ b/otherlibs/labltk/support/slave.ml
@@ -0,0 +1,49 @@
+(*************************************************************************)
+(* *)
+(* Objective Caml LablTk library *)
+(* *)
+(* Francois Rouaix, Francois Pessaux and Jun Furuse *)
+(* projet Cristal, INRIA Rocquencourt *)
+(* Jacques Garrigue, Kyoto University RIMS *)
+(* *)
+(* Copyright 1999 Institut National de Recherche en Informatique et *)
+(* en Automatique and Kyoto University. All rights reserved. *)
+(* This file is distributed under the terms of the GNU Library *)
+(* General Public License. *)
+(* *)
+(*************************************************************************)
+
+(* $Id$ *)
+
+(* The code run on initialisation, in addition to normal Tk code
+ * NOTE: camltk has not fully been initialised yet
+ *)
+external tcl_eval : string -> string
+ = "camltk_tcl_eval"
+let tcl_command s = ignore (tcl_eval s);;
+open Printf
+
+let dynload args =
+ List.iter Dynlink.loadfile args
+
+(* Default modules include everything from
+let default_modules = []
+
+(* [caml::run foo.cmo .. bar.cmo] is now available from Tcl *)
+let init () =
+ Dynlink.init();
+ (* Make it unsafe by default, with everything available *)
+ Dynlink.allow_unsafe_modules true;
+ Dynlink.add_interfaces [] []
+ let s = register_callback Widget.dummy dynload in
+ tcl_command (sprintf "proc caml::run {l} {camlcb %s l}" s)
+
+let _ =
+ Printexc.print init ()
+
+(* A typical master program would then
+ * caml::run foo.cmo
+ * # during initialisation, "foo" was registered as a tcl procedure
+ * foo x y z
+ * # proceed with some Tcl code calling foo
+ *)