Skip to content

Commit 1fbb005

Browse files
committed
Improve streamer handling
1 parent 5990ddb commit 1fbb005

File tree

4 files changed

+67
-2
lines changed

4 files changed

+67
-2
lines changed

src/bootstrap.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,13 @@ function parsetobject(f, tkey::TKey, streamer)
11201120
# simple custom streamers which instantiate the full objects data
11211121
tkey.fClassName Base.keys(f.customstructs) && return readtype(io, f.customstructs[tkey.fClassName]; tkey=tkey, original_streamer=streamer)
11221122

1123+
if ismissing(streamer)
1124+
error("There is no streamer information for '$(tkey.fClassName)' stored in the ROOT file, " *
1125+
"consider providing a custom streamer by passing " *
1126+
"`customstreamer=Dict(\"$(tkey.fClassName)\" => TheStreamer)` to the `ROOTFile` " *
1127+
"and implement the struct `TheStreamer` and `UnROOT.readtype(io, ::Type{TheStreamer}; tkey, original_streamer)`.")
1128+
end
1129+
11231130
# FIXME: this is just a hack, for TObject-derivatives which are subclassing map<string,string>
11241131
s = streamer.streamer.fElements.elements[2]
11251132
if s.fTypeName == "map<string,string>"

src/bootstrap.jl.rej

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
diff a/src/bootstrap.jl b/src/bootstrap.jl (rejected hunks)
2+
@@ -131,8 +131,23 @@ function readfields!(io, fields, T::Type{TAttAxis_4})
3+
end
4+
5+
abstract type TAxis <: ROOTStreamedObject end
6+
+struct TAxis_6 <: TAxis end
7+
struct TAxis_9 <: TAxis end
8+
struct TAxis_10 <: TAxis end
9+
+function readfields!(io, fields, T::Type{TAxis_6})
10+
+ # overrides things like fName,... that were set from the parent TH1 :(
11+
+ stream!(io, fields, TNamed)
12+
+ stream!(io, fields, TAttAxis)
13+
+ fields[:fNbins] = readtype(io, Int32)
14+
+ fields[:fXmin] = readtype(io, Float64)
15+
+ fields[:fXmax] = readtype(io, Float64)
16+
+ fields[:fXbins] = readtype(io, TArrayD)
17+
+ fields[:fFirst] = readtype(io, Int16)
18+
+ fields[:fLast] = readtype(io, Int16)
19+
+ fields[:fBits2] = readtype(io, UInt16)
20+
+ fields[:fTimeDisplay] = readtype(io, Bool)
21+
+ fields[:fTimeFormat] = readtype(io, String)
22+
+end
23+
function readfields!(io, fields, T::Type{TAxis_9})
24+
# overrides things like fName,... that were set from the parent TH1 :(
25+
stream!(io, fields, TNamed)

src/precompile.jl

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Use
2+
# @warnpcfail precompile(args...)
3+
# if you want to be warned when a precompile directive fails
4+
macro warnpcfail(ex::Expr)
5+
modl = __module__
6+
file = __source__.file === nothing ? "?" : String(__source__.file)
7+
line = __source__.line
8+
quote
9+
$(esc(ex)) || @warn """precompile directive
10+
$($(Expr(:quote, ex)))
11+
failed. Please report an issue in $($modl) (after checking for duplicates) or remove this directive.""" _file=$file _line=$line
12+
end
13+
end
14+
15+
16+
function _precompile_()
17+
ccall(:jl_generating_output, Cint, ()) == 1 || return nothing
18+
Base.precompile(Tuple{Type{ROOTFile},String})
19+
Base.precompile(Tuple{Type{TTree},IOStream,TKey32,Dict{Int32, Any}})
20+
Base.precompile(Tuple{typeof(getindex),ROOTFile,String})
21+
Base.precompile(Tuple{typeof(readfields!),Cursor,Dict{Symbol, Any},Type{TBranch_13}})
22+
Base.precompile(Tuple{typeof(unpack),IOBuffer,TKey32,Dict{Int32, Any},Type{TLeafF}})
23+
Base.precompile(Tuple{typeof(unpack),IOBuffer,TKey32,Dict{Int32, Any},Type{TLeafI}})
24+
Base.precompile(Tuple{typeof(unpack),IOBuffer,TKey32,Dict{Int32, Any},Type{TObjArray}})
25+
Base.precompile(Tuple{typeof(unpack),IOBuffer,TKey32,Dict{Int32, Any},Type{TStreamerBase}})
26+
Base.precompile(Tuple{typeof(unpack),IOBuffer,TKey32,Dict{Int32, Any},Type{TStreamerBasicPointer}})
27+
Base.precompile(Tuple{typeof(unpack),IOBuffer,TKey32,Dict{Int32, Any},Type{TStreamerBasicType}})
28+
Base.precompile(Tuple{typeof(unpack),IOBuffer,TKey32,Dict{Int32, Any},Type{TStreamerSTL}})
29+
Base.precompile(Tuple{var"##s446#126",Any,Any,Any})
30+
end

src/streamers.jl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,11 @@ function readobjany!(io, tkey::TKey, refs)
240240
try
241241
streamer = getfield(@__MODULE__, Symbol(cname))
242242
catch UndefVarError
243-
@warn "Could not get streamer for '$(cname)' (TKey: $(tkey))"
244-
return missing
243+
streamer = getfield(@__MODULE__, :TBranchElement)
244+
# @show tkey.fClassName
245+
246+
# @warn "Could not get streamer for '$(cname)' (TKey: $(tkey))"
247+
# return missing
245248
end
246249
end
247250

0 commit comments

Comments
 (0)