2016-02-18 07:11:59 -08:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* OCaml *)
|
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 1996 Institut National de Recherche en Informatique et *)
|
|
|
|
(* en Automatique. *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. This file is distributed under the terms of *)
|
|
|
|
(* the GNU Lesser General Public License version 2.1, with the *)
|
|
|
|
(* special exception on linking described in the 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
|