-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
/
Copy pathcoreio.jl
40 lines (33 loc) · 1.27 KB
/
coreio.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# This file is a part of Julia. License is MIT: https://julialang.org/license
print(x) = print(stdout, x)
print(x1, x2) = print(stdout, x1, x2)
println(x) = print(stdout, x, "\n")
println(x1, x2) = print(stdout, x1, x2, "\n")
print(xs...) = print(stdout, xs...)
println(xs...) = print(stdout, xs..., "\n") # fewer allocations than `println(stdout, xs...)`
println(io::IO) = print(io, "\n")
function show end
function repr end
struct DevNull <: IO end
const devnull = DevNull()
write(::DevNull, ::UInt8) = 1
unsafe_write(::DevNull, ::Ptr{UInt8}, n::UInt)::Int = n
closewrite(::DevNull) = nothing
close(::DevNull) = nothing
wait_close(::DevNull) = wait()
bytesavailable(io::DevNull) = 0
let CoreIO = Union{Core.CoreSTDOUT, Core.CoreSTDERR}
global write(io::CoreIO, x::UInt8) = Core.write(io, x)
global unsafe_write(io::CoreIO, x::Ptr{UInt8}, nb::UInt) = Core.unsafe_write(io, x, nb)
CoreIO = Union{CoreIO, DevNull}
global read(::CoreIO, ::Type{UInt8}) = throw(EOFError())
global isopen(::CoreIO) = true
global isreadable(::CoreIO) = false
global iswritable(::CoreIO) = true
global flush(::CoreIO) = nothing
global eof(::CoreIO) = true
global wait_readnb(::CoreIO, nb::Int) = nothing
end
stdin::IO = devnull
stdout::IO = Core.stdout
stderr::IO = Core.stderr