1 /**************************************************************************/
2 /*                                                                        */
3 /*                                 OCaml                                  */
4 /*                                                                        */
5 /*             Xavier Leroy, projet Cristal, INRIA Rocquencourt           */
6 /*                                                                        */
7 /*   Copyright 1996 Institut National de Recherche en Informatique et     */
8 /*     en Automatique.                                                    */
9 /*                                                                        */
10 /*   All rights reserved.  This file is distributed under the terms of    */
11 /*   the GNU Lesser General Public License version 2.1, with the          */
12 /*   special exception on linking described in the file LICENSE.          */
13 /*                                                                        */
14 /**************************************************************************/
15 
16 /* Callbacks from C to OCaml */
17 
18 #ifndef CAML_CALLBACK_H
19 #define CAML_CALLBACK_H
20 
21 #ifndef CAML_NAME_SPACE
22 #include "compatibility.h"
23 #endif
24 #include "mlvalues.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 CAMLextern value caml_callback (value closure, value arg);
31 CAMLextern value caml_callback2 (value closure, value arg1, value arg2);
32 CAMLextern value caml_callback3 (value closure, value arg1, value arg2,
33                                  value arg3);
34 CAMLextern value caml_callbackN (value closure, int narg, value args[]);
35 
36 CAMLextern value caml_callback_exn (value closure, value arg);
37 CAMLextern value caml_callback2_exn (value closure, value arg1, value arg2);
38 CAMLextern value caml_callback3_exn (value closure,
39                                      value arg1, value arg2, value arg3);
40 CAMLextern value caml_callbackN_exn (value closure, int narg, value args[]);
41 
42 #define Make_exception_result(v) ((v) | 2)
43 #define Is_exception_result(v) (((v) & 3) == 2)
44 #define Extract_exception(v) ((v) & ~3)
45 
46 CAMLextern value * caml_named_value (char const * name);
47 typedef void (*caml_named_action) (value*, char *);
48 CAMLextern void caml_iterate_named_values(caml_named_action f);
49 
50 CAMLextern void caml_main (char ** argv);
51 CAMLextern void caml_startup (char ** argv);
52 CAMLextern value caml_startup_exn (char ** argv);
53 
54 CAMLextern int caml_callback_depth;
55 
56 #ifdef __cplusplus
57 }
58 #endif
59 
60 #endif
61