1996-11-08 06:48:23 -08:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
2011-07-27 07:17:02 -07:00
|
|
|
(* OCaml *)
|
1996-11-08 06:48:23 -08:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
2001-12-07 05:41:02 -08:00
|
|
|
(* under the terms of the GNU Library General Public License, with *)
|
|
|
|
(* the special exception on linking described in file ../LICENSE. *)
|
1996-11-08 06:48:23 -08:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
2011-12-21 07:37:54 -08:00
|
|
|
(* Registering OCaml values with the C runtime for later callbacks *)
|
1996-11-08 06:48:23 -08:00
|
|
|
|
2003-12-31 06:20:40 -08:00
|
|
|
external register_named_value : string -> Obj.t -> unit
|
|
|
|
= "caml_register_named_value"
|
1996-11-08 06:48:23 -08:00
|
|
|
|
|
|
|
let register name v =
|
|
|
|
register_named_value name (Obj.repr v)
|
|
|
|
|
1999-12-08 00:21:57 -08:00
|
|
|
let register_exception name (exn : exn) =
|
2013-10-18 06:00:58 -07:00
|
|
|
let exn = Obj.repr exn in
|
2013-10-23 07:28:31 -07:00
|
|
|
let slot = if Obj.tag exn = Obj.object_tag then exn else Obj.field exn 0 in
|
2013-10-18 06:00:58 -07:00
|
|
|
register_named_value name slot
|