Skip to content

Commit 4cbd995

Browse files
committed
clean up js_output
1 parent c656c7b commit 4cbd995

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

jscomp/stdlib/Makefile.shared

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ CAMLC=$(CAMLRUN) $(COMPILER)
2121

2222
#COMPFLAGS=-strict-sequence -w +33..39 -g -warn-error A -bin-annot -nostdlib \
2323
# -safe-string
24-
BS_COMMON_FLAGS= -bs-no-version-header -bs-no-builtin-ppx-mli -bs-diagnose -bs-no-check-div-by-zero -bs-cross-module-opt -bs-package-name bs-platform -bs-no-warn-unimplemented-external
24+
BS_COMMON_FLAGS= -bs-no-version-header -bs-diagnose -bs-no-check-div-by-zero -bs-cross-module-opt -bs-package-name bs-platform -bs-no-warn-unimplemented-external
2525

2626
include ../Makefile.shared
2727

jscomp/stdlib/pervasives.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,14 @@ let print_string s = output_string stdout s
425425
let print_bytes s = output_bytes stdout s
426426
let print_int i = output_string stdout (string_of_int i)
427427
let print_float f = output_string stdout (string_of_float f)
428+
429+
#if BS then
430+
external print_endline : string -> unit = "log"
431+
[@@bs.val] [@@bs.scope "console"]
432+
#else
428433
let print_endline s =
429434
output_string stdout s; output_char stdout '\n'; flush stdout
435+
#end
430436
let print_newline () = output_char stdout '\n'; flush stdout
431437

432438
(* Output functions on standard error *)
@@ -436,8 +442,13 @@ let prerr_string s = output_string stderr s
436442
let prerr_bytes s = output_bytes stderr s
437443
let prerr_int i = output_string stderr (string_of_int i)
438444
let prerr_float f = output_string stderr (string_of_float f)
445+
#if BS then
446+
external prerr_endline : string -> unit = "error"
447+
[@@bs.val] [@@bs.scope "console"]
448+
#else
439449
let prerr_endline s =
440450
output_string stderr s; output_char stderr '\n'; flush stderr
451+
#end
441452
let prerr_newline () = output_char stderr '\n'; flush stderr
442453

443454
(* Input functions on standard input *)

jscomp/stdlib/pervasives.mli

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,12 @@ val print_int : int -> unit
628628
val print_float : float -> unit
629629
(** Print a floating-point number, in decimal, on standard output. *)
630630

631+
#if BS then
632+
external print_endline : string -> unit = "log"
633+
[@@bs.val] [@@bs.scope "console"]
634+
#else
631635
val print_endline : string -> unit
636+
#end
632637
(** Print a string, followed by a newline character, on
633638
standard output and flush standard output. *)
634639

@@ -656,7 +661,12 @@ val prerr_int : int -> unit
656661
val prerr_float : float -> unit
657662
(** Print a floating-point number, in decimal, on standard error. *)
658663

664+
#if BS then
665+
external prerr_endline : string -> unit = "error"
666+
[@@bs.val] [@@bs.scope "console"]
667+
#else
659668
val prerr_endline : string -> unit
669+
#end
660670
(** Print a string, followed by a newline character on standard
661671
error and flush standard error. *)
662672

0 commit comments

Comments
 (0)