Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions core/base/inc/TBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@
TBuffer(const TBuffer &) = delete;
void operator=(const TBuffer &) = delete;

Int_t Read(const char *name) override { return TObject::Read(name); }
Int_t Write(const char *name, Int_t opt, Int_t bufsize) override
Long64_t Read(const char *name) override { return TObject::Read(name); }
Long64_t Write(const char *name, Int_t opt, Long64_t bufsize) override
{ return TObject::Write(name, opt, bufsize); }
Int_t Write(const char *name, Int_t opt, Int_t bufsize) const override
Long64_t Write(const char *name, Int_t opt, Long64_t bufsize) const override

Check warning on line 69 in core/base/inc/TBuffer.h

View workflow job for this annotation

GitHub Actions / alma8

by ‘TBuffer::Write’ [-Woverloaded-virtual]

Check warning on line 69 in core/base/inc/TBuffer.h

View workflow job for this annotation

GitHub Actions / alma8

by ‘TBuffer::Write’ [-Woverloaded-virtual]

Check warning on line 69 in core/base/inc/TBuffer.h

View workflow job for this annotation

GitHub Actions / alma8

by ‘TBuffer::Write’ [-Woverloaded-virtual]

Check warning on line 69 in core/base/inc/TBuffer.h

View workflow job for this annotation

GitHub Actions / alma8

by ‘TBuffer::Write’ [-Woverloaded-virtual]
{ return TObject::Write(name, opt, bufsize); }

public:
Expand All @@ -78,53 +78,53 @@
enum { kInitialSize = 1024, kMinimalSize = 128 };

TBuffer(EMode mode);
TBuffer(EMode mode, Int_t bufsize);
TBuffer(EMode mode, Int_t bufsize, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr);
TBuffer(EMode mode, Long64_t bufsize);
TBuffer(EMode mode, Long64_t bufsize, void *buf, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr);
virtual ~TBuffer();

Int_t GetBufferVersion() const { return fVersion; }
Bool_t IsReading() const { return (fMode & kWrite) == 0; }
Bool_t IsWriting() const { return (fMode & kWrite) != 0; }
void SetReadMode();
void SetWriteMode();
void SetBuffer(void *buf, UInt_t bufsize = 0, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr);
void SetBuffer(void *buf, Long64_t bufsize = 0, Bool_t adopt = kTRUE, ReAllocCharFun_t reallocfunc = nullptr);
ReAllocCharFun_t GetReAllocFunc() const;
void SetReAllocFunc(ReAllocCharFun_t reallocfunc = nullptr);
void SetBufferOffset(Int_t offset = 0) { fBufCur = fBuffer+offset; }
void SetBufferOffset(Long64_t offset = 0) { fBufCur = fBuffer+offset; }
void SetParent(TObject *parent);
TObject *GetParent() const;
char *Buffer() const { return fBuffer; }
char *GetCurrent() const { return fBufCur; }
Int_t BufferSize() const { return fBufSize; }
void DetachBuffer() { fBuffer = nullptr; }
Int_t Length() const { return (Int_t)(fBufCur - fBuffer); }
void Expand(Int_t newsize, Bool_t copy = kTRUE); // expand buffer to newsize
void AutoExpand(Int_t size_needed); // expand buffer to newsize
void Expand(Long64_t newsize, Bool_t copy = kTRUE); // expand buffer to newsize
void AutoExpand(ULong64_t size_needed); // expand buffer to newsize
Bool_t ByteSwapBuffer(Long64_t n, EDataType type); // Byte-swap N primitive-elements in the buffer

virtual Bool_t CheckObject(const TObject *obj) = 0;
virtual Bool_t CheckObject(const void *obj, const TClass *ptrClass) = 0;

virtual Int_t ReadBuf(void *buf, Int_t max) = 0;
virtual void WriteBuf(const void *buf, Int_t max) = 0;
virtual Long64_t ReadBuf(void *buf, Long64_t max) = 0;
virtual void WriteBuf(const void *buf, Long64_t max) = 0;

virtual char *ReadString(char *s, Int_t max) = 0;
virtual char *ReadString(char *s, Long64_t max) = 0;
virtual void WriteString(const char *s) = 0;

virtual Int_t GetVersionOwner() const = 0;
virtual Int_t GetMapCount() const = 0;
virtual void GetMappedObject(UInt_t tag, void* &ptr, TClass* &ClassPtr) const = 0;
virtual void MapObject(const TObject *obj, UInt_t offset = 1) = 0;
virtual void MapObject(const void *obj, const TClass *cl, UInt_t offset = 1) = 0;
virtual void MapObject(const TObject *obj, ULong64_t offset = 1) = 0;
virtual void MapObject(const void *obj, const TClass *cl, ULong64_t offset = 1) = 0;
virtual void Reset() = 0;
virtual void InitMap() = 0;
virtual void ResetMap() = 0;
virtual void SetReadParam(Int_t mapsize) = 0;
virtual void SetWriteParam(Int_t mapsize) = 0;

virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss) = 0;
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const char *classname) = 0;
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion = kFALSE)= 0;
virtual Long64_t CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const TClass *clss) = 0;
virtual Long64_t CheckByteCount(ULong64_t startpos, ULong64_t bcnt, const char *classname) = 0;
virtual void SetByteCount(ULong64_t cntpos, Bool_t packInVersion = kFALSE)= 0;

virtual void SkipVersion(const TClass *cl = nullptr) = 0;
virtual Version_t ReadVersion(UInt_t *start = nullptr, UInt_t *bcnt = nullptr, const TClass *cl = nullptr) = 0;
Expand Down Expand Up @@ -164,7 +164,7 @@
virtual void SetPidOffset(UShort_t offset) = 0;
virtual Int_t GetBufferDisplacement() const = 0;
virtual void SetBufferDisplacement() = 0;
virtual void SetBufferDisplacement(Int_t skipped) = 0;
virtual void SetBufferDisplacement(Long64_t skipped) = 0;

// basic types and arrays of basic types
virtual void ReadFloat16 (Float_t *f, TStreamerElement *ele = nullptr) = 0;
Expand Down Expand Up @@ -320,8 +320,8 @@
// Utilities for TStreamerInfo
virtual void ForceWriteInfo(TVirtualStreamerInfo *info, Bool_t force) = 0;
virtual void ForceWriteInfoClones(TClonesArray *a) = 0;
virtual Int_t ReadClones (TClonesArray *a, Int_t nobjects, Version_t objvers) = 0;
virtual Int_t WriteClones(TClonesArray *a, Int_t nobjects) = 0;
virtual Int_t ReadClones (TClonesArray *a, Long64_t nobjects, Version_t objvers) = 0;
virtual Int_t WriteClones(TClonesArray *a, Long64_t nobjects) = 0;

// Utilities for TClass
virtual Int_t ReadClassEmulated(const TClass *cl, void *object, const TClass *onfile_class = nullptr) = 0;
Expand Down
26 changes: 13 additions & 13 deletions core/base/inc/TDirectory.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,27 +247,27 @@
virtual void pwd() const;
virtual void ReadAll(Option_t * /*option*/="") {}
virtual Int_t ReadKeys(Bool_t /*forceRead*/=kTRUE) {return 0;}
virtual Int_t ReadTObject(TObject * /*obj*/, const char * /*keyname*/) {return 0;}
virtual Long64_t ReadTObject(TObject * /*obj*/, const char * /*keyname*/) {return 0;}
virtual TObject *Remove(TObject*);
void RecursiveRemove(TObject *obj) override;
virtual void rmdir(const char *name);
virtual void Save() {}
virtual Int_t SaveObjectAs(const TObject * /*obj*/, const char * /*filename*/="", Option_t * /*option*/="") const;
virtual Long64_t SaveObjectAs(const TObject * /*obj*/, const char * /*filename*/="", Option_t * /*option*/="") const;
virtual void SaveSelf(Bool_t /*force*/ = kFALSE) {}
virtual void SetBufferSize(Int_t /* bufsize */) {}
virtual void SetBufferSize(Long64_t /* bufsize */) {}
virtual void SetModified() {}
virtual void SetMother(TObject *mother) {fMother = (TObject*)mother;}
void SetName(const char* newname) override;
virtual void SetTRefAction(TObject * /*ref*/, TObject * /*parent*/) {}
virtual void SetSeekDir(Long64_t) {}
virtual void SetWritable(Bool_t) {}
Int_t Sizeof() const override {return 0;}
virtual Int_t Write(const char * /*name*/=nullptr, Int_t /*opt*/=0, Int_t /*bufsize*/=0) override {return 0;}
virtual Int_t Write(const char * /*name*/=nullptr, Int_t /*opt*/=0, Int_t /*bufsize*/=0) const override {return 0;}
virtual Int_t WriteTObject(const TObject *obj, const char *name =nullptr, Option_t * /*option*/="", Int_t /*bufsize*/ =0);
Long64_t Sizeof() const override {return 0;}
Long64_t Write(const char * /*name*/=nullptr, Int_t /*opt*/=0, Long64_t /*bufsize*/=0) override {return 0;}
Long64_t Write(const char * /*name*/=nullptr, Int_t /*opt*/=0, Long64_t /*bufsize*/=0) const override {return 0;}

Check warning on line 266 in core/base/inc/TDirectory.h

View workflow job for this annotation

GitHub Actions / alma8

by ‘TDirectory::Write’ [-Woverloaded-virtual]

Check warning on line 266 in core/base/inc/TDirectory.h

View workflow job for this annotation

GitHub Actions / alma8

by ‘TDirectory::Write’ [-Woverloaded-virtual]
virtual Long64_t WriteTObject(const TObject *obj, const char *name =nullptr, Option_t * /*option*/="", Long64_t /*bufsize*/ =0);
private:
/// \cond HIDDEN_SYMBOLS
Int_t WriteObject(void *obj, const char* name, Option_t *option="", Int_t bufsize=0); // Intentionally not implemented.
Long64_t WriteObject(void *obj, const char* name, Option_t *option="", Long64_t bufsize=0); // Intentionally not implemented.
/// \endcond
public:
/// \brief Write an object with proper type checking.
Expand All @@ -280,7 +280,7 @@
/// from TObject. The method redirects to TDirectory::WriteObjectAny.
template <typename T>
inline std::enable_if_t<!std::is_base_of<TObject, T>::value, Int_t>
WriteObject(const T *obj, const char *name, Option_t *option = "", Int_t bufsize = 0)
WriteObject(const T *obj, const char *name, Option_t *option = "", Long64_t bufsize = 0)
{
return WriteObjectAny(obj, TClass::GetClass<T>(), name, option, bufsize);
}
Expand All @@ -293,13 +293,13 @@
/// This overload takes care of instances of classes that are derived from
/// TObject. The method redirects to TDirectory::WriteTObject.
template <typename T>
inline std::enable_if_t<std::is_base_of<TObject, T>::value, Int_t>
WriteObject(const T *obj, const char *name, Option_t *option = "", Int_t bufsize = 0)
inline std::enable_if_t<std::is_base_of<TObject, T>::value, Long64_t>
WriteObject(const T *obj, const char *name, Option_t *option = "", Long64_t bufsize = 0)
{
return WriteTObject(obj, name, option, bufsize);
}
virtual Int_t WriteObjectAny(const void *, const char * /*classname*/, const char * /*name*/, Option_t * /*option*/="", Int_t /*bufsize*/ =0) {return 0;}
virtual Int_t WriteObjectAny(const void *, const TClass * /*cl*/, const char * /*name*/, Option_t * /*option*/="", Int_t /*bufsize*/ =0) {return 0;}
virtual Long64_t WriteObjectAny(const void *, const char * /*classname*/, const char * /*name*/, Option_t * /*option*/="", Long64_t /*bufsize*/ =0) {return 0;}
virtual Long64_t WriteObjectAny(const void *, const TClass * /*cl*/, const char * /*name*/, Option_t * /*option*/="", Long64_t /*bufsize*/ =0) {return 0;}
virtual void WriteDirHeader() {}
virtual void WriteKeys() {}

Expand Down
2 changes: 1 addition & 1 deletion core/base/inc/TNamed.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class TNamed : public TObject {
virtual void SetTitle(const char *title=""); // *MENU*
void ls(Option_t *option="") const override;
void Print(Option_t *option="") const override;
virtual Int_t Sizeof() const;
virtual Long64_t Sizeof() const;

ClassDefOverride(TNamed,1) //The basis for a named object (name, title)
};
Expand Down
24 changes: 21 additions & 3 deletions core/base/inc/TObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,33 @@ class TObject {
virtual void Paint(Option_t *option="");
virtual void Pop();
virtual void Print(Option_t *option="") const;
virtual Int_t Read(const char *name);
virtual Long64_t Read(const char *name);
virtual void RecursiveRemove(TObject *obj);
virtual void SaveAs(const char *filename="",Option_t *option="") const; // *MENU*
virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
virtual void SetDrawOption(Option_t *option=""); // *MENU*
virtual void SetUniqueID(UInt_t uid);
virtual void UseCurrentStyle();
virtual Int_t Write(const char *name = nullptr, Int_t option = 0, Int_t bufsize = 0);
virtual Int_t Write(const char *name = nullptr, Int_t option = 0, Int_t bufsize = 0) const;
virtual Long64_t Write(const char *name = nullptr, Int_t option = 0, Long64_t bufsize = 0);
virtual Long64_t Write(const char *name = nullptr, Int_t option = 0, Long64_t bufsize = 0) const;
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Woverloaded-virtual"
#elif __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Woverloaded-virtual"
#endif
/// \deprecated Please override the `Long64_t` overload instead of the `Int_t` version.
[[deprecated]] virtual Long64_t Write(const char *name, Int_t option, Int_t bufsize) final
{ return Write(name, option, (Long64_t)bufsize); }
/// \deprecated Please override the `Long64_t` overload instead of the `Int_t` version.
[[deprecated]] virtual Long64_t Write(const char *name, Int_t option, Int_t bufsize) const final
{ return Write(name, option, (Long64_t)bufsize); }
#ifdef __clang__
#pragma clang diagnostic pop
#elif __GNUC__
#pragma GCC diagnostic pop
#endif

/// IsDestructed
///
Expand Down
37 changes: 20 additions & 17 deletions core/base/src/TBuffer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ TBuffer::TBuffer(EMode mode)
/// Create an I/O buffer object. Mode should be either TBuffer::kRead or
/// TBuffer::kWrite.

TBuffer::TBuffer(EMode mode, Int_t bufsize)
TBuffer::TBuffer(EMode mode, Long64_t bufsize)
{
if (bufsize < 0)
Fatal("TBuffer","Request to create a buffer with a negative size, likely due to an integer overflow: 0x%x for a max of 0x%x.", bufsize, kMaxBufferSize);
if (bufsize > kMaxBufferSize)
Fatal("TBuffer","Request to create a too large buffer: 0x%llx for a max of 0x%x.", bufsize, kMaxBufferSize);
if (bufsize < kMinimalSize) bufsize = kMinimalSize;
fBufSize = bufsize;
fMode = mode;
Expand Down Expand Up @@ -100,10 +100,10 @@ TBuffer::TBuffer(EMode mode, Int_t bufsize)
/// is provided, a Fatal error will be issued if the Buffer attempts to
/// expand.

TBuffer::TBuffer(EMode mode, Int_t bufsize, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc)
TBuffer::TBuffer(EMode mode, Long64_t bufsize, void *buf, Bool_t adopt, ReAllocCharFun_t reallocfunc)
{
if (bufsize < 0)
Fatal("TBuffer","Request to create a buffer with a negative size, likely due to an integer overflow: 0x%x for a max of 0x%x.", bufsize, kMaxBufferSize);
if (bufsize > kMaxBufferSize)
Fatal("TBuffer","Request to create a too large buffer: 0x%llx for a max of 0x%x.", bufsize, kMaxBufferSize);
fBufSize = bufsize;
fMode = mode;
fVersion = 0;
Expand Down Expand Up @@ -154,17 +154,18 @@ TBuffer::~TBuffer()
/// If the size_needed is larger than the current size, the policy
/// is to expand to double the current size or the size_needed which ever is largest.

void TBuffer::AutoExpand(Int_t size_needed)
void TBuffer::AutoExpand(ULong64_t size_needed)
{
if (size_needed < 0) {
Fatal("AutoExpand","Request to expand to a negative size, likely due to an integer overflow: 0x%x for a max of 0x%x.", size_needed, kMaxBufferSize);
if (size_needed > kMaxBufferSize) {
Fatal("AutoExpand","Request to expand a too large buffer: 0x%llx for a max of 0x%x.", size_needed, kMaxBufferSize);
}
if (size_needed > fBufSize) {
auto size_asked = Long64_t(size_needed); // temporary cast as long as fBufSize keeps being a signed variable
if (size_asked > fBufSize) {
Long64_t doubling = 2LLU * fBufSize;
if (doubling > kMaxBufferSize)
doubling = kMaxBufferSize;
if (size_needed > doubling) {
Expand(size_needed);
if (size_asked > doubling) {
Expand(size_asked);
} else {
Expand(doubling);
}
Expand All @@ -183,8 +184,10 @@ void TBuffer::AutoExpand(Int_t size_needed)
/// is provided, a Fatal error will be issued if the Buffer attempts to
/// expand.

void TBuffer::SetBuffer(void *buf, UInt_t newsiz, Bool_t adopt, ReAllocCharFun_t reallocfunc)
void TBuffer::SetBuffer(void *buf, Long64_t newsiz, Bool_t adopt, ReAllocCharFun_t reallocfunc)
{
if (newsiz > kMaxBufferSize)
Fatal("SetBuffer","Request to create a too large buffer: 0x%llx for a max of 0x%x.", newsiz, kMaxBufferSize);
if (fBuffer && TestBit(kIsOwner))
delete [] fBuffer;

Expand Down Expand Up @@ -219,19 +222,19 @@ void TBuffer::SetBuffer(void *buf, UInt_t newsiz, Bool_t adopt, ReAllocCharFun_t
/// In order to avoid losing data, if the current length is greater than
/// the requested size, we only shrink down to the current length.

void TBuffer::Expand(Int_t newsize, Bool_t copy)
void TBuffer::Expand(Long64_t newsize, Bool_t copy)
{
Int_t l = Length();
if ( (l > newsize) && copy ) {
if ( (Long64_t(l) > newsize) && copy ) {
newsize = l;
}
const Int_t extraspace = (fMode&kWrite)!=0 ? kExtraSpace : 0;

if ( ((Long64_t)newsize+extraspace) > kMaxBufferSize) {
if ( newsize > kMaxBufferSize - kExtraSpace) {
if (l < kMaxBufferSize) {
newsize = kMaxBufferSize - extraspace;
} else {
Fatal("Expand","Requested size (%d) is too large (max is %d).", newsize, kMaxBufferSize);
Fatal("Expand","Requested size (%lld) is too large (max is %d).", newsize, kMaxBufferSize);
}
}
if ( (fMode&kWrite)!=0 ) {
Expand Down
13 changes: 7 additions & 6 deletions core/base/src/TDirectory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,12 @@ static TBuffer* R__CreateBuffer()
if (!creator) {
R__LOCKGUARD(gROOTMutex);
TClass *c = TClass::GetClass("TBufferFile");
TMethod *m = c->GetMethodWithPrototype("TBufferFile","TBuffer::EMode,Int_t",kFALSE,ROOT::kExactMatch);
TMethod *m = c->GetMethodWithPrototype("TBufferFile","TBuffer::EMode,Long64_t",kFALSE,ROOT::kExactMatch);
assert(m != nullptr);
creator = (tcling_callfunc_Wrapper_t)( m->InterfaceMethod() );
}
TBuffer::EMode mode = TBuffer::kWrite;
Int_t size = 10000;
Long64_t size = 10000;
void *args[] = { &mode, &size };
TBuffer *result;
creator(nullptr,2,args,&result);
Expand Down Expand Up @@ -1253,12 +1254,12 @@ void TDirectory::rmdir(const char *name)
/// JavaScript ROOT (https://root.cern/js/) to display object in web browser
/// When creating JSON file, option string may contain compression level from 0 to 3 (default 0)

Int_t TDirectory::SaveObjectAs(const TObject *obj, const char *filename, Option_t *option) const
Long64_t TDirectory::SaveObjectAs(const TObject *obj, const char *filename, Option_t *option) const
{
// option can contain single letter args: "a" for append, "q" for quiet in any combinations

if (!obj) return 0;
Int_t nbytes = 0;
Long64_t nbytes = 0;
TString fname, opt = option, cmd;
if (filename && *filename)
fname = filename;
Expand Down Expand Up @@ -1423,9 +1424,9 @@ void TDirectory::RegisterGDirectory(TDirectory::SharedGDirectory_t &gdirectory_p
}

////////////////////////////////////////////////////////////////////////////////
/// \copydoc TDirectoryFile::WriteObject(const T*,const char*,Option_t*,Int_t).
/// \copydoc TDirectoryFile::WriteObject(const T*,const char*,Option_t*,Long64_t).

Int_t TDirectory::WriteTObject(const TObject *obj, const char *name, Option_t * /*option*/, Int_t /*bufsize*/)
Long64_t TDirectory::WriteTObject(const TObject *obj, const char *name, Option_t * /*option*/, Long64_t /*bufsize*/)
{
const char *objname = "no name specified";
if (name) objname = name;
Expand Down
4 changes: 2 additions & 2 deletions core/base/src/TNamed.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ void TNamed::SetTitle(const char *title)
////////////////////////////////////////////////////////////////////////////////
/// Return size of the TNamed part of the TObject.

Int_t TNamed::Sizeof() const
Long64_t TNamed::Sizeof() const
{
Int_t nbytes = fName.Sizeof() + fTitle.Sizeof();
Long64_t nbytes = fName.Sizeof() + fTitle.Sizeof();
return nbytes;
}
Loading
Loading