Skip to content

Commit 63940e7

Browse files
author
Hongbo Zhang
committed
use gz for ocaml since gitignore issues
1 parent 4c96d10 commit 63940e7

File tree

6 files changed

+366
-13
lines changed

6 files changed

+366
-13
lines changed

.gitignore

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ ocaml_pack
2727
*~
2828
stdlib/c.js
2929
*.map
30-
*.zip
31-
*.gz
3230
*#
3331
qcc/
3432
.#*
@@ -38,15 +36,12 @@ oxml
3836

3937
*.rawlambda
4038
*.lambda
41-
ocaml/*.js
42-
ocaml/*/*/*.js
43-
ocaml/*.js
39+
40+
41+
ocaml/
4442

4543

4644
test.json
47-
ocaml/bin
48-
ocaml/lib
49-
ocaml/man
5045
*~
5146
*.annot
5247
*.mj

jscomp/runtime/fn.ml

Lines changed: 0 additions & 1 deletion
This file was deleted.

jscomp/runtime/fn.ml

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2+
*
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU Lesser General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* In addition to the permissions granted to you by the LGPL, you may combine
9+
* or link a "work that uses the Library" with a publicly distributed version
10+
* of this file to produce a combined library or application, then distribute
11+
* that combined work under the terms of your choosing, with no requirement
12+
* to comply with the obligations normally placed on you by section 4 of the
13+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
14+
* should you choose to use a later version).
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Lesser General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Lesser General Public License
22+
* along with this program; if not, write to the Free Software
23+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24+
25+
26+
27+
28+
29+
30+
31+
32+
(* if we allow a ppx like [%bs.uncurry [@n]], we would allow creating this
33+
external functions dynamically.
34+
It can not reduce dependency on [Js_fn] though, since the type depends
35+
on it.
36+
Example:
37+
{[
38+
let v = [%bs.uncurry 3 f ]
39+
]}
40+
*)
41+
42+
43+
type + 'a t
44+
45+
external mk0 : (unit -> 'a0) -> 'a0 t =
46+
"js_fn_mk_00"
47+
48+
external run0 : 'a0 t -> 'a0 = "js_fn_run_00"
49+
50+
external mk1 : ('a0 -> 'a1) -> ('a0 * 'a1) t =
51+
"js_fn_mk_01"
52+
53+
external run1 : ('a0 * 'a1) t -> 'a0 -> 'a1 =
54+
"js_fn_run_01"
55+
56+
external mk2 : ('a0 -> 'a1 -> 'a2 ) -> ('a0 * 'a1 * 'a2) t =
57+
"js_fn_mk_02"
58+
59+
external run2 : ('a0 * 'a1 * 'a2 )t -> 'a0 -> 'a1 -> 'a2 =
60+
"js_fn_run_02"
61+
62+
external mk3 :
63+
('a0 -> 'a1 -> 'a2 -> 'a3 ) -> ('a0 * 'a1 * 'a2 * 'a3) t =
64+
"js_fn_mk_03"
65+
66+
external run3 :
67+
('a0 * 'a1 * 'a2 * 'a3) t -> 'a0 -> 'a1 -> 'a2 -> 'a3 =
68+
"js_fn_run_03"
69+
70+
external mk4 : ('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 )
71+
-> ('a0 * 'a1 * 'a2 * 'a3 * 'a4) t =
72+
"js_fn_mk_04"
73+
74+
external run4 : ('a0 * 'a1 * 'a2 * 'a3 * 'a4) t ->
75+
'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 =
76+
"js_fn_run_04"
77+
78+
external mk5 :
79+
('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 ) ->
80+
('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5) t =
81+
"js_fn_mk_05"
82+
83+
external run5 :
84+
('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5) t
85+
-> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 =
86+
"js_fn_run_05"
87+
88+
external mk6 : ('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6) ->
89+
('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6) t =
90+
"js_fn_mk_06"
91+
external run6 : ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6) t
92+
-> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 =
93+
"js_fn_run_06"
94+
95+
external mk7 : ('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7) ->
96+
('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 ) t =
97+
"js_fn_mk_07"
98+
99+
external run7 : ('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 ) t
100+
-> 'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 =
101+
"js_fn_run_07"
102+
103+
external mk8 : ('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 ) ->
104+
('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8 ) t =
105+
"js_fn_mk_08"
106+
107+
external run8 :
108+
('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8 ) t ->
109+
'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8
110+
=
111+
"js_fn_run_08"
112+
113+
external mk9 :
114+
('a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 -> 'a9) ->
115+
('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8 * 'a9 ) t =
116+
"js_fn_mk_09"
117+
118+
external run9 :
119+
('a0 * 'a1 * 'a2 * 'a3 * 'a4 * 'a5 * 'a6 * 'a7 * 'a8 * 'a9 ) t ->
120+
'a0 -> 'a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'a8 -> 'a9 =
121+
"js_fn_run_09"

jscomp/runtime/js.ml

Lines changed: 0 additions & 1 deletion
This file was deleted.

jscomp/runtime/js.ml

Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
2+
*
3+
* This program is free software: you can redistribute it and/or modify
4+
* it under the terms of the GNU Lesser General Public License as published by
5+
* the Free Software Foundation, either version 3 of the License, or
6+
* (at your option) any later version.
7+
*
8+
* In addition to the permissions granted to you by the LGPL, you may combine
9+
* or link a "work that uses the Library" with a publicly distributed version
10+
* of this file to produce a combined library or application, then distribute
11+
* that combined work under the terms of your choosing, with no requirement
12+
* to comply with the obligations normally placed on you by section 4 of the
13+
* LGPL version 3 (or the corresponding section of a later version of the LGPL
14+
* should you choose to use a later version).
15+
*
16+
* This program is distributed in the hope that it will be useful,
17+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19+
* GNU Lesser General Public License for more details.
20+
*
21+
* You should have received a copy of the GNU Lesser General Public License
22+
* along with this program; if not, write to the Free Software
23+
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
24+
25+
26+
27+
28+
29+
30+
(** This file will also be exported to external users
31+
Attention: it should not have any code, all its code will be inlined so that
32+
there will be never
33+
{[ require('js')]}
34+
*)
35+
external typeof : 'a -> string = "js_typeof"
36+
37+
external to_json_string : 'a -> string = "js_json_stringify"
38+
39+
external log : 'a -> unit = "js_dump"
40+
41+
42+
43+
44+
45+
type any = Obj.t
46+
47+
external erase : 'a -> any = "%identity"
48+
external cast : any -> 'a = "%identity"
49+
50+
(* Note [to_opt null] will be [null : 'a opt opt]*)
51+
52+
module Null = struct
53+
type + 'a t
54+
external to_opt : 'a t -> 'a option = "js_from_nullable"
55+
external return : 'a -> 'a t = "%identity"
56+
external test : 'a t -> bool = "js_is_nil"
57+
external empty : 'a t = "null" [@@bs.val]
58+
end
59+
60+
module Def = struct
61+
type + 'a t
62+
external to_opt : 'a t -> 'a option = "js_from_def"
63+
external return : 'a -> 'a t = "%identity"
64+
external test : 'a t -> bool = "js_is_undef"
65+
external empty : 'a t = "undefined" [@@bs.val]
66+
end
67+
68+
module Null_def = struct
69+
type + 'a t
70+
external to_opt : 'a t -> 'a option = "js_from_nullable_def"
71+
external return : 'a -> 'a t = "%identity"
72+
external test : 'a t -> bool = "js_is_nil_undef"
73+
external empty : 'a t = "undefined" [@@bs.val]
74+
end
75+
76+
type boolean
77+
78+
79+
external true_ : boolean = "true" [@@bs.val]
80+
external false_ : boolean = "false" [@@bs.val]
81+
82+
external to_bool : boolean -> bool = "js_boolean_to_bool"
83+
external to_number : 'a -> int = "js_anything_to_number" (* + conversion*)
84+
external string_of_nativeint : nativeint -> string = "js_anything_to_string"
85+
86+
external string_of_char : char -> string = "js_string_of_char"
87+
(** TODO: check with {!String.of_char}
88+
it's quite common that we have
89+
{[ Js.String.of_char x.[0] ]}
90+
It would be nice to generate code as below
91+
{[ x[0]
92+
]}
93+
*)
94+
module String = struct
95+
external of_char : char -> string = "String.fromCharCode"
96+
[@@bs.call]
97+
external toUpperCase : string -> string = "toUpperCase" [@@bs.send]
98+
external of_int : int -> base:int -> string = "toString" [@@bs.send]
99+
external of_nativeint : nativeint -> base:int -> string = "toString" [@@bs.send]
100+
external slice : string -> int -> int -> string = "slice"
101+
[@@bs.send]
102+
external slice_rest : string -> int -> string = "slice"
103+
[@@bs.send]
104+
external index_of : string -> string -> int = "indexOf"
105+
[@@bs.send]
106+
external append : string -> string -> string = "js_string_append"
107+
external of_small_int_array : int array -> string = "js_string_of_small_int_array"
108+
external of_small_int32_array : int32 array -> string = "js_string_of_small_int_array"
109+
external lastIndexOf : string -> string -> int = "lastIndexOf"
110+
[@@bs.send]
111+
external of_any : 'a -> string = "js_anything_to_string"
112+
113+
114+
(***********************)
115+
(* replaced primitives *)
116+
external length : string -> int = "%string_length"
117+
external get : string -> int -> char = "%string_safe_get"
118+
external create : int -> bytes = "caml_create_string"
119+
external unsafe_get : string -> int -> char = "%string_unsafe_get"
120+
external unsafe_set : bytes -> int -> char -> unit = "%bytes_unsafe_set"
121+
external unsafe_blit : string -> int -> bytes -> int -> int -> unit
122+
= "caml_blit_string" "noalloc"
123+
external unsafe_fill : bytes -> int -> int -> char -> unit
124+
= "caml_fill_string" "noalloc"
125+
126+
end
127+
128+
module Array = struct
129+
external new_uninitialized : int -> 'a array = "js_create_array"
130+
external append : 'a array -> 'a array -> 'a array = "js_array_append"
131+
external make : int -> 'a -> 'a array = "caml_make_vect"
132+
end
133+
module Bytes = struct
134+
external to_int_array : bytes -> int array = "%identity"
135+
external of_int_array : int array -> bytes = "%identity"
136+
external new_uninitialized : int -> bytes = "js_create_array"
137+
138+
(***********************)
139+
(* replaced primitives *)
140+
(* Note that we explicitly define [unsafe_set] instead of
141+
using {!Bytes.unsafe_set} since for some standard libraries,
142+
it might point to ["%string_unsafe_set"]
143+
*)
144+
external unsafe_set : bytes -> int -> char -> unit = "%bytes_unsafe_set"
145+
external unsafe_get : bytes -> int -> char = "%bytes_unsafe_get"
146+
external length : bytes -> int = "%bytes_length"
147+
end
148+
module Float = struct
149+
external nan : float = "NaN"
150+
[@@bs.val ]
151+
152+
external to_fixed : float -> int -> string = "toFixed"
153+
[@@bs.send]
154+
155+
external is_finite : float -> bool = "isFinite"
156+
[@@bs.call ]
157+
158+
external is_nan : float -> bool = "isNaN"
159+
[@@bs.call ]
160+
161+
external exp : float -> float = "Math.exp"
162+
[@@bs.call ]
163+
164+
external log : float -> float = "Math.log"
165+
[@@bs.call ]
166+
167+
external to_exponential : float -> prec:int -> string = "toExponential"
168+
[@@bs.send]
169+
170+
external log2 : float = "Math.LN2" [@@ bs.val ]
171+
external max : float -> float -> float = "Math.max"
172+
[@@bs.call]
173+
external random : unit -> float = "Math.random"
174+
[@@bs.call ]
175+
external of_any : 'a -> float = "js_anything_to_number"
176+
end
177+
178+
module Caml_obj = struct
179+
external set_tag : any -> int -> unit = "caml_obj_set_tag"
180+
external set_length : any -> int -> unit = "js_obj_set_length"
181+
external length : any -> int = "js_obj_length"
182+
external tag : any -> int = "caml_obj_tag"
183+
external set_tag : any -> int -> unit = "caml_obj_set_tag"
184+
external uninitialized_object : int -> int -> any = "js_uninitialized_object"
185+
external is_instance_array : any -> bool =
186+
"js_is_instance_array" (* use Array.isArray instead*)
187+
external size_of_any : any -> 'a Def.t =
188+
"length" [@@bs.get]
189+
external tag_of_any : any -> 'a Def.t =
190+
"tag" [@@bs.get]
191+
external magic : 'a -> 'b = "%identity"
192+
end
193+
194+
module Caml_int64 = struct
195+
external discard_sign : int64 -> int64 = "js_int64_discard_sign"
196+
external div_mod : int64 -> int64 -> int64 * int64 = "js_int64_div_mod"
197+
external to_hex : int64 -> string = "js_int64_to_hex"
198+
end

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
"coverage":
2222
"`npm bin`/istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- './lib/js/test/*test.js' -R spec",
2323
"coveralls": "npm run-script coverage && node ./node_modules/.bin/coveralls < coverage/lcov.info",
24-
"postinstall" : "./.travis-ci.sh"
25-
24+
"postinstall" : "./scripts/postinstall.sh",
25+
"prepublish" : "./scripts/prepublish.sh"
2626
},
2727

2828
"name": "bs-platform",
29-
"version": "0.2.0",
29+
"version": "0.2.1",
3030
"description": "bucklescript compiler, ocaml standard libary by bucklescript and its required runtime support",
3131

3232
"repository": {

0 commit comments

Comments
 (0)