Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 68 lines (52 sloc) 2.517 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 Specific bsl processing for Javascript files.
21
22 This module implements part of the bslregister process.
23
24 @author Mathieu Barbin
25 *)
26
27 (** {6 Type alias for clarty} *)
28 (** *)
29 type filename = string
30 type contents = string
31
32 (**
33 Bsl Preprocessing for Javascript files.
34
35 This function is called at the end, once we have parsed all javascript files,
36 the fonction implements a fold on decorated_files, for building
37 the runtime and the wanted interface (for checking).
38
39 The function should also perform calls to the Register API,
40 given as a record of type [BslPluginInterface.dynloader_interface],
41 which contains support for registering types and primitives.
42
43 The preprocess should respect the module hiearchy and keys names,
44 for beeing coherent with Ocaml, but the actual implementation is free,
45 as long as the generated javascript is coherent
46 with the impl used as argument for calling the dynload interface.
47
48 The [options] are passed for checking issues.
49
50 The [depends] is the js code of previous built plugins.
51 If the js writen for a plugin depends on a previous plugin,
52 its javascript code may depends on the javascirpt code of
53 one of the previous plugins, so it is passes to the function
54 preprocess to be used e.g. during checking to avoid unbound values.
55
56 The returned js_code must be inserted into the plugin and escaped,
57 so we need a string. Internally, the implementation does not use
58 string concatenation, but a FBuffer, with a final [FBuffer.contents],
59 before checking e.g.
60 *)
61 val preprocess :
62 options:BslInterface.options ->
63 plugins:BslPluginInterface.plugin list ->
64 dynloader_interface:BslPluginInterface.dynloader_interface ->
65 depends:(filename * contents) list ->
66 BslDirectives.bypasslang_decorated_file list ->
67 BslPluginInterface.javascript_env * (filename * contents) list
Something went wrong with that request. Please try again.