Skip to content

Commit e8bbaa4

Browse files
committed
merge
2 parents b8a9aa3 + 73fb33f commit e8bbaa4

36 files changed

+876
-925
lines changed

.hgignore

+2
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ glob:base/sexplib/_build
257257
glob:base/sexplib/_oasis
258258
glob:base/sexplib/_tags
259259
glob:base/sexplib/configure
260+
glob:base/sexplib/conv_test.byte
260261
glob:base/sexplib/lib/META
261262
glob:base/sexplib/lib/lexer.ml
262263
glob:base/sexplib/lib/parser.ml
@@ -269,6 +270,7 @@ glob:base/sexplib/myocamlbuild.ml
269270
glob:base/sexplib/setup.data
270271
glob:base/sexplib/setup.log
271272
glob:base/sexplib/setup.ml
273+
glob:base/sexplib/sexp_test.byte
272274
glob:base/sexplib/syntax/pa_sexp_conv.mllib
273275
glob:base/sexplib/top/sexplib_top.mllib
274276
glob:base/type_conv/INSTALL

base/async/unix/lib/reader.ml

+18-16
Original file line numberDiff line numberDiff line change
@@ -418,40 +418,42 @@ let space = Bigstring.of_string " "
418418

419419
let gen_read_sexp ?parse_pos t parse =
420420
Deferred.create (fun result ->
421-
let rec loop ~ws_only parse_fun =
421+
let rec loop ~cont_state parse_fun =
422422
nonempty_buffer t (function
423423
| `Eof ->
424-
if ws_only then Ivar.fill result `Eof
425-
else begin
426-
(* The sexp parser doesn't know that a token ends at EOF, so we add a space to
427-
be sure. *)
424+
begin
425+
(* The sexp parser doesn't know that a token ends at EOF, so we
426+
add a space to be sure. *)
428427
match parse_fun ~pos:0 ~len:1 space with
429428
| Sexp.Done (sexp, parse_pos) ->
430-
Ivar.fill result (`Ok (sexp, parse_pos))
429+
Ivar.fill result (`Ok (sexp, parse_pos))
430+
| Sexp.Cont (Sexp.Cont_state.Parsing_whitespace, _) ->
431+
Ivar.fill result `Eof
431432
| Sexp.Cont _ ->
432-
failwiths "Reader.read_sexp got unexpected eof" t <:sexp_of< t >>
433+
failwiths "Reader.read_sexp got unexpected eof"
434+
t <:sexp_of< t >>
433435
end
434436
| `Ok ->
435437
match parse_fun ~pos:t.pos ~len:t.available t.buf with
436438
| Sexp.Done (sexp, parse_pos) ->
437-
consume t (parse_pos.Sexp.Parse_pos.buf_pos - t.pos);
438-
Ivar.fill result (`Ok (sexp, parse_pos));
439-
| Sexp.Cont (ws_only, parse_fun) ->
440-
t.available <- 0;
441-
loop ~ws_only parse_fun)
439+
consume t (parse_pos.Sexp.Parse_pos.buf_pos - t.pos);
440+
Ivar.fill result (`Ok (sexp, parse_pos));
441+
| Sexp.Cont (cont_state, parse_fun) ->
442+
t.available <- 0;
443+
loop ~cont_state parse_fun)
442444
in
443445
let parse ~pos ~len buf =
444-
(* [parse_pos] will be threaded through the entire reading process by the sexplib
445-
code. Every occurrence of [parse_pos] above will be identical to the [parse_pos]
446-
defined here. *)
446+
(* [parse_pos] will be threaded through the entire reading process by
447+
the sexplib code. Every occurrence of [parse_pos] above will be
448+
identical to the [parse_pos] defined here. *)
447449
let parse_pos =
448450
match parse_pos with
449451
| None -> Sexp.Parse_pos.create ~buf_pos:pos ()
450452
| Some parse_pos -> Sexp.Parse_pos.with_buf_pos parse_pos pos
451453
in
452454
parse ?parse_pos:(Some parse_pos) ?len:(Some len) buf
453455
in
454-
loop ~ws_only:true parse)
456+
loop ~cont_state:Sexp.Cont_state.Parsing_whitespace parse)
455457
;;
456458

457459
type 'a read = ?parse_pos : Sexp.Parse_pos.t -> 'a

base/bin_prot/lib/bin_prot.odocl

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# OASIS_START
2+
# DO NOT EDIT (digest: 587ff1270b3446e9490aea8b3ff16a98)
3+
Binable
4+
Nat0
5+
Common
6+
Unsafe_common
7+
Unsafe_write_c
8+
Unsafe_read_c
9+
Size
10+
Write_ml
11+
Read_ml
12+
Write_c
13+
Read_c
14+
Std
15+
Type_class
16+
Map_to_safe
17+
Utils
18+
# OASIS_STOP

base/bin_prot/oasis.sh

+2
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ Ocamlbuild_plugin.dispatch
142142
143143
flag ["compile"; "ocaml"; "cpp"] cpp;
144144
145+
flag ["compile"; "ocaml"] (S [A "-w"; A "@Ae" ]);
146+
145147
let cflags =
146148
let flags =
147149
[

base/core/extended/lib/command.ml

+3-3
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,8 @@ end = struct
323323
| `Ok tbl -> (fun flag ->
324324
match partial_match tbl flag with
325325
| `Exact (_, v)
326-
| `Partial (_, ({full_flag_required = false} as v)) -> Some v.spec
327-
| `Partial (_, ({full_flag_required = true} as v)) ->
326+
| `Partial (_, ({full_flag_required = false; _} as v)) -> Some v.spec
327+
| `Partial (_, ({full_flag_required = true; _} as v)) ->
328328
eprintf "Note: cannot abbreviate flag \"%s\".\n%!" v.name; None
329329
| `Ambiguous l ->
330330
eprintf "Note: flag \"%s\" is an ambiguous prefix: %s\n%!"
@@ -333,7 +333,7 @@ end = struct
333333
| `None -> None)
334334
;;
335335

336-
let help { name = name; doc = doc; aliases = aliases} =
336+
let help { name = name; doc = doc; aliases = aliases; _} =
337337
if String.is_prefix doc ~prefix:" " then
338338
(name, String.lstrip doc) ::
339339
List.map aliases

base/core/extended/lib/core_command.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ module Flag = struct
128128
(x ^ " " ^ arg, sprintf "same as \"%s\"" name))
129129
end
130130

131-
let align {name; doc; aliases; action = _} =
131+
let align {name; doc; aliases; _} =
132132
let (name, doc) =
133133
match String.lsplit2 doc ~on:' ' with
134134
| None | Some ("", _) -> (name, String.strip doc)

base/core/extended/lib/documented_match_statement.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ let prepend ~specific_cases t =
5151

5252
let match_ t x =
5353
match List.filter t.specific_cases
54-
~f:(fun { pattern = x' } -> List.exists x' ~f:(fun y -> x = y)) with
54+
~f:(fun { pattern = x'; _ } -> List.exists x' ~f:(fun y -> x = y)) with
5555
| case1::case2::_ -> failwithf "pattern appears twice in documented_match (%s,%s)"
5656
case1.documentation case2.documentation ()
5757
| [case] -> case.value ()

base/core/extended/lib/exception_check.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let create ?(listen_port = 65100) exns =
3030
U.set_nonblock s;
3131
while true do
3232
try
33-
let { U.Select_fds.read = rd } =
33+
let { U.Select_fds.read = rd; _ } =
3434
U.select ~read:(s :: !clients) ~write:[] ~except:[]
3535
~timeout:(- 1.0) ()
3636
in

base/core/extended/lib/loggers.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ module MakeChannelSpec (ChannelSpec : CHANNEL_SPEC) : SPEC = struct
6868
let
6969
{
7070
tm_year = m_year; tm_mon = m_month; tm_mday = m_mday;
71-
tm_hour = m_hour; tm_min = m_min; tm_sec = m_sec;
71+
tm_hour = m_hour; tm_min = m_min; tm_sec = m_sec; _
7272
} = localtime mtime in
7373
let m_sec = float m_sec +. mod_float mtime 1. in
7474
sprintf "%04d-%02d-%02d/%02d:%02d:%05.2f"

base/core/extended/lib/sys_utils.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ module Cpu_use = struct
205205

206206
let sample_exn pid =
207207
let module P = Procfs.Process in
208-
let {P.Stat.utime; stime} = (Procfs.with_pid_exn pid).P.stat in
208+
let {P.Stat.utime; stime; _} = (Procfs.with_pid_exn pid).P.stat in
209209
{ jiffies = Big_int.add_big_int utime stime;
210210
time = Time.now () }
211211

@@ -219,7 +219,7 @@ module Cpu_use = struct
219219
t.s0 <- t.s1;
220220
t.s1 <- sample_exn t.pid
221221

222-
let cpu_use {jps; s0={jiffies=j0;time=t0}; s1={jiffies=j1;time=t1}} =
222+
let cpu_use {jps; s0={jiffies=j0;time=t0}; s1={jiffies=j1;time=t1}; _} =
223223
let my_jps =
224224
Big_int.float_of_big_int (Big_int.sub_big_int j1 j0)
225225
/. Time.Span.to_sec (Time.diff t1 t0)

base/core/extended/oasis.sh

+1
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ let dispatch = function
153153
List.concat (List.map f flags)
154154
in
155155
flag ["compile"; "c"] (S cflags);
156+
flag ["compile"; "ocaml"] (S [A "-w"; A "@Ae" ]);
156157
157158
dispatch_default e
158159
| e -> dispatch_default e

base/core/lib/bigstring_stubs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ CAMLprim value bigstring_recvfrom_assume_fd_is_nonblocking_stub(
253253

254254
typedef off_t file_offset;
255255

256-
#define IO_BUFFER_SIZE 4096
256+
#define IO_BUFFER_SIZE 65536
257257

258258
struct channel {
259259
int fd; /* Unix file descriptor */

base/core/lib/in_channel.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ let unsafe_input_value t = may_eof (fun () -> Pervasives.input_value t)
3535
let set_binary_mode = Pervasives.set_binary_mode_in
3636

3737
let input_all t =
38-
(* We use 4096 because that is the size of OCaml's IO buffers. *)
39-
let buf_size = 4096 in
38+
(* We use 65536 because that is the size of OCaml's IO buffers. *)
39+
let buf_size = 65536 in
4040
let buf = String.create buf_size in
4141
let buffer = Buffer.create buf_size in
4242
let rec loop () =

base/core/lib/misc.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ WRAP_TIME_FUN(gmtime, "gmtime")
176176
/* Fix the broken close_(in/out) function which does not release the
177177
caml lock. */
178178

179-
#define IO_BUFFER_SIZE 4096
179+
#define IO_BUFFER_SIZE 65536
180180

181181
typedef long file_offset;
182182

base/core/oasis.sh

+1
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ let dispatch = function
140140
List.concat (List.map f flags)
141141
in
142142
flag ["compile"; "c"] (S cflags);
143+
flag ["compile"; "ocaml"] (S [A "-w"; A "@Ae" ]);
143144
144145
dispatch_default e
145146
| e -> dispatch_default e

base/sexplib/.hgignore.in

+2
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@ _oasis
1313
_build
1414
_tags
1515
lib/sexplib.odocl
16+
conv_test.byte
17+
sexp_test.byte

base/sexplib/README

+52-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
1+
22

33
README: library "Sexplib"
44
*************************
55
Copyright (C) 2012 Jane Street Holding, LLC (1)
66
=====================================================
77
Author: Markus Mottl
88
======================
9-
New York, 2012-03-20
9+
New York, 2012-04-20
1010
====================
1111

1212

@@ -138,15 +138,25 @@ using OCamlMakefile just add it to the 'PACKS'-variable.
138138
4.1 Lexical conventions of S-expression
139139
========================================
140140

141-
Whitespace, which consists of space, newline, carriage return, horizontal
142-
tab and form feed, is ignored unless within an OCaml-string, where it is
143-
treated according to OCaml-conventions. The semicolon introduces comments.
144-
Comments are ignored, and range up to the next newline character. The left
145-
parenthesis opens a new list, the right parenthesis closes it again. Lists can
146-
be empty. The double quote denotes the beginning and end of a string following
147-
the lexical conventions of OCaml (see OCaml-manual for details). All
148-
characters other than double quotes, left- and right parentheses, and
149-
whitespace are considered part of a contiguous string.
141+
Whitespace, which consists of space, newline, horizontal tab, and form feed,
142+
is ignored unless within an OCaml-string, where it is treated according to
143+
OCaml-conventions. The left parenthesis opens a new list, the right one closes
144+
it again. Lists can be empty. The double quote denotes the beginning and end
145+
of a string following the lexical conventions of OCaml (see the OCaml-manual
146+
for details). All characters other than double quotes, left- and right
147+
parentheses, whitespace, carriage return, and comment-introducing characters
148+
or sequences (see next paragraph) are considered part of a contiguous string.
149+
150+
A line comment is introduced using a semicolon, which comments out all text
151+
up to the end of the next newline character. The sequence '%;' introduces an
152+
S-expression comment. This means that the next S-expression, which must be
153+
syntactically correct and may be an atom (quoted or unquoted) or list,
154+
following this two-character sequence will be ignored. Whitespace or other
155+
comments between this sequence and the subsequent S-expression are ignored.
156+
Block comments are opened with '#|' and closed with '|#'. They can be nested
157+
and require that double-quotes within the block balance and contain
158+
syntactically correct OCaml-strings, similar to quoted atoms. These
159+
OCaml-strings may contain comment characters without causing parsing problems.
150160

151161

152162
4.2 Grammar of S-expressions
@@ -222,7 +232,7 @@ which indicates that a record field should be optional. E.g.:
222232
{
223233
x : int option;
224234
y : int sexp_option;
225-
}
235+
} with sexp
226236
>>
227237

228238
The type 'sexp_option' is equivalent to ordinary options, but is treated
@@ -263,6 +273,36 @@ field should be defined.
263273
similar to the type 'sexp_option'. They assume the empty list, empty array,
264274
and false value respectively as default values.
265275

276+
More complex default values can be specified explicitly using several
277+
constructs, e.g.:
278+
<< let z_test v = v > 42
279+
280+
type t =
281+
{
282+
x : int with default(42);
283+
y : int with default(3), sexp_drop_default;
284+
z : int with default(3), sexp_drop_if(z_test);
285+
} with sexp
286+
>>
287+
288+
The 'default' record field extension above is supported by the underlying
289+
preprocessor library 'type_conv' and specifies the intended default value for
290+
a record field in its argument. Sexplib will use this information to generate
291+
code which will set this record field to the default value if an S-expression
292+
omits this field. If a record is converted to an S-expression, record fields
293+
with default values will be emitted as usual. Specifying 'sexp_drop_default'
294+
will add a test for polymorphic equality to the generated code such that a
295+
record field containing its default value will be suppressed in the resulting
296+
S-expression. This option requires the presence of a default value.
297+
'sexp_drop_if' on the other hand does not require a default. Its argument must
298+
be a function, which will receive the current record value. If the result of
299+
this function is 'true', then the record field will be suppressed in the
300+
resulting S-expression.
301+
302+
The above extensions can be quite creatively used together with manifest
303+
types, functors, and first-class modules to make the emission of record fields
304+
or the definition of their default values configurable at runtime.
305+
266306

267307
4.7 Conversion of sum types
268308
============================

0 commit comments

Comments
 (0)