Skip to content
This repository
tag: v998
Fetching contributors…

Cannot retrieve contributors at this time

file 151 lines (113 sloc) 5.073 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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151
(*
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/>.
*)

(**
Marshalling bypass maps.
This module offers an alternative to cmxs ocaml shared object
for the bypass plugin system.

@author Mathieu Barbin
*)


(**
Using this module :

With bslregister :
+ create a new session of type [session]
+ use the register API to modify it by side-effect
+ [finalize] your session, and use I/O API to save your plugin.

With Dynlink : use I/O facilty and Dynlink API, manipulating type [t] only.

This module can be used instead if for any reason we have some problemes
dealing with the native dynloading with ocaml,
since this feature is not well ported (e.g windows), or can
simply be not well supported in any further version of ocaml
on some architecture.

This does not work for the interpreters, just for compilers.
For interpreters we should relink the interpreter, with the
generated Loaders.
*)

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

(** {6 Error reporting} *)
(**
This module uses [OManager] errors.
*)

(** {6 I/O facility} *)

(** the row type for a plugin bymap : serializable with marshal.
a value of this type is not mutable *)
type t

(** [output_t filename r] outputs a value of type [t] to a file, using ocaml marshaling.
@param filename the name of the file
@raise Error in case of I/O or Marshal errors *)
val output_file : filename -> t -> unit

(** [intput_t filename] loads a value of type [t] from a file, using ocaml unmarshaling.
@param filename the name of the file
@raise Error in case of I/O or Marshal errors *)
val input_file : filename -> t

(**
Same function, but with low level channel.
The function does not open or close the channel.
<!> Ocaml manual mention that channel should have be opened in binary mode
under certain OS.

The filename is used for error messages
*)
(** *)

val output : out_channel -> t -> unit
val input : filename:string -> in_channel -> t

(** {6 COMPATIBILITY with BslLib interface} *)

(** Build the same plugin structure as you would optained after the native dynloading of a Loader.*)
val plugin : t -> BslPluginInterface.plugin

(** {6 Dynlink API} *)

(** Marshaled structure Dynlinker.

[loadfile_private filename] does :
+ loads the type [t] from a file
+ build the [BslLib.loader_introspection] using [loader_introspection]
+ register it in the loader table of libbsl using [BslLib.LoaderTable.register_bootstrap_loader]
@param filename the name of the file containing the marshaled structure
@raise Error in case of I/O error
@see "BslDynlink" which uses this function
@see "Dynlink" from ocaml standard library
*)
val loadfile_private : filename -> unit

(** an alias for [loadfile_private]
@deprecated Please use [loadfile_private] *)
val loadfile : filename -> unit

(** {6 Registering API for bslregister} *)

(**
The type to construct a [t] from BslLib register API.
the type [session] is imperative, and register functions have
a side effect on values of this type.
Once finished registering things in session, use [finalize],
to build a functionnal structure of type [t].
*)
type session

(** build a fresh new session *)
val create : unit -> session

(** EXPORT an session to a serializable and not mutable value *)
val finalize : session -> t

(** a) dynloader fields *)
(** *)
val unsafe_register_primitive : session -> BslPluginInterface.register_primitive
val unsafe_register_type : session -> BslPluginInterface.register_type

(** b) other fields *)

type contents = string
type module_name = string
type uniq_id = string

(** *)

val register_basename : session -> BslPluginInterface.plugin_basename -> unit
val register_module_name : session -> module_name -> unit
val register_uniq_id : session -> uniq_id -> unit
val register_conf : session -> BslConf.conf -> unit
val register_ml_runtime : session -> module_name -> unit
val register_depends : session -> module_name list -> unit

val register_opa_code : session -> (filename * contents) list -> unit
val register_js_code : session -> (filename * contents * BslJsConf.conf) list -> unit

val register_ocaml_env : session -> BslPluginInterface.ocaml_env -> unit
val register_javascript_env : session -> BslPluginInterface.javascript_env -> unit
Something went wrong with that request. Please try again.