1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset= ISO-8859-1">
<TITLE>
Module Callback: registering Caml values with the C runtime
</TITLE>
</HEAD>
<BODY >
<A HREF="manual033.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual035.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
<HR>
<H2>17.4 Module <TT>Callback</TT>: registering Caml values with the C runtime</H2><A NAME="s:Callback"></A>
<A NAME="@manual195"></A><BLOCKQUOTE>
This module allows Caml values to be registered with the C runtime
under a symbolic name, so that C code can later call back registered
Caml functions, or raise registered Caml exceptions.
</BLOCKQUOTE>
<PRE>
val register: string -> 'a -> unit
</PRE>
<A NAME="@manual196"></A><BLOCKQUOTE>
<CODE>Callback.register n v</CODE> registers the value <CODE>v</CODE> under
the name <CODE>n</CODE>. C code can later retrieve a handle to <CODE>v</CODE>
by calling <CODE>caml_named_value(n)</CODE>.
</BLOCKQUOTE>
<PRE>
val register_exception: string -> exn -> unit
</PRE>
<A NAME="@manual197"></A><BLOCKQUOTE>
<CODE>Callback.register_exception n exn</CODE> registers the
exception contained in the exception value <CODE>exn</CODE>
under the name <CODE>n</CODE>. C code can later retrieve a handle to
the exception by calling <CODE>caml_named_value(n)</CODE>. The exception
value thus obtained is suitable for passign as first argument
to <CODE>raise_constant</CODE> or <CODE>raise_with_arg</CODE>.
</BLOCKQUOTE>
<HR>
<A HREF="manual033.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="manual035.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<A HREF="manual030.html"><IMG SRC ="contents_motif.gif" ALT="Contents"></A>
</BODY>
</HTML>
|