Skip to content

Commit 32c309b

Browse files
committed
more bindings for string
1 parent 82b7345 commit 32c309b

24 files changed

+216
-220
lines changed

docs/Manual.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ <h1><a href="https://github.com/bloomberg/bucklescript">BuckleScript</a> User Ma
571571
<li><a href="#_debugger_support">Debugger support</a></li>
572572
<li><a href="#_regex_support">Regex support</a></li>
573573
<li><a href="#_examples_2">Examples</a>
574-
<ul class="sectlevel4">
574+
<ul class="sectlevel3">
575575
<li><a href="#_a_simple_example_binding_to_mocha_unit_test_library">A simple example: binding to mocha unit test library</a></li>
576576
</ul>
577577
</li>
@@ -2661,8 +2661,8 @@ <h3 id="_examples_2"><a class="anchor" href="#_examples_2"></a>Examples</h3>
26612661
more examples, please visit
26622662
<a href="https://github.com/bloomberg/bucklescript-addons" class="bare">https://github.com/bloomberg/bucklescript-addons</a></p>
26632663
</div>
2664-
<div class="sect4">
2665-
<h5 id="_a_simple_example_binding_to_mocha_unit_test_library"><a class="anchor" href="#_a_simple_example_binding_to_mocha_unit_test_library"></a>A simple example: binding to mocha unit test library</h5>
2664+
<div class="sect3">
2665+
<h4 id="_a_simple_example_binding_to_mocha_unit_test_library"><a class="anchor" href="#_a_simple_example_binding_to_mocha_unit_test_library"></a>A simple example: binding to mocha unit test library</h4>
26662666
<div class="paragraph">
26672667
<p>This is an example showing how too provide bindings to the
26682668
<a href="https://mochajs.org/">mochajs</a> unit test framework.</p>

jscomp/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ travis-world-test:./bin/bspack
119119
# since in npm mode, they are generated from a single file
120120
install:
121121
cp ./bin/bsc ./bin/bsppx ./bin/bspack ../bin/
122-
cp ./runtime/*.cmt* ./runtime/*.cmj* ./stdlib/*.cm* ./others/*.cm* ../lib/ocaml/
123-
cp ./runtime/js.ml ./runtime/js.cmi ./runtime/js_array.mli ./runtime/js_array.ml ./runtime/js_array.cmi ./runtime/js_string.ml ./runtime/js_string.mli ./runtime/js_string.cmi ./runtime/js_re.ml ./runtime/js_re.mli ./runtime/js_re.cmi ./runtime/js_unsafe.cmi ../lib/ocaml/
122+
cp ./runtime/*.cmt* ./runtime/*.cmj* ./stdlib/*.cm* ./others/*.ml ./others/*.mli ./others/*.cm* ../lib/ocaml/
123+
cp ./runtime/js.ml ./runtime/js.cmi ./runtime/js_unsafe.cmi ../lib/ocaml/
124124

125125

126126

jscomp/others/.depend

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,16 @@ bs_node_process.cmj :
66
bs_node_process.cmx :
77
bs_dict.cmj :
88
bs_dict.cmx :
9-
bs_node_module.cmj : bs_node.cmi bs_dict.cmj
10-
bs_node_module.cmx : bs_node.cmi bs_dict.cmx
9+
bs_node_module.cmj : bs_node.cmj bs_dict.cmj
10+
bs_node_module.cmx : bs_node.cmx bs_dict.cmx
11+
js_array.cmj :
12+
js_array.cmx :
13+
js_string.cmj : bs.cmj js_string.cmi
14+
js_string.cmx : bs.cmx js_string.cmi
15+
js_re.cmj : js_re.cmi
16+
js_re.cmx : js_re.cmi
17+
js_string.cmi :
18+
js_re.cmi :
1119
bs_node_path.cmo :
1220
bs_node_path.cmj :
1321
bs_node_fs.cmo :
@@ -16,5 +24,11 @@ bs_node_process.cmo :
1624
bs_node_process.cmj :
1725
bs_dict.cmo :
1826
bs_dict.cmj :
19-
bs_node_module.cmo : bs_node.cmi bs_dict.cmo
20-
bs_node_module.cmj : bs_node.cmi bs_dict.cmj
27+
bs_node_module.cmo : bs_node.cmo bs_dict.cmo
28+
bs_node_module.cmj : bs_node.cmj bs_dict.cmj
29+
js_array.cmo :
30+
js_array.cmj :
31+
js_string.cmo : bs.cmo js_string.cmi
32+
js_string.cmj : bs.cmj js_string.cmi
33+
js_re.cmo : js_re.cmi
34+
js_re.cmj : js_re.cmi

jscomp/others/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ COMPILER=../bin/bsc
44

55
MAP_FILES= bs_node bs
66

7-
SOURCE_LIST= bs_node_path bs_node_fs bs_node_process bs_dict bs_node_module
7+
SOURCE_LIST= bs_node_path bs_node_fs bs_node_process bs_dict bs_node_module js_array js_string js_re
88

9-
$(addsuffix .cmj, $(MAP_FILES)): bs_node.cmj bs.cmj
9+
$(addsuffix .cmj, $(SOURCE_LIST)): bs_node.cmj bs.cmj # TODO
1010

1111
RUNTIME := $(addsuffix .cmj, $(SOURCE_LIST))
1212

13-
BS_COMMON_FLAGS= -no-alias-deps -bs-no-version-header -bs-diagnose -bs-no-check-div-by-zero -bs-cross-module-opt -bs-package-name $(npm_package_name)
13+
BS_COMMON_FLAGS= -no-alias-deps -bs-no-version-header -bs-diagnose -bs-no-check-div-by-zero -bs-cross-module-opt -bs-package-name bs-platform
1414

1515
ifdef BS_RELEASE_BUILD
1616
BS_FLAGS= $(BS_COMMON_FLAGS) -bs-package-output lib/js -bs-package-output goog:lib/goog -bs-package-output amdjs:lib/amdjs

jscomp/others/bs.ml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@
2828
module Dict = Bs_dict
2929

3030
module Node = Bs_node
31+
32+
module Array = Js_array
33+
34+
module String = Js_string
35+
36+
module Re = Js_re
37+
38+
File renamed without changes.

jscomp/others/js_array.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
'use strict';
2+
3+
4+
5+
/* No side effect */

jscomp/others/js_array.ml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
type 'a t = 'a array
27+
28+
external toString : unit -> string = "" [@@bs.send.pipe: 'a t as 'this]
29+
external toLocaleString : unit -> string = "" [@@bs.send.pipe: 'a t as 'this]
30+
external concat : 'this -> 'this = "" [@@bs.send.pipe: 'a t as 'this]
31+
external append : 'a -> 'this = "concat" [@@bs.send.pipe: 'a t as 'this]
32+
33+
external slice : int -> int -> 'this = "" [@@bs.send.pipe: 'a t as 'this]
34+
external slice_copy : unit -> 'this = "slice"[@@bs.send.pipe: 'a t as 'this]
35+
external slice_start : int -> 'this = "slice"[@@bs.send.pipe: 'a t as 'this]
36+
37+
external indexOf : 'a -> int -> int = "" [@@bs.send.pipe: 'a t as 'this]
38+
external indexOf_start : 'a -> int = "indexOf" [@@bs.send.pipe: 'a t as 'this]
39+
40+
external lastIndexOf : 'a -> int -> int = "" [@@bs.send.pipe: 'a t as 'this]
41+
external lastIndexOf_start : 'a -> int = "lastIndex" [@@bs.send.pipe: 'a t as 'this]
42+
43+
external every : ('a -> Js.boolean [@bs]) -> Js.boolean = "" [@@bs.send.pipe: 'a t as 'this]
44+
external everyi : ('a -> int -> Js.boolean [@bs]) -> Js.boolean = "every" [@@bs.send.pipe: 'a t as 'this]
45+
46+
external some : ('a -> Js.boolean [@bs]) -> Js.boolean = "" [@@bs.send.pipe: 'a t as 'this]
47+
external somei : ('a -> int -> Js.boolean [@bs]) -> Js.boolean = "some" [@@bs.send.pipe: 'a t as 'this]
48+
49+
external forEach : ('a -> 'int -> unit [@bs]) -> unit = "" [@@bs.send.pipe: 'a t as 'this]
50+
51+
external map : ('a -> 'b [@bs]) -> 'b t = "" [@@bs.send.pipe: 'a t as 'this]
52+
external mapi : ('a -> int -> 'b [@bs]) -> 'b t = "map" [@@bs.send.pipe: 'a t as 'this]
53+
54+
(** should we use [bool] or [boolan] seems they are intechangeable here *)
55+
external filter : ('a -> bool [@bs]) -> 'this = "" [@@bs.send.pipe: 'a t as 'this]
56+
external filteri : ('a -> int -> Js.boolean[@bs]) -> 'this = "filter" [@@bs.send.pipe: 'a t as 'this]
57+
58+
external reducei : ('a -> 'a -> int -> 'a [@bs]) -> 'a -> 'a = "reduce" [@@bs.send.pipe: 'a t as 'this]
59+
external reduce : ('a -> 'a -> 'a [@bs]) -> 'a -> 'a = "reduce" [@@bs.send.pipe: 'a t as 'this]
60+
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)