Skip to content
This repository
tag: v1067
Fetching contributors…

Cannot retrieve contributors at this time

file 67 lines (52 sloc) 2.517 kb
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)

(**
Specific bsl processing for Javascript files.

This module implements part of the bslregister process.

@author Mathieu Barbin
*)

(** {6 Type alias for clarty} *)
(** *)
type filename = string
type contents = string

(**
Bsl Preprocessing for Javascript files.

This function is called at the end, once we have parsed all javascript files,
the fonction implements a fold on decorated_files, for building
the runtime and the wanted interface (for checking).

The function should also perform calls to the Register API,
given as a record of type [BslPluginInterface.dynloader_interface],
which contains support for registering types and primitives.

The preprocess should respect the module hiearchy and keys names,
for beeing coherent with Ocaml, but the actual implementation is free,
as long as the generated javascript is coherent
with the impl used as argument for calling the dynload interface.

The [options] are passed for checking issues.

The [depends] is the js code of previous built plugins.
If the js writen for a plugin depends on a previous plugin,
its javascript code may depends on the javascirpt code of
one of the previous plugins, so it is passes to the function
preprocess to be used e.g. during checking to avoid unbound values.

The returned js_code must be inserted into the plugin and escaped,
so we need a string. Internally, the implementation does not use
string concatenation, but a FBuffer, with a final [FBuffer.contents],
before checking e.g.
*)
val preprocess :
  options:BslInterface.options ->
  plugins:BslPluginInterface.plugin list ->
  dynloader_interface:BslPluginInterface.dynloader_interface ->
  depends:(filename * contents) list ->
  BslDirectives.bypasslang_decorated_file list ->
  BslPluginInterface.javascript_env * (filename * contents) list
Something went wrong with that request. Please try again.