Module Server.Data

module Data: sig .. end


Data Encoding.

Datatypes

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 '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.

type json = Json.t 
val page : Server.Doc.page
Documentation page for general purpose data types.
val pretty : Format.formatter -> json -> unit
module type S = sig .. end
Datatype module signature.
module type Info = sig .. end
Datatype informations.
type 'a data = (module Server.Data.S with type t = 'a) 
Polymorphic data value.

Collections


module type S_collection = sig .. end
module Collection: 
functor (A : S-> S_collection with type t = A.t

Atomic Data


module Junit: S  with type t = unit
module Jany: S  with type t = json
module Jbool: S_collection  with type t = bool
module Jint: S_collection  with type t = int
module Jfloat: S_collection  with type t = float
module Jstring: S_collection  with type t = string
module Jident: S_collection  with type t = string
Syntax is ident.
module Jtext: S  with type t = json
Rich text encoding, see Jbuffer.
module Jmarkdown: S  with type t = Markdown.text

Constructors


module Joption: 
functor (A : S-> S with type t = A.t option
module Jpair: 
functor (A : S-> 
functor (B : S-> S with type t = A.t * B.t
module Jtriple: 
functor (A : S-> 
functor (B : S-> 
functor (C : S-> S with type t = A.t * B.t * C.t
module Jlist: 
functor (A : S-> S with type t = A.t list
module Jarray: 
functor (A : S-> S with type t = A.t array

Records


module Record: sig .. end
Record factory.

Enums


module Tag: S_collection  with type t = Syntax.tag
module Enum: sig .. end
Enum factory.

Indexed Values

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:


module type Map = sig .. end
Simplified Map.S.
module type Index = sig .. end
Datatype extended with access to value identifiers.
module Static: 
functor (M : Map-> 
functor (I : Info-> Index with type t = M.key
Builds an indexer that does not depend on current project.
module Index: 
functor (M : Map-> 
functor (I : Info-> Index with type t = M.key
Builds a projectified index.
module type IdentifiedType = sig .. end
Datatype already identified by unique integers.
module Identified: 
functor (A : IdentifiedType-> Index with type t = A.t
Builds a projectified index on types with unique identifiers.

Error handling

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, Format.formatter, unit, 'b) Pervasives.format4 -> 'a
Raises InputError with provided message.
val failure_from_type_error : string -> json -> 'a
Raises InputError from Yojson.Basic.Util.Type_error arguments.