12
12
(***********************************************************************)
14
(* $Id: dynlink.mli,v 1.21 2002/11/17 16:42:11 xleroy Exp $ *)
16
(** Dynamic loading of bytecode object files. *)
18
(** {6 Initialization} *)
20
val init : unit -> unit
21
(** Initialize the [Dynlink] library.
22
Must be called before any other function in this module. *)
24
(** {6 Dynamic loading of compiled bytecode files} *)
14
(* $Id: dynlink.mli,v 1.23 2008/04/22 12:24:10 frisch Exp $ *)
16
(** Dynamic loading of object files. *)
19
(** [true] if the program is native,
20
[false] if the program is bytecode. *)
22
(** {6 Dynamic loading of compiled files} *)
26
24
val loadfile : string -> unit
27
(** Load the given bytecode object file ([.cmo] file) or
28
bytecode library file ([.cma] file), and link it with the running program.
25
(** In bytecode: load the given bytecode object file ([.cmo] file) or
26
bytecode library file ([.cma] file), and link it with the running
27
program. In native code: load the given OCaml plugin file (usually
28
[.cmxs]), and link it with the running
29
30
All toplevel expressions in the loaded compilation units
30
31
are evaluated. No facilities are provided to
31
32
access value names defined by the unit. Therefore, the unit
37
38
are hidden (cannot be referenced) from other modules dynamically
38
39
loaded afterwards. *)
41
val adapt_filename : string -> string
42
(** In bytecode, the identity function. In native code, replace the last
43
extension with [.cmxs]. *)
40
45
(** {6 Access control} *)
42
47
val allow_only: string list -> unit
68
73
dynamically linked. A compilation unit is ``unsafe'' if it contains
69
74
declarations of external functions, which can break type safety.
70
75
By default, dynamic linking of unsafe object files is
76
not allowed. In native code, this function does nothing; object files
77
with external functions are always allowed to be dynamically linked. *)
73
79
(** {6 Deprecated, low-level API for access control} *)
77
83
since the default initialization of allowed units, along with the
78
84
[allow_only] and [prohibit] function, provides a better, safer
79
85
mechanism to control access to program units. The three functions
80
below are provided for backward compatibility only. *)
86
below are provided for backward compatibility only and are not
87
available in native code. *)
82
89
val add_interfaces : string list -> string list -> unit
83
90
(** [add_interfaces units path] grants dynamically-linked object
97
104
(** Empty the list of compilation units accessible to dynamically-linked
107
(** {6 Deprecated, initialization} *)
109
val init : unit -> unit
110
(** @deprecated Initialize the [Dynlink] library. This function is called
111
automatically when needed. *)
100
113
(** {6 Error reporting} *)
102
115
type linking_error =
113
126
| Corrupted_interface of string
114
127
| File_not_found of string
115
128
| Cannot_open_dll of string
129
| Inconsistent_implementation of string
117
131
exception Error of error
118
132
(** Errors in dynamic linking are reported by raising the [Error]