aboutsummaryrefslogtreecommitdiff
path: root/library
diff options
context:
space:
mode:
authorMaxime Dénès2020-01-30 08:33:36 +0100
committerMaxime Dénès2020-01-30 08:33:36 +0100
commit504f3d6842fa91cdb3f5df1712c0fbb0c9bde112 (patch)
tree55d8bd378801fe69eb32a31eb3d26cfd7bc325c8 /library
parentd05e061cafc543955700dcbd7fb0f15495efad13 (diff)
parentc2341feb58a233598658eeb68a08395b12715b2a (diff)
Merge PR #11307: Remove the hacks relying on hardwired libobject tags.
Reviewed-by: maximedenes
Diffstat (limited to 'library')
-rw-r--r--library/libobject.ml14
-rw-r--r--library/libobject.mli8
2 files changed, 9 insertions, 13 deletions
diff --git a/library/libobject.ml b/library/libobject.ml
index c9ea6bcff8..28d0654444 100644
--- a/library/libobject.ml
+++ b/library/libobject.ml
@@ -82,8 +82,6 @@ and objects = (Names.Id.t * t) list
and substitutive_objects = MBId.t list * algebraic_objects
-let object_tag (Dyn.Dyn (t, _)) = Dyn.repr t
-
module DynMap = Dyn.Map (struct type 'a t = 'a object_declaration end)
let cache_tab = ref DynMap.empty
@@ -92,14 +90,12 @@ let declare_object_full odecl =
let na = odecl.object_name in
let tag = Dyn.create na in
let () = cache_tab := DynMap.add tag odecl !cache_tab in
- let infun v = Dyn.Dyn (tag, v) in
- let outfun v = match Dyn.Easy.prj v tag with
- | None -> assert false
- | Some v -> v
- in
- (infun,outfun)
+ tag
-let declare_object odecl = fst (declare_object_full odecl)
+let declare_object odecl =
+ let tag = declare_object_full odecl in
+ let infun v = Dyn.Dyn (tag, v) in
+ infun
let cache_object (sp, Dyn.Dyn (tag, v)) =
let decl = DynMap.find tag !cache_tab in
diff --git a/library/libobject.mli b/library/libobject.mli
index 146ccc293f..c25345994a 100644
--- a/library/libobject.mli
+++ b/library/libobject.mli
@@ -101,7 +101,9 @@ val ident_subst_function : substitution * 'a -> 'a
will hand back two functions, the "injection" and "projection"
functions for dynamically typed library-objects. *)
-type obj
+module Dyn : Dyn.S
+
+type obj = Dyn.t
type algebraic_objects =
| Objs of objects
@@ -120,13 +122,11 @@ and objects = (Names.Id.t * t) list
and substitutive_objects = Names.MBId.t list * algebraic_objects
val declare_object_full :
- 'a object_declaration -> ('a -> obj) * (obj -> 'a)
+ 'a object_declaration -> 'a Dyn.tag
val declare_object :
'a object_declaration -> ('a -> obj)
-val object_tag : obj -> string
-
val cache_object : object_name * obj -> unit
val load_object : int -> object_name * obj -> unit
val open_object : int -> object_name * obj -> unit