Skip to content

Commit 1e04e18

Browse files
committed
Migrate to Julia v1.0.
1 parent 43ab95e commit 1e04e18

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

sample/demo1.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ using SpiceData
55
include("importCppSimData.jl")
66

77
#No real test code yet... just demonstrate use:
8+
stdout_ct = IOContext(stdout, :compact=>true)
89

910
testpath(testfile::String) = joinpath(CppSimData.rootpath, "core/data", testfile)
1011

@@ -13,6 +14,9 @@ filepath = testpath(testfile)
1314
println("\nLoad $filepath:")
1415
reader = SpiceData._open(filepath)
1516
@show(reader)
17+
println("\nCompact output:")
18+
show(stdout_ct, reader)
19+
println("\n")
1620

1721
println("\nRead in list of signal names:")
1822
@show names(reader)

src/show.jl

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,31 @@
44
Base.show(io::IO, ::BigEndian) = print(io, "BigEndian")
55
Base.show(io::IO, ::LittleEndian) = print(io, "LittleEndian")
66

7-
Base.showcompact(io::IO, ::SpiceFormat) = print(io, "Format:Unknown")
8-
Base.showcompact(io::IO, ::Format_9601) = print(io, "SPICE:9601")
9-
Base.showcompact(io::IO, ::Format_9602) = print(io, "CppSim:9602")
10-
Base.showcompact(io::IO, ::Format_2001) = print(io, "SPICE:2001")
11-
Base.showcompact(io::IO, ::Format_2013) = print(io, "SPICE:2013")
7+
_showcompact(io::IO, ::SpiceFormat) = print(io, "Format:Unknown")
8+
_showcompact(io::IO, ::Format_9601) = print(io, "SPICE:9601")
9+
_showcompact(io::IO, ::Format_9602) = print(io, "CppSim:9602")
10+
_showcompact(io::IO, ::Format_2001) = print(io, "SPICE:2001")
11+
_showcompact(io::IO, ::Format_2013) = print(io, "SPICE:2013")
1212

13-
Base.show(io::IO, fmt::Format_Unknown) = showcompact(io, fmt)
13+
Base.show(io::IO, fmt::Format_Unknown) = _showcompact(io, fmt)
1414

1515
function Base.show(io::IO, fmt::SpiceFormat)
16-
showcompact(io, fmt)
16+
_showcompact(io, fmt)
1717
print(io, " (x: $(xtype(fmt))[], y: $(ytype(fmt))[])")
1818
end
1919

20-
function Base.showcompact(io::IO, r::DataReader)
20+
function _show(io::IO, r::DataReader, compact::Bool = false)
21+
#Base (compact) information:
2122
print(io, DataReader, "(")
2223
print(io, basename(r.filepath))
2324
print(io, ", nsig=", length(r.signalnames))
2425
print(io, ", npts=", length(r.sweep))
2526
print(io, ", ")
2627
print(io, r.format)
2728
print(io, ")")
28-
end
29+
if compact; return; end
2930

30-
function Base.show(io::IO, r::DataReader)
31-
showcompact(io, r)
31+
#Extended information:
3232
println(io)
3333
print(io, ">> (", r.endianness, ")")
3434
print(io, " sweep = '", r.sweepname, "'")
@@ -39,4 +39,7 @@ function Base.show(io::IO, r::DataReader)
3939
println(io, ">> ", tags.comments)
4040
end
4141

42+
Base.show(io::IO, r::DataReader) = _show(io, r)
43+
Base.show(io::IOContext, r::DataReader) = _show(io, r, haskey(io.dict, :compact))
44+
4245
#End

0 commit comments

Comments
 (0)