1
(************************************************************************)
2
(* v * The Coq Proof Assistant / The Coq Development Team *)
3
(* <O___,, * CNRS-Ecole Polytechnique-INRIA Futurs-Universite Paris Sud *)
4
(* \VV/ **************************************************************)
5
(* // * This file is distributed under the terms of the *)
6
(* * GNU Lesser General Public License Version 2.1 *)
7
(************************************************************************)
9
(*i $Id: libobject.mli 11282 2008-07-28 11:51:53Z msozeau $ i*)
17
(* [Libobject] declares persistent objects, given with methods:
19
* a caching function specifying how to add the object in the current
21
If the object wishes to register its visibility in the Nametab,
22
it should do so for all possible sufixes.
24
* a loading function, specifying what to do when the module
25
containing the object is loaded;
26
If the object wishes to register its visibility in the Nametab,
27
it should do so for all sufixes no shorter then the "int" argument
29
* an opening function, specifying what to do when the module
30
containing the object is opened (imported);
31
If the object wishes to register its visibility in the Nametab,
32
it should do so for the sufix of the length the "int" argument
34
* a classification function, specyfying what to do with the object,
35
when the current module (containing the object) is ended;
36
The possibilities are:
37
Dispose - the object dies at the end of the module
38
Substitue - meaning the object is substitutive and
39
the module name must be updated
40
Keep - the object is not substitutive, but survives module
42
Anticipate - this is for objects which have to be explicitely
43
managed by the [end_module] function (like Require
46
The classification function is also an occasion for a cleanup
47
(if this function returns Keep or Substitute of some object, the
48
cache method is never called for it)
50
* a substitution function, performing the substitution;
51
this function should be declared for substitutive objects
54
* a discharge function, that is applied at section closing time to
55
collect the data necessary to rebuild the discharged form of the
58
* a rebuild function, that is applied after section closing to
59
rebuild the non volatile content of a section from the data
60
collected by the discharge function
62
* an export function, to enable optional writing of its contents
63
to disk (.vo). This function is also the oportunity to remove
64
redundant information in order to keep .vo size small
66
The export function is a little obsolete and will be removed
71
type 'a substitutivity =
72
Dispose | Substitute of 'a | Keep of 'a | Anticipate of 'a
74
type 'a object_declaration = {
76
cache_function : object_name * 'a -> unit;
77
load_function : int -> object_name * 'a -> unit;
78
open_function : int -> object_name * 'a -> unit;
79
classify_function : object_name * 'a -> 'a substitutivity;
80
subst_function : object_name * substitution * 'a -> 'a;
81
discharge_function : object_name * 'a -> 'a option;
82
rebuild_function : 'a -> 'a;
83
export_function : 'a -> 'a option }
85
(* The default object is a "Keep" object with empty methods.
86
Object creators are advised to use the construction
87
[{(default_object "MY_OBJECT") with
90
and specify only these functions which are not empty/meaningless
94
val default_object : string -> 'a object_declaration
96
(* the identity substitution function *)
97
val ident_subst_function : object_name * substitution * 'a -> 'a
99
(*s Given an object declaration, the function [declare_object]
100
will hand back two functions, the "injection" and "projection"
101
functions for dynamically typed library-objects. *)
106
'a object_declaration -> ('a -> obj) * (obj -> 'a)
108
val object_tag : obj -> string
110
val cache_object : object_name * obj -> unit
111
val load_object : int -> object_name * obj -> unit
112
val open_object : int -> object_name * obj -> unit
113
val subst_object : object_name * substitution * obj -> obj
114
val classify_object : object_name * obj -> obj substitutivity
115
val export_object : obj -> obj option
116
val discharge_object : object_name * obj -> obj option
117
val rebuild_object : obj -> obj
118
val relax : bool -> unit