mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
feat(runtimes/jsoo): add a new class type duration with conv functions
This commit is contained in:
parent
0c180e12f9
commit
d3d254033c
@ -7,7 +7,13 @@
|
|||||||
(library
|
(library
|
||||||
(name clerk_driver)
|
(name clerk_driver)
|
||||||
(public_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))
|
(modules clerk_driver))
|
||||||
|
|
||||||
(executable
|
(executable
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
(library
|
(library
|
||||||
(name runtime_jsoo)
|
(name runtime_jsoo)
|
||||||
(public_name catala.runtime_jsoo)
|
(public_name catala.runtime_jsoo)
|
||||||
|
(preprocess
|
||||||
|
(pps js_of_ocaml-ppx))
|
||||||
(libraries catala.runtime_ocaml js_of_ocaml)
|
(libraries catala.runtime_ocaml js_of_ocaml)
|
||||||
(modules runtime))
|
(modules runtime))
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
the License. *)
|
the License. *)
|
||||||
|
|
||||||
open Js_of_ocaml
|
open Js_of_ocaml
|
||||||
|
module R_ocaml = Runtime_ocaml.Runtime
|
||||||
|
|
||||||
class type source_position =
|
class type source_position =
|
||||||
object
|
object
|
||||||
@ -41,10 +42,18 @@ class type event =
|
|||||||
|
|
||||||
class type duration =
|
class type duration =
|
||||||
object
|
object
|
||||||
method years : int Js.prop
|
method years : int Js.readonly_prop
|
||||||
method months : int Js.prop
|
method months : int Js.readonly_prop
|
||||||
method days : int Js.prop
|
method days : int Js.readonly_prop
|
||||||
end
|
end
|
||||||
|
|
||||||
(* let duration_of_jsoo d = *)
|
let duration_of_jsoo d =
|
||||||
(* Runtime.duration_of_numbers d##.years d##.months d##.days *)
|
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
|
||||||
|
@ -44,10 +44,10 @@ class type event =
|
|||||||
|
|
||||||
class type duration =
|
class type duration =
|
||||||
object
|
object
|
||||||
method years : int Js.prop
|
method years : int Js.readonly_prop
|
||||||
method months : int Js.prop
|
method months : int Js.readonly_prop
|
||||||
method days : int Js.prop
|
method days : int Js.readonly_prop
|
||||||
end
|
end
|
||||||
|
|
||||||
(* let duration_of_jsoo d = *)
|
val duration_of_jsoo : duration Js.t -> Runtime_ocaml.Runtime.duration
|
||||||
(* Runtime.duration_of_numbers d##.years d##.months d##.days *)
|
val duration_to_jsoo : Runtime_ocaml.Runtime.duration -> duration Js.t
|
||||||
|
Loading…
Reference in New Issue
Block a user