Frama-C API - Enum
Enum factory.
You shall start by declaring a dictionary with Enum.dictionary for your values. Then, populate the dictionary with Enum.tag values. Finally, you shall call Enum.publish to obtain a new data module for your type.
You have two options for computing tags: either you provide values when declaring tags, and these tags will be associated to registered values for both directions; alternatively you might provide a ~tag function to Enum.publish.
The difficulty when providing values only at tag definition is to ensure that all possible value has been registered.
The conversion values from and to json may fail when no value has been registered with tags.
val tag_name : 'a tag -> stringval dictionary : unit -> 'a dictionaryCreates an opened, empty dictionary.
val tag : name:string -> ?label:Frama_c_kernel.Markdown.text -> descr:Frama_c_kernel.Markdown.text -> ?value:'a -> 'a dictionary -> 'a tagRegister a new tag in the dictionary. The default label is the capitalized name. The provided value, if any, will be used for decoding json tags. If would be used also for encoding values to json tags if no ~tag function is provided when publishing the dictionary. Registered values must be hashable with Hashtbl.hash function.
You may register a new tag after the dictionary has been published.
val add : name:string -> ?label:Frama_c_kernel.Markdown.text -> descr:Frama_c_kernel.Markdown.text -> ?value:'a -> 'a dictionary -> unitSame as tag but to not return the associated tag.
val find : 'a dictionary -> 'a tag -> 'aReturns the value associated to some tag.
val lookup : 'a dictionary -> 'a -> 'a tagReturns the tag associated to a value.
val find_tag : 'a dictionary -> string -> 'a tagReturns the tag from its name.
val prefix : name:string -> ?var:string -> ?label:Frama_c_kernel.Markdown.text -> descr:Frama_c_kernel.Markdown.text -> 'a dictionary -> 'a prefixRegister a new prefix tag in the dictionary. The default label is the capitalized prefix. To decoding from json is provided to prefix tags. Encoding is done by emitting tags with form 'prefix:*'. The variable part of the prefix is documented as 'prefix:xxx' when ~var:"xxx" is provided.
You may register a new prefix-tag after the dictionary has been published.
Returns the tag for a value associated with the given prefix.
val extends : name:string -> ?label:Frama_c_kernel.Markdown.text -> descr:Frama_c_kernel.Markdown.text -> ?value:'a -> 'a prefix -> 'a tagPublish a new instance in the documentation.
val tags : 'a dictionary -> Tag.t listObtain all the tags registered in the dictionary so far.
val set_lookup : 'a dictionary -> ('a -> 'a tag) -> unitSet tagging function for values. If the lookup function raises `Not_found`, the dictionary will use the tag associated with the provided value, if any.
val publish : package:Package.package -> name:string -> descr:Frama_c_kernel.Markdown.text -> 'a dictionary -> (module S with type t = 'a)Publish the dictionary. No more tag nor prefix can be added afterwards. If no ~tag function is provided, the values registered with tags are used.
