diff --git a/build_system/dune b/build_system/dune index 515077bd..9fe70d05 100644 --- a/build_system/dune +++ b/build_system/dune @@ -7,7 +7,13 @@ (library (name clerk_driver) (public_name clerk.driver) - (libraries catala.runtime_ocaml catala.utils ninja_utils cmdliner re ANSITerminal) + (libraries + catala.runtime_ocaml + catala.utils + ninja_utils + cmdliner + re + ANSITerminal) (modules clerk_driver)) (executable diff --git a/runtimes/jsoo/dune b/runtimes/jsoo/dune index 8fa72b53..0cf5f2ef 100644 --- a/runtimes/jsoo/dune +++ b/runtimes/jsoo/dune @@ -1,5 +1,7 @@ (library (name runtime_jsoo) (public_name catala.runtime_jsoo) + (preprocess + (pps js_of_ocaml-ppx)) (libraries catala.runtime_ocaml js_of_ocaml) (modules runtime)) diff --git a/runtimes/jsoo/runtime.ml b/runtimes/jsoo/runtime.ml index 64a63c51..394f5334 100644 --- a/runtimes/jsoo/runtime.ml +++ b/runtimes/jsoo/runtime.ml @@ -15,6 +15,7 @@ the License. *) open Js_of_ocaml +module R_ocaml = Runtime_ocaml.Runtime class type source_position = object @@ -41,10 +42,18 @@ class type event = class type duration = object - method years : int Js.prop - method months : int Js.prop - method days : int Js.prop + method years : int Js.readonly_prop + method months : int Js.readonly_prop + method days : int Js.readonly_prop end -(* let duration_of_jsoo d = *) -(* Runtime.duration_of_numbers d##.years d##.months d##.days *) +let duration_of_jsoo d = + R_ocaml.duration_of_numbers d##.years d##.months d##.days + +let duration_to_jsoo d = + let years, months, days = R_ocaml.duration_to_years_months_days d in + object%js + val years = years + val months = months + val days = days + end diff --git a/runtimes/jsoo/runtime.mli b/runtimes/jsoo/runtime.mli index 7bc88e8e..8e829abd 100644 --- a/runtimes/jsoo/runtime.mli +++ b/runtimes/jsoo/runtime.mli @@ -44,10 +44,10 @@ class type event = class type duration = object - method years : int Js.prop - method months : int Js.prop - method days : int Js.prop + method years : int Js.readonly_prop + method months : int Js.readonly_prop + method days : int Js.readonly_prop end -(* let duration_of_jsoo d = *) -(* Runtime.duration_of_numbers d##.years d##.months d##.days *) +val duration_of_jsoo : duration Js.t -> Runtime_ocaml.Runtime.duration +val duration_to_jsoo : Runtime_ocaml.Runtime.duration -> duration Js.t