Skip to content

Commit c2faa20

Browse files
committed
jsoo stdlib internal mli
1 parent 85bb103 commit c2faa20

10 files changed

+212
-38
lines changed

stdlib/jsoo/date_internal_jsoo.ml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,29 @@ let add_rounded_up_jsoo d dur =
2424
@@ Dates_calc.add_dates ~round:Dates_calc.RoundUp (date_of_jsoo d)
2525
(duration_of_jsoo dur)
2626

27-
let () =
28-
Js.export "Date_internal"
29-
(object%js
30-
method of_ymd_ pos y m d = of_ymd_jsoo pos y m d
31-
method to_ymd_ d = to_ymd_jsoo d
32-
method last_day_of_month_ d = last_day_of_month_jsoo d
33-
method add_rounded_down_ d dur = add_rounded_down_jsoo d dur
34-
method add_rounded_up_ d dur = add_rounded_up_jsoo d dur
35-
end)
27+
class type default_ct = object
28+
method of_ymd_ :
29+
code_location_jsoo ->
30+
integer_jsoo ->
31+
integer_jsoo ->
32+
integer_jsoo ->
33+
date_jsoo Js.meth
34+
35+
method to_ymd_ : date_jsoo -> integer_jsoo Js.js_array Js.t Js.meth
36+
method last_day_of_month_ : date_jsoo -> date_jsoo Js.meth
37+
method add_rounded_down_ : date_jsoo -> duration_jsoo -> date_jsoo Js.meth
38+
method add_rounded_up_ : date_jsoo -> duration_jsoo -> date_jsoo Js.meth
39+
end
40+
41+
type default = default_ct Js.t
42+
43+
let default : default =
44+
object%js
45+
method of_ymd_ pos y m d = of_ymd_jsoo pos y m d
46+
method to_ymd_ d = to_ymd_jsoo d
47+
method last_day_of_month_ d = last_day_of_month_jsoo d
48+
method add_rounded_down_ d dur = add_rounded_down_jsoo d dur
49+
method add_rounded_up_ d dur = add_rounded_up_jsoo d dur
50+
end
51+
52+
let () = Js.export "Date_internal" default

stdlib/jsoo/date_internal_jsoo.mli

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
open Js_of_ocaml
2+
open Catala_runtime_jsoo
3+
4+
class type default_ct = object
5+
method of_ymd_ :
6+
code_location_jsoo ->
7+
integer_jsoo ->
8+
integer_jsoo ->
9+
integer_jsoo ->
10+
date_jsoo Js.meth
11+
12+
method to_ymd_ : date_jsoo -> integer_jsoo Js.js_array Js.t Js.meth
13+
method last_day_of_month_ : date_jsoo -> date_jsoo Js.meth
14+
method add_rounded_down_ : date_jsoo -> duration_jsoo -> date_jsoo Js.meth
15+
method add_rounded_up_ : date_jsoo -> duration_jsoo -> date_jsoo Js.meth
16+
end
17+
18+
type default = default_ct Js.t
19+
20+
val default : default

stdlib/jsoo/decimal_internal_jsoo.ml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ open Decimal_internal
44
let round_to_decimal_jsoo m n =
55
decimal_to_jsoo @@ round_to_decimal (decimal_of_jsoo m) (integer_of_jsoo n)
66

7-
let () =
8-
Js_of_ocaml.Js.export "Decimal_internal"
9-
(object%js
10-
method round_to_decimal_ m n = round_to_decimal_jsoo m n
11-
end)
7+
class type default_ct = object
8+
method round_to_decimal_ :
9+
decimal_jsoo -> integer_jsoo -> decimal_jsoo Js_of_ocaml.Js.meth
10+
end
11+
12+
type default = default_ct Js_of_ocaml.Js.t
13+
14+
let default : default =
15+
object%js
16+
method round_to_decimal_ m n = round_to_decimal_jsoo m n
17+
end
18+
19+
let () = Js_of_ocaml.Js.export "Decimal_internal" default
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
open Catala_runtime_jsoo
2+
open Decimal_internal
3+
4+
class type default_ct = object
5+
method round_to_decimal_ :
6+
decimal_jsoo -> integer_jsoo -> decimal_jsoo Js_of_ocaml.Js.meth
7+
end
8+
9+
type default = default_ct Js_of_ocaml.Js.t
10+
11+
val default : default

stdlib/jsoo/list_internal_jsoo.ml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,32 @@ let remove_nth_element_jsoo arr n =
1515

1616
let reverse_jsoo arr = Js.array (reverse (Js.to_array arr))
1717

18-
let () =
19-
Js.export "List_internal"
20-
(object%js
21-
method sequence start stop = sequence_jsoo start stop
22-
method nth_element_ arr n = nth_element_jsoo arr n
23-
method remove_nth_element_ arr n = remove_nth_element_jsoo arr n
24-
method reverse arr = reverse_jsoo arr
25-
end)
18+
class type default_ct = object
19+
method sequence :
20+
integer_jsoo -> integer_jsoo -> integer_jsoo Js.js_array Js.t Js.meth
21+
22+
method nth_element_ :
23+
Js.Unsafe.any Js.js_array Js.t ->
24+
integer_jsoo ->
25+
Js.Unsafe.any Optional.jsoo Js.meth
26+
27+
method remove_nth_element_ :
28+
Js.Unsafe.any Js.js_array Js.t ->
29+
integer_jsoo ->
30+
Js.Unsafe.any Js.js_array Js.t Js.meth
31+
32+
method reverse :
33+
Js.Unsafe.any Js.js_array Js.t -> Js.Unsafe.any Js.js_array Js.t Js.meth
34+
end
35+
36+
type default = default_ct Js.t
37+
38+
let default : default =
39+
object%js
40+
method sequence start stop = sequence_jsoo start stop
41+
method nth_element_ arr n = nth_element_jsoo arr n
42+
method remove_nth_element_ arr n = remove_nth_element_jsoo arr n
43+
method reverse arr = reverse_jsoo arr
44+
end
45+
46+
let () = Js.export "List_internal" default

stdlib/jsoo/list_internal_jsoo.mli

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
open Js_of_ocaml
2+
open Catala_runtime_jsoo
3+
4+
class type default_ct = object
5+
method sequence :
6+
integer_jsoo -> integer_jsoo -> integer_jsoo Js.js_array Js.t Js.meth
7+
8+
method nth_element_ :
9+
Js.Unsafe.any Js.js_array Js.t ->
10+
integer_jsoo ->
11+
Js.Unsafe.any Optional.jsoo Js.meth
12+
13+
method remove_nth_element_ :
14+
Js.Unsafe.any Js.js_array Js.t ->
15+
integer_jsoo ->
16+
Js.Unsafe.any Js.js_array Js.t Js.meth
17+
18+
method reverse :
19+
Js.Unsafe.any Js.js_array Js.t -> Js.Unsafe.any Js.js_array Js.t Js.meth
20+
end
21+
22+
type default = default_ct Js.t
23+
24+
val default : default

stdlib/jsoo/money_internal_jsoo.ml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,16 @@ open Money_internal
44
let round_to_decimal_jsoo m n =
55
money_to_jsoo (round_to_decimal (money_of_jsoo m) (integer_of_jsoo n))
66

7-
let () =
8-
Js_of_ocaml.Js.export "Money_internal"
9-
(object%js
10-
method round_to_decimal_ m n = round_to_decimal_jsoo m n
11-
end)
7+
class type default_ct = object
8+
method round_to_decimal_ :
9+
money_jsoo -> integer_jsoo -> money_jsoo Js_of_ocaml.Js.meth
10+
end
11+
12+
type default = default_ct Js_of_ocaml.Js.t
13+
14+
let default : default =
15+
object%js
16+
method round_to_decimal_ m n = round_to_decimal_jsoo m n
17+
end
18+
19+
let () = Js_of_ocaml.Js.export "Money_internal" default
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
open Catala_runtime_jsoo
2+
3+
class type default_ct = object
4+
method round_to_decimal_ :
5+
money_jsoo -> integer_jsoo -> money_jsoo Js_of_ocaml.Js.meth
6+
end
7+
8+
type default = default_ct Js_of_ocaml.Js.t
9+
10+
val default : default

stdlib/jsoo/period_internal_jsoo.ml

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,35 @@ let sort_jsoo a =
88
let x = Option.get @@ Js.Optdef.to_option @@ Js.array_get a 0 in
99
let y = Option.get @@ Js.Optdef.to_option @@ Js.array_get a 1 in
1010
let start =
11-
date_of_jsoo @@ Option.get @@ Js.Optdef.to_option @@ Js.array_get x 0
11+
date_of_jsoo
12+
@@ Js.Unsafe.coerce
13+
@@ Option.get
14+
@@ Js.Optdef.to_option
15+
@@ Js.array_get x 0
1216
in
1317
let stop =
14-
date_of_jsoo @@ Option.get @@ Js.Optdef.to_option @@ Js.array_get x 1
18+
date_of_jsoo
19+
@@ Js.Unsafe.coerce
20+
@@ Option.get
21+
@@ Js.Optdef.to_option
22+
@@ Js.array_get x 1
1523
in
16-
(start, stop), y)
24+
(start, stop), Js.Unsafe.coerce y)
1725
@@ Js.to_array a
1826
in
1927
let a = sort a in
2028
Js.array
2129
@@ Array.map
2230
(fun ((start, stop), b) ->
23-
Js.array [| Js.array [| date_to_jsoo start; date_to_jsoo stop |]; b |])
31+
Js.array
32+
[|
33+
Js.array
34+
[|
35+
Js.Unsafe.inject @@ date_to_jsoo start;
36+
Js.Unsafe.inject @@ date_to_jsoo stop;
37+
|];
38+
Js.Unsafe.coerce b;
39+
|])
2440
a
2541

2642
let split_by_month_jsoo a =
@@ -40,10 +56,28 @@ let split_by_year_jsoo start_month a =
4056
(fun (d1, d2) -> Js.array [| date_to_jsoo d1; date_to_jsoo d2 |])
4157
(split_by_year start_month (date_of_jsoo start, date_of_jsoo stop)))
4258

43-
let () =
44-
Js.export "Period_internal"
45-
(object%js
46-
method sort a = sort_jsoo a
47-
method split_by_month_ a = split_by_month_jsoo a
48-
method split_by_year_ s a = split_by_year_jsoo s a
49-
end)
59+
class type default_ct = object
60+
method sort :
61+
Js.Unsafe.any Js.js_array Js.t Js.js_array Js.t Js.js_array Js.t ->
62+
Js.Unsafe.any Js.js_array Js.t Js.js_array Js.t Js.js_array Js.t Js.meth
63+
64+
method split_by_month_ :
65+
date_jsoo Js.js_array Js.t ->
66+
date_jsoo Js.js_array Js.t Js.js_array Js.t Js.meth
67+
68+
method split_by_year_ :
69+
integer_jsoo ->
70+
date_jsoo Js.js_array Js.t ->
71+
date_jsoo Js.js_array Js.t Js.js_array Js.t Js.meth
72+
end
73+
74+
type default = default_ct Js.t
75+
76+
let default : default =
77+
object%js
78+
method sort a = sort_jsoo a
79+
method split_by_month_ a = split_by_month_jsoo a
80+
method split_by_year_ s a = split_by_year_jsoo s a
81+
end
82+
83+
let () = Js.export "Period_internal" default
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
open Js_of_ocaml
2+
open Catala_runtime_jsoo
3+
4+
class type default_ct = object
5+
method sort :
6+
Js.Unsafe.any Js.js_array Js.t Js.js_array Js.t Js.js_array Js.t ->
7+
Js.Unsafe.any Js.js_array Js.t Js.js_array Js.t Js.js_array Js.t Js.meth
8+
9+
method split_by_month_ :
10+
date_jsoo Js.js_array Js.t ->
11+
date_jsoo Js.js_array Js.t Js.js_array Js.t Js.meth
12+
13+
method split_by_year_ :
14+
integer_jsoo ->
15+
date_jsoo Js.js_array Js.t ->
16+
date_jsoo Js.js_array Js.t Js.js_array Js.t Js.meth
17+
end
18+
19+
type default = default_ct Js.t
20+
21+
val default : default

0 commit comments

Comments
 (0)