Skip to content

Commit

Permalink
Remove hard dependency on Biniou
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonidas-from-XIV committed Jul 21, 2020
1 parent 87bc552 commit 9310500
Show file tree
Hide file tree
Showing 14 changed files with 215 additions and 197 deletions.
1 change: 1 addition & 0 deletions bin/dune
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(executable
(name ydump)
(public_name ydump)
(package yojson)
(flags (-safe-string))
(libraries yojson))
2 changes: 1 addition & 1 deletion bin/ydump.ml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ let cat sort output_biniou std compact streaming in_file out_file =

else
let write_one oc x =
output_string oc (Bi_io.string_of_tree (Yojson_biniou.biniou_of_json x))
output_string oc (Yojson.Safe.to_string x)
in
polycat write_one streaming in_file out_file

Expand Down
8 changes: 4 additions & 4 deletions lib/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let create_in_param ?(len = 256) () = {


let utf8_of_code buf x =
let add = Bi_outbuf.add_char in
let add = Buffer.add_char in

(* Straight <= doesn't work with signed 31-bit ints *)
let maxbits n x = x lsr n = 0 in
Expand Down Expand Up @@ -80,7 +80,7 @@ let is_object_or_array x =


type lexer_state = {
buf : Bi_outbuf.t;
buf : Buffer.t;
(* Buffer used to accumulate substrings *)

mutable lnum : int;
Expand All @@ -97,7 +97,7 @@ type lexer_state = {
module Lexer_state =
struct
type t = lexer_state = {
buf : Bi_outbuf.t;
buf : Buffer.t;
mutable lnum : int;
mutable bol : int;
mutable fname : string option;
Expand All @@ -107,7 +107,7 @@ end
let init_lexer ?buf ?fname ?(lnum = 1) () =
let buf =
match buf with
None -> Bi_outbuf.create 256
None -> Buffer.create 256
| Some buf -> buf
in
{
Expand Down
6 changes: 3 additions & 3 deletions lib/common.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ exception Json_error of string
val json_error : string -> 'a

type lexer_state = {
buf : Bi_outbuf.t;
buf : Buffer.t;
(** Buffer used to accumulate substrings *)

mutable lnum : int;
Expand All @@ -22,15 +22,15 @@ type lexer_state = {
module Lexer_state :
sig
type t = lexer_state = {
buf : Bi_outbuf.t;
buf : Buffer.t;
mutable lnum : int;
mutable bol : int;
mutable fname : string option;
}
end

val init_lexer :
?buf: Bi_outbuf.t ->
?buf: Buffer.t ->
?fname: string ->
?lnum: int ->
unit -> lexer_state
Expand Down
8 changes: 3 additions & 5 deletions lib/dune
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
(library
(name yojson)
(public_name yojson)
(modules yojson yojson_biniou)
(wrapped false)
(synopsis "JSON parsing and printing (successor of json-wheel)")
(flags (-safe-string))
(libraries biniou))
(modules yojson)
(synopsis "JSON parsing and printing")
(flags (-safe-string)))
20 changes: 10 additions & 10 deletions lib/read.mli
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exception Finally of exn * exn
(** Exception describing a failure in both finalizer and parsing. *)

val from_string :
?buf:Bi_outbuf.t ->
?buf:Buffer.t ->
?fname:string ->
?lnum:int ->
string -> t
Expand All @@ -25,15 +25,15 @@ val from_string :
*)

val from_channel :
?buf:Bi_outbuf.t ->
?buf:Buffer.t ->
?fname:string ->
?lnum:int ->
in_channel -> t
(** Read a JSON value from a channel.
See [from_string] for the meaning of the optional arguments. *)

val from_file :
?buf:Bi_outbuf.t ->
?buf:Buffer.t ->
?fname:string ->
?lnum:int ->
string -> t
Expand All @@ -42,7 +42,7 @@ val from_file :


type lexer_state = Lexer_state.t = {
buf : Bi_outbuf.t;
buf : Buffer.t;
mutable lnum : int;
mutable bol : int;
mutable fname : string option;
Expand All @@ -52,7 +52,7 @@ type lexer_state = Lexer_state.t = {
*)

val init_lexer :
?buf: Bi_outbuf.t ->
?buf: Buffer.t ->
?fname: string ->
?lnum: int ->
unit -> lexer_state
Expand All @@ -72,7 +72,7 @@ val from_lexbuf :
the end of the JSON value and the end of the input. *)

val stream_from_string :
?buf:Bi_outbuf.t ->
?buf:Buffer.t ->
?fname:string ->
?lnum:int ->
string -> t Stream.t
Expand All @@ -81,7 +81,7 @@ val stream_from_string :
See [from_string] for the meaning of the optional arguments. *)

val stream_from_channel :
?buf:Bi_outbuf.t ->
?buf:Buffer.t ->
?fin:(unit -> unit) ->
?fname:string ->
?lnum:int ->
Expand All @@ -97,7 +97,7 @@ val stream_from_channel :
See [from_string] for the meaning of the other optional arguments. *)

val stream_from_file :
?buf:Bi_outbuf.t ->
?buf:Buffer.t ->
?fname:string ->
?lnum:int ->
string -> t Stream.t
Expand All @@ -124,7 +124,7 @@ type json_line = [ `Json of t | `Exn of exn ]
(** The type of values resulting from a parsing attempt of a JSON value. *)

val linestream_from_channel :
?buf:Bi_outbuf.t ->
?buf:Buffer.t ->
?fin:(unit -> unit) ->
?fname:string ->
?lnum:int ->
Expand All @@ -138,7 +138,7 @@ val linestream_from_channel :
See [from_string] for the meaning of the other optional arguments. *)

val linestream_from_file :
?buf:Bi_outbuf.t ->
?buf:Buffer.t ->
?fname:string ->
?lnum:int ->
string -> json_line Stream.t
Expand Down
Loading

0 comments on commit 9310500

Please sign in to comment.