-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
groot/rdict: add r/w-streamer+type handling for TString
- Loading branch information
Showing
3 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright ©2022 The go-hep Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package rdict | ||
|
||
import ( | ||
"fmt" | ||
|
||
"go-hep.org/x/hep/groot/rbase" | ||
"go-hep.org/x/hep/groot/rmeta" | ||
) | ||
|
||
func init() { | ||
si, ok := StreamerInfos.Get("TString", -1) | ||
if !ok { | ||
panic(fmt.Errorf("rdict: could not get streamer info for TString")) | ||
} | ||
if len(si.Elements()) != 0 { | ||
return | ||
} | ||
|
||
// FIXME(sbinet): the ROOT/C++ streamer for TString is a simple placeholder. | ||
// but groot relies on the actual list of StreamerElements to generate the r/w-streaming code. | ||
// So, apply this "regularization" and hope for the best. | ||
sinfo := si.(*StreamerInfo) | ||
sinfo.elems = append(sinfo.elems, &StreamerBasicType{ | ||
StreamerElement: Element{ | ||
Name: *rbase.NewNamed("This", "Used to call the proper TStreamerInfo case"), | ||
Type: rmeta.TString, | ||
Size: 25, | ||
MaxIdx: [5]int32{0, 0, 0, 0, 0}, | ||
EName: "TString", | ||
}.New(), | ||
}) | ||
} |