Skip to content

Commit 83bd24b

Browse files
committedNov 22, 2017
bump version, dos2unix compflags and change into jsConverter for better names
1 parent 159d5ff commit 83bd24b

19 files changed

+75
-71
lines changed
 

‎docs/Manual.html

+12-11
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ <h1><a href="https://github.com/bucklescript/bucklescript">BuckleScript</a> User
590590
<ul class="sectlevel3">
591591
<li><a href="#_mapping_js_int_enums_to_ocaml_enums_since_2_1_0">Mapping JS Int enums to OCaml enums (@since 2.1.0)</a></li>
592592
<li><a href="#_mapping_js_string_enums_to_ocaml_enums_since_2_1_0">Mapping JS string enums to OCaml enums (@since 2.1.0)</a></li>
593-
<li><a href="#_mapping_js_int_enums_to_ocaml_enums_since_2_1_0_2">Mapping JS Int enums to OCaml enums (@since 2.1.0)</a></li>
593+
<li><a href="#_mapping_js_objects_to_ocaml_records_since_2_1_0">Mapping JS objects to OCaml records (@since 2.1.0)</a></li>
594594
</ul>
595595
</li>
596596
<li><a href="#_embedding_untyped_javascript_code">Embedding untyped Javascript code</a>
@@ -3557,7 +3557,7 @@ <h4 id="_mapping_js_int_enums_to_ocaml_enums_since_2_1_0"><a class="anchor" href
35573557
<span class="tok-o">|</span> <span class="tok-nc">A2</span>
35583558
<span class="tok-o">|</span> <span class="tok-nc">A3</span>
35593559
<span class="tok-o">|</span> <span class="tok-nc">A4</span>
3560-
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-n">jsMapper</span><span class="tok-o">]</span></code></pre>
3560+
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-n">jsConverter</span><span class="tok-o">]</span></code></pre>
35613561
</div>
35623562
</div>
35633563
<div class="paragraph">
@@ -3581,7 +3581,7 @@ <h4 id="_mapping_js_int_enums_to_ocaml_enums_since_2_1_0"><a class="anchor" href
35813581
<span class="tok-o">|</span> <span class="tok-nc">A2</span>
35823582
<span class="tok-o">|</span> <span class="tok-nc">A3</span> <span class="tok-o">[@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-k">as</span> <span class="tok-mi">7</span><span class="tok-o">]</span>
35833583
<span class="tok-o">|</span> <span class="tok-nc">A4</span>
3584-
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-n">jsMapper</span><span class="tok-o">]</span></code></pre>
3584+
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-n">jsConverter</span><span class="tok-o">]</span></code></pre>
35853585
</div>
35863586
</div>
35873587
<div class="paragraph">
@@ -3599,11 +3599,12 @@ <h4 id="_mapping_js_int_enums_to_ocaml_enums_since_2_1_0"><a class="anchor" href
35993599
<span class="tok-o">|</span> <span class="tok-nc">A2</span>
36003600
<span class="tok-o">|</span> <span class="tok-nc">A3</span>
36013601
<span class="tok-o">|</span> <span class="tok-nc">A4</span>
3602-
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-o">{</span><span class="tok-n">jsMapper</span> <span class="tok-o">=</span> <span class="tok-n">jsType</span><span class="tok-o">}</span> <span class="tok-o">]</span></code></pre>
3602+
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-o">{</span><span class="tok-n">jsConverter</span> <span class="tok-o">=</span> <span class="tok-n">newType</span><span class="tok-o">}</span> <span class="tok-o">]</span></code></pre>
36033603
</div>
36043604
</div>
36053605
<div class="paragraph">
3606-
<p>In this case, it would generate two functions of such type:</p>
3606+
<p>In this case, it would generate two functions of such type, note <code>newType</code> means
3607+
a new type declaration (by default to be abstract) is created:</p>
36073608
</div>
36083609
<div class="listingblock">
36093610
<div class="content">
@@ -3632,7 +3633,7 @@ <h4 id="_mapping_js_string_enums_to_ocaml_enums_since_2_1_0"><a class="anchor" h
36323633
<span class="tok-o">|</span> <span class="tok-o">`</span><span class="tok-nc">A3</span>
36333634
<span class="tok-o">|</span> <span class="tok-o">`</span><span class="tok-nc">A4</span>
36343635
<span class="tok-o">]</span>
3635-
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-n">jsMapper</span><span class="tok-o">]</span></code></pre>
3636+
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-n">jsConverter</span><span class="tok-o">]</span></code></pre>
36363637
</div>
36373638
</div>
36383639
<div class="paragraph">
@@ -3657,7 +3658,7 @@ <h4 id="_mapping_js_string_enums_to_ocaml_enums_since_2_1_0"><a class="anchor" h
36573658
<span class="tok-o">|</span> <span class="tok-o">`</span><span class="tok-nc">A3</span> <span class="tok-o">[@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-k">as</span> <span class="tok-s2">&quot;d&quot;</span><span class="tok-o">]</span>
36583659
<span class="tok-o">|</span> <span class="tok-o">`</span><span class="tok-nc">A4</span>
36593660
<span class="tok-o">]</span>
3660-
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-n">jsMapper</span><span class="tok-o">]</span></code></pre>
3661+
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-n">jsConverter</span><span class="tok-o">]</span></code></pre>
36613662
</div>
36623663
</div>
36633664
<div class="paragraph">
@@ -3673,7 +3674,7 @@ <h4 id="_mapping_js_string_enums_to_ocaml_enums_since_2_1_0"><a class="anchor" h
36733674
<span class="tok-o">|</span> <span class="tok-o">`</span><span class="tok-nc">A3</span>
36743675
<span class="tok-o">|</span> <span class="tok-o">`</span><span class="tok-nc">A4</span>
36753676
<span class="tok-o">]</span>
3676-
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-o">{</span><span class="tok-n">jsMapper</span> <span class="tok-o">=</span> <span class="tok-n">jsType</span><span class="tok-o">}</span> <span class="tok-o">]</span></code></pre>
3677+
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-o">{</span><span class="tok-n">jsConverter</span> <span class="tok-o">=</span> <span class="tok-n">newType</span><span class="tok-o">}</span> <span class="tok-o">]</span></code></pre>
36773678
</div>
36783679
</div>
36793680
<div class="paragraph">
@@ -3696,15 +3697,15 @@ <h4 id="_mapping_js_string_enums_to_ocaml_enums_since_2_1_0"><a class="anchor" h
36963697
</div>
36973698
</div>
36983699
<div class="sect3">
3699-
<h4 id="_mapping_js_int_enums_to_ocaml_enums_since_2_1_0_2"><a class="anchor" href="#_mapping_js_int_enums_to_ocaml_enums_since_2_1_0_2"></a>Mapping JS Int enums to OCaml enums (@since 2.1.0)</h4>
3700+
<h4 id="_mapping_js_objects_to_ocaml_records_since_2_1_0"><a class="anchor" href="#_mapping_js_objects_to_ocaml_records_since_2_1_0"></a>Mapping JS objects to OCaml records (@since 2.1.0)</h4>
37003701
<div class="listingblock">
37013702
<div class="content">
37023703
<pre class="pygments highlight"><code data-lang="ocaml"><span class="tok-k">type</span> <span class="tok-n">t</span> <span class="tok-o">=</span>
37033704
<span class="tok-o">{</span>
37043705
<span class="tok-n">x</span> <span class="tok-o">:</span> <span class="tok-kt">int</span> <span class="tok-o">;</span>
37053706
<span class="tok-n">y</span> <span class="tok-o">:</span> <span class="tok-kt">int</span>
37063707
<span class="tok-o">}</span>
3707-
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-n">jsMapper</span><span class="tok-o">]</span></code></pre>
3708+
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-n">jsConverter</span><span class="tok-o">]</span></code></pre>
37083709
</div>
37093710
</div>
37103711
<div class="paragraph">
@@ -3730,7 +3731,7 @@ <h4 id="_mapping_js_int_enums_to_ocaml_enums_since_2_1_0_2"><a class="anchor" hr
37303731
<span class="tok-n">x</span> <span class="tok-o">:</span> <span class="tok-kt">int</span> <span class="tok-o">;</span>
37313732
<span class="tok-n">y</span> <span class="tok-o">:</span> <span class="tok-kt">int</span>
37323733
<span class="tok-o">}</span>
3733-
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-o">{</span><span class="tok-n">jsMapper</span><span class="tok-o">=</span> <span class="tok-n">jsType</span><span class="tok-o">}]</span></code></pre>
3734+
<span class="tok-o">[@@</span><span class="tok-n">bs</span><span class="tok-o">.</span><span class="tok-n">deriving</span> <span class="tok-o">{</span><span class="tok-n">jsConverter</span><span class="tok-o">=</span> <span class="tok-n">newType</span><span class="tok-o">}]</span></code></pre>
37343735
</div>
37353736
</div>
37363737
<div class="paragraph">

‎jscomp/build_tests/gg/yy.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
type t =
22
| Foo
3-
[@@bs.deriving jsMapper]
3+
[@@bs.deriving jsConverter]
44

55
let u = Xx.sum 3
66

‎jscomp/common/bs_version.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
* You should have received a copy of the GNU Lesser General Public License
2323
* along with this program; if not, write to the Free Software
2424
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
25-
let version = "2.0.1"
25+
let version = "2.1.0"
2626
let header =
27-
"// Generated by BUCKLESCRIPT VERSION 2.0.1, PLEASE EDIT WITH CARE"
27+
"// Generated by BUCKLESCRIPT VERSION 2.1.0, PLEASE EDIT WITH CARE"
2828
let package_name = "bs-platform"
2929

‎jscomp/syntax/ast_derive_js_mapper.ml

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,20 @@ let handle_config (config : Parsetree.expression option) =
4545
(match config.pexp_desc with
4646
| Pexp_record (
4747
[
48-
{txt = Lident "jsType"},
48+
{txt = Lident "newType"},
4949
{pexp_desc =
5050
(Pexp_construct
5151
(
5252
{txt =
5353
Lident ("true"
5454
| "false"
5555
as x)}, None)
56-
| Pexp_ident {txt = Lident ("jsType" as x)}
56+
| Pexp_ident {txt = Lident ("newType" as x)}
5757
)
5858
}
5959
],None)
6060
-> not (x = "false")
61-
| Pexp_ident {txt = Lident ("jsType")}
61+
| Pexp_ident {txt = Lident ("newType")}
6262
-> true
6363
| _ -> invalid_config config)
6464
| None -> false
@@ -157,7 +157,7 @@ let assertExp e =
157157

158158
let init () =
159159
Ast_derive.register
160-
"jsMapper"
160+
"jsConverter"
161161
(fun ( x : Parsetree.expression option) ->
162162
let createType = handle_config x in
163163

‎jscomp/test/ast_abstract_test.ml

+7-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type 'a t =
1414
z : 'a
1515
}
1616

17-
[@@bs.deriving {jsMapper = {jsType = true} }]
17+
[@@bs.deriving {jsConverter = newType} ]
1818

1919

2020
let v0 = tToJs { x = 3 ; y = false; z = false}
@@ -25,7 +25,7 @@ type x =
2525
[`a
2626
|`b
2727
|`c]
28-
[@@bs.deriving {jsMapper = {jsType = true}}]
28+
[@@bs.deriving {jsConverter = newType}]
2929

3030

3131

@@ -43,7 +43,7 @@ type a =
4343
| A
4444
| B [@bs.as 3]
4545
| C
46-
[@@bs.deriving {jsMapper = {jsType = true}}]
46+
[@@bs.deriving {jsConverter = newType}]
4747

4848
let id x =
4949
eq __LOC__ (aFromJs (aToJs x )) x
@@ -61,7 +61,7 @@ type b =
6161
| D1
6262
| D2
6363
| D3
64-
[@@bs.deriving {jsMapper = {jsType = true}}]
64+
[@@bs.deriving {jsConverter = newType }]
6565

6666

6767
let b0 = bToJs D0
@@ -76,7 +76,7 @@ type c =
7676
| D1
7777
| D2
7878
| D3
79-
[@@bs.deriving {jsMapper = {jsType }}]
79+
[@@bs.deriving {jsConverter = {newType }}]
8080

8181
let c0 = cToJs D0
8282

@@ -85,7 +85,7 @@ let idc v = eq __LOC__ (cFromJs (cToJs v)) v
8585
let () = idc D0; idc D1 ; idc D2; idc D3
8686
type h =
8787
| JsMapperEraseType
88-
| B [@@bs.deriving {accessors; jsMapper = {jsType = true}} ]
88+
| B [@@bs.deriving {accessors; jsConverter = newType} ]
8989

9090

9191
type z =
@@ -94,7 +94,7 @@ type z =
9494
| ZXx (* not overridden *)
9595
[@@bs.deriving {
9696
accessors;
97-
jsMapper
97+
jsConverter
9898
}
9999
]
100100

‎jscomp/test/ast_js_mapper_poly_test.ml

+5-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type u =
1212
| `C
1313
| `f [@bs.as "x"]
1414
]
15-
[@@bs.deriving jsMapper]
15+
[@@bs.deriving jsConverter]
1616

1717
let eqU (x : u) (y : u) = x = y
1818
let eqUOpt (x : u option) y =
@@ -35,7 +35,7 @@ type v =
3535
| A1 [@bs.as 3]
3636
| A2
3737
| A3
38-
[@@bs.deriving jsMapper]
38+
[@@bs.deriving jsConverter]
3939

4040
let eqV (x : v) (y : v) = x = y
4141
let eqVOpt (x : v option) y=
@@ -63,21 +63,21 @@ type v1 =
6363
| B3
6464
| B4
6565
| B5
66-
[@@bs.deriving jsMapper]
66+
[@@bs.deriving jsConverter]
6767
let () =
6868
eq __LOC__ (Array.map v1ToJs [|B0;B1;B2;B3;B4;B5|]) [|0;1;2;3;4;5|];
6969
eq __LOC__ (Array.map v1FromJs [|-1;0;1;2;3;4;5;6|])
7070
[|None;Some B0; Some B1; Some B2; Some B3; Some B4; Some B5; None|]
7171

72-
(** TODO: add jsType support *)
72+
(** TODO: add newType support *)
7373
type v2 =
7474
| C0 [@bs.as 2 ]
7575
| C1
7676
| C2
7777
| C3
7878
| C4
7979
| C5
80-
[@@bs.deriving jsMapper ]
80+
[@@bs.deriving jsConverter ]
8181

8282

8383
;;

‎jscomp/test/ast_js_mapper_test.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type 'a t = {
88
}
99
[@@bs.deriving
1010

11-
jsMapper
11+
jsConverter
1212

1313
]
1414

@@ -26,7 +26,7 @@ let vx = tFromJs [%obj{ xx = 3; yy = "2"; zz = 1,2; cc = 3}]
2626
| `C
2727
| `f [@bs.as "x"]
2828
]
29-
[@@bs.deriving jsMapper] *)
29+
[@@bs.deriving jsConverter] *)
3030

3131
let rec searchAux i (xs : (int * _) array) (k : int) =
3232
let (a,b) = Array.unsafe_get xs i in
@@ -48,7 +48,7 @@ and b =
4848
| `b2
4949
| `b3
5050
]
51-
[@@bs.deriving {jsMapper = {jsType}}]
51+
[@@bs.deriving {jsConverter = newType}]
5252

5353
let v = bToJs `b0
5454

‎jscomp/test/ast_js_mapper_test.mli

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ type 'a t = {
44
xx : int ;
55
yy : string ;
66
zz : 'a * int
7-
} [@@bs.deriving {jsMapper }]
7+
} [@@bs.deriving {jsConverter }]
88

99
val searchForSureExists : (int * 'a) array -> int -> 'a
1010

@@ -20,4 +20,4 @@ and b =
2020
| `b2
2121
| `b3
2222
]
23-
[@@bs.deriving { jsMapper = {jsType} }]
23+
[@@bs.deriving { jsConverter = newType }]

‎jscomp/test/ast_mapper_defensive_test.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ and c = [
2121
| `c1
2222
| `c2
2323
]
24-
[@@bs.deriving { jsMapper = jsType }]
24+
[@@bs.deriving { jsConverter = newType }]
2525

2626

2727
(* ;; aFromJs (Obj.magic 3) *)

‎jscomp/test/big_polyvar_test.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ type t = [
300300
| `variant298
301301
| `variant299
302302

303-
] [@@bs.deriving jsMapper]
303+
] [@@bs.deriving jsConverter]
304304
let eq (x : t option) (y: t option) =
305305
match x with
306306
| Some x ->

‎lib/bsb.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ end = struct
5555
* You should have received a copy of the GNU Lesser General Public License
5656
* along with this program; if not, write to the Free Software
5757
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
58-
let version = "2.0.1"
58+
let version = "2.1.0"
5959
let header =
60-
"// Generated by BUCKLESCRIPT VERSION 2.0.1, PLEASE EDIT WITH CARE"
60+
"// Generated by BUCKLESCRIPT VERSION 2.1.0, PLEASE EDIT WITH CARE"
6161
let package_name = "bs-platform"
6262

6363
end

‎lib/bsb_helper.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -177,9 +177,9 @@ end = struct
177177
* You should have received a copy of the GNU Lesser General Public License
178178
* along with this program; if not, write to the Free Software
179179
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
180-
let version = "2.0.1"
180+
let version = "2.1.0"
181181
let header =
182-
"// Generated by BUCKLESCRIPT VERSION 2.0.1, PLEASE EDIT WITH CARE"
182+
"// Generated by BUCKLESCRIPT VERSION 2.1.0, PLEASE EDIT WITH CARE"
183183
let package_name = "bs-platform"
184184

185185
end

‎lib/bsdep.ml

+6-6
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ end = struct
5555
* You should have received a copy of the GNU Lesser General Public License
5656
* along with this program; if not, write to the Free Software
5757
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
58-
let version = "2.0.1"
58+
let version = "2.1.0"
5959
let header =
60-
"// Generated by BUCKLESCRIPT VERSION 2.0.1, PLEASE EDIT WITH CARE"
60+
"// Generated by BUCKLESCRIPT VERSION 2.1.0, PLEASE EDIT WITH CARE"
6161
let package_name = "bs-platform"
6262

6363
end
@@ -30922,20 +30922,20 @@ let handle_config (config : Parsetree.expression option) =
3092230922
(match config.pexp_desc with
3092330923
| Pexp_record (
3092430924
[
30925-
{txt = Lident "jsType"},
30925+
{txt = Lident "newType"},
3092630926
{pexp_desc =
3092730927
(Pexp_construct
3092830928
(
3092930929
{txt =
3093030930
Lident ("true"
3093130931
| "false"
3093230932
as x)}, None)
30933-
| Pexp_ident {txt = Lident ("jsType" as x)}
30933+
| Pexp_ident {txt = Lident ("newType" as x)}
3093430934
)
3093530935
}
3093630936
],None)
3093730937
-> not (x = "false")
30938-
| Pexp_ident {txt = Lident ("jsType")}
30938+
| Pexp_ident {txt = Lident ("newType")}
3093930939
-> true
3094030940
| _ -> invalid_config config)
3094130941
| None -> false
@@ -31034,7 +31034,7 @@ let assertExp e =
3103431034

3103531035
let init () =
3103631036
Ast_derive.register
31037-
"jsMapper"
31037+
"jsConverter"
3103831038
(fun ( x : Parsetree.expression option) ->
3103931039
let createType = handle_config x in
3104031040

0 commit comments

Comments
 (0)
Please sign in to comment.