Skip to content

Commit

Permalink
conditionalize the changes in ocaml/ocaml#13193
Browse files Browse the repository at this point in the history
  • Loading branch information
anmonteiro committed Oct 20, 2024
1 parent ef0ce7a commit 6eca58d
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 3 deletions.
8 changes: 8 additions & 0 deletions jscomp/stdlib/camlinternalMod.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,17 @@ let rec update_mod_field modu i shape n =
| Value _ ->
() (* the value is already there *)
| Class ->
#if OCAML_VERSION >= (5, 3, 0)
assert (Obj.tag n = 0 && Obj.size n = 3);
#else
assert (Obj.tag n = 0 && Obj.size n = 4);
#endif
let cl = Obj.field modu i in
#if OCAML_VERSION >= (5, 3, 0)
for j = 0 to 2 do
#else
for j = 0 to 3 do
#endif
Obj.set_field cl j (Obj.field n j)
done
| Module comps ->
Expand Down
9 changes: 9 additions & 0 deletions jscomp/stdlib/camlinternalOO.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,12 @@ let init_class table =
table.initializers <- List.rev table.initializers;
resize table (3 + Obj.magic table.methods.(1) * 16 / Sys.word_size)


#if OCAML_VERSION >= (5, 3, 0)
let inherits cla vals virt_meths concr_meths (_, super, env) top =
#else
let inherits cla vals virt_meths concr_meths (_, super, _, env) top =
#endif
narrow cla vals virt_meths concr_meths;
let init =
if top then super cla env else Obj.repr (super cla) in
Expand All @@ -345,7 +350,11 @@ let make_class pub_meths class_init =
let table = create_table pub_meths in
let env_init = class_init table in
init_class table;
#if OCAML_VERSION >= (5, 3, 0)
(env_init (Obj.repr 0), class_init, Obj.repr 0)
#else
(env_init (Obj.repr 0), class_init, env_init, Obj.repr 0)
#endif

type init_table = { mutable env_init: t; mutable class_init: table -> t }
[@@warning "-unused-field"]
Expand Down
8 changes: 8 additions & 0 deletions jscomp/stdlib/camlinternalOO.cppo.mli
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,18 @@ val create_table : string array -> table
val init_class : table -> unit
val inherits :
table -> string array -> string array -> string array ->
#if OCAML_VERSION >= (5, 3, 0)
(t * (table -> obj -> Obj.t) * obj) -> bool -> Obj.t array
#else
(t * (table -> obj -> Obj.t) * t * obj) -> bool -> Obj.t array
#endif
val make_class :
string array -> (table -> Obj.t -> t) ->
#if OCAML_VERSION >= (5, 3, 0)
(t * (table -> Obj.t -> t) * Obj.t)
#else
(t * (table -> Obj.t -> t) * (Obj.t -> t) * Obj.t)
#endif
type init_table
val make_class_store :
string array -> (table -> t) -> init_table -> unit
Expand Down
30 changes: 27 additions & 3 deletions jscomp/stdlib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,15 @@
(deps camlinternalMod.cppo.ml)
(target camlinternalMod.ml)
(action
(run cppo -D=BS %{env:CPPO_FLAGS=} %{deps} -o %{target})))
(run
cppo
-D=BS
-V
OCAML:%{ocaml_version}
%{env:CPPO_FLAGS=}
%{deps}
-o
%{target})))

(rule
(deps camlinternalMod.cppo.mli)
Expand All @@ -83,13 +91,29 @@
(deps camlinternalOO.cppo.ml)
(target camlinternalOO.ml)
(action
(run cppo -D=BS %{env:CPPO_FLAGS=} %{deps} -o %{target})))
(run
cppo
-D=BS
-V
OCAML:%{ocaml_version}
%{env:CPPO_FLAGS=}
%{deps}
-o
%{target})))

(rule
(deps camlinternalOO.cppo.mli)
(target camlinternalOO.mli)
(action
(run cppo -D=BS %{env:CPPO_FLAGS=} %{deps} -o %{target})))
(run
cppo
-D=BS
-V
OCAML:%{ocaml_version}
%{env:CPPO_FLAGS=}
%{deps}
-o
%{target})))

(rule
(deps float.cppo.ml)
Expand Down

0 comments on commit 6eca58d

Please sign in to comment.