Skip to content
This repository
tag: v783
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 119 lines (91 sloc) 4.104 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
(*
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/>.
*)
(** Retrieve the current idents, after any renaming, from original
names. *)
(** {6 How use it?}*)

(** This module link ident expressions with a string corresponding to
the original name on the code after any renaming. So, once
renaming is done, you can call [typ "list"] to get the ident of
the type "list", or [val_ "myvar"] to get the ident of the myvar
variable.

All optional argument [side] is by default equals to
[`server]. Before slicing, for all functions that take an optional
argument [side:`client] should be throw an exception.

With the introduction of opacapi in the compiler, you are not
allowed to perform query to string which are not in opacapi.
*)

(** {6 Side definition} *)
(** Describe the side *)
type side = [`server | `client]

(** Get the other side *)
val other_side : side -> side

(** {6 Values}*)

val val_no_opacapi_check : ?side:side -> string -> QmlAst.ident
  (** only use for determinitic hashed naming schemes *)

val val_noerr : ?side:side -> string -> QmlAst.ident
  (** Get the ident of the value originally named by the given
[string]. Throw [Not_found] if the name doesn't exists on the
corresponding [side]. *)

val val_ : ?side:side -> string -> QmlAst.ident
  (**
same as [val_noerr], excepts that is prints an error message and exits instead
of raising an exception
*)

(** Get the optional ident of the value originally named by the
given [string]. *)
val val_opt : ?side:side -> string -> QmlAst.ident option

(** Add [ident] as the value originally named by the given
[string]. Throw an exception if the linking already exists.*)
val val_add : ?side:side -> string -> QmlAst.ident

(** Same as [val_add] but doesn't throw any exception. *)
val val_unsafe_add : ?side:side -> string -> QmlAst.ident

(** {6 Starting server value}
If we need other internal ident we can make this function :
- val_internal : string -> QmlAst.ident option
- val_internal_add : string -> QmlAst.ident
...
*)
(** Create a [start_server] ident.
@raise Failure "start_server" If an start_server ident was
already created.
*)
val val_start_server_add : unit -> QmlAst.ident

(** Getting the [start_server] ident if it was already created. *)
val val_start_server : unit -> QmlAst.ident option

(** {6 Types}*)
(** Get the ident of the value originally named by the given
[string]. Throw [Not_found] if the name doesn't exists on the
corresponding [side]. *)
val typ : string -> QmlAst.ident

(** {6 Map setter & getter}*)
(** Directly get the map of values *)
val get_val_map : ?side: side -> unit -> QmlAst.ident StringMap.t

(** Directly set the map of values *)
val set_val_map : ?side:side -> QmlAst.ident StringMap.t -> unit

(** Directly set the map of types *)
val set_typ_map : QmlAst.ident StringMap.t -> unit

(** {6 Iterators}*)
(** Iter on the map of value.*)
val iter_val_map : ?side:side -> (string -> QmlAst.ident -> unit) -> unit

(** Map on the map of value.*)
val map_val_map : ?side:side -> (QmlAst.ident -> 'a) -> 'a StringMap.t

(** Fold on the map of value.*)
val fold_val_map : ?side:side -> (string -> QmlAst.ident -> 'a -> 'a) -> 'a -> 'a

(** keep the maps only the identifiers satisfying the given predicates
this function is applied to the two maps of identifiers (client and server) *)
val filter : (Ident.t -> bool) -> unit

(**
Clears the state of this module
*)
val reset : unit -> unit
Something went wrong with that request. Please try again.