module Data:sig..end
Data Encoding.
This module is responsible for marshaling and demarshaling data to handle communications between the server and the client in both directions.
Each datatype must be equipped with functions to encode and decode values to/from JSON format. Moreover, data types shall be also properly documented and registered in the generated documentation of the Frama-C server.
Generally speaking, we will have a module with signature Data.D for every
datatype to be exchanged with the server. For simple values, predefined
modules are already provided. More complex datatypes can be built with some
functors, typically for options, lists or arrays.
Records and enumerated types are typical in JSON formatting, but difficult to build from OCaml records and abstract datatypes. For those kinds of data, we provide an API based on the following general scheme:
Hence, in addition to module signature Data.S for values, there is also a
polymorphic type 'a Data.data for module values carrying a data module with
type t = 'a.
The same mechanism is used throughout modules States and Request each
time a JSON record or tag is needed.
typejson =Json.t
val pretty : Stdlib.Format.formatter -> json -> unit
module type S =sig..end
Datatype module signature.
module Junit:Swith type t = unit
module Jany:Swith type t = json
module Jbool:Swith type t = bool
module Jint:Swith type t = int
module Jfloat:Swith type t = float
module Jstring:Swith type t = string
module Jalpha:Swith type t = string
module Jtext:Swith type t = json
Rich text encoding, see Jbuffer.
module Jmarkdown:Swith type t = Markdown.text
val jpretty : ?indent:int ->
?margin:int ->
(Stdlib.Format.formatter -> 'a -> unit) -> 'a -> Jtext.tAll-in-one formatter. Return the JSON encoding of formatted text.
module Joption:
module Jpair:
module Jtriple:
module Jlist:
module Jalist:
module Jarray:
type'adata =(module Server.Data.S with type t = 'a)
Polymorphic data value.
val junit : unit data
val jany : json data
val jbool : bool data
val jint : int data
val jfloat : float data
val jstring : string data
val jalpha : string data
val jindex : kind:string -> int data
val jkey : kind:string -> string data
val jlist : 'a data -> 'a list data
val jalist : 'a data -> 'a list data
val jarray : 'a data -> 'a array data
val joption : 'a data -> 'a option data
val derived : package:Server.Package.package ->
id:Server.Package.ident -> Server.Package.jtype -> unitDeclare the derived names for the provided type. Shall not be used directely.
val declare : package:Server.Package.package ->
name:string ->
?descr:Markdown.text -> Server.Package.jtype -> Server.Package.jtypeDeclare a new type and returns its alias.
Same as Jdata (declare_id ~package ~name (D_type js)).
Automatically declare the derived names.
module Record:sig..end
Record factory.
module Tag:Swith type t = tagInfo
module Enum:sig..end
Enum factory.
These datatypes automatically index complex values with unique identifiers. This avoids to encode the internal OCaml representation of each value, by only providing to the server a unique identifier for each value.
These datatype functors come into three flavors:
Index() for projectified datatypes,Static() for project independant datatypes,Identified() for projectified values already identified by integers.module type Info =sig..end
Datatype information.
module type Map =sig..end
Simplified Map.S.
module type Index =sig..end
Datatype extended with access to value identifiers.
module Static:
Builds an indexer that does not depend on current project.
module Index:
Builds a projectified index.
module type IdentifiedType =sig..end
Datatype already identified by unique integers.
module Identified:
Builds a projectified index on types with unique identifiers.
These utilities shall be used when writing your own encoding and decoding values to JSON format.
exception InputError of string
Exception thrown during the decoding of a request's inputs.
val failure : ?json:json ->
('a, Stdlib.Format.formatter, unit, 'b) Stdlib.format4 -> 'aInputError with provided message.val failure_from_type_error : string -> json -> 'aInputError from Yojson.Basic.Util.Type_error arguments.