Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 152 lines (113 sloc) 5.073 kB
fccc685 Initial open-source release
MLstate authored
1 (*
2 Copyright © 2011 MLstate
3
4 This file is part of OPA.
5
6 OPA is free software: you can redistribute it and/or modify it under the
7 terms of the GNU Affero General Public License, version 3, as published by
8 the Free Software Foundation.
9
10 OPA is distributed in the hope that it will be useful, but WITHOUT ANY
11 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
13 more details.
14
15 You should have received a copy of the GNU Affero General Public License
16 along with OPA. If not, see <http://www.gnu.org/licenses/>.
17 *)
18
19 (**
20 Marshalling bypass maps.
21 This module offers an alternative to cmxs ocaml shared object
22 for the bypass plugin system.
23
24 @author Mathieu Barbin
25 *)
26
27
28 (**
29 Using this module :
30
31 With bslregister :
32 + create a new session of type [session]
33 + use the register API to modify it by side-effect
34 + [finalize] your session, and use I/O API to save your plugin.
35
36 With Dynlink : use I/O facilty and Dynlink API, manipulating type [t] only.
37
38 This module can be used instead if for any reason we have some problemes
39 dealing with the native dynloading with ocaml,
40 since this feature is not well ported (e.g windows), or can
41 simply be not well supported in any further version of ocaml
42 on some architecture.
43
44 This does not work for the interpreters, just for compilers.
45 For interpreters we should relink the interpreter, with the
46 generated Loaders.
47 *)
48
49 (** {6 Type alias} *)
50 type filename = string
51
52 (** {6 Error reporting} *)
53 (**
54 This module uses [OManager] errors.
55 *)
56
57 (** {6 I/O facility} *)
58
59 (** the row type for a plugin bymap : serializable with marshal.
60 a value of this type is not mutable *)
61 type t
62
63 (** [output_t filename r] outputs a value of type [t] to a file, using ocaml marshaling.
64 @param filename the name of the file
65 @raise Error in case of I/O or Marshal errors *)
66 val output_file : filename -> t -> unit
67
68 (** [intput_t filename] loads a value of type [t] from a file, using ocaml unmarshaling.
69 @param filename the name of the file
70 @raise Error in case of I/O or Marshal errors *)
71 val input_file : filename -> t
72
73 (**
74 Same function, but with low level channel.
75 The function does not open or close the channel.
76 <!> Ocaml manual mention that channel should have be opened in binary mode
77 under certain OS.
78
79 The filename is used for error messages
80 *)
81 (** *)
82
83 val output : out_channel -> t -> unit
84 val input : filename:string -> in_channel -> t
85
86 (** {6 COMPATIBILITY with BslLib interface} *)
87
88 (** Build the same plugin structure as you would optained after the native dynloading of a Loader.*)
89 val plugin : t -> BslPluginInterface.plugin
90
91 (** {6 Dynlink API} *)
92
93 (** Marshaled structure Dynlinker.
94
95 [loadfile_private filename] does :
96 + loads the type [t] from a file
97 + build the [BslLib.loader_introspection] using [loader_introspection]
98 + register it in the loader table of libbsl using [BslLib.LoaderTable.register_bootstrap_loader]
99 @param filename the name of the file containing the marshaled structure
100 @raise Error in case of I/O error
101 @see "BslDynlink" which uses this function
102 @see "Dynlink" from ocaml standard library
103 *)
104 val loadfile_private : filename -> unit
105
106 (** an alias for [loadfile_private]
107 @deprecated Please use [loadfile_private] *)
108 val loadfile : filename -> unit
109
110 (** {6 Registering API for bslregister} *)
111
112 (**
113 The type to construct a [t] from BslLib register API.
114 the type [session] is imperative, and register functions have
115 a side effect on values of this type.
116 Once finished registering things in session, use [finalize],
117 to build a functionnal structure of type [t].
118 *)
119 type session
120
121 (** build a fresh new session *)
122 val create : unit -> session
123
124 (** EXPORT an session to a serializable and not mutable value *)
125 val finalize : session -> t
126
127 (** a) dynloader fields *)
128 (** *)
129 val unsafe_register_primitive : session -> BslPluginInterface.register_primitive
130 val unsafe_register_type : session -> BslPluginInterface.register_type
131
132 (** b) other fields *)
133
134 type contents = string
135 type module_name = string
136 type uniq_id = string
137
138 (** *)
139
140 val register_basename : session -> BslPluginInterface.plugin_basename -> unit
141 val register_module_name : session -> module_name -> unit
142 val register_uniq_id : session -> uniq_id -> unit
143 val register_conf : session -> BslConf.conf -> unit
144 val register_ml_runtime : session -> module_name -> unit
145 val register_depends : session -> module_name list -> unit
146
147 val register_opa_code : session -> (filename * contents) list -> unit
148 val register_js_code : session -> (filename * contents * BslJsConf.conf) list -> unit
149
150 val register_ocaml_env : session -> BslPluginInterface.ocaml_env -> unit
151 val register_javascript_env : session -> BslPluginInterface.javascript_env -> unit
Something went wrong with that request. Please try again.