From 90c9156e282784848b9df49a211ac5a881d1a347 Mon Sep 17 00:00:00 2001 From: CristinaCristescu Date: Fri, 12 Jul 2013 10:50:54 +0200 Subject: [PATCH 01/27] TEnum and TEnumConstant linked --- core/meta/inc/LinkDef.h | 2 ++ core/meta/inc/TEnum.h | 63 +++++++++++++++++++++++++++++++++++ core/meta/inc/TEnumConstant.h | 50 +++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 core/meta/inc/TEnum.h create mode 100644 core/meta/inc/TEnumConstant.h diff --git a/core/meta/inc/LinkDef.h b/core/meta/inc/LinkDef.h index 7b9aa38caa5fe..86c81248db96b 100644 --- a/core/meta/inc/LinkDef.h +++ b/core/meta/inc/LinkDef.h @@ -27,6 +27,8 @@ #pragma link C++ class TDataMember; #pragma link C++ class TDataType; #pragma link C++ class TDictionary; +#pragma link C++ class TEnumConstant+; +#pragma link C++ class TEnum+; #pragma link C++ class TFunction; #pragma link C++ class ROOT::TSchemaMatch+; #pragma link C++ class ROOT::TSchemaRule+; diff --git a/core/meta/inc/TEnum.h b/core/meta/inc/TEnum.h new file mode 100644 index 0000000000000..e9bed7a30bfaa --- /dev/null +++ b/core/meta/inc/TEnum.h @@ -0,0 +1,63 @@ +// @(#)root/meta:$Id$ +// Author: Bianca-Cristina Cristescu 09/07/13 + +/************************************************************************* + * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +#ifndef ROOT_TEnum +#define ROOT_TEnum + +////////////////////////////////////////////////////////////////////////// +// // +// TEnum // +// // +// TEnum class defines enum type. // +// // +////////////////////////////////////////////////////////////////////////// + +#ifndef ROOT_TObject +#include "TObject.h" +#endif +#ifndef ROOT_THashList +#include "THashList.h" +#endif +#ifndef ROOT_TString +#include "TString.h" +#endif +#ifndef ROOT_TSeqCollection +#include "TSeqCollection.h" +#endif +#ifndef ROOT_TEnumConstant +#include "TEnumConstant.h" +#endif + +class TEnumConstant; + +class TEnum : public TObject { + +private: + TString fName; //name of the enum type + THashList fConstantList; //list of constants the enum type + void* fInfo; //interpreter implementation provided declaration + +public: + + TEnum(): fInfo(0) {} + TEnum(const char* name, bool isGlobal, void* info); + virtual ~TEnum(); + + void AddConstant(TEnumConstant* constant); + const TSeqCollection* GetConstants() const { return &fConstantList; } + const TEnumConstant* GetConstant(const char* name) const { + return (TEnumConstant*) fConstantList.FindObject(name); + } + + ClassDef(TEnum,1) //Enum type class +}; + +#endif diff --git a/core/meta/inc/TEnumConstant.h b/core/meta/inc/TEnumConstant.h new file mode 100644 index 0000000000000..100b6d643d138 --- /dev/null +++ b/core/meta/inc/TEnumConstant.h @@ -0,0 +1,50 @@ +// @(#)root/meta:$Id$ +// Author: Bianca-Cristina Cristescu 09/07/13 + +/************************************************************************* + * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +#ifndef ROOT_TEnumConstant +#define ROOT_TEnumConstant + + +////////////////////////////////////////////////////////////////////////// +// // +// TEnumConstant // +// // +// TEnumConstant class defines a constant in the TEnum type. // +// // +////////////////////////////////////////////////////////////////////////// + +#ifndef ROOT_TGlobal +#include "TGlobal.h" +#endif +#ifndef ROOT_TEnum +#include "TEnum.h" +#endif + +class TEnum; + +class TEnumConstant : public TGlobal { +private: + const TEnum *fEnum; //the enum type + Long64_t fValue; //the value for the constant + DataMemberInfo_t *fDataMemberInfo_t; //the data member information + +public: + TEnumConstant(): fEnum(0), fValue(-1) {} + TEnumConstant(DataMemberInfo_t *info, Long64_t value, TEnum* type); + virtual ~TEnumConstant(); + + Long64_t GetValue() const { return fValue; } + const TEnum *GetType() const { return fEnum; } + + ClassDef(TEnumConstant,1) //Enum type constant +}; + +#endif From d5a27ee9ac5ea57516c958b482de077e45b5eacf Mon Sep 17 00:00:00 2001 From: CristinaCristescu Date: Fri, 12 Jul 2013 10:55:04 +0200 Subject: [PATCH 02/27] TEnum and TEnumConstant linked --- build/unix/gminimalHeaders.list | 2 ++ core/meta/src/TEnum.cxx | 50 +++++++++++++++++++++++++++++++++ core/meta/src/TEnumConstant.cxx | 43 ++++++++++++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 core/meta/src/TEnum.cxx create mode 100644 core/meta/src/TEnumConstant.cxx diff --git a/build/unix/gminimalHeaders.list b/build/unix/gminimalHeaders.list index 42bc012acc187..16a66b3586e03 100644 --- a/build/unix/gminimalHeaders.list +++ b/build/unix/gminimalHeaders.list @@ -334,6 +334,8 @@ include/TEntryList.h include/TEntryListArray.h include/TEntryListBlock.h include/TEntryListFromFile.h +include/TEnum.h +include/TEnumConstant.h include/TEnv.h include/TError.h include/TEventIter.h diff --git a/core/meta/src/TEnum.cxx b/core/meta/src/TEnum.cxx new file mode 100644 index 0000000000000..1d8c312119ea2 --- /dev/null +++ b/core/meta/src/TEnum.cxx @@ -0,0 +1,50 @@ +// @(#)root/meta:$Id$ +// Author: Bianca-Cristina Cristescu 10/07/13 + +/************************************************************************* + * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// // +// THe TEnum class implements the enum type. // +// // +////////////////////////////////////////////////////////////////////////// + +#include "TEnum.h" +#include "TEnumConstant.h" + +ClassImp(TEnum) +//______________________________________________________________________________ +TEnum::TEnum(const char* name, bool isGlobal, void* info) +{ + //Constructor for TEnum class. + //It take the name of the TEnum type, specification if it is global + //and interpreter info. + //Constant List is owner if enum not on global scope (thus constants not + //in TROOT::GetListOfGlobals). + + fName = name; + fInfo = info; + if (!isGlobal) + fConstantList.SetOwner(kTRUE); +} + +//______________________________________________________________________________ +TEnum::~TEnum() +{ + //Destructor +} + +//______________________________________________________________________________ +void TEnum::AddConstant(TEnumConstant* constant) +{ + //Add a EnumConstant to the list of constants of the Enum Type. + + fConstantList.Add(constant); +} + diff --git a/core/meta/src/TEnumConstant.cxx b/core/meta/src/TEnumConstant.cxx new file mode 100644 index 0000000000000..b4c3a4022679e --- /dev/null +++ b/core/meta/src/TEnumConstant.cxx @@ -0,0 +1,43 @@ +// @(#)root/meta:$Id$ +// Author: Bianca-Cristina Cristescu 10/07/13 + +/************************************************************************* + * Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. * + * All rights reserved. * + * * + * For the licensing terms see $ROOTSYS/LICENSE. * + * For the list of contributors see $ROOTSYS/README/CREDITS. * + *************************************************************************/ + +////////////////////////////////////////////////////////////////////////// +// // +// THe TEnumConstnt class implements the constants of the enum type. // +// // +////////////////////////////////////////////////////////////////////////// + +#include "TEnumConstant.h" +#include "TEnum.h" + + +ClassImp(TEnumConstant) +//______________________________________________________________________________ +TEnumConstant::TEnumConstant(DataMemberInfo_t *info, Long64_t value, TEnum* type) +{ + //Constructor of the TEnumConstant. + //Takes as parameters DataMemeberInfo, value, and enum type. + + fValue = value; + fEnum = type; + fDataMemberInfo_t = info; + + //add teh constant to the enum type + type->AddConstant(this); +} + +//______________________________________________________________________________ +TEnumConstant::~TEnumConstant() +{ + //Destructor +} + +//______________________________________________________________________________ From 9d2dab8038b3bd3b2d63ab6d6da2060e30af52e2 Mon Sep 17 00:00:00 2001 From: CristinaCristescu Date: Fri, 12 Jul 2013 14:03:55 +0200 Subject: [PATCH 03/27] Integrate TEnum and TEnumConstant with TCling. --- core/base/inc/TROOT.h | 4 ++- core/meta/src/TCling.cxx | 69 +++++++++++++++++++++++++++++++++++----- 2 files changed, 64 insertions(+), 9 deletions(-) diff --git a/core/base/inc/TROOT.h b/core/base/inc/TROOT.h index 0043278a97b4b..dcf120b18b413 100644 --- a/core/base/inc/TROOT.h +++ b/core/base/inc/TROOT.h @@ -110,7 +110,7 @@ friend TROOT *ROOT::GetROOT2(); TCollection *fTypes; //List of data types definition TCollection *fGlobals; //List of global variables TCollection *fGlobalFunctions; //List of global functions - TSeqCollection *fClosedObjects; //List of closed objects from the list of files and sockets, so we can delete them if neededCl. + TSeqCollection *fClosedObjects; //List of closed objects from the list of files and sockets, so we can delete them if neededCl. TSeqCollection *fFiles; //List of files TSeqCollection *fMappedFiles; //List of memory mapped files TSeqCollection *fSockets; //List of network sockets @@ -130,6 +130,7 @@ friend TROOT *ROOT::GetROOT2(); TSeqCollection *fProofs; //List of proof sessions TSeqCollection *fClipboard; //List of clipbard objects TSeqCollection *fDataSets; //List of data sets (TDSet or TChain) + TSeqCollection *fEnums; //List of enum types TProcessUUID *fUUIDs; //Pointer to TProcessID managing TUUIDs TFolder *fRootFolder; //top level folder //root TList *fBrowsables; //List of browsables @@ -212,6 +213,7 @@ friend TROOT *ROOT::GetROOT2(); TSeqCollection *GetListOfProofs() const { return fProofs; } TSeqCollection *GetClipboard() const { return fClipboard; } TSeqCollection *GetListOfDataSets() const { return fDataSets; } + TSeqCollection *GetListOfEnums() const { return fEnums; } TList *GetListOfBrowsables() const { return fBrowsables; } TDataType *GetType(const char *name, Bool_t load = kFALSE) const; TFile *GetFile() const { if (gDirectory != this) return gDirectory->GetFile(); else return 0;} diff --git a/core/meta/src/TCling.cxx b/core/meta/src/TCling.cxx index c0fd69ac710cd..2d124b397691c 100644 --- a/core/meta/src/TCling.cxx +++ b/core/meta/src/TCling.cxx @@ -55,6 +55,7 @@ #include "TVirtualMutex.h" #include "TError.h" #include "TEnv.h" +#include "TEnum.h" #include "THashTable.h" #include "RConfigure.h" #include "compiledata.h" @@ -222,8 +223,39 @@ void TCling::HandleNewDecl(const void* DV, bool isDeserialized, std::set(DV); if (!D->isCanonicalDecl()) return; - if (isa(D->getDeclContext()) - || isa(D->getDeclContext())) + if (isa(D->getDeclContext())) return; + + // We handle nested enums here, globals are handled later. + if (!isa(D->getDeclContext())) { + if (const clang::EnumDecl* ED = dyn_cast(D)) { + + // Get name of the enum type. + // Note: This *must* be static because we are returning a pointer inside it! + static std::string buf; + buf.clear(); + PrintingPolicy Policy(D->getASTContext().getPrintingPolicy()); + llvm::raw_string_ostream stream(buf); + ED->getNameForDiagnostic(stream, Policy, /*Qualified=*/true); + const char* name = buf.c_str(); + + // Create the enum type. + TEnum* enumType = new TEnum(name, false /*!global*/, &D); + gROOT->GetListOfEnums()->Add(enumType); + + // Add the constants to the enum type. + for (EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(), + EDE = ED->enumerator_end(); EDI != EDE; ++EDI) { + + // Get title of the constant. + DataMemberInfo_t *info = new TClingDataMemberInfo(fInterpreter, *EDI); + Long64_t value = (Long64_t)DataMemberInfo_Title(info); + // Create the constant. + new TEnumConstant(info, value, enumType); + } + } + } + + if (isa(D->getDeclContext())) return; // Don't list templates. @@ -320,18 +352,39 @@ void TCling::HandleNewDecl(const void* DV, bool isDeserialized, std::setGetListOfGlobals()->FindObject(ND->getNameAsString().c_str())) return; + //Put the global constants in the list. if (const EnumDecl *ED = dyn_cast(D)) { - for(EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(), - EDE = ED->enumerator_end(); EDI != EDE; ++EDI) { - if (!gROOT->GetListOfGlobals()->FindObject((*EDI)->getNameAsString().c_str())) { - gROOT->GetListOfGlobals()->Add(new TGlobal(new TClingDataMemberInfo(fInterpreter, *EDI))); + if (!gROOT->GetListOfEnums()->FindObject(ND->getNameAsString().c_str())) { + + // Get name of the enum type. + // Note: This *must* be static because we are returning a pointer inside it! + static std::string buf; + buf.clear(); + PrintingPolicy Policy(D->getASTContext().getPrintingPolicy()); + llvm::raw_string_ostream stream(buf); + ED->getNameForDiagnostic(stream, Policy, /*Qualified=*/true); + const char* name = buf.c_str(); + + // Create the enum type. + TEnum* enumType = new TEnum(name, true /*global!*/, &D); + gROOT->GetListOfEnums()->Add(enumType); + + // Add the constants to the enum type. + for(EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(), + EDE = ED->enumerator_end(); EDI != EDE; ++EDI) { + + // Get title of the constant. + DataMemberInfo_t *info = new TClingDataMemberInfo(fInterpreter, *EDI); + Long64_t value = (Long64_t)DataMemberInfo_Title(info); + // Create the constant and add it to the list of globals. + gROOT->GetListOfGlobals()->Add(new TEnumConstant(info, value, enumType)); } } - } - else + } else gROOT->GetListOfGlobals()->Add(new TGlobal(new TClingDataMemberInfo(fInterpreter, cast(ND)))); + } } From fbe1e7c58f9762170f2a543d79f2f59af829a3f1 Mon Sep 17 00:00:00 2001 From: CristinaCristescu Date: Tue, 16 Jul 2013 10:03:54 +0200 Subject: [PATCH 04/27] Fix enums and test TCling with enums. --- core/base/inc/TROOT.h | 4 +- core/base/src/TROOT.cxx | 3 + core/meta/inc/TEnum.h | 13 +--- core/meta/inc/TEnumConstant.h | 10 +--- core/meta/src/TCling.cxx | 103 +++++++++++++++++--------------- core/meta/src/TCling.h | 10 ++-- core/meta/src/TEnum.cxx | 7 +-- core/meta/src/TEnumConstant.cxx | 20 +++---- 8 files changed, 81 insertions(+), 89 deletions(-) diff --git a/core/base/inc/TROOT.h b/core/base/inc/TROOT.h index dcf120b18b413..ed271a3d3b864 100644 --- a/core/base/inc/TROOT.h +++ b/core/base/inc/TROOT.h @@ -130,7 +130,7 @@ friend TROOT *ROOT::GetROOT2(); TSeqCollection *fProofs; //List of proof sessions TSeqCollection *fClipboard; //List of clipbard objects TSeqCollection *fDataSets; //List of data sets (TDSet or TChain) - TSeqCollection *fEnums; //List of enum types + TCollection *fEnums; //List of enum types TProcessUUID *fUUIDs; //Pointer to TProcessID managing TUUIDs TFolder *fRootFolder; //top level folder //root TList *fBrowsables; //List of browsables @@ -213,7 +213,7 @@ friend TROOT *ROOT::GetROOT2(); TSeqCollection *GetListOfProofs() const { return fProofs; } TSeqCollection *GetClipboard() const { return fClipboard; } TSeqCollection *GetListOfDataSets() const { return fDataSets; } - TSeqCollection *GetListOfEnums() const { return fEnums; } + TCollection *GetListOfEnums() const { return fEnums; } TList *GetListOfBrowsables() const { return fBrowsables; } TDataType *GetType(const char *name, Bool_t load = kFALSE) const; TFile *GetFile() const { if (gDirectory != this) return gDirectory->GetFile(); else return 0;} diff --git a/core/base/src/TROOT.cxx b/core/base/src/TROOT.cxx index c7cbea8aa7ccf..ee93356a89cb3 100644 --- a/core/base/src/TROOT.cxx +++ b/core/base/src/TROOT.cxx @@ -399,6 +399,7 @@ TROOT::TROOT(const char *name, const char *title, VoidFuncPtr_t *initfunc) // Initialize interface to CINT C++ interpreter fVersionInt = 0; // check in TROOT dtor in case TCling fails fClasses = 0; // might be checked via TCling ctor + fEnums = 0; fConfigOptions = R__CONFIGUREOPTIONS; fConfigFeatures = R__CONFIGUREFEATURES; @@ -416,6 +417,7 @@ TROOT::TROOT(const char *name, const char *title, VoidFuncPtr_t *initfunc) //fIdMap = new IdMap_t; fStreamerInfo = new TObjArray(100); fClassGenerators = new TList; + fEnums = new THashTable(200, 3); // FIXME: should be 1.2 * number of ROOT enums at startup // initialize plugin manager early fPluginManager->LoadHandlersFromEnv(gEnv); @@ -630,6 +632,7 @@ TROOT::~TROOT() SafeDelete(fGlobals); if (fGlobalFunctions) fGlobalFunctions->Delete(); SafeDelete(fGlobalFunctions); + fEnums->Delete(); fClasses->Delete(); SafeDelete(fClasses); // TClass'es must be deleted last #endif diff --git a/core/meta/inc/TEnum.h b/core/meta/inc/TEnum.h index e9bed7a30bfaa..160bc1bf6f88e 100644 --- a/core/meta/inc/TEnum.h +++ b/core/meta/inc/TEnum.h @@ -20,8 +20,8 @@ // // ////////////////////////////////////////////////////////////////////////// -#ifndef ROOT_TObject -#include "TObject.h" +#ifndef ROOT_TNamed +#include "TNamed.h" #endif #ifndef ROOT_THashList #include "THashList.h" @@ -29,19 +29,12 @@ #ifndef ROOT_TString #include "TString.h" #endif -#ifndef ROOT_TSeqCollection -#include "TSeqCollection.h" -#endif -#ifndef ROOT_TEnumConstant -#include "TEnumConstant.h" -#endif class TEnumConstant; -class TEnum : public TObject { +class TEnum : public TNamed { private: - TString fName; //name of the enum type THashList fConstantList; //list of constants the enum type void* fInfo; //interpreter implementation provided declaration diff --git a/core/meta/inc/TEnumConstant.h b/core/meta/inc/TEnumConstant.h index 100b6d643d138..0b5360f2bed70 100644 --- a/core/meta/inc/TEnumConstant.h +++ b/core/meta/inc/TEnumConstant.h @@ -24,21 +24,17 @@ #ifndef ROOT_TGlobal #include "TGlobal.h" #endif -#ifndef ROOT_TEnum -#include "TEnum.h" -#endif class TEnum; class TEnumConstant : public TGlobal { private: - const TEnum *fEnum; //the enum type - Long64_t fValue; //the value for the constant - DataMemberInfo_t *fDataMemberInfo_t; //the data member information + const TEnum *fEnum; //the enum type + Long64_t fValue; //the value for the constant public: TEnumConstant(): fEnum(0), fValue(-1) {} - TEnumConstant(DataMemberInfo_t *info, Long64_t value, TEnum* type); + TEnumConstant(DataMemberInfo_t *info, const char* name, Long64_t value, TEnum* type); virtual ~TEnumConstant(); Long64_t GetValue() const { return fValue; } diff --git a/core/meta/src/TCling.cxx b/core/meta/src/TCling.cxx index 2d124b397691c..1b479c84ba0f8 100644 --- a/core/meta/src/TCling.cxx +++ b/core/meta/src/TCling.cxx @@ -56,6 +56,7 @@ #include "TError.h" #include "TEnv.h" #include "TEnum.h" +#include "TEnumConstant.h" #include "THashTable.h" #include "RConfigure.h" #include "compiledata.h" @@ -216,6 +217,55 @@ static void TCling__UpdateClassInfo(const NamedDecl* TD) } } +void TCling::HandleEnumDecl(const clang::EnumDecl* ED, bool isGlobal) +{ + + // Get name of the enum type. + std::string buf; + PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy()); + llvm::raw_string_ostream stream(buf); + ED->getNameForDiagnostic(stream, Policy, /*Qualified=*/true); + const char* name = buf.c_str(); + + // Create the enum type. + TEnum* enumType = new TEnum(name, false /*!global*/, &ED); + if (!enumType) { + Error ("HandleEnumDecl", "The enum type %s was not created.", name); + } else { + gROOT->GetListOfEnums()->Add(enumType); + } + + // Add the constants to the enum type. + for (EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(), + EDE = ED->enumerator_end(); EDI != EDE; ++EDI) { + + // Get name of the enum type. + buf.clear(); + PrintingPolicy Policy(EDI->getASTContext().getPrintingPolicy()); + llvm::raw_string_ostream stream(buf); + EDI->getNameForDiagnostic(stream, Policy, /*Qualified=*/true); + const char* constantName = buf.c_str(); + + // Get value of the constant. + Long64_t value; + const llvm::APSInt valAPSInt = EDI->getInitVal(); + if (valAPSInt.isSigned()) { + value = valAPSInt.getSExtValue(); + } else { + value = valAPSInt.getZExtValue(); + } + + TEnumConstant* enumConstant = new TEnumConstant(new TClingDataMemberInfo(fInterpreter, *EDI) + , constantName, value, enumType); + if (!enumConstant) { + Error ("HandleEnumDecl", "The enum constant %s was not created.", constantName); + } else { + if (isGlobal) { + gROOT->GetListOfGlobals()->Add(enumConstant); + } + } + } +} void TCling::HandleNewDecl(const void* DV, bool isDeserialized, std::set &modifiedTClasses) { // Handle new declaration. @@ -228,30 +278,7 @@ void TCling::HandleNewDecl(const void* DV, bool isDeserialized, std::set(D->getDeclContext())) { if (const clang::EnumDecl* ED = dyn_cast(D)) { - - // Get name of the enum type. - // Note: This *must* be static because we are returning a pointer inside it! - static std::string buf; - buf.clear(); - PrintingPolicy Policy(D->getASTContext().getPrintingPolicy()); - llvm::raw_string_ostream stream(buf); - ED->getNameForDiagnostic(stream, Policy, /*Qualified=*/true); - const char* name = buf.c_str(); - - // Create the enum type. - TEnum* enumType = new TEnum(name, false /*!global*/, &D); - gROOT->GetListOfEnums()->Add(enumType); - - // Add the constants to the enum type. - for (EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(), - EDE = ED->enumerator_end(); EDI != EDE; ++EDI) { - - // Get title of the constant. - DataMemberInfo_t *info = new TClingDataMemberInfo(fInterpreter, *EDI); - Long64_t value = (Long64_t)DataMemberInfo_Title(info); - // Create the constant. - new TEnumConstant(info, value, enumType); - } + HandleEnumDecl(ED, false /* not global*/); } } @@ -356,34 +383,12 @@ void TCling::HandleNewDecl(const void* DV, bool isDeserialized, std::set(D)) { if (!gROOT->GetListOfEnums()->FindObject(ND->getNameAsString().c_str())) { - - // Get name of the enum type. - // Note: This *must* be static because we are returning a pointer inside it! - static std::string buf; - buf.clear(); - PrintingPolicy Policy(D->getASTContext().getPrintingPolicy()); - llvm::raw_string_ostream stream(buf); - ED->getNameForDiagnostic(stream, Policy, /*Qualified=*/true); - const char* name = buf.c_str(); - - // Create the enum type. - TEnum* enumType = new TEnum(name, true /*global!*/, &D); - gROOT->GetListOfEnums()->Add(enumType); - - // Add the constants to the enum type. - for(EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(), - EDE = ED->enumerator_end(); EDI != EDE; ++EDI) { - - // Get title of the constant. - DataMemberInfo_t *info = new TClingDataMemberInfo(fInterpreter, *EDI); - Long64_t value = (Long64_t)DataMemberInfo_Title(info); - // Create the constant and add it to the list of globals. - gROOT->GetListOfGlobals()->Add(new TEnumConstant(info, value, enumType)); - } + HandleEnumDecl(ED, true /* is global*/); } - } else + } else { gROOT->GetListOfGlobals()->Add(new TGlobal(new TClingDataMemberInfo(fInterpreter, cast(ND)))); + } } } diff --git a/core/meta/src/TCling.h b/core/meta/src/TCling.h index dbcb364d34670..a552498eac82c 100644 --- a/core/meta/src/TCling.h +++ b/core/meta/src/TCling.h @@ -39,9 +39,12 @@ extern "C" { namespace clang { class Decl; + class EnumDecl; } namespace cling { class Transaction; + class MetaProcessor; + class StoredValueRef; class Interpreter; } void TCling__UpdateListsOnCommitted(const cling::Transaction&, @@ -58,12 +61,6 @@ class TMethod; class TObjArray; class TInterpreterValue; -namespace cling { - class Interpreter; - class MetaProcessor; - class StoredValueRef; -} - namespace ROOT { namespace TMetaUtils { class TNormalizedCtxt; @@ -388,6 +385,7 @@ class TCling : public TInterpreter { std::set& GetModTClasses() { return fModTClasses; } void HandleNewDecl(const void* DV, bool isDeserialized, std::set& modifiedClasses); + void HandleEnumDecl(const clang::EnumDecl* ED, bool isGlobal); private: // Private Utility Functions TCling(); diff --git a/core/meta/src/TEnum.cxx b/core/meta/src/TEnum.cxx index 1d8c312119ea2..5ff31faa78d4a 100644 --- a/core/meta/src/TEnum.cxx +++ b/core/meta/src/TEnum.cxx @@ -11,25 +11,24 @@ ////////////////////////////////////////////////////////////////////////// // // -// THe TEnum class implements the enum type. // +// The TEnum class implements the enum type. // // // ////////////////////////////////////////////////////////////////////////// #include "TEnum.h" #include "TEnumConstant.h" + ClassImp(TEnum) //______________________________________________________________________________ TEnum::TEnum(const char* name, bool isGlobal, void* info) -{ +: TNamed(name, "An enum type"), fInfo(info) { //Constructor for TEnum class. //It take the name of the TEnum type, specification if it is global //and interpreter info. //Constant List is owner if enum not on global scope (thus constants not //in TROOT::GetListOfGlobals). - fName = name; - fInfo = info; if (!isGlobal) fConstantList.SetOwner(kTRUE); } diff --git a/core/meta/src/TEnumConstant.cxx b/core/meta/src/TEnumConstant.cxx index b4c3a4022679e..19a3dfd8acfe7 100644 --- a/core/meta/src/TEnumConstant.cxx +++ b/core/meta/src/TEnumConstant.cxx @@ -11,7 +11,7 @@ ////////////////////////////////////////////////////////////////////////// // // -// THe TEnumConstnt class implements the constants of the enum type. // +// The TEnumConstant class implements the constants of the enum type. // // // ////////////////////////////////////////////////////////////////////////// @@ -21,16 +21,14 @@ ClassImp(TEnumConstant) //______________________________________________________________________________ -TEnumConstant::TEnumConstant(DataMemberInfo_t *info, Long64_t value, TEnum* type) -{ - //Constructor of the TEnumConstant. - //Takes as parameters DataMemeberInfo, value, and enum type. - - fValue = value; - fEnum = type; - fDataMemberInfo_t = info; - - //add teh constant to the enum type +TEnumConstant::TEnumConstant(DataMemberInfo_t *info, const char* name, Long64_t value, TEnum* type) +: TGlobal(info), fEnum(type), fValue(value) { + // Constructor of the TEnumConstant. + // Takes as parameters DataMemberInfo, value, and enum type. + + //Set name of constant + this->SetName(name); + // Add the constant to the enum type. type->AddConstant(this); } From 2270680b2c4980d2c304d30e47a52d83c1ae2d9a Mon Sep 17 00:00:00 2001 From: CristinaCristescu Date: Mon, 5 Aug 2013 16:08:54 +0200 Subject: [PATCH 05/27] New interface to TEnum and update in TClass and TCling --- core/base/inc/TROOT.h | 2 +- core/base/src/TROOT.cxx | 2 +- core/meta/inc/TClass.h | 2 + core/meta/inc/TInterpreter.h | 1 + core/meta/src/TClass.cxx | 37 ++++++++-- core/meta/src/TCling.cxx | 131 ++++++++++++++++++++++++++++------- core/meta/src/TCling.h | 5 +- 7 files changed, 147 insertions(+), 33 deletions(-) diff --git a/core/base/inc/TROOT.h b/core/base/inc/TROOT.h index ed271a3d3b864..ab3bdfa253700 100644 --- a/core/base/inc/TROOT.h +++ b/core/base/inc/TROOT.h @@ -110,7 +110,7 @@ friend TROOT *ROOT::GetROOT2(); TCollection *fTypes; //List of data types definition TCollection *fGlobals; //List of global variables TCollection *fGlobalFunctions; //List of global functions - TSeqCollection *fClosedObjects; //List of closed objects from the list of files and sockets, so we can delete them if neededCl. + TSeqCollection *fClosedObjects; //List of closed objects from the list of files and sockets, so we can delete them if neededCl. TSeqCollection *fFiles; //List of files TSeqCollection *fMappedFiles; //List of memory mapped files TSeqCollection *fSockets; //List of network sockets diff --git a/core/base/src/TROOT.cxx b/core/base/src/TROOT.cxx index ee93356a89cb3..adc814b3a3cf5 100644 --- a/core/base/src/TROOT.cxx +++ b/core/base/src/TROOT.cxx @@ -417,7 +417,7 @@ TROOT::TROOT(const char *name, const char *title, VoidFuncPtr_t *initfunc) //fIdMap = new IdMap_t; fStreamerInfo = new TObjArray(100); fClassGenerators = new TList; - fEnums = new THashTable(200, 3); // FIXME: should be 1.2 * number of ROOT enums at startup + fEnums = new THashTable(200, 3); // FIXME: should be 1.2 * number of ROOT global enums at startup // initialize plugin manager early fPluginManager->LoadHandlersFromEnv(gEnv); diff --git a/core/meta/inc/TClass.h b/core/meta/inc/TClass.h index b12b6e5c557b7..44a8ae88b6021 100644 --- a/core/meta/inc/TClass.h +++ b/core/meta/inc/TClass.h @@ -92,6 +92,7 @@ friend class ROOT::TGenericClassInfo; TList *fRealData; //linked list for persistent members including base classes TList *fBase; //linked list for base classes TList *fData; //linked list for data members + TList *fEnums; //linked list for the enums TList *fMethod; //linked list for methods TList *fAllPubData; //all public data members (including from base classes) TList *fAllPubMethod; //all public methods (including from base classes) @@ -267,6 +268,7 @@ friend class ROOT::TGenericClassInfo; else return (fCurrentInfo=(TVirtualStreamerInfo*)(fStreamerInfo->At(fClassVersion))); } TList *GetListOfDataMembers(); + TList *GetListOfEnums(); TList *GetListOfBases(); TList *GetListOfMethods(); TList *GetListOfRealData() const { return fRealData; } diff --git a/core/meta/inc/TInterpreter.h b/core/meta/inc/TInterpreter.h index 4af21b61d732d..820ec33caa57f 100644 --- a/core/meta/inc/TInterpreter.h +++ b/core/meta/inc/TInterpreter.h @@ -113,6 +113,7 @@ class TInterpreter : public TNamed { virtual Bool_t CheckClassTemplate(const char *name) = 0; virtual Long_t Calc(const char *line, EErrorCode* error = 0) = 0; virtual void CreateListOfBaseClasses(TClass *cl) const = 0; + virtual void CreateListOfEnums(TClass *cl) const = 0; virtual void CreateListOfDataMembers(TClass *cl) const = 0; virtual void CreateListOfMethods(TClass *cl) const = 0; virtual void CreateListOfMethodArgs(TFunction *m) const = 0; diff --git a/core/meta/src/TClass.cxx b/core/meta/src/TClass.cxx index cb55a3013c30a..892274ec347b2 100644 --- a/core/meta/src/TClass.cxx +++ b/core/meta/src/TClass.cxx @@ -771,7 +771,7 @@ ClassImp(TClass) TClass::TClass() : TDictionary(), fStreamerInfo(0), fConversionStreamerInfo(0), fRealData(0), - fBase(0), fData(0), fMethod(0), fAllPubData(0), fAllPubMethod(0), + fBase(0), fData(0), fEnums(0), fMethod(0), fAllPubData(0), fAllPubMethod(0), fClassMenuList(0), fDeclFileName(""), fImplFileName(""), fDeclFileLine(0), fImplFileLine(0), fInstanceCount(0), fOnHeap(0), @@ -797,7 +797,7 @@ TClass::TClass() : TClass::TClass(const char *name, Bool_t silent) : TDictionary(name), fStreamerInfo(0), fConversionStreamerInfo(0), fRealData(0), - fBase(0), fData(0), fMethod(0), fAllPubData(0), fAllPubMethod(0), + fBase(0), fData(0), fEnums(0), fMethod(0), fAllPubData(0), fAllPubMethod(0), fClassMenuList(0), fDeclFileName(""), fImplFileName(""), fDeclFileLine(0), fImplFileLine(0), fInstanceCount(0), fOnHeap(0), @@ -846,7 +846,7 @@ TClass::TClass(const char *name, Version_t cversion, const char *dfil, const char *ifil, Int_t dl, Int_t il, Bool_t silent) : TDictionary(name), fStreamerInfo(0), fConversionStreamerInfo(0), fRealData(0), - fBase(0), fData(0), fMethod(0), fAllPubData(0), fAllPubMethod(0), + fBase(0), fData(0), fEnums(0), fMethod(0), fAllPubData(0), fAllPubMethod(0), fClassMenuList(0), fDeclFileName(""), fImplFileName(""), fDeclFileLine(0), fImplFileLine(0), fInstanceCount(0), fOnHeap(0), @@ -875,7 +875,7 @@ TClass::TClass(const char *name, Version_t cversion, Bool_t silent) : TDictionary(name), fStreamerInfo(0), fConversionStreamerInfo(0), fRealData(0), - fBase(0), fData(0), fMethod(0), fAllPubData(0), fAllPubMethod(0), + fBase(0), fData(0), fEnums(0), fMethod(0), fAllPubData(0), fAllPubMethod(0), fClassMenuList(0), fDeclFileName(""), fImplFileName(""), fDeclFileLine(0), fImplFileLine(0), fInstanceCount(0), fOnHeap(0), @@ -1129,6 +1129,7 @@ TClass::TClass(const TClass& cl) : fRealData(cl.fRealData), fBase(cl.fBase), fData(cl.fData), + fEnums(cl.fEnums), fMethod(cl.fMethod), fAllPubData(cl.fAllPubData), fAllPubMethod(cl.fAllPubMethod), @@ -1231,6 +1232,10 @@ TClass::~TClass() fData->Delete(); delete fData; fData = 0; + if (fEnums) + fEnums->Delete(); + delete fEnums; fEnums = 0; + if (fMethod) fMethod->Delete(); delete fMethod; fMethod=0; @@ -2983,6 +2988,26 @@ TList *TClass::GetListOfBases() return fBase; } +//______________________________________________________________________________ +TList *TClass::GetListOfEnums() +{ + // Return list containing the TEnums of a class. + + R__LOCKGUARD(gClingMutex); + if (!fClassInfo) { + if (!fEnums) fEnums = new TList; + return fEnums; + } + + if (!fEnums) { + if (!gInterpreter) + Fatal("GetListOfEnums", "gInterpreter not initialized"); + + gInterpreter->CreateListOfEnums(this); + } + return fEnums; +} + //______________________________________________________________________________ TList *TClass::GetListOfDataMembers() { @@ -3241,6 +3266,10 @@ void TClass::ResetCaches() fData->Delete(); delete fData; fData = 0; + if (fEnums) + fEnums->Delete(); + delete fEnums; fEnums = 0; + if (fMethod) fMethod->Delete(); delete fMethod; fMethod=0; diff --git a/core/meta/src/TCling.cxx b/core/meta/src/TCling.cxx index 1b479c84ba0f8..1b459fc039029 100644 --- a/core/meta/src/TCling.cxx +++ b/core/meta/src/TCling.cxx @@ -181,6 +181,39 @@ class TypedefVisitor : public RecursiveASTVisitor { return true; // returning false will abort the in-depth traversal. } }; +//______________________________________________________________________________ + +// Class extracting recursively every Enum type defined for a class. +class EnumVisitor : public RecursiveASTVisitor { +private: + llvm::SmallVector &fClassEnums; +public: + EnumVisitor(llvm::SmallVector &enums) : fClassEnums(enums) + {} + + bool TraverseStmt(Stmt*) { + // Don't descend into function bodies. + return true; + } + + bool shouldVisitTemplateInstantiations() const { return true; } + + bool TraverseClassTemplateDecl(ClassTemplateDecl*) { + // Don't descend into templates (but only instances thereof). + return true; // returning false will abort the in-depth traversal. + } + + bool TraverseClassTemplatePartialSpecializationDecl(ClassTemplatePartialSpecializationDecl*) { + // Don't descend into templates partial specialization (but only instances thereof). + return true; // returning false will abort the in-depth traversal. + } + + bool VisitEnumDecl(EnumDecl *TEnumD) { + if (!TEnumD->getDeclContext()->isDependentContext()) + fClassEnums.push_back(TEnumD); + return true; // returning false will abort the in-depth traversal. + } +}; //______________________________________________________________________________ static void TCling__UpdateClassInfo(const NamedDecl* TD) @@ -217,52 +250,67 @@ static void TCling__UpdateClassInfo(const NamedDecl* TD) } } -void TCling::HandleEnumDecl(const clang::EnumDecl* ED, bool isGlobal) +void TCling::HandleEnumDecl(const clang::Decl* D, bool isGlobal, TClass *cl) const { + // Handle new enum declaration for either global and nested enums. // Get name of the enum type. std::string buf; - PrintingPolicy Policy(ED->getASTContext().getPrintingPolicy()); - llvm::raw_string_ostream stream(buf); - ED->getNameForDiagnostic(stream, Policy, /*Qualified=*/true); + if (const NamedDecl* ND = llvm::dyn_cast(D)) { + PrintingPolicy Policy(D->getASTContext().getPrintingPolicy()); + llvm::raw_string_ostream stream(buf); + ND->getNameForDiagnostic(stream, Policy, /*Qualified=*/false); + } const char* name = buf.c_str(); // Create the enum type. - TEnum* enumType = new TEnum(name, false /*!global*/, &ED); + TEnum* enumType = new TEnum(name, false /*!global*/, &D); + // Check TEnum is created. if (!enumType) { Error ("HandleEnumDecl", "The enum type %s was not created.", name); } else { - gROOT->GetListOfEnums()->Add(enumType); + // Add global enums to the list of globals TEnums. + if (isGlobal) { + gROOT->GetListOfEnums()->Add(enumType); + } else { + cl->fEnums->Add(enumType); + } } // Add the constants to the enum type. + const EnumDecl* ED = llvm::dyn_cast(D); for (EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(), EDE = ED->enumerator_end(); EDI != EDE; ++EDI) { - // Get name of the enum type. - buf.clear(); - PrintingPolicy Policy(EDI->getASTContext().getPrintingPolicy()); - llvm::raw_string_ostream stream(buf); - EDI->getNameForDiagnostic(stream, Policy, /*Qualified=*/true); - const char* constantName = buf.c_str(); + std::string constbuf; + if (const NamedDecl* END = llvm::dyn_cast(*EDI)) { + PrintingPolicy Policy((*EDI)->getASTContext().getPrintingPolicy()); + llvm::raw_string_ostream stream(constbuf); + (END)->getNameForDiagnostic(stream, Policy, /*Qualified=*/false); + } + const char* constantName = constbuf.c_str(); // Get value of the constant. Long64_t value; - const llvm::APSInt valAPSInt = EDI->getInitVal(); + const llvm::APSInt valAPSInt = (*EDI)->getInitVal(); if (valAPSInt.isSigned()) { value = valAPSInt.getSExtValue(); } else { value = valAPSInt.getZExtValue(); } + // Create the TEnumConstant. TEnumConstant* enumConstant = new TEnumConstant(new TClingDataMemberInfo(fInterpreter, *EDI) , constantName, value, enumType); + // Check that the constant was created. if (!enumConstant) { Error ("HandleEnumDecl", "The enum constant %s was not created.", constantName); } else { + // Add the global constants to the list of Globals. if (isGlobal) { gROOT->GetListOfGlobals()->Add(enumConstant); } + } } } @@ -272,17 +320,10 @@ void TCling::HandleNewDecl(const void* DV, bool isDeserialized, std::set(DV); - if (!D->isCanonicalDecl()) return; - if (isa(D->getDeclContext())) return; - - // We handle nested enums here, globals are handled later. - if (!isa(D->getDeclContext())) { - if (const clang::EnumDecl* ED = dyn_cast(D)) { - HandleEnumDecl(ED, false /* not global*/); - } - } - if (isa(D->getDeclContext())) + if (!D->isCanonicalDecl()) return; + if (isa(D->getDeclContext()) + || isa(D->getDeclContext())) return; // Don't list templates. @@ -379,9 +420,8 @@ void TCling::HandleNewDecl(const void* DV, bool isDeserialized, std::setGetListOfGlobals()->FindObject(ND->getNameAsString().c_str())) return; - //Put the global constants in the list. + // Put the global constants and global enums in the coresponding lists. if (const EnumDecl *ED = dyn_cast(D)) { - if (!gROOT->GetListOfEnums()->FindObject(ND->getNameAsString().c_str())) { HandleEnumDecl(ED, true /* is global*/); } @@ -439,6 +479,9 @@ void TCling__UpdateListsOnCommitted(const cling::Transaction &T, const clang::Decl* WrapperFD = T.getWrapperFD(); for (cling::Transaction::const_iterator I = T.decls_begin(), E = T.decls_end(); I != E; ++I) { + if (I->m_Call != cling::Transaction::kCCIHandleTopLevelDecl) + continue; + for (DeclGroupRef::const_iterator DI = I->m_DGR.begin(), DE = I->m_DGR.end(); DI != DE; ++DI) { if (*DI == WrapperFD) @@ -492,7 +535,7 @@ void TCling__UpdateListsOnCommitted(const cling::Transaction &T, cling::Interpreter::PushTransactionRAII RAII(interp); ((TCling*)gCling)->UpdateListOfMethods(*I); ((TCling*)gCling)->UpdateListOfDataMembers(*I); - + ((TCling*)gCling)->UpdateListOfEnums(*I); // Unlock the TClass for updates ((TCling*)gCling)->GetModTClasses().erase(*I); } @@ -2309,6 +2352,33 @@ void TCling::CreateListOfBaseClasses(TClass* cl) const } } +//______________________________________________________________________________ +void TCling::CreateListOfEnums(TClass* cl) const +{ + // Create list of pointers to enums for TClass cl. + R__LOCKGUARD2(gClingMutex); + if (cl->fEnums) { + return; + } + cl->fEnums = new TList; + cl->fEnums->SetOwner(); + const Decl * D = ((TClingClassInfo*)cl->GetClassInfo())->GetDecl(); + + // Recurse on the data member of the class and get the enums. + if (const clang::RecordDecl* RD = dyn_cast(D)) { + llvm::SmallVector enums; cout<(D)); + for (size_t i = 0; i < enums.size(); ++i) { + // Add the enum to the list of enums of the corresponding class. + if (!gROOT->GetListOfEnums()->FindObject(enums[i]->getNameAsString().c_str())) { + HandleEnumDecl(enums[i], false /* not global*/, cl); + } + } + } +} + //______________________________________________________________________________ void TCling::CreateListOfDataMembers(TClass* cl) const { @@ -2363,6 +2433,15 @@ void TCling::UpdateListOfMethods(TClass* cl) const CreateListOfMethods(cl); } +//______________________________________________________________________________ +void TCling::UpdateListOfEnums(TClass* cl) const +{ + // Update the list of pointers to enums for TClass cl. + delete cl->fEnums; + cl->fEnums = 0; + CreateListOfEnums(cl); +} + //______________________________________________________________________________ void TCling::UpdateListOfDataMembers(TClass* cl) const { diff --git a/core/meta/src/TCling.h b/core/meta/src/TCling.h index a552498eac82c..2b1b790aeffe5 100644 --- a/core/meta/src/TCling.h +++ b/core/meta/src/TCling.h @@ -176,10 +176,12 @@ class TCling : public TInterpreter { Long_t Calc(const char* line, EErrorCode* error = 0); void CreateListOfBaseClasses(TClass* cl) const; void CreateListOfDataMembers(TClass* cl) const; + void CreateListOfEnums(TClass* cl) const; void CreateListOfMethods(TClass* cl) const; void CreateListOfMethodArgs(TFunction* m) const; void UpdateListOfMethods(TClass* cl) const; void UpdateListOfDataMembers(TClass* cl) const; + void UpdateListOfEnums(TClass* cl) const; TString GetMangledName(TClass* cl, const char* method, const char* params); TString GetMangledNameWithPrototype(TClass* cl, const char* method, const char* proto); @@ -385,7 +387,7 @@ class TCling : public TInterpreter { std::set& GetModTClasses() { return fModTClasses; } void HandleNewDecl(const void* DV, bool isDeserialized, std::set& modifiedClasses); - void HandleEnumDecl(const clang::EnumDecl* ED, bool isGlobal); + private: // Private Utility Functions TCling(); @@ -401,6 +403,7 @@ class TCling : public TInterpreter { bool LoadPCM(TString pcmFileName, const char** headers, void (*triggerFunc)()) const; + void HandleEnumDecl(const clang::Decl* D, bool isGlobal, TClass *cl = 0) const; ClassDef(TCling, 0) //Interface to cling C++ interpreter }; From faae06a9a8327d17ac8f29f32eac5b2f258cbdbf Mon Sep 17 00:00:00 2001 From: CristinaCristescu Date: Thu, 8 Aug 2013 16:22:40 +0200 Subject: [PATCH 06/27] Fix enum decls by pushing manually the transation. --- core/meta/src/TCling.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/meta/src/TCling.cxx b/core/meta/src/TCling.cxx index 1b459fc039029..43a3d1c15738c 100644 --- a/core/meta/src/TCling.cxx +++ b/core/meta/src/TCling.cxx @@ -538,6 +538,7 @@ void TCling__UpdateListsOnCommitted(const cling::Transaction &T, ((TCling*)gCling)->UpdateListOfEnums(*I); // Unlock the TClass for updates ((TCling*)gCling)->GetModTClasses().erase(*I); + } } @@ -2365,16 +2366,15 @@ void TCling::CreateListOfEnums(TClass* cl) const const Decl * D = ((TClingClassInfo*)cl->GetClassInfo())->GetDecl(); // Recurse on the data member of the class and get the enums. - if (const clang::RecordDecl* RD = dyn_cast(D)) { - llvm::SmallVector enums; cout<(D)) { + llvm::SmallVector enums; EnumVisitor E(enums); // Traverse the list of enums for this RecordDecl. + // Iteration over the decls might cause deserialization. + cling::Interpreter::PushTransactionRAII deserRAII(fInterpreter); E.TraverseDecl(const_cast(D)); for (size_t i = 0; i < enums.size(); ++i) { - // Add the enum to the list of enums of the corresponding class. - if (!gROOT->GetListOfEnums()->FindObject(enums[i]->getNameAsString().c_str())) { HandleEnumDecl(enums[i], false /* not global*/, cl); - } } } } From 091bb9427780e1d784c135c68431417fe72aa436 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Thu, 8 Aug 2013 11:22:29 +0200 Subject: [PATCH 07/27] Finally: enable the asserts that assure very conservative integrity checks. --- interpreter/cling/lib/Interpreter/IncrementalParser.cpp | 8 +++++++- interpreter/cling/lib/Interpreter/IncrementalParser.h | 2 +- interpreter/cling/lib/Interpreter/Transaction.cpp | 4 ---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/interpreter/cling/lib/Interpreter/IncrementalParser.cpp b/interpreter/cling/lib/Interpreter/IncrementalParser.cpp index e15af33824ea5..9a3c5ffb47f01 100644 --- a/interpreter/cling/lib/Interpreter/IncrementalParser.cpp +++ b/interpreter/cling/lib/Interpreter/IncrementalParser.cpp @@ -398,12 +398,18 @@ namespace cling { commitTransaction(deserT); } - void IncrementalParser::transformTransactionAST(Transaction* T) const { + void IncrementalParser::transformTransactionAST(Transaction* T) { bool success = true; // We are sure it's safe to pipe it through the transformers + // Consume late transformers init + Transaction* initT = beginTransaction(CompilationOptions()); + for (size_t i = 0; success && i < m_ASTTransformers.size(); ++i) success = m_ASTTransformers[i]->TransformTransaction(*T); + if (endTransaction(initT)) + commitTransaction(initT); + if (!success) T->setIssuedDiags(Transaction::kErrors); } diff --git a/interpreter/cling/lib/Interpreter/IncrementalParser.h b/interpreter/cling/lib/Interpreter/IncrementalParser.h index 4c2f82ae8056b..a6c870b7f9e88 100644 --- a/interpreter/cling/lib/Interpreter/IncrementalParser.h +++ b/interpreter/cling/lib/Interpreter/IncrementalParser.h @@ -211,7 +211,7 @@ namespace cling { /// ///\param[in] T - the transaction to be transformed. /// - void transformTransactionAST(Transaction* T) const; + void transformTransactionAST(Transaction* T); ///\brief Runs IR transformers on a transaction. /// diff --git a/interpreter/cling/lib/Interpreter/Transaction.cpp b/interpreter/cling/lib/Interpreter/Transaction.cpp index 5b27ebf2f54c4..8b83eaa122bc7 100644 --- a/interpreter/cling/lib/Interpreter/Transaction.cpp +++ b/interpreter/cling/lib/Interpreter/Transaction.cpp @@ -103,10 +103,8 @@ namespace cling { void Transaction::append(DelayCallInfo DCI) { assert(!DCI.m_DGR.isNull() && "Appending null DGR?!"); -#ifdef TEMPORARILY_DISABLED assert(getState() == kCollecting && "Cannot append declarations in current state."); -#endif forceAppend(DCI); } @@ -115,7 +113,6 @@ namespace cling { assert((getState() == kCollecting || getState() == kCompleted) && "Must not be"); -#ifdef TEMPORARILY_DISABLED #ifndef NDEBUG // Check for duplicates for (size_t i = 0, e = m_DeclQueue.size(); i < e; ++i) { @@ -127,7 +124,6 @@ namespace cling { if (oldDCI.m_Call != kCCIHandleVTable) assert(oldDCI != DCI && "Duplicates?!"); } -#endif #endif bool checkForWrapper = !m_WrapperFD; From ae65cac6513a92e85d2082382324a16c953bea10 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Thu, 8 Aug 2013 11:27:09 +0200 Subject: [PATCH 08/27] Add another expected to pass construct for null deref. --- interpreter/cling/test/NullDeref/MethodCalls.C | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/interpreter/cling/test/NullDeref/MethodCalls.C b/interpreter/cling/test/NullDeref/MethodCalls.C index ccde829a0cf21..34ba54d2a8ef2 100644 --- a/interpreter/cling/test/NullDeref/MethodCalls.C +++ b/interpreter/cling/test/NullDeref/MethodCalls.C @@ -12,4 +12,13 @@ public: }; MyClass* my = 0; my->getA() // expected-warning {{you are about to dereference null ptr, which probably will lead to seg violation. Do you want to proceed?[y/n]}} + +struct AggregatedNull { + AggregatedNull() : m(0) {} + MyClass m; +} + +AggregatedNull agrNull; +agrNull.m->getA(); // expected-warning {{you are about to dereference null ptr, which probably will lead to seg violation. Do you want to proceed?[y/n]}} + .q From cd0762ccc8f5663bf7abeef61d507827a11cfab9 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Thu, 8 Aug 2013 14:50:44 +0200 Subject: [PATCH 09/27] Loosen the asserts due to not well-enough-understood behavior in clang. Maybe it's a bug or it is a feature. --- interpreter/cling/lib/Interpreter/Transaction.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/interpreter/cling/lib/Interpreter/Transaction.cpp b/interpreter/cling/lib/Interpreter/Transaction.cpp index 8b83eaa122bc7..ba72dd9c58e7a 100644 --- a/interpreter/cling/lib/Interpreter/Transaction.cpp +++ b/interpreter/cling/lib/Interpreter/Transaction.cpp @@ -117,6 +117,19 @@ namespace cling { // Check for duplicates for (size_t i = 0, e = m_DeclQueue.size(); i < e; ++i) { DelayCallInfo &oldDCI (m_DeclQueue[i]); + // FIXME: This is possible bug in clang, which will instantiate one and + // the same CXXStaticMemberVar several times. This happens when there are + // two dependent expressions and the first uses another declaration from + // the redeclaration chain. This will force Sema in to instantiate the + // definition (usually the most recent decl in the chain) and then the + // second expression might referece the definition (which was already) + // instantiated, but Sema seems not to keep track of these kinds of + // instantiations, even though the points of instantiation are the same! + // + // This should be investigated further when we merge with newest clang. + // This is triggered by running the roottest: ./root/io/newstl + if (oldDCI.m_Call == kCCIHandleCXXStaticMemberVarInstantiation) + continue; // It is possible to have duplicate calls to HandleVTable with the same // declaration, because each time Sema believes a vtable is used it emits // that callback. From 659caed0ff0fa896ec840f987117548073c98936 Mon Sep 17 00:00:00 2001 From: Bertrand Bellenot Date: Thu, 8 Aug 2013 15:16:31 +0200 Subject: [PATCH 10/27] Allow to change text of context menu items even when they are of type "toggle" --- gui/gui/src/TRootContextMenu.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gui/gui/src/TRootContextMenu.cxx b/gui/gui/src/TRootContextMenu.cxx index 229ea59028a0b..4419ee12b7c58 100644 --- a/gui/gui/src/TRootContextMenu.cxx +++ b/gui/gui/src/TRootContextMenu.cxx @@ -350,6 +350,7 @@ void TRootContextMenu::CreateMenu(TObject *object) break; case TClassMenuItem::kPopupUserFunction: { + const char* menuItemTitle = menuItem->GetTitle(); if (menuItem->IsToggle()) { TMethod* method = object->IsA()->GetMethodWithPrototype(menuItem->GetFunctionName(),menuItem->GetArgs()); @@ -359,11 +360,11 @@ void TRootContextMenu::CreateMenu(TObject *object) t->SetOnValue(1); fTrash->Add(t); - AddEntry(method->GetName(), toggle++, t); + if (strlen(menuItemTitle)==0) menuItemTitle = method->GetName(); + AddEntry(menuItemTitle, toggle++, t); if (t->GetState()) CheckEntry(toggle-1); } } else { - const char* menuItemTitle = menuItem->GetTitle(); if (strlen(menuItemTitle)==0) menuItemTitle = menuItem->GetFunctionName(); AddEntry(menuItemTitle,userfunction++,menuItem); } From 9d31735f4331defc377760c4e8e1cc05268c2a4b Mon Sep 17 00:00:00 2001 From: Bertrand Bellenot Date: Thu, 8 Aug 2013 15:28:34 +0200 Subject: [PATCH 11/27] Fix a problem on Windows with TContextMenu::Execute() parameters --- core/base/src/TContextMenu.cxx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/core/base/src/TContextMenu.cxx b/core/base/src/TContextMenu.cxx index 1645083378b67..bbc7992aa2f49 100644 --- a/core/base/src/TContextMenu.cxx +++ b/core/base/src/TContextMenu.cxx @@ -159,7 +159,7 @@ void TContextMenu::Action(TClassMenuItem *menuitem) #else // It is a workaround of the "Dead lock under Windows char *cmd = Form("((TContextMenu *)0x%lx)->Execute((TObject *)0x%lx," - "(TMethod *)0x%lx,(TObjArray *)0);", + "(TMethod *)0x%lx,\"\");", (Long_t)this,(Long_t)object,(Long_t)method); //Printf("%s", cmd); gROOT->ProcessLine(cmd); @@ -171,8 +171,9 @@ void TContextMenu::Action(TClassMenuItem *menuitem) #else // It is a workaround of the "Dead lock under Windows char *cmd = Form("((TContextMenu *)0x%lx)->Execute((TObject *)0x%lx," - "(TMethod *)0x%lx,(TObjArray *)0);", - (Long_t)this,(Long_t)object,(Long_t)method); + "(TMethod *)0x%lx,(TObject*)0x%lx);", + (Long_t)this,(Long_t)object,(Long_t)method, + (Long_t)fSelectedObject); //Printf("%s", cmd); gROOT->ProcessLine(cmd); //Execute( object, method, (TObjArray *)NULL ); From b44a177ba506fe0ce454864f6f8fa6258d774517 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Thu, 8 Aug 2013 16:54:39 +0200 Subject: [PATCH 12/27] Only if I could spell C++ :) --- interpreter/cling/test/NullDeref/MethodCalls.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interpreter/cling/test/NullDeref/MethodCalls.C b/interpreter/cling/test/NullDeref/MethodCalls.C index 34ba54d2a8ef2..639fe4089f271 100644 --- a/interpreter/cling/test/NullDeref/MethodCalls.C +++ b/interpreter/cling/test/NullDeref/MethodCalls.C @@ -14,8 +14,8 @@ MyClass* my = 0; my->getA() // expected-warning {{you are about to dereference null ptr, which probably will lead to seg violation. Do you want to proceed?[y/n]}} struct AggregatedNull { + MyClass* m; AggregatedNull() : m(0) {} - MyClass m; } AggregatedNull agrNull; From baa7b98fb7280627871788b188bba27544cb8b7b Mon Sep 17 00:00:00 2001 From: Baozeng Ding Date: Thu, 8 Aug 2013 17:18:21 +0200 Subject: [PATCH 13/27] Instead of check each load and store instruction, we check the usage of the load instruction. Currently, there are four kinds of instruction that may use a load instruction as its argument: load, store, GEP and call instruction. We instrument these four kinds instruction to check there may be a null pointer dereference. --- .../NullDerefProtectionTransformer.cpp | 125 ++++++++++-------- .../NullDerefProtectionTransformer.h | 5 +- 2 files changed, 72 insertions(+), 58 deletions(-) diff --git a/interpreter/cling/lib/Interpreter/NullDerefProtectionTransformer.cpp b/interpreter/cling/lib/Interpreter/NullDerefProtectionTransformer.cpp index 84a255e0fe092..19b4b2c5d368b 100644 --- a/interpreter/cling/lib/Interpreter/NullDerefProtectionTransformer.cpp +++ b/interpreter/cling/lib/Interpreter/NullDerefProtectionTransformer.cpp @@ -19,6 +19,7 @@ #include "llvm/IR/Module.h" #include "llvm/IR/Constants.h" #include "llvm/IR/IRBuilder.h" +#include "llvm/Support/CallSite.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Support/InstIterator.h" @@ -108,12 +109,12 @@ namespace cling { runOnFunction(*F); } - llvm::BasicBlock* NullDerefProtectionTransformer::getTrapBB() { + llvm::BasicBlock* + NullDerefProtectionTransformer::getTrapBB(llvm::BasicBlock* BB) { llvm::Function* Fn = Inst->getParent()->getParent(); llvm::Module* Md = Fn->getParent(); llvm::LLVMContext& ctx = Fn->getContext(); - llvm::BasicBlock::iterator PreInsertInst = Builder->GetInsertPoint(); FailBB = llvm::BasicBlock::Create(ctx, "FailBlock", Fn); Builder->SetInsertPoint(FailBB); @@ -149,57 +150,35 @@ namespace cling { llvm::Value* TrueVl = llvm::ConstantInt::get(ctx, llvm::APInt(1, 1)); llvm::Value* RetVl = CI; - llvm::ICmpInst*Cmp + llvm::ICmpInst* Cmp = new llvm::ICmpInst(*FailBB, llvm::CmpInst::ICMP_EQ, RetVl, TrueVl, ""); llvm::BasicBlock *HandleBB = llvm::BasicBlock::Create(ctx,"HandleBlock", Fn); - llvm::BranchInst::Create(HandleBB, Inst->getParent(), Cmp, FailBB); + llvm::BranchInst::Create(HandleBB, BB, Cmp, FailBB); llvm::ReturnInst::Create(Fn->getContext(), HandleBB); - Builder->SetInsertPoint(PreInsertInst); return FailBB; } - void NullDerefProtectionTransformer::instrumentLoadInst(llvm::LoadInst *LI) { - llvm::Value* Addr = LI->getOperand(0); - if(llvm::isa(Addr)) - return; - - llvm::PointerType* PTy = llvm::cast(Addr->getType()); - llvm::Type* ElTy = PTy->getElementType(); - if (!ElTy->isPointerTy()) { - llvm::BasicBlock* OldBB = LI->getParent(); - llvm::ICmpInst* Cmp - = new llvm::ICmpInst(LI, llvm::CmpInst::ICMP_EQ, Addr, - llvm::Constant::getNullValue(Addr->getType()), ""); - - llvm::Instruction *Inst = Builder->GetInsertPoint(); - llvm::BasicBlock *NewBB = OldBB->splitBasicBlock(Inst); - - OldBB->getTerminator()->eraseFromParent(); - llvm::BranchInst::Create(getTrapBB(), NewBB, Cmp, OldBB); - } - } - - void NullDerefProtectionTransformer::instrumentStoreInst(llvm::StoreInst *SI){ - llvm::Value* Addr = SI->getOperand(1); - if(llvm::isa(Addr)) - return; - - llvm::PointerType* PTy = llvm::cast(Addr->getType()); - llvm::Type* ElTy = PTy -> getElementType(); - if (!ElTy->isPointerTy()) { - llvm::BasicBlock* OldBB = SI->getParent(); - llvm::ICmpInst* Cmp - = new llvm::ICmpInst(SI, llvm::CmpInst::ICMP_EQ, Addr, - llvm::Constant::getNullValue(Addr->getType()), ""); - - llvm::Instruction* Inst = Builder->GetInsertPoint(); - llvm::BasicBlock* NewBB = OldBB->splitBasicBlock(Inst); - - OldBB->getTerminator()->eraseFromParent(); - llvm::BranchInst::Create(getTrapBB(), NewBB, Cmp, OldBB); - } + // Insert a cmp instruction before the "Inst" instruction to check whether the + // argument "Arg" for the instruction "Inst" is null or not. + void NullDerefProtectionTransformer::instrumentInst( + llvm::Instruction* Inst, llvm::Value* Arg) { + llvm::BasicBlock* OldBB = Inst->getParent(); + + // Insert a cmp instruction to check whether "Arg" is null or not. + llvm::ICmpInst* Cmp + = new llvm::ICmpInst(Inst, llvm::CmpInst::ICMP_EQ, Arg, + llvm::Constant::getNullValue(Arg->getType()), ""); + + // The block is splited into two blocks, "OldBB" and "NewBB", by the "Inst" + // instruction. After that split, "Inst" is at the start of "NewBB". Then + // insert a branch instruction at the end of "OldBB". If "Arg" is null, + // it will jump to "FailBB" created by "getTrapBB" function. Else, it means + // jump to the "NewBB". + llvm::BasicBlock* NewBB = OldBB->splitBasicBlock(Inst); + OldBB->getTerminator()->eraseFromParent(); + llvm::BranchInst::Create(getTrapBB(NewBB), NewBB, Cmp, OldBB); } bool NullDerefProtectionTransformer::runOnFunction(llvm::Function &F) { @@ -209,21 +188,57 @@ namespace cling { std::vector WorkList; for (llvm::inst_iterator i = inst_begin(F), e = inst_end(F); i != e; ++i) { llvm::Instruction* I = &*i; - if (llvm::isa(I) || llvm::isa(I)) + if (llvm::isa(I)) WorkList.push_back(I); - } + } for (std::vector::iterator i = WorkList.begin(), e = WorkList.end(); i != e; ++i) { Inst = *i; - - Builder->SetInsertPoint(Inst); - if (llvm::LoadInst* LI = llvm::dyn_cast(Inst)) { - instrumentLoadInst(LI); - } else if (llvm::StoreInst* SI = llvm::dyn_cast(Inst)) { - instrumentStoreInst(SI); - } else { - llvm_unreachable("unknown Instruction type"); + llvm::LoadInst* I = llvm::cast(*i); + + // Find all the instructions that uses the instruction I. + for (llvm::Value::use_iterator UI = I->use_begin(), UE = I->use_end(); + UI != UE; ++UI) { + + // Check whether I is used as the first argument for a load instruction. + // If it is, then instrument the load instruction. + if (llvm::LoadInst* LI = llvm::dyn_cast(*UI)) { + llvm::Value* Arg = LI->getOperand(0); + if (Arg == I) + instrumentInst(LI, Arg); + } + + // Check whether I is used as the second argument for a store + // instruction. If it is, then instrument the store instruction. + else if (llvm::StoreInst* SI = llvm::dyn_cast(*UI)) { + llvm::Value* Arg = SI->getOperand(1); + if (Arg == I) + instrumentInst(SI, Arg); + } + + // Check whether I is used as the first argument for a GEP instruction. + // If it is, then instrument the GEP instruction. + else if (llvm::GetElementPtrInst* GEP = llvm::dyn_cast< + llvm::GetElementPtrInst>(*UI)) { + llvm::Value* Arg = GEP->getOperand(0); + if (Arg == I) + instrumentInst(GEP, Arg); + } + + else { + // Check whether I is used as the first argument for a call instruction. + // If it is, then instrument the call instruction. + llvm::CallSite CS(*UI); + if (CS) { + llvm::CallSite::arg_iterator i = CS.arg_begin(), e = CS.arg_end(); + if (i != e) { + llvm::Value *Arg = *i; + if (Arg == I) + instrumentInst(CS.getInstruction(), Arg); + } + } + } } } return true; diff --git a/interpreter/cling/lib/Interpreter/NullDerefProtectionTransformer.h b/interpreter/cling/lib/Interpreter/NullDerefProtectionTransformer.h index 69a282b44658c..ac2214934e2fa 100644 --- a/interpreter/cling/lib/Interpreter/NullDerefProtectionTransformer.h +++ b/interpreter/cling/lib/Interpreter/NullDerefProtectionTransformer.h @@ -35,9 +35,8 @@ namespace cling { llvm::Instruction* Inst; llvm::OwningPtr m_MangleCtx; - llvm::BasicBlock* getTrapBB(); - void instrumentLoadInst(llvm::LoadInst* LI); - void instrumentStoreInst(llvm::StoreInst* SI); + llvm::BasicBlock* getTrapBB(llvm::BasicBlock* BB); + void instrumentInst(llvm::Instruction* Inst, llvm::Value* Arg); bool runOnFunction(llvm::Function& F); public: From 24a120319d5984eabdcf493b662149fb919e7320 Mon Sep 17 00:00:00 2001 From: Philippe Canal Date: Thu, 8 Aug 2013 15:37:38 -0500 Subject: [PATCH 14/27] In CLINGCXXFLAGS, put the source include dir first. This will make sure that the build is 'consistent' and the source version of the cling include files is not superseeded by the (possible stale) copy that might be in interpreter/llvm/inst. --- interpreter/cling/Module.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interpreter/cling/Module.mk b/interpreter/cling/Module.mk index 3cd27bfd74568..616378b7b774b 100644 --- a/interpreter/cling/Module.mk +++ b/interpreter/cling/Module.mk @@ -51,7 +51,7 @@ INCLUDEFILES += $(CLINGDEP) # include dir for picking up RuntimeUniverse.h etc - need to # 1) copy relevant headers to include/ # 2) rely on TCling to addIncludePath instead of using CLING_..._INCL below -CLINGCXXFLAGS = $(patsubst -O%,,$(shell $(LLVMCONFIG) --cxxflags) -I$(CLINGDIR)/include \ +CLINGCXXFLAGS = -I$(CLINGDIR)/include $(patsubst -O%,,$(shell $(LLVMCONFIG) --cxxflags) \ -fno-strict-aliasing) ifeq ($(CTORSINITARRAY),yes) From 4326f210fd76d9cc75645b606f9df844e4b04788 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Thu, 8 Aug 2013 22:48:01 +0200 Subject: [PATCH 15/27] Not using real SourceLocation is bad, especially in -verify mode. In the value printer synthesis we have real source location of the expression that we are replacing. Use its begin and end location. This will allow us to remove the XFAIL-ed test that now passes. --- .../lib/Interpreter/ValuePrinterSynthesizer.cpp | 12 ++++++------ interpreter/cling/test/NullDeref/MethodCalls.C | 1 - 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/interpreter/cling/lib/Interpreter/ValuePrinterSynthesizer.cpp b/interpreter/cling/lib/Interpreter/ValuePrinterSynthesizer.cpp index b4a3828c31e3d..bd1107508e63d 100644 --- a/interpreter/cling/lib/Interpreter/ValuePrinterSynthesizer.cpp +++ b/interpreter/cling/lib/Interpreter/ValuePrinterSynthesizer.cpp @@ -131,7 +131,7 @@ namespace cling { DeclarationName PVName = &m_Context->Idents.get("Select"); - LookupResult R(*m_Sema, PVName, NoSLoc, Sema::LookupOrdinaryName, + LookupResult R(*m_Sema, PVName, E->getLocStart(), Sema::LookupOrdinaryName, Sema::ForRedeclaration); assert(NSD && "There must be a valid namespace."); m_Sema->LookupQualifiedName(R, NSD); @@ -205,8 +205,8 @@ namespace cling { // that we are currently work with. Transaction::State oldState = getTransaction()->getState(); getTransaction()->setState(Transaction::kCollecting); - Expr* Result = m_Sema->ActOnCallExpr(S, UnresolvedLookup, NoSLoc, - CallArgs, NoSLoc).take(); + Expr* Result = m_Sema->ActOnCallExpr(S, UnresolvedLookup, E->getLocStart(), + CallArgs, E->getLocEnd()).take(); getTransaction()->setState(oldState); Result = m_Sema->ActOnFinishFullExpr(Result).take(); @@ -233,7 +233,7 @@ namespace cling { // Find cling_PrintValue SourceLocation NoSLoc = SourceLocation(); DeclarationName PVName = &m_Context->Idents.get("cling_PrintValue"); - LookupResult R(*m_Sema, PVName, NoSLoc, Sema::LookupOrdinaryName, + LookupResult R(*m_Sema, PVName, E->getLocStart(), Sema::LookupOrdinaryName, Sema::ForRedeclaration); Scope* S = m_Sema->getScopeForContext(m_Sema->CurContext); @@ -263,8 +263,8 @@ namespace cling { CallArgs.push_back(VoidCArg); CallArgs.push_back(E); - Expr* Result = m_Sema->ActOnCallExpr(S, UnresolvedLookup, NoSLoc, - CallArgs, NoSLoc).take(); + Expr* Result = m_Sema->ActOnCallExpr(S, UnresolvedLookup, E->getLocStart(), + CallArgs, E->getLocEnd()).take(); assert(Result && "Cannot create value printer!"); return Result; diff --git a/interpreter/cling/test/NullDeref/MethodCalls.C b/interpreter/cling/test/NullDeref/MethodCalls.C index 639fe4089f271..a6a6e8c794a2e 100644 --- a/interpreter/cling/test/NullDeref/MethodCalls.C +++ b/interpreter/cling/test/NullDeref/MethodCalls.C @@ -1,7 +1,6 @@ // RUN: cat %s | %cling -Xclang -verify // This test verifies that we get nice warning if a method on null ptr object is // called. -// XFAIL:* extern "C" int printf(const char* fmt, ...); class MyClass { private: From 956b885107ed5ddb6bb560f601c03d0db633b6a7 Mon Sep 17 00:00:00 2001 From: ganis Date: Thu, 8 Aug 2013 00:45:21 +0200 Subject: [PATCH 16/27] Add support for per-packet max proc time --- proof/proof/inc/TDSet.h | 6 ++- proof/proof/src/TDSet.cxx | 2 + proof/proofplayer/inc/TProofPlayer.h | 7 ++- proof/proofplayer/src/TProofPlayer.cxx | 72 ++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 2 deletions(-) diff --git a/proof/proof/inc/TDSet.h b/proof/proof/inc/TDSet.h index ebc371798f311..a824e8150dc9d 100644 --- a/proof/proof/inc/TDSet.h +++ b/proof/proof/inc/TDSet.h @@ -93,6 +93,7 @@ class TDSetElement : public TNamed { TString fDataSet; // Name of the dataset of which this element is part TList *fAssocObjList; // List of objects associated to this element // (e.g. TObjString describing associated files) + Float_t fMaxProcTime; // Max processing time in secs; -1 no limit Bool_t HasBeenLookedUp() const { return TestBit(kHasBeenLookedUp); } @@ -140,9 +141,12 @@ class TDSetElement : public TNamed { void SetLookedUp() { SetBit(kHasBeenLookedUp); } TFileInfo *GetFileInfo(const char *type = "TTree"); + Float_t GetMaxProcTime() const { return fMaxProcTime; } + void SetMaxProcTime(Float_t mpt) { fMaxProcTime = mpt; } + Int_t MergeElement(TDSetElement *elem); - ClassDef(TDSetElement,8) // A TDSet element + ClassDef(TDSetElement,9) // A TDSet element }; diff --git a/proof/proof/src/TDSet.cxx b/proof/proof/src/TDSet.cxx index 09663ffd6b378..66de197754a42 100644 --- a/proof/proof/src/TDSet.cxx +++ b/proof/proof/src/TDSet.cxx @@ -124,6 +124,7 @@ TDSetElement::TDSetElement(const char *file, const char *objname, const char *di fAssocObjList = 0; if (dir) fDirectory = dir; + fMaxProcTime = -1.; ResetBit(kWriteV3); ResetBit(kHasBeenLookedUp); @@ -149,6 +150,7 @@ TDSetElement::TDSetElement(const TDSetElement& elem) fFriends = 0; fDataSet = elem.fDataSet; fAssocObjList = 0; + fMaxProcTime = elem.fMaxProcTime; ResetBit(kWriteV3); ResetBit(kHasBeenLookedUp); ResetBit(kEmpty); diff --git a/proof/proofplayer/inc/TProofPlayer.h b/proof/proofplayer/inc/TProofPlayer.h index 8a9ffe3c40fcd..9ea3b9e88caa0 100644 --- a/proof/proofplayer/inc/TProofPlayer.h +++ b/proof/proofplayer/inc/TProofPlayer.h @@ -70,6 +70,7 @@ class TTimer; class THashList; class TH1; class TFile; +class TStopwatch; //------------------------------------------------------------------------ @@ -107,6 +108,9 @@ class TProofPlayer : public TVirtualProofPlayer { TTimer *fDispatchTimer; //Dispatch pending events while processing + TTimer *fProcTimeTimer; //Notifies reaching of allowed max proc time + TStopwatch *fProcTime; //Packet proc time + TString fOutputFilePath; //Path to file with (partial) results of the query TFile *fOutputFile; //TFile object attached to fOutputFilePath Long_t fSaveMemThreshold; //Threshold for saving output to file @@ -141,7 +145,8 @@ class TProofPlayer : public TVirtualProofPlayer { void MapOutputListToDataMembers() const; public: - enum EStatusBits { kDispatchOneEvent = BIT(15), kIsProcessing = BIT(16) }; + enum EStatusBits { kDispatchOneEvent = BIT(15), kIsProcessing = BIT(16), + kMaxProcTimeReached = BIT(17), kMaxProcTimeExtended = BIT(18) }; TProofPlayer(TProof *proof = 0); virtual ~TProofPlayer(); diff --git a/proof/proofplayer/src/TProofPlayer.cxx b/proof/proofplayer/src/TProofPlayer.cxx index eb4ceba97153e..981732ce2be39 100644 --- a/proof/proofplayer/src/TProofPlayer.cxx +++ b/proof/proofplayer/src/TProofPlayer.cxx @@ -75,6 +75,7 @@ #include "TVirtualMonitoring.h" #include "TParameter.h" #include "TOutputListSelectorDataMap.h" +#include "TStopwatch.h" // Timeout exception #define kPEX_STOPPED 1001 @@ -134,6 +135,33 @@ Bool_t TDispatchTimer::Notify() return kTRUE; } +// +// Special timer to notify reach of max packet proc time +//______________________________________________________________________________ +class TProctimeTimer : public TTimer { +private: + TProofPlayer *fPlayer; + +public: + TProctimeTimer(TProofPlayer *p, Long_t to) : TTimer(to, kFALSE), fPlayer(p) { } + + Bool_t Notify(); +}; +//______________________________________________________________________________ +Bool_t TProctimeTimer::Notify() +{ + // Handle expiration of the timer associated with dispatching pending + // events while processing. We must act as fast as possible here, so + // we just set a flag submitting a request for dispatching pending events + + if (gDebug > 0) printf("TProctimeTimer::Notify: called!\n"); + + fPlayer->SetBit(TProofPlayer::kMaxProcTimeReached); + + // One shot only + return kTRUE; +} + // // Special timer to handle stop/abort request via exception raising //______________________________________________________________________________ @@ -199,6 +227,7 @@ TProofPlayer::TProofPlayer(TProof *) fTotalEvents(0), fReadBytesRun(0), fReadCallsRun(0), fProcessedRun(0), fQueryResults(0), fQuery(0), fPreviousQuery(0), fDrawQueries(0), fMaxDrawQueries(1), fStopTimer(0), fStopTimerMtx(0), fDispatchTimer(0), + fProcTimeTimer(0), fProcTime(0), fOutputFile(0), fSaveMemThreshold(-1), fSavePartialResults(kFALSE), fSaveResultsPerPacket(kFALSE) { @@ -207,7 +236,10 @@ TProofPlayer::TProofPlayer(TProof *) fInput = new TList; fExitStatus = kFinished; fProgressStatus = new TProofProgressStatus(); + ResetBit(TProofPlayer::kDispatchOneEvent); ResetBit(TProofPlayer::kIsProcessing); + ResetBit(TProofPlayer::kMaxProcTimeReached); + ResetBit(TProofPlayer::kMaxProcTimeExtended); static Bool_t initLimitsFinder = kFALSE; if (!initLimitsFinder && gProofServ && !gProofServ->IsMaster()) { @@ -230,6 +262,8 @@ TProofPlayer::~TProofPlayer() SafeDelete(fEvIter); SafeDelete(fQueryResults); SafeDelete(fDispatchTimer); + SafeDelete(fProcTimeTimer); + SafeDelete(fProcTime); SafeDelete(fStopTimer); } @@ -1167,6 +1201,8 @@ Long64_t TProofPlayer::Process(TDSet *dset, const char *selector_file, Long64_t fst = -1, num; TEntryList *enl = 0; TEventList *evl = 0; + Long_t maxproctime = -1; + Bool_t newrun = kFALSE; while ((fEvIter->GetNextPacket(fst, num, &enl, &evl) != -1) && !fSelStatus->TestBit(TStatus::kNotOk) && fSelector->GetAbort() == TSelector::kContinue) { @@ -1199,9 +1235,45 @@ Long64_t TProofPlayer::Process(TDSet *dset, const char *selector_file, } TProofServ::SetLastMsg(lastMsg); } + // Set the max proc time, if any + if (dset->Current()->GetMaxProcTime() >= 0.) + maxproctime = (Long_t) (1000 * dset->Current()->GetMaxProcTime()); + newrun = (dset->Current()->TestBit(TDSetElement::kNewPacket)) ? kTRUE : kFALSE; } + ResetBit(TProofPlayer::kMaxProcTimeReached); + ResetBit(TProofPlayer::kMaxProcTimeExtended); + // Setup packet proc time measurement + if (maxproctime > 0) { + if (!fProcTimeTimer) fProcTimeTimer = new TProctimeTimer(this, maxproctime); + fProcTimeTimer->Start(maxproctime, kTRUE); // One shot + if (!fProcTime) fProcTime = new TStopwatch(); + fProcTime->Reset(); // Reset counters + } + Long64_t refnum = num; while (num--) { + + // Did we use all our time? + if (TestBit(TProofPlayer::kMaxProcTimeReached)) { + fProcTime->Stop(); + if (!newrun && !TestBit(TProofPlayer::kMaxProcTimeExtended)) { + // How much are we left with? + Float_t xleft = (refnum > num) ? (Float_t) num / (Float_t) (refnum) : 1.; + if (xleft < 0.2) { + // Give another try, 1.5 times the remaining measured expected time + Long_t mpt = (Long_t) (1500 * num / ((Double_t)(refnum - num) / fProcTime->RealTime())); + SetBit(TProofPlayer::kMaxProcTimeExtended); + fProcTimeTimer->Start(mpt, kTRUE); // One shot + ResetBit(TProofPlayer::kMaxProcTimeReached); + } + } + if (TestBit(TProofPlayer::kMaxProcTimeReached)) { + Info("Process", "max proc time reached (%ld msecs): packet processing stopped:\n%s", + maxproctime, lastMsg.Data()); + + break; + } + } if (!(!fSelStatus->TestBit(TStatus::kNotOk) && fSelector->GetAbort() == TSelector::kContinue)) break; From 641a1fa63bf34dc64a8aa4b666fcb91d66f68116 Mon Sep 17 00:00:00 2001 From: Gerardo Ganis Date: Fri, 9 Aug 2013 00:13:48 +0200 Subject: [PATCH 17/27] Fine-tune previous patch --- proof/proofplayer/src/TProofPlayer.cxx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/proof/proofplayer/src/TProofPlayer.cxx b/proof/proofplayer/src/TProofPlayer.cxx index 981732ce2be39..68abc3914e5ae 100644 --- a/proof/proofplayer/src/TProofPlayer.cxx +++ b/proof/proofplayer/src/TProofPlayer.cxx @@ -1251,12 +1251,25 @@ Long64_t TProofPlayer::Process(TDSet *dset, const char *selector_file, fProcTime->Reset(); // Reset counters } Long64_t refnum = num; - while (num--) { + if (refnum < 0 && maxproctime <= 0) { + wmsg.Form("neither entries nor max proc time specified:" + " risk of infinite loop: processing aborted"); + Error("Process", "%s", wmsg.Data()); + if (gProofServ) { + wmsg.Insert(0, TString::Format("ERROR:%s, entry:%lld, ", + gProofServ->GetOrdinal(), fProcessedRun)); + gProofServ->SendAsynMessage(wmsg.Data()); + } + fExitStatus = kAborted; + ResetBit(TProofPlayer::kIsProcessing); + break; + } + while (refnum < 0 || num--) { // Did we use all our time? if (TestBit(TProofPlayer::kMaxProcTimeReached)) { fProcTime->Stop(); - if (!newrun && !TestBit(TProofPlayer::kMaxProcTimeExtended)) { + if (!newrun && !TestBit(TProofPlayer::kMaxProcTimeExtended) && refnum > 0) { // How much are we left with? Float_t xleft = (refnum > num) ? (Float_t) num / (Float_t) (refnum) : 1.; if (xleft < 0.2) { From cc511bfa529b455a7b32e5e954a15eb0f7be8be7 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Fri, 9 Aug 2013 09:30:41 +0200 Subject: [PATCH 18/27] Remove unused variable. --- interpreter/cling/lib/Interpreter/ValuePrinterSynthesizer.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/interpreter/cling/lib/Interpreter/ValuePrinterSynthesizer.cpp b/interpreter/cling/lib/Interpreter/ValuePrinterSynthesizer.cpp index bd1107508e63d..c9164b4b48260 100644 --- a/interpreter/cling/lib/Interpreter/ValuePrinterSynthesizer.cpp +++ b/interpreter/cling/lib/Interpreter/ValuePrinterSynthesizer.cpp @@ -124,8 +124,6 @@ namespace cling { // 1. Call gCling->getValuePrinterStream() // 1.1. Find gCling - SourceLocation NoSLoc = SourceLocation(); - NamespaceDecl* NSD = utils::Lookup::Namespace(m_Sema, "cling"); NSD = utils::Lookup::Namespace(m_Sema, "valuePrinterInternal", NSD); From e653ef698efc11f65fc825bc008fcda2c124e7b6 Mon Sep 17 00:00:00 2001 From: Anders Eie Date: Thu, 8 Aug 2013 16:17:15 +0200 Subject: [PATCH 19/27] Replaced tabs with spaces in testcode --- tree/treeplayer/test/hardTreeReaderTest.cpp | 1326 +++++++++---------- 1 file changed, 663 insertions(+), 663 deletions(-) diff --git a/tree/treeplayer/test/hardTreeReaderTest.cpp b/tree/treeplayer/test/hardTreeReaderTest.cpp index 86d51098cc7d1..a87cf0c94c827 100644 --- a/tree/treeplayer/test/hardTreeReaderTest.cpp +++ b/tree/treeplayer/test/hardTreeReaderTest.cpp @@ -24,836 +24,836 @@ #define MYBOOLARRAYB_SIZE 12 void makeTree(const char* fileName = "HardTreeFile.root", Int_t startI = 1){ - TFile *myFile = new TFile(fileName, "RECREATE"); - TTree *myTree = new TTree("HardTree", "This is hard to read"); - - A myObject0 (NUM_CONSTANT); - - struct { - Float_t myFloatX; - Float_t myFloatY; - Int_t myIntN; - Bool_t myBoolArrayB [MYBOOLARRAYB_SIZE]; - Double_t myDoubleArrayA [MYDOUBLEARRAY_SIZE]; - } myLeaves; - - myLeaves.myFloatX = 0.0; - myLeaves.myFloatY = 0.0; - myLeaves.myIntN = MYDOUBLEARRAY_SIZE; - - myTree->Branch("A0.", "A", &myObject0, 32000, 0); - myTree->Branch("A1.", "A", &myObject0, 32000, 1); - myTree->Branch("A99.", "A", &myObject0, 32000, 99); - myTree->Branch("A101.", "A", &myObject0, 32000, 101); - - myTree->Branch("S0_num", &myObject0.num, 32000, 0); - myTree->Branch("S1_num", &myObject0.num, 32000, 1); - myTree->Branch("S99_num", &myObject0.num, 32000, 99); - myTree->Branch("S101_num", &myObject0.num, 32000, 101); - - myTree->Branch("S0_vectorB", &myObject0.vectorB, 32000, 0); - myTree->Branch("S1_vectorB", &myObject0.vectorB, 32000, 1); - myTree->Branch("S99_vectorB", &myObject0.vectorB, 32000, 99); - // myTree->Branch("S101_vectorB", &myObject0.vectorB, 32000, 101); // Breaks Fill() - - myTree->Branch("S0_vectorBStar", &myObject0.vectorBStar, 32000, 0); - myTree->Branch("S1_vectorBStar", &myObject0.vectorBStar, 32000, 1); - myTree->Branch("S99_vectorBStar", &myObject0.vectorBStar, 32000, 99); - // myTree->Branch("S101_vectorBStar", &myObject0.vectorBStar, 32000, 101); // Breaks Fill() - - myTree->Branch("S0_vectorStarB", &myObject0.vectorStarB, 32000, 0); - myTree->Branch("S1_vectorStarB", &myObject0.vectorStarB, 32000, 1); - myTree->Branch("S99_vectorStarB", &myObject0.vectorStarB, 32000, 99); - // myTree->Branch("S101_vectorStarB", &myObject0.vectorStarB, 32000, 101); // Breaks Fill() - - myTree->Branch("S0_BStar", &myObject0.BStar, 32000, 0); - myTree->Branch("S1_BStar", &myObject0.BStar, 32000, 1); - myTree->Branch("S99_BStar", &myObject0.BStar, 32000, 99); - myTree->Branch("S101_BStar", &myObject0.BStar, 32000, 101); - - // myTree->Branch("S0_BArray[12]", "B[12]", &myObject0.BArray, 32000, 0); // Will not get made - // myTree->Branch(199_BArray[12]", "B[12]", &myObject0.BArray, 32000, 99); // Will not get made - // myTree->Branch("S99_BArray[12]", "B[12]", &myObject0.BArray, 32000, 99); // Will not get made - - // myTree->Branch("S0_BStarArray", &myObject0.BStarArray, 32000, 0); // No way of specifying an array - // myTree->Branch(199_BStarArray", &myObject0.BStarArray, 32000, 99); // No way of specifying an array - // myTree->Branch("S99_BStarArray", &myObject0.BStarArray, 32000, 99); // No way of specifying an array - - myTree->Branch("S0_BObject.", &myObject0.BObject, 32000, 0); - myTree->Branch("S1_BObject.", &myObject0.BObject, 32000, 1); - myTree->Branch("S99_BObject.", &myObject0.BObject, 32000, 99); - myTree->Branch("S101_BObject.", &myObject0.BObject, 32000, 101); - - myTree->Branch("S0_BClonesArray", &myObject0.BClonesArray, 32000, 0); - myTree->Branch("S1_BClonesArray", &myObject0.BClonesArray, 32000, 1); - myTree->Branch("S99_BClonesArray", &myObject0.BClonesArray, 32000, 99); - myTree->Branch("S101_BClonesArray", &myObject0.BClonesArray, 32000, 101); - - myTree->Branch("MyLeafList", &myLeaves, "x:y/F:n/I:b[12]/O:a[n]/D"); - - - for (int i = startI; i < TREE_ENTRIES + startI; ++i){ - printf("\nEntry %i\n\n", i); - - // Clear old values - myObject0.ResetVectorB(); - - printf("Setting BObject\n"); - myObject0.BObject.dummy = i; - - for (int j = 0; j < LIST_ENTRIES; ++j){ - // Vector of objects - B obj (i*j); - printf("Adding %i to vectorB\n", i*j); - myObject0.AddToVectorB(obj); - - obj.dummy *= 2; - // Hangs makeTree - printf("Adding %i to vectorStarB\n", obj.dummy); - myObject0.AddToVectorStarB(obj); - - // Vector of pointers - printf("Adding %i to vectorBStar\n", i*j*2); - B *ptr = new B(i*j*3); - myObject0.AddToVectorBStar(ptr); - } - - printf("Setting BStar\n"); - B *objPtr = new B(i*2); - myObject0.SetBStar(objPtr); - - printf("Filling BArray\n"); - B *myArray = new B[12]; - for (int j = 0; j < 12; ++j){ - myArray[j].dummy = i * j * 4; - } - myObject0.FillBArray(myArray); - delete [] myArray; - - printf("Filling BStarArray\n"); - for (int j = 0; j < NUM_CONSTANT; ++j){ - myObject0.BStarArray[j] = i*j*5; - } - - printf("Filling BClonesArray\n"); - for (int j = 0; j < LIST_ENTRIES; ++j ){ - ((B*)myObject0.BClonesArray.New(j))->dummy = i*j*6; - } - - printf("Filling leaflist\n"); - myLeaves.myFloatX = (Float_t)i; - myLeaves.myFloatY = (Float_t)i / 10.0f; - for (int j = 0; j < MYDOUBLEARRAY_SIZE; ++j){ - myLeaves.myDoubleArrayA[j] = myLeaves.myFloatY * j; - } - for (int j = 0; j < MYBOOLARRAYB_SIZE; ++j){ - //myLeaves.myBoolArrayB[j] = (i + (i * j)) % 2; - myLeaves.myBoolArrayB[j] = j % 2; - //myLeaves.myBoolArrayB[j] = true; - } - - printf("Filling tree\n"); - myTree->Fill(); - - myObject0.ResetVectorStarB(); - - myObject0.vectorBStar.clear(); - - printf("Entry created\n"); - } - printf("Tree created\n"); - - myFile->Write(); + TFile *myFile = new TFile(fileName, "RECREATE"); + TTree *myTree = new TTree("HardTree", "This is hard to read"); + + A myObject0 (NUM_CONSTANT); + + struct { + Float_t myFloatX; + Float_t myFloatY; + Int_t myIntN; + Bool_t myBoolArrayB [MYBOOLARRAYB_SIZE]; + Double_t myDoubleArrayA [MYDOUBLEARRAY_SIZE]; + } myLeaves; + + myLeaves.myFloatX = 0.0; + myLeaves.myFloatY = 0.0; + myLeaves.myIntN = MYDOUBLEARRAY_SIZE; + + myTree->Branch("A0.", "A", &myObject0, 32000, 0); + myTree->Branch("A1.", "A", &myObject0, 32000, 1); + myTree->Branch("A99.", "A", &myObject0, 32000, 99); + myTree->Branch("A101.", "A", &myObject0, 32000, 101); + + myTree->Branch("S0_num", &myObject0.num, 32000, 0); + myTree->Branch("S1_num", &myObject0.num, 32000, 1); + myTree->Branch("S99_num", &myObject0.num, 32000, 99); + myTree->Branch("S101_num", &myObject0.num, 32000, 101); + + myTree->Branch("S0_vectorB", &myObject0.vectorB, 32000, 0); + myTree->Branch("S1_vectorB", &myObject0.vectorB, 32000, 1); + myTree->Branch("S99_vectorB", &myObject0.vectorB, 32000, 99); + // myTree->Branch("S101_vectorB", &myObject0.vectorB, 32000, 101); // Breaks Fill() + + myTree->Branch("S0_vectorBStar", &myObject0.vectorBStar, 32000, 0); + myTree->Branch("S1_vectorBStar", &myObject0.vectorBStar, 32000, 1); + myTree->Branch("S99_vectorBStar", &myObject0.vectorBStar, 32000, 99); + // myTree->Branch("S101_vectorBStar", &myObject0.vectorBStar, 32000, 101); // Breaks Fill() + + myTree->Branch("S0_vectorStarB", &myObject0.vectorStarB, 32000, 0); + myTree->Branch("S1_vectorStarB", &myObject0.vectorStarB, 32000, 1); + myTree->Branch("S99_vectorStarB", &myObject0.vectorStarB, 32000, 99); + // myTree->Branch("S101_vectorStarB", &myObject0.vectorStarB, 32000, 101); // Breaks Fill() + + myTree->Branch("S0_BStar", &myObject0.BStar, 32000, 0); + myTree->Branch("S1_BStar", &myObject0.BStar, 32000, 1); + myTree->Branch("S99_BStar", &myObject0.BStar, 32000, 99); + myTree->Branch("S101_BStar", &myObject0.BStar, 32000, 101); + + // myTree->Branch("S0_BArray[12]", "B[12]", &myObject0.BArray, 32000, 0); // Will not get made + // myTree->Branch(199_BArray[12]", "B[12]", &myObject0.BArray, 32000, 99); // Will not get made + // myTree->Branch("S99_BArray[12]", "B[12]", &myObject0.BArray, 32000, 99); // Will not get made + + // myTree->Branch("S0_BStarArray", &myObject0.BStarArray, 32000, 0); // No way of specifying an array + // myTree->Branch(199_BStarArray", &myObject0.BStarArray, 32000, 99); // No way of specifying an array + // myTree->Branch("S99_BStarArray", &myObject0.BStarArray, 32000, 99); // No way of specifying an array + + myTree->Branch("S0_BObject.", &myObject0.BObject, 32000, 0); + myTree->Branch("S1_BObject.", &myObject0.BObject, 32000, 1); + myTree->Branch("S99_BObject.", &myObject0.BObject, 32000, 99); + myTree->Branch("S101_BObject.", &myObject0.BObject, 32000, 101); + + myTree->Branch("S0_BClonesArray", &myObject0.BClonesArray, 32000, 0); + myTree->Branch("S1_BClonesArray", &myObject0.BClonesArray, 32000, 1); + myTree->Branch("S99_BClonesArray", &myObject0.BClonesArray, 32000, 99); + myTree->Branch("S101_BClonesArray", &myObject0.BClonesArray, 32000, 101); + + myTree->Branch("MyLeafList", &myLeaves, "x:y/F:n/I:b[12]/O:a[n]/D"); + + + for (int i = startI; i < TREE_ENTRIES + startI; ++i){ + printf("\nEntry %i\n\n", i); + + // Clear old values + myObject0.ResetVectorB(); + + printf("Setting BObject\n"); + myObject0.BObject.dummy = i; + + for (int j = 0; j < LIST_ENTRIES; ++j){ + // Vector of objects + B obj (i*j); + printf("Adding %i to vectorB\n", i*j); + myObject0.AddToVectorB(obj); + + obj.dummy *= 2; + // Hangs makeTree + printf("Adding %i to vectorStarB\n", obj.dummy); + myObject0.AddToVectorStarB(obj); + + // Vector of pointers + printf("Adding %i to vectorBStar\n", i*j*2); + B *ptr = new B(i*j*3); + myObject0.AddToVectorBStar(ptr); + } + + printf("Setting BStar\n"); + B *objPtr = new B(i*2); + myObject0.SetBStar(objPtr); + + printf("Filling BArray\n"); + B *myArray = new B[12]; + for (int j = 0; j < 12; ++j){ + myArray[j].dummy = i * j * 4; + } + myObject0.FillBArray(myArray); + delete [] myArray; + + printf("Filling BStarArray\n"); + for (int j = 0; j < NUM_CONSTANT; ++j){ + myObject0.BStarArray[j] = i*j*5; + } + + printf("Filling BClonesArray\n"); + for (int j = 0; j < LIST_ENTRIES; ++j ){ + ((B*)myObject0.BClonesArray.New(j))->dummy = i*j*6; + } + + printf("Filling leaflist\n"); + myLeaves.myFloatX = (Float_t)i; + myLeaves.myFloatY = (Float_t)i / 10.0f; + for (int j = 0; j < MYDOUBLEARRAY_SIZE; ++j){ + myLeaves.myDoubleArrayA[j] = myLeaves.myFloatY * j; + } + for (int j = 0; j < MYBOOLARRAYB_SIZE; ++j){ + //myLeaves.myBoolArrayB[j] = (i + (i * j)) % 2; + myLeaves.myBoolArrayB[j] = j % 2; + //myLeaves.myBoolArrayB[j] = true; + } + + printf("Filling tree\n"); + myTree->Fill(); + + myObject0.ResetVectorStarB(); + + myObject0.vectorBStar.clear(); + + printf("Entry created\n"); + } + printf("Tree created\n"); + + myFile->Write(); } void readNum(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); - - TString finalBranchName = branchName; - finalBranchName += "num"; - - TTreeReaderValue myNum (myTreeReader, finalBranchName); - - // Bool_t success = !myNum.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (testValues && *myNum != NUM_CONSTANT) success = false; - if (printOut) printf("Num: %i\n", *myNum); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); + + TString finalBranchName = branchName; + finalBranchName += "num"; + + TTreeReaderValue myNum (myTreeReader, finalBranchName); + + // Bool_t success = !myNum.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (testValues && *myNum != NUM_CONSTANT) success = false; + if (printOut) printf("Num: %i\n", *myNum); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readBObject(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); - - TString finalBranchName = branchName; - finalBranchName += "BObject"; - - TTreeReaderValue myBObject (myTreeReader, finalBranchName); - - // Bool_t success = !myBObject.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (testValues && myBObject->dummy != i * MULTIPLIER_B_OBJECT) success = false; - if (printOut) printf("Dummy: %i\n", myBObject->dummy); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); + + TString finalBranchName = branchName; + finalBranchName += "BObject"; + + TTreeReaderValue myBObject (myTreeReader, finalBranchName); + + // Bool_t success = !myBObject.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (testValues && myBObject->dummy != i * MULTIPLIER_B_OBJECT) success = false; + if (printOut) printf("Dummy: %i\n", myBObject->dummy); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readBObjectBranch(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); - - TString finalBranchName = branchName; - finalBranchName += "BObject."; - - TTreeReaderValue myBObject (myTreeReader, finalBranchName); - - // Bool_t success = !myBObject.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (testValues && myBObject->dummy != i * MULTIPLIER_B_OBJECT) success = false; - if (printOut) printf("Dummy: %i\n", myBObject->dummy); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); + + TString finalBranchName = branchName; + finalBranchName += "BObject."; + + TTreeReaderValue myBObject (myTreeReader, finalBranchName); + + // Bool_t success = !myBObject.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (testValues && myBObject->dummy != i * MULTIPLIER_B_OBJECT) success = false; + if (printOut) printf("Dummy: %i\n", myBObject->dummy); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readBObjectDummy(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); - - TString finalBranchName = branchName; - finalBranchName += "BObject.dummy"; - - TTreeReaderValue myDummy (myTreeReader, finalBranchName); - - // Bool_t success = !myDummy.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (testValues && *myDummy != i * MULTIPLIER_B_OBJECT) success = false; - if (printOut) printf("Dummy: %i\n", *myDummy); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); + + TString finalBranchName = branchName; + finalBranchName += "BObject.dummy"; + + TTreeReaderValue myDummy (myTreeReader, finalBranchName); + + // Bool_t success = !myDummy.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (testValues && *myDummy != i * MULTIPLIER_B_OBJECT) success = false; + if (printOut) printf("Dummy: %i\n", *myDummy); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readBStar(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); - - TString finalBranchName = branchName; - finalBranchName += "BStar"; - - TTreeReaderValue myBStar (myTreeReader, finalBranchName); - - // Bool_t success = !myBStar.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (testValues && myBStar->dummy != i * MULTIPLIER_B_STAR) success = false; - if (printOut) printf("Dummy: %i\n", myBStar->dummy); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); + + TString finalBranchName = branchName; + finalBranchName += "BStar"; + + TTreeReaderValue myBStar (myTreeReader, finalBranchName); + + // Bool_t success = !myBStar.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (testValues && myBStar->dummy != i * MULTIPLIER_B_STAR) success = false; + if (printOut) printf("Dummy: %i\n", myBStar->dummy); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readVectorBValue(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString finalBranchName = branchName; - finalBranchName += "vectorB"; + TString finalBranchName = branchName; + finalBranchName += "vectorB"; - TTreeReaderValue > myVectorB (myTreeReader, finalBranchName); + TTreeReaderValue > myVectorB (myTreeReader, finalBranchName); - // Bool_t success = !myVectorB.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("vectorB dummies:"); + // Bool_t success = !myVectorB.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("vectorB dummies:"); - for (int j = 0; j < LIST_ENTRIES; ++j){ - if (testValues && myVectorB->at(j).dummy != i * j * MULTIPLIER_VECTOR_B) success = false; - if (printOut) printf(" %i", myVectorB->at(j).dummy); - } + for (int j = 0; j < LIST_ENTRIES; ++j){ + if (testValues && myVectorB->at(j).dummy != i * j * MULTIPLIER_VECTOR_B) success = false; + if (printOut) printf(" %i", myVectorB->at(j).dummy); + } - if (printOut) printf("\n"); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (printOut) printf("\n"); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readVectorStarBValue(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString finalBranchName = branchName; - finalBranchName += "vectorStarB"; + TString finalBranchName = branchName; + finalBranchName += "vectorStarB"; - TTreeReaderValue > myVectorStarB (myTreeReader, finalBranchName); + TTreeReaderValue > myVectorStarB (myTreeReader, finalBranchName); - // Bool_t success = !myVectorStarB.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("vectorB dummies(%lu):", myVectorStarB->size()); + // Bool_t success = !myVectorStarB.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("vectorB dummies(%lu):", myVectorStarB->size()); - for (int j = 0; j < LIST_ENTRIES; ++j){ - if (testValues && myVectorStarB->at(j).dummy != i * j * MULTIPLIER_VECTOR_STAR_B) success = false; - if (printOut) printf(" %i", myVectorStarB->at(j).dummy); - } + for (int j = 0; j < LIST_ENTRIES; ++j){ + if (testValues && myVectorStarB->at(j).dummy != i * j * MULTIPLIER_VECTOR_STAR_B) success = false; + if (printOut) printf(" %i", myVectorStarB->at(j).dummy); + } - if (printOut) printf("\n"); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (printOut) printf("\n"); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readVectorStarBArray(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString finalBranchName = branchName; - finalBranchName += "vectorStarB"; + TString finalBranchName = branchName; + finalBranchName += "vectorStarB"; - TTreeReaderArray myVectorStarB (myTreeReader, finalBranchName); + TTreeReaderArray myVectorStarB (myTreeReader, finalBranchName); - // Bool_t success = !myVectorStarB.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("vectorB dummies(%lu):", myVectorStarB.GetSize()); + // Bool_t success = !myVectorStarB.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("vectorB dummies(%lu):", myVectorStarB.GetSize()); - for (int j = 0; j < LIST_ENTRIES; ++j){ - if (testValues && myVectorStarB.At(j).dummy != i * j * MULTIPLIER_VECTOR_STAR_B) success = false; - if (printOut) printf(" %i", myVectorStarB.At(j).dummy); - } + for (int j = 0; j < LIST_ENTRIES; ++j){ + if (testValues && myVectorStarB.At(j).dummy != i * j * MULTIPLIER_VECTOR_STAR_B) success = false; + if (printOut) printf(" %i", myVectorStarB.At(j).dummy); + } - if (printOut) printf("\n"); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (printOut) printf("\n"); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readVectorBArray(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString finalBranchName = branchName; - finalBranchName += "vectorB"; + TString finalBranchName = branchName; + finalBranchName += "vectorB"; - TTreeReaderArray myVectorB (myTreeReader, finalBranchName); + TTreeReaderArray myVectorB (myTreeReader, finalBranchName); - // Bool_t success = !myVectorB.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("vectorB dummies(%lu):", myVectorB.GetSize()); + // Bool_t success = !myVectorB.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("vectorB dummies(%lu):", myVectorB.GetSize()); - for (int j = 0; j < LIST_ENTRIES && j < (int)myVectorB.GetSize(); ++j){ - if (testValues && myVectorB.At(j).dummy != i * j * MULTIPLIER_VECTOR_B) success = false; - if (printOut) printf(" %i", myVectorB.At(j).dummy); - } + for (int j = 0; j < LIST_ENTRIES && j < (int)myVectorB.GetSize(); ++j){ + if (testValues && myVectorB.At(j).dummy != i * j * MULTIPLIER_VECTOR_B) success = false; + if (printOut) printf(" %i", myVectorB.At(j).dummy); + } - if (printOut) printf("\n"); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (printOut) printf("\n"); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readBArray(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString finalBranchName = branchName; - finalBranchName += "BArray[12]"; + TString finalBranchName = branchName; + finalBranchName += "BArray[12]"; - TTreeReaderArray myBArray (myTreeReader, finalBranchName); + TTreeReaderArray myBArray (myTreeReader, finalBranchName); - // Bool_t success = !myBArray.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("BArray dummies(%lu):", myBArray.GetSize()); + // Bool_t success = !myBArray.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("BArray dummies(%lu):", myBArray.GetSize()); - for (int j = 0; j < LIST_ENTRIES; ++j){ - if (testValues && myBArray.At(j).dummy != i * j * MULTIPLIER_B_ARRAY) success = false; - if (printOut) printf(" %i", myBArray.At(j).dummy); - } + for (int j = 0; j < LIST_ENTRIES; ++j){ + if (testValues && myBArray.At(j).dummy != i * j * MULTIPLIER_B_ARRAY) success = false; + if (printOut) printf(" %i", myBArray.At(j).dummy); + } - if (printOut) printf("\n"); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (printOut) printf("\n"); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readBStarArray(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString finalBranchName = branchName; - finalBranchName += "BStarArray"; + TString finalBranchName = branchName; + finalBranchName += "BStarArray"; - TTreeReaderArray myBStarArray (myTreeReader, finalBranchName); + TTreeReaderArray myBStarArray (myTreeReader, finalBranchName); - // Bool_t success = !myBStarArray.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("BStarArray dummies(%lu):", myBStarArray.GetSize()); + // Bool_t success = !myBStarArray.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("BStarArray dummies(%lu):", myBStarArray.GetSize()); - for (int j = 0; j < (int)myBStarArray.GetSize(); ++j){ - if (testValues && myBStarArray.At(j).dummy != i * j * MULTIPLIER_B_STAR_ARRAY) success = false; - if (printOut) printf(" %i", myBStarArray.At(j).dummy); - } + for (int j = 0; j < (int)myBStarArray.GetSize(); ++j){ + if (testValues && myBStarArray.At(j).dummy != i * j * MULTIPLIER_B_STAR_ARRAY) success = false; + if (printOut) printf(" %i", myBStarArray.At(j).dummy); + } - if (printOut) printf("\n"); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (printOut) printf("\n"); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readVectorBStarValue(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString finalBranchName = branchName; - finalBranchName += "vectorBStar"; + TString finalBranchName = branchName; + finalBranchName += "vectorBStar"; - TTreeReaderValue > myVectorBStar (myTreeReader, finalBranchName); + TTreeReaderValue > myVectorBStar (myTreeReader, finalBranchName); - // Bool_t success = !myVectorBStar.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("vectorBStar dummies(%lu):", myVectorBStar->size()); + // Bool_t success = !myVectorBStar.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("vectorBStar dummies(%lu):", myVectorBStar->size()); - for (int j = 0; j < LIST_ENTRIES && j < (int)myVectorBStar->size(); ++j){ - if (testValues && myVectorBStar->at(j)->dummy != i * j * MULTIPLIER_VECTOR_B_STAR) success = false; - if (printOut) printf(" %i", myVectorBStar->at(j)->dummy); - } + for (int j = 0; j < LIST_ENTRIES && j < (int)myVectorBStar->size(); ++j){ + if (testValues && myVectorBStar->at(j)->dummy != i * j * MULTIPLIER_VECTOR_B_STAR) success = false; + if (printOut) printf(" %i", myVectorBStar->at(j)->dummy); + } - if (printOut) printf("\n"); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (printOut) printf("\n"); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readVectorBStarArray(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString finalBranchName = branchName; - finalBranchName += "vectorBStar"; + TString finalBranchName = branchName; + finalBranchName += "vectorBStar"; - TTreeReaderArray myVectorBStar (myTreeReader, finalBranchName); + TTreeReaderArray myVectorBStar (myTreeReader, finalBranchName); - // Bool_t success = !myVectorBStar.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("vectorBStar dummies(%lu):", myVectorBStar.GetSize()); + // Bool_t success = !myVectorBStar.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("vectorBStar dummies(%lu):", myVectorBStar.GetSize()); - for (int j = 0; j < LIST_ENTRIES && (int)myVectorBStar.GetSize(); ++j){ - if (testValues && myVectorBStar.At(j).dummy != i * j * MULTIPLIER_VECTOR_B_STAR) success = false; - if (printOut) printf(" %i", myVectorBStar.At(j).dummy); - } + for (int j = 0; j < LIST_ENTRIES && (int)myVectorBStar.GetSize(); ++j){ + if (testValues && myVectorBStar.At(j).dummy != i * j * MULTIPLIER_VECTOR_B_STAR) success = false; + if (printOut) printf(" %i", myVectorBStar.At(j).dummy); + } - if (printOut) printf("\n"); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (printOut) printf("\n"); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readBClonesArrayValue(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString finalBranchName = branchName; - finalBranchName += "BClonesArray"; + TString finalBranchName = branchName; + finalBranchName += "BClonesArray"; - TTreeReaderValue myBClonesArray (myTreeReader, finalBranchName); + TTreeReaderValue myBClonesArray (myTreeReader, finalBranchName); - // Bool_t success = !myBClonesArray.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("BClonesArray dummies(%i):", myBClonesArray->GetEntries()); + // Bool_t success = !myBClonesArray.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("BClonesArray dummies(%i):", myBClonesArray->GetEntries()); - for (int j = 0; j < LIST_ENTRIES && j < myBClonesArray->GetEntries(); ++j){ - if (testValues && ((B*)myBClonesArray->At(j))->dummy != i * j * MULTIPLIER_B_CLONES_ARRAY) success = false; - if (printOut) printf(" %i", ((B*)myBClonesArray->At(j))->dummy); - } + for (int j = 0; j < LIST_ENTRIES && j < myBClonesArray->GetEntries(); ++j){ + if (testValues && ((B*)myBClonesArray->At(j))->dummy != i * j * MULTIPLIER_B_CLONES_ARRAY) success = false; + if (printOut) printf(" %i", ((B*)myBClonesArray->At(j))->dummy); + } - if (printOut) printf("\n"); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (printOut) printf("\n"); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readBClonesArrayArray(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString finalBranchName = branchName; - finalBranchName += "BClonesArray"; + TString finalBranchName = branchName; + finalBranchName += "BClonesArray"; - TTreeReaderArray myBClonesArray (myTreeReader, finalBranchName); + TTreeReaderArray myBClonesArray (myTreeReader, finalBranchName); - // Bool_t success = !myBClonesArray.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("BClonesArray dummies(%lu):", myBClonesArray.GetSize()); + // Bool_t success = !myBClonesArray.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("BClonesArray dummies(%lu):", myBClonesArray.GetSize()); - for (int j = 0; j < LIST_ENTRIES && j < (int)myBClonesArray.GetSize(); ++j){ - if (testValues && myBClonesArray.At(j).dummy != i * j * MULTIPLIER_B_CLONES_ARRAY) success = false; - if (printOut) printf(" %i", myBClonesArray.At(j).dummy); - } + for (int j = 0; j < LIST_ENTRIES && j < (int)myBClonesArray.GetSize(); ++j){ + if (testValues && myBClonesArray.At(j).dummy != i * j * MULTIPLIER_B_CLONES_ARRAY) success = false; + if (printOut) printf(" %i", myBClonesArray.At(j).dummy); + } - if (printOut) printf("\n"); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (printOut) printf("\n"); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readVectorBDummyArray(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString finalBranchName = branchName; - finalBranchName += "vectorB.dummy"; + TString finalBranchName = branchName; + finalBranchName += "vectorB.dummy"; - TTreeReaderArray myVectorBDummyArray (myTreeReader, finalBranchName); + TTreeReaderArray myVectorBDummyArray (myTreeReader, finalBranchName); - // Bool_t success = !myVectorBDummyArray.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("vectorB.dummies(%lu):", myVectorBDummyArray.GetSize()); + // Bool_t success = !myVectorBDummyArray.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("vectorB.dummies(%lu):", myVectorBDummyArray.GetSize()); - for (int j = 0; j < LIST_ENTRIES && j < (int)myVectorBDummyArray.GetSize(); ++j){ - if (testValues && myVectorBDummyArray.At(j) != i * j * MULTIPLIER_VECTOR_B) success = false; - if (printOut) printf(" %i", myVectorBDummyArray.At(j)); - } + for (int j = 0; j < LIST_ENTRIES && j < (int)myVectorBDummyArray.GetSize(); ++j){ + if (testValues && myVectorBDummyArray.At(j) != i * j * MULTIPLIER_VECTOR_B) success = false; + if (printOut) printf(" %i", myVectorBDummyArray.At(j)); + } - if (printOut) printf("\n"); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (printOut) printf("\n"); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readBClonesArrayDummyArray(const char* branchName = "A99.", Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString finalBranchName = branchName; - finalBranchName += "BClonesArray.dummy"; + TString finalBranchName = branchName; + finalBranchName += "BClonesArray.dummy"; - TTreeReaderArray myBClonesArrayDummy (myTreeReader, finalBranchName); + TTreeReaderArray myBClonesArrayDummy (myTreeReader, finalBranchName); - // Bool_t success = !myBClonesArrayDummy.GetSetupStatus(); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("BClonesArray.dummies(%lu):", myBClonesArrayDummy.GetSize()); + // Bool_t success = !myBClonesArrayDummy.GetSetupStatus(); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("BClonesArray.dummies(%lu):", myBClonesArrayDummy.GetSize()); - for (int j = 0; j < LIST_ENTRIES && j < (int)myBClonesArrayDummy.GetSize(); ++j){ - if (testValues && myBClonesArrayDummy.At(j) != i * j * MULTIPLIER_B_CLONES_ARRAY) success = false; - if (printOut) printf(" %i", myBClonesArrayDummy.At(j)); - } + for (int j = 0; j < LIST_ENTRIES && j < (int)myBClonesArrayDummy.GetSize(); ++j){ + if (testValues && myBClonesArrayDummy.At(j) != i * j * MULTIPLIER_B_CLONES_ARRAY) success = false; + if (printOut) printf(" %i", myBClonesArrayDummy.At(j)); + } - if (printOut) printf("\n"); - } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (printOut) printf("\n"); + } + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readLeafFloatX(Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString branchName = "MyLeafList.x"; + TString branchName = "MyLeafList.x"; - TTreeReaderValue myFloat (myTreeReader, branchName); + TTreeReaderValue myFloat (myTreeReader, branchName); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (testValues && *myFloat - (Float_t)i > 0.0001f) success = false; - if (printOut) printf("MyLeafList.x: %f\n", *myFloat); - } + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (testValues && *myFloat - (Float_t)i > 0.0001f) success = false; + if (printOut) printf("MyLeafList.x: %f\n", *myFloat); + } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readLeafFloatY(Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString branchName = "MyLeafList.y"; + TString branchName = "MyLeafList.y"; - TTreeReaderValue myFloat (myTreeReader, branchName); + TTreeReaderValue myFloat (myTreeReader, branchName); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (testValues && *myFloat - ((Float_t)i / 10.0f) > 0.0001f) success = false; - if (printOut) printf("MyLeafList.y: %f\n", *myFloat); - } + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (testValues && *myFloat - ((Float_t)i / 10.0f) > 0.0001f) success = false; + if (printOut) printf("MyLeafList.y: %f\n", *myFloat); + } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readLeafIntN(Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString branchName = "MyLeafList.n"; + TString branchName = "MyLeafList.n"; - TTreeReaderValue myInt (myTreeReader, branchName); + TTreeReaderValue myInt (myTreeReader, branchName); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (testValues && *myInt != MYDOUBLEARRAY_SIZE) success = false; - if (printOut) printf("MyLeafList.n: %i\n", *myInt); - } + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (testValues && *myInt != MYDOUBLEARRAY_SIZE) success = false; + if (printOut) printf("MyLeafList.n: %i\n", *myInt); + } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readLeafDoubleAArray(Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString branchName = "MyLeafList.a"; + TString branchName = "MyLeafList.a"; - TTreeReaderArray myDoubles (myTreeReader, branchName); + TTreeReaderArray myDoubles (myTreeReader, branchName); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("MyLeafList.a(%lu):", myDoubles.GetSize()); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("MyLeafList.a(%lu):", myDoubles.GetSize()); - for (size_t j = 0; j < myDoubles.GetSize() && j < 10; ++j){ - if (testValues && fabs(myDoubles.At(j) - (i * j) / 10.0f) > 0.0001f) success = false; - if (printOut) printf(" %f", myDoubles.At(j)); - } + for (size_t j = 0; j < myDoubles.GetSize() && j < 10; ++j){ + if (testValues && fabs(myDoubles.At(j) - (i * j) / 10.0f) > 0.0001f) success = false; + if (printOut) printf(" %f", myDoubles.At(j)); + } - if (printOut) printf("\n"); - } + if (printOut) printf("\n"); + } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readLeafBoolBArray(Bool_t printOut = true, Bool_t testValues = false, const char* fileName = "HardTreeFile.root"){ - TFile::Open(fileName); - TTreeReader myTreeReader ("HardTree"); + TFile::Open(fileName); + TTreeReader myTreeReader ("HardTree"); - TString branchName = "MyLeafList.b"; + TString branchName = "MyLeafList.b"; - TTreeReaderArray myBools (myTreeReader, branchName); + TTreeReaderArray myBools (myTreeReader, branchName); - Bool_t success = true; - Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ - read = true; - if (printOut) printf("MyLeafList.b(%lu):", myBools.GetSize()); + Bool_t success = true; + Bool_t read = false; + for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + read = true; + if (printOut) printf("MyLeafList.b(%lu):", myBools.GetSize()); - for (size_t j = 0; j < myBools.GetSize() && j < 10; ++j){ - if (testValues && myBools.At(j) != j % 2) success = false; - if (printOut) printf(" %s", myBools.At(j) ? "true" : "false" ); - } + for (size_t j = 0; j < myBools.GetSize() && j < 10; ++j){ + if (testValues && myBools.At(j) != j % 2) success = false; + if (printOut) printf(" %s", myBools.At(j) ? "true" : "false" ); + } - if (printOut) printf("\n"); - } + if (printOut) printf("\n"); + } - if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); + if (testValues) printf("%s\n", success && read ? "Success!" : "Failure"); } void readTree(const char* fileName = "HardTreeFile.root"){ - TFile *myFile = TFile::Open(fileName); - TTree *myTree = (TTree*)myFile->Get("HardTree"); - myTree->Print(); - - for (int i = 0; i < 10 && i < myTree->GetEntries(); ++i){ - myTree->Show(i); - } - - myFile->Close(); + TFile *myFile = TFile::Open(fileName); + TTree *myTree = (TTree*)myFile->Get("HardTree"); + myTree->Print(); + + for (int i = 0; i < 10 && i < myTree->GetEntries(); ++i){ + myTree->Show(i); + } + + myFile->Close(); } void output(Bool_t printAll = false, Bool_t testAll = true, const char* fileName = "HardTreeFile.root"){ - printf("A0: readNum(): ----------------------------- %s", printAll ? "\n": ""); readNum( "A0.", printAll, testAll, fileName); - printf("A0: readBObject(): ------------------------- %s", printAll ? "\n": ""); readBObject( "A0.", printAll, testAll, fileName); - printf("A0: readBObjectDummy(): -------------------- %s", printAll ? "\n": ""); readBObjectDummy( "A0.", printAll, testAll, fileName); - printf("A0: readBStar(): --------------------------- %s", printAll ? "\n": ""); readBStar( "A0.", printAll, testAll, fileName); - printf("A0: readVectorBValue(): -------------------- %s", printAll ? "\n": ""); readVectorBValue( "A0.", printAll, testAll, fileName); - printf("A0: readVectorStarBValue(): ---------------- %s", printAll ? "\n": ""); readVectorStarBValue( "A0.", printAll, testAll, fileName); - printf("A0: readVectorStarBArray(): ---------------- %s", printAll ? "\n": ""); readVectorStarBArray( "A0.", printAll, testAll, fileName); - printf("A0: readVectorBArray(): -------------------- %s", printAll ? "\n": ""); readVectorBArray( "A0.", printAll, testAll, fileName); - printf("A0: readBArray(): -------------------------- %s", printAll ? "\n": ""); readBArray( "A0.", printAll, testAll, fileName); - printf("A0: readBStarArray(): ---------------------- %s", printAll ? "\n": ""); readBStarArray( "A0.", printAll, testAll, fileName); - printf("A0: readVectorBStarValue(): ---------------- %s", printAll ? "\n": ""); readVectorBStarValue( "A0.", printAll, testAll, fileName); - printf("A0: readVectorBStarArray(): ---------------- %s", printAll ? "\n": ""); readVectorBStarArray( "A0.", printAll, testAll, fileName); - printf("A0: readBClonesArrayValue(): --------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "A0.", printAll, testAll, fileName); - printf("A0: readBClonesArrayArray(): --------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "A0.", printAll, testAll, fileName); - printf("A0: readVectorBDummyArray(): --------------- %s", printAll ? "\n": ""); readVectorBDummyArray( "A0.", printAll, testAll, fileName); - printf("A0: readBClonesArrayDummyArray(): ---------- %s", printAll ? "\n": ""); readBClonesArrayDummyArray("A0.", printAll, testAll, fileName); - - printf("A1: readNum(): ------------------------------ %s", printAll ? "\n": ""); readNum( "A1.", printAll, testAll, fileName); - printf("A1: readBObject(): -------------------------- %s", printAll ? "\n": ""); readBObject( "A1.", printAll, testAll, fileName); - printf("A1: readBStar(): ---------------------------- %s", printAll ? "\n": ""); readBStar( "A1.", printAll, testAll, fileName); - printf("A1: readVectorBValue(): --------------------- %s", printAll ? "\n": ""); readVectorBValue( "A1.", printAll, testAll, fileName); - printf("A1: readVectorStarBValue(): ----------------- %s", printAll ? "\n": ""); readVectorStarBValue( "A1.", printAll, testAll, fileName); - printf("A1: readVectorStarBArray(): ----------------- %s", printAll ? "\n": ""); readVectorStarBArray( "A1.", printAll, testAll, fileName); - printf("A1: readVectorBArray(): --------------------- %s", printAll ? "\n": ""); readVectorBArray( "A1.", printAll, testAll, fileName); - printf("A1: readBArray(): --------------------------- %s", printAll ? "\n": ""); readBArray( "A1.", printAll, testAll, fileName); - printf("A1: readBStarArray(): ----------------------- %s", printAll ? "\n": ""); readBStarArray( "A1.", printAll, testAll, fileName); - printf("A1: readVectorBStarValue(): ----------------- %s", printAll ? "\n": ""); readVectorBStarValue( "A1.", printAll, testAll, fileName); - printf("A1: readVectorBStarArray(): ----------------- %s", printAll ? "\n": ""); readVectorBStarArray( "A1.", printAll, testAll, fileName); - printf("A1: readBClonesArrayValue(): ---------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "A1.", printAll, testAll, fileName); - printf("A1: readBClonesArrayArray(): ---------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "A1.", printAll, testAll, fileName); - - - printf("A99: readNum(): ----------------------------- %s", printAll ? "\n": ""); readNum( "A99.", printAll, testAll, fileName); - printf("A99: readBObject(): ------------------------- %s", printAll ? "\n": ""); readBObject( "A99.", printAll, testAll, fileName); - printf("A99: readBObjectDummy(): -------------------- %s", printAll ? "\n": ""); readBObjectDummy( "A99.", printAll, testAll, fileName); - printf("A99: readBStar(): --------------------------- %s", printAll ? "\n": ""); readBStar( "A99.", printAll, testAll, fileName); - printf("A99: readVectorBValue(): -------------------- %s", printAll ? "\n": ""); readVectorBValue( "A99.", printAll, testAll, fileName); - printf("A99: readVectorStarBValue(): ---------------- %s", printAll ? "\n": ""); readVectorStarBValue( "A99.", printAll, testAll, fileName); - printf("A99: readVectorStarBArray(): ---------------- %s", printAll ? "\n": ""); readVectorStarBArray( "A99.", printAll, testAll, fileName); - printf("A99: readVectorBArray(): -------------------- %s", printAll ? "\n": ""); readVectorBArray( "A99.", printAll, testAll, fileName); - printf("A99: readBArray(): -------------------------- %s", printAll ? "\n": ""); readBArray( "A99.", printAll, testAll, fileName); - printf("A99: readBStarArray(): ---------------------- %s", printAll ? "\n": ""); readBStarArray( "A99.", printAll, testAll, fileName); - printf("A99: readVectorBStarValue(): ---------------- %s", printAll ? "\n": ""); readVectorBStarValue( "A99.", printAll, testAll, fileName); - printf("A99: readVectorBStarArray(): ---------------- %s", printAll ? "\n": ""); readVectorBStarArray( "A99.", printAll, testAll, fileName); - printf("A99: readBClonesArrayValue(): --------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "A99.", printAll, testAll, fileName); - printf("A99: readBClonesArrayArray(): --------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "A99.", printAll, testAll, fileName); - printf("A99: readVectorBDummyArray(): --------------- %s", printAll ? "\n": ""); readVectorBDummyArray( "A99.", printAll, testAll, fileName); - printf("A99: readBClonesArrayDummyArray(): ---------- %s", printAll ? "\n": ""); readBClonesArrayDummyArray("A99.", printAll, testAll, fileName); - //printf("readAObject(): ------------------------ %s", printAll ? "\n": ""); readAObject(); - - - printf("A101: readNum(): ---------------------------- %s", printAll ? "\n": ""); readNum( "A101.", printAll, testAll, fileName); - printf("A101: readBObject(): ------------------------ %s", printAll ? "\n": ""); readBObject( "A101.", printAll, testAll, fileName); - printf("A101: readBStar(): -------------------------- %s", printAll ? "\n": ""); readBStar( "A101.", printAll, testAll, fileName); - printf("A101: readVectorBValue(): ------------------- %s", printAll ? "\n": ""); readVectorBValue( "A101.", printAll, testAll, fileName); - printf("A101: readVectorStarBValue(): --------------- %s", printAll ? "\n": ""); readVectorStarBValue( "A101.", printAll, testAll, fileName); - printf("A101: readVectorStarBArray(): --------------- %s", printAll ? "\n": ""); readVectorStarBArray( "A101.", printAll, testAll, fileName); - printf("A101: readVectorBArray(): ------------------- %s", printAll ? "\n": ""); readVectorBArray( "A101.", printAll, testAll, fileName); - printf("A101: readBArray(): ------------------------- %s", printAll ? "\n": ""); readBArray( "A101.", printAll, testAll, fileName); - printf("A101: readBStarArray(): --------------------- %s", printAll ? "\n": ""); readBStarArray( "A101.", printAll, testAll, fileName); - //printf("A101: readVectorBStarValue(): --------------- %s", printAll ? "\n": ""); readVectorBStarValue( "A101.", printAll, testAll, fileName); // Segfault - //printf("A101: readVectorBStarArray(): --------------- %s", printAll ? "\n": ""); readVectorBStarArray( "A101.", printAll, testAll, fileName); // Segfault - printf("A101: readBClonesArrayValue(): -------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "A101.", printAll, testAll, fileName); - printf("A101: readBClonesArrayArray(): -------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "A101.", printAll, testAll, fileName); - - - // printf("S0_: readNum(): ----------------------------- %s", printAll ? "\n": ""); readNum( "S0_", printAll, testAll, fileName); // Leaflist - printf("S0_: readBObject(): ------------------------- %s", printAll ? "\n": ""); readBObjectBranch( "S0_", printAll, testAll, fileName); - // printf("S0_: readBObjectDummy(): -------------------- %s", printAll ? "\n": ""); readBObjectDummy( "S0_", printAll, testAll, fileName); // Branch not created - printf("S0_: readBStar(): --------------------------- %s", printAll ? "\n": ""); readBStar( "S0_", printAll, testAll, fileName); - printf("S0_: readVectorBValue(): -------------------- %s", printAll ? "\n": ""); readVectorBValue( "S0_", printAll, testAll, fileName); - printf("S0_: readVectorStarBValue(): ---------------- %s", printAll ? "\n": ""); readVectorStarBValue( "S0_", printAll, testAll, fileName); - printf("S0_: readVectorStarBArray(): ---------------- %s", printAll ? "\n": ""); readVectorStarBArray( "S0_", printAll, testAll, fileName); - printf("S0_: readVectorBArray(): -------------------- %s", printAll ? "\n": ""); readVectorBArray( "S0_", printAll, testAll, fileName); - // printf("S0_: readBArray(): -------------------------- %s", printAll ? "\n": ""); readBArray( "S0_", printAll, testAll, fileName); // Branch not created - // printf("S0_: readBStarArray(): ---------------------- %s", printAll ? "\n": ""); readBStarArray( "S0_", printAll, testAll, fileName); // Branch not created - printf("S0_: readVectorBStarValue(): ---------------- %s", printAll ? "\n": ""); readVectorBStarValue( "S0_", printAll, testAll, fileName); - printf("S0_: readVectorBStarArray(): ---------------- %s", printAll ? "\n": ""); readVectorBStarArray( "S0_", printAll, testAll, fileName); - // printf("S0_: readBClonesArrayValue(): --------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "S0_", printAll, testAll, fileName); // TBranchProxy->Read() fails - // printf("S0_: readBClonesArrayArray(): --------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "S0_", printAll, testAll, fileName); // TBranchProxy->Read() fails - // printf("S0_: readVectorBDummyArray(): --------------- %s", printAll ? "\n": ""); readVectorBDummyArray( "S0_", printAll, testAll, fileName); // Branch not found - // printf("S0_: readBClonesArrayDummyArray(): ---------- %s", printAll ? "\n": ""); readBClonesArrayDummyArray( "S0_", printAll, testAll, fileName); // Branch not found - - - // printf("S1_: readNum(): ----------------------------- %s", printAll ? "\n": ""); readNum( "S1_", printAll, testAll, fileName); // Leaflist - printf("S1_: readBObject(): ------------------------- %s", printAll ? "\n": ""); readBObjectBranch( "S1_", printAll, testAll, fileName); - printf("S1_: readBObjectDummy(): -------------------- %s", printAll ? "\n": ""); readBObjectDummy( "S1_", printAll, testAll, fileName); - printf("S1_: readBStar(): --------------------------- %s", printAll ? "\n": ""); readBStar( "S1_", printAll, testAll, fileName); - printf("S1_: readVectorBValue(): -------------------- %s", printAll ? "\n": ""); readVectorBValue( "S1_", printAll, testAll, fileName); - printf("S1_: readVectorStarBValue(): ---------------- %s", printAll ? "\n": ""); readVectorStarBValue( "S1_", printAll, testAll, fileName); - printf("S1_: readVectorStarBArray(): ---------------- %s", printAll ? "\n": ""); readVectorStarBArray( "S1_", printAll, testAll, fileName); - printf("S1_: readVectorBArray(): -------------------- %s", printAll ? "\n": ""); readVectorBArray( "S1_", printAll, testAll, fileName); - // printf("S1_: readBArray(): -------------------------- %s", printAll ? "\n": ""); readBArray( "S1_", printAll, testAll, fileName); // Branch not created - // printf("S1_: readBStarArray(): ---------------------- %s", printAll ? "\n": ""); readBStarArray( "S1_", printAll, testAll, fileName); // Branch not created - printf("S1_: readVectorBStarValue(): ---------------- %s", printAll ? "\n": ""); readVectorBStarValue( "S1_", printAll, testAll, fileName); - printf("S1_: readVectorBStarArray(): ---------------- %s", printAll ? "\n": ""); readVectorBStarArray( "S1_", printAll, testAll, fileName); - printf("S1_: readBClonesArrayValue(): --------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "S1_", printAll, testAll, fileName); - printf("S1_: readBClonesArrayArray(): --------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "S1_", printAll, testAll, fileName); - printf("S1_: readVectorBDummyArray(): --------------- %s", printAll ? "\n": ""); readVectorBDummyArray( "S1_", printAll, testAll, fileName); - printf("S1_: readBClonesArrayDummyArray(): ---------- %s", printAll ? "\n": ""); readBClonesArrayDummyArray( "S1_", printAll, testAll, fileName); - - - // printf("S99_: readNum(): ---------------------------- %s", printAll ? "\n": ""); readNum( "S99_", printAll, testAll, fileName); // Leaflist - printf("S99_: readBObject(): ------------------------ %s", printAll ? "\n": ""); readBObjectBranch( "S99_", printAll, testAll, fileName); - printf("S99_: readBObjectDummy(): ------------------- %s", printAll ? "\n": ""); readBObjectDummy( "S99_", printAll, testAll, fileName); - printf("S99_: readBStar(): -------------------------- %s", printAll ? "\n": ""); readBStar( "S99_", printAll, testAll, fileName); - printf("S99_: readVectorBValue(): ------------------- %s", printAll ? "\n": ""); readVectorBValue( "S99_", printAll, testAll, fileName); - printf("S99_: readVectorStarBValue(): --------------- %s", printAll ? "\n": ""); readVectorStarBValue( "S99_", printAll, testAll, fileName); - printf("S99_: readVectorStarBArray(): --------------- %s", printAll ? "\n": ""); readVectorStarBArray( "S99_", printAll, testAll, fileName); - printf("S99_: readVectorBArray(): ------------------- %s", printAll ? "\n": ""); readVectorBArray( "S99_", printAll, testAll, fileName); - // printf("S99_: readBArray(): ------------------------- %s", printAll ? "\n": ""); readBArray( "S99_", printAll, testAll, fileName); // Branch not created - // printf("S99_: readBStarArray(): --------------------- %s", printAll ? "\n": ""); readBStarArray( "S99_", printAll, testAll, fileName); // Branch not created - printf("S99_: readVectorBStarValue(): --------------- %s", printAll ? "\n": ""); readVectorBStarValue( "S99_", printAll, testAll, fileName); - printf("S99_: readVectorBStarArray(): --------------- %s", printAll ? "\n": ""); readVectorBStarArray( "S99_", printAll, testAll, fileName); - printf("S99_: readBClonesArrayValue(): -------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "S99_", printAll, testAll, fileName); - printf("S99_: readBClonesArrayArray(): -------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "S99_", printAll, testAll, fileName); - printf("S99_: readVectorBDummyArray(): -------------- %s", printAll ? "\n": ""); readVectorBDummyArray( "S99_", printAll, testAll, fileName); - printf("S99_: readBClonesArrayDummyArray(): --------- %s", printAll ? "\n": ""); readBClonesArrayDummyArray( "S99_", printAll, testAll, fileName); - - // printf("S101_: readNum(): --------------------------- %s", printAll ? "\n": ""); readNum( "S101_", printAll, testAll, fileName); // Leaflist - printf("S101_: readBObject(): ----------------------- %s", printAll ? "\n": ""); readBObjectBranch( "S101_", printAll, testAll, fileName); - printf("S101_: readBObjectDummy(): ------------------ %s", printAll ? "\n": ""); readBObjectDummy( "S101_", printAll, testAll, fileName); - printf("S101_: readBStar(): ------------------------- %s", printAll ? "\n": ""); readBStar( "S101_", printAll, testAll, fileName); - // printf("S101_: readVectorBValue(): ------------------ %s", printAll ? "\n": ""); readVectorBValue( "S101_", printAll, testAll, fileName); // Branch not created - // printf("S101_: readVectorStarBValue(): -------------- %s", printAll ? "\n": ""); readVectorStarBValue( "S101_", printAll, testAll, fileName); // Branch not created - // printf("S101_: readVectorStarBArray(): -------------- %s", printAll ? "\n": ""); readVectorStarBArray( "S101_", printAll, testAll, fileName); // Branch not created - // printf("S101_: readVectorBArray(): ------------------ %s", printAll ? "\n": ""); readVectorBArray( "S101_", printAll, testAll, fileName); // Branch not created - // printf("S101_: readBArray(): ------------------------ %s", printAll ? "\n": ""); readBArray( "S101_", printAll, testAll, fileName); // Branch not created - // printf("S101_: readBStarArray(): -------------------- %s", printAll ? "\n": ""); readBStarArray( "S101_", printAll, testAll, fileName); // Branch not created - // printf("S101_: readVectorBStarValue(): -------------- %s", printAll ? "\n": ""); readVectorBStarValue( "S101_", printAll, testAll, fileName); // Branch not created - // printf("S101_: readVectorBStarArray(): -------------- %s", printAll ? "\n": ""); readVectorBStarArray( "S101_", printAll, testAll, fileName); // Branch not created - printf("S101_: readBClonesArrayValue(): ------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "S101_", printAll, testAll, fileName); - printf("S101_: readBClonesArrayArray(): ------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "S101_", printAll, testAll, fileName); - // printf("S101_: readVectorBDummyArray(): ------------- %s", printAll ? "\n": ""); readVectorBDummyArray( "S101_", printAll, testAll, fileName); // Branch not created - printf("S101_: readBClonesArrayDummyArray(): -------- %s", printAll ? "\n": ""); readBClonesArrayDummyArray( "S101_", printAll, testAll, fileName); - - printf("readLeafFloatX(): --------------------------- %s", printAll ? "\n": ""); readLeafFloatX( printAll, testAll, fileName); - printf("readLeafFloatY(): --------------------------- %s", printAll ? "\n": ""); readLeafFloatY( printAll, testAll, fileName); - printf("readLeafIntN(): ----------------------------- %s", printAll ? "\n": ""); readLeafIntN( printAll, testAll, fileName); - printf("readLeafDoubleAArray(): --------------------- %s", printAll ? "\n": ""); readLeafDoubleAArray( printAll, testAll, fileName); - printf("readLeafBoolBArray(): ----------------------- %s", printAll ? "\n": ""); readLeafBoolBArray( printAll, testAll, fileName); + printf("A0: readNum(): ----------------------------- %s", printAll ? "\n": ""); readNum( "A0.", printAll, testAll, fileName); + printf("A0: readBObject(): ------------------------- %s", printAll ? "\n": ""); readBObject( "A0.", printAll, testAll, fileName); + printf("A0: readBObjectDummy(): -------------------- %s", printAll ? "\n": ""); readBObjectDummy( "A0.", printAll, testAll, fileName); + printf("A0: readBStar(): --------------------------- %s", printAll ? "\n": ""); readBStar( "A0.", printAll, testAll, fileName); + printf("A0: readVectorBValue(): -------------------- %s", printAll ? "\n": ""); readVectorBValue( "A0.", printAll, testAll, fileName); + printf("A0: readVectorStarBValue(): ---------------- %s", printAll ? "\n": ""); readVectorStarBValue( "A0.", printAll, testAll, fileName); + printf("A0: readVectorStarBArray(): ---------------- %s", printAll ? "\n": ""); readVectorStarBArray( "A0.", printAll, testAll, fileName); + printf("A0: readVectorBArray(): -------------------- %s", printAll ? "\n": ""); readVectorBArray( "A0.", printAll, testAll, fileName); + printf("A0: readBArray(): -------------------------- %s", printAll ? "\n": ""); readBArray( "A0.", printAll, testAll, fileName); + printf("A0: readBStarArray(): ---------------------- %s", printAll ? "\n": ""); readBStarArray( "A0.", printAll, testAll, fileName); + printf("A0: readVectorBStarValue(): ---------------- %s", printAll ? "\n": ""); readVectorBStarValue( "A0.", printAll, testAll, fileName); + printf("A0: readVectorBStarArray(): ---------------- %s", printAll ? "\n": ""); readVectorBStarArray( "A0.", printAll, testAll, fileName); + printf("A0: readBClonesArrayValue(): --------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "A0.", printAll, testAll, fileName); + printf("A0: readBClonesArrayArray(): --------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "A0.", printAll, testAll, fileName); + printf("A0: readVectorBDummyArray(): --------------- %s", printAll ? "\n": ""); readVectorBDummyArray( "A0.", printAll, testAll, fileName); + printf("A0: readBClonesArrayDummyArray(): ---------- %s", printAll ? "\n": ""); readBClonesArrayDummyArray( "A0.", printAll, testAll, fileName); + + printf("A1: readNum(): ------------------------------ %s", printAll ? "\n": ""); readNum( "A1.", printAll, testAll, fileName); + printf("A1: readBObject(): -------------------------- %s", printAll ? "\n": ""); readBObject( "A1.", printAll, testAll, fileName); + printf("A1: readBStar(): ---------------------------- %s", printAll ? "\n": ""); readBStar( "A1.", printAll, testAll, fileName); + printf("A1: readVectorBValue(): --------------------- %s", printAll ? "\n": ""); readVectorBValue( "A1.", printAll, testAll, fileName); + printf("A1: readVectorStarBValue(): ----------------- %s", printAll ? "\n": ""); readVectorStarBValue( "A1.", printAll, testAll, fileName); + printf("A1: readVectorStarBArray(): ----------------- %s", printAll ? "\n": ""); readVectorStarBArray( "A1.", printAll, testAll, fileName); + printf("A1: readVectorBArray(): --------------------- %s", printAll ? "\n": ""); readVectorBArray( "A1.", printAll, testAll, fileName); + printf("A1: readBArray(): --------------------------- %s", printAll ? "\n": ""); readBArray( "A1.", printAll, testAll, fileName); + printf("A1: readBStarArray(): ----------------------- %s", printAll ? "\n": ""); readBStarArray( "A1.", printAll, testAll, fileName); + printf("A1: readVectorBStarValue(): ----------------- %s", printAll ? "\n": ""); readVectorBStarValue( "A1.", printAll, testAll, fileName); + printf("A1: readVectorBStarArray(): ----------------- %s", printAll ? "\n": ""); readVectorBStarArray( "A1.", printAll, testAll, fileName); + printf("A1: readBClonesArrayValue(): ---------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "A1.", printAll, testAll, fileName); + printf("A1: readBClonesArrayArray(): ---------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "A1.", printAll, testAll, fileName); + + + printf("A99: readNum(): ----------------------------- %s", printAll ? "\n": ""); readNum( "A99.", printAll, testAll, fileName); + printf("A99: readBObject(): ------------------------- %s", printAll ? "\n": ""); readBObject( "A99.", printAll, testAll, fileName); + printf("A99: readBObjectDummy(): -------------------- %s", printAll ? "\n": ""); readBObjectDummy( "A99.", printAll, testAll, fileName); + printf("A99: readBStar(): --------------------------- %s", printAll ? "\n": ""); readBStar( "A99.", printAll, testAll, fileName); + printf("A99: readVectorBValue(): -------------------- %s", printAll ? "\n": ""); readVectorBValue( "A99.", printAll, testAll, fileName); + printf("A99: readVectorStarBValue(): ---------------- %s", printAll ? "\n": ""); readVectorStarBValue( "A99.", printAll, testAll, fileName); + printf("A99: readVectorStarBArray(): ---------------- %s", printAll ? "\n": ""); readVectorStarBArray( "A99.", printAll, testAll, fileName); + printf("A99: readVectorBArray(): -------------------- %s", printAll ? "\n": ""); readVectorBArray( "A99.", printAll, testAll, fileName); + printf("A99: readBArray(): -------------------------- %s", printAll ? "\n": ""); readBArray( "A99.", printAll, testAll, fileName); + printf("A99: readBStarArray(): ---------------------- %s", printAll ? "\n": ""); readBStarArray( "A99.", printAll, testAll, fileName); + printf("A99: readVectorBStarValue(): ---------------- %s", printAll ? "\n": ""); readVectorBStarValue( "A99.", printAll, testAll, fileName); + printf("A99: readVectorBStarArray(): ---------------- %s", printAll ? "\n": ""); readVectorBStarArray( "A99.", printAll, testAll, fileName); + printf("A99: readBClonesArrayValue(): --------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "A99.", printAll, testAll, fileName); + printf("A99: readBClonesArrayArray(): --------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "A99.", printAll, testAll, fileName); + printf("A99: readVectorBDummyArray(): --------------- %s", printAll ? "\n": ""); readVectorBDummyArray( "A99.", printAll, testAll, fileName); + printf("A99: readBClonesArrayDummyArray(): ---------- %s", printAll ? "\n": ""); readBClonesArrayDummyArray("A99.", printAll, testAll, fileName); + //printf("readAObject(): ------------------------ %s", printAll ? "\n": ""); readAObject(); + + + printf("A101: readNum(): ---------------------------- %s", printAll ? "\n": ""); readNum( "A101.", printAll, testAll, fileName); + printf("A101: readBObject(): ------------------------ %s", printAll ? "\n": ""); readBObject( "A101.", printAll, testAll, fileName); + printf("A101: readBStar(): -------------------------- %s", printAll ? "\n": ""); readBStar( "A101.", printAll, testAll, fileName); + printf("A101: readVectorBValue(): ------------------- %s", printAll ? "\n": ""); readVectorBValue( "A101.", printAll, testAll, fileName); + printf("A101: readVectorStarBValue(): --------------- %s", printAll ? "\n": ""); readVectorStarBValue( "A101.", printAll, testAll, fileName); + printf("A101: readVectorStarBArray(): --------------- %s", printAll ? "\n": ""); readVectorStarBArray( "A101.", printAll, testAll, fileName); + printf("A101: readVectorBArray(): ------------------- %s", printAll ? "\n": ""); readVectorBArray( "A101.", printAll, testAll, fileName); + printf("A101: readBArray(): ------------------------- %s", printAll ? "\n": ""); readBArray( "A101.", printAll, testAll, fileName); + printf("A101: readBStarArray(): --------------------- %s", printAll ? "\n": ""); readBStarArray( "A101.", printAll, testAll, fileName); + //printf("A101: readVectorBStarValue(): --------------- %s", printAll ? "\n": ""); readVectorBStarValue( "A101.", printAll, testAll, fileName); // Segfault + //printf("A101: readVectorBStarArray(): --------------- %s", printAll ? "\n": ""); readVectorBStarArray( "A101.", printAll, testAll, fileName); // Segfault + printf("A101: readBClonesArrayValue(): -------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "A101.", printAll, testAll, fileName); + printf("A101: readBClonesArrayArray(): -------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "A101.", printAll, testAll, fileName); + + + // printf("S0_: readNum(): ----------------------------- %s", printAll ? "\n": ""); readNum( "S0_", printAll, testAll, fileName); // Leaflist + printf("S0_: readBObject(): ------------------------- %s", printAll ? "\n": ""); readBObjectBranch( "S0_", printAll, testAll, fileName); + // printf("S0_: readBObjectDummy(): -------------------- %s", printAll ? "\n": ""); readBObjectDummy( "S0_", printAll, testAll, fileName); // Branch not created + printf("S0_: readBStar(): --------------------------- %s", printAll ? "\n": ""); readBStar( "S0_", printAll, testAll, fileName); + printf("S0_: readVectorBValue(): -------------------- %s", printAll ? "\n": ""); readVectorBValue( "S0_", printAll, testAll, fileName); + printf("S0_: readVectorStarBValue(): ---------------- %s", printAll ? "\n": ""); readVectorStarBValue( "S0_", printAll, testAll, fileName); + printf("S0_: readVectorStarBArray(): ---------------- %s", printAll ? "\n": ""); readVectorStarBArray( "S0_", printAll, testAll, fileName); + printf("S0_: readVectorBArray(): -------------------- %s", printAll ? "\n": ""); readVectorBArray( "S0_", printAll, testAll, fileName); + // printf("S0_: readBArray(): -------------------------- %s", printAll ? "\n": ""); readBArray( "S0_", printAll, testAll, fileName); // Branch not created + // printf("S0_: readBStarArray(): ---------------------- %s", printAll ? "\n": ""); readBStarArray( "S0_", printAll, testAll, fileName); // Branch not created + printf("S0_: readVectorBStarValue(): ---------------- %s", printAll ? "\n": ""); readVectorBStarValue( "S0_", printAll, testAll, fileName); + printf("S0_: readVectorBStarArray(): ---------------- %s", printAll ? "\n": ""); readVectorBStarArray( "S0_", printAll, testAll, fileName); + // printf("S0_: readBClonesArrayValue(): --------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "S0_", printAll, testAll, fileName); // TBranchProxy->Read() fails + // printf("S0_: readBClonesArrayArray(): --------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "S0_", printAll, testAll, fileName); // TBranchProxy->Read() fails + // printf("S0_: readVectorBDummyArray(): --------------- %s", printAll ? "\n": ""); readVectorBDummyArray( "S0_", printAll, testAll, fileName); // Branch not found + // printf("S0_: readBClonesArrayDummyArray(): ---------- %s", printAll ? "\n": ""); readBClonesArrayDummyArray( "S0_", printAll, testAll, fileName); // Branch not found + + + // printf("S1_: readNum(): ----------------------------- %s", printAll ? "\n": ""); readNum( "S1_", printAll, testAll, fileName); // Leaflist + printf("S1_: readBObject(): ------------------------- %s", printAll ? "\n": ""); readBObjectBranch( "S1_", printAll, testAll, fileName); + printf("S1_: readBObjectDummy(): -------------------- %s", printAll ? "\n": ""); readBObjectDummy( "S1_", printAll, testAll, fileName); + printf("S1_: readBStar(): --------------------------- %s", printAll ? "\n": ""); readBStar( "S1_", printAll, testAll, fileName); + printf("S1_: readVectorBValue(): -------------------- %s", printAll ? "\n": ""); readVectorBValue( "S1_", printAll, testAll, fileName); + printf("S1_: readVectorStarBValue(): ---------------- %s", printAll ? "\n": ""); readVectorStarBValue( "S1_", printAll, testAll, fileName); + printf("S1_: readVectorStarBArray(): ---------------- %s", printAll ? "\n": ""); readVectorStarBArray( "S1_", printAll, testAll, fileName); + printf("S1_: readVectorBArray(): -------------------- %s", printAll ? "\n": ""); readVectorBArray( "S1_", printAll, testAll, fileName); + // printf("S1_: readBArray(): -------------------------- %s", printAll ? "\n": ""); readBArray( "S1_", printAll, testAll, fileName); // Branch not created + // printf("S1_: readBStarArray(): ---------------------- %s", printAll ? "\n": ""); readBStarArray( "S1_", printAll, testAll, fileName); // Branch not created + printf("S1_: readVectorBStarValue(): ---------------- %s", printAll ? "\n": ""); readVectorBStarValue( "S1_", printAll, testAll, fileName); + printf("S1_: readVectorBStarArray(): ---------------- %s", printAll ? "\n": ""); readVectorBStarArray( "S1_", printAll, testAll, fileName); + printf("S1_: readBClonesArrayValue(): --------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "S1_", printAll, testAll, fileName); + printf("S1_: readBClonesArrayArray(): --------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "S1_", printAll, testAll, fileName); + printf("S1_: readVectorBDummyArray(): --------------- %s", printAll ? "\n": ""); readVectorBDummyArray( "S1_", printAll, testAll, fileName); + printf("S1_: readBClonesArrayDummyArray(): ---------- %s", printAll ? "\n": ""); readBClonesArrayDummyArray( "S1_", printAll, testAll, fileName); + + + // printf("S99_: readNum(): ---------------------------- %s", printAll ? "\n": ""); readNum( "S99_", printAll, testAll, fileName); // Leaflist + printf("S99_: readBObject(): ------------------------ %s", printAll ? "\n": ""); readBObjectBranch( "S99_", printAll, testAll, fileName); + printf("S99_: readBObjectDummy(): ------------------- %s", printAll ? "\n": ""); readBObjectDummy( "S99_", printAll, testAll, fileName); + printf("S99_: readBStar(): -------------------------- %s", printAll ? "\n": ""); readBStar( "S99_", printAll, testAll, fileName); + printf("S99_: readVectorBValue(): ------------------- %s", printAll ? "\n": ""); readVectorBValue( "S99_", printAll, testAll, fileName); + printf("S99_: readVectorStarBValue(): --------------- %s", printAll ? "\n": ""); readVectorStarBValue( "S99_", printAll, testAll, fileName); + printf("S99_: readVectorStarBArray(): --------------- %s", printAll ? "\n": ""); readVectorStarBArray( "S99_", printAll, testAll, fileName); + printf("S99_: readVectorBArray(): ------------------- %s", printAll ? "\n": ""); readVectorBArray( "S99_", printAll, testAll, fileName); + // printf("S99_: readBArray(): ------------------------- %s", printAll ? "\n": ""); readBArray( "S99_", printAll, testAll, fileName); // Branch not created + // printf("S99_: readBStarArray(): --------------------- %s", printAll ? "\n": ""); readBStarArray( "S99_", printAll, testAll, fileName); // Branch not created + printf("S99_: readVectorBStarValue(): --------------- %s", printAll ? "\n": ""); readVectorBStarValue( "S99_", printAll, testAll, fileName); + printf("S99_: readVectorBStarArray(): --------------- %s", printAll ? "\n": ""); readVectorBStarArray( "S99_", printAll, testAll, fileName); + printf("S99_: readBClonesArrayValue(): -------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "S99_", printAll, testAll, fileName); + printf("S99_: readBClonesArrayArray(): -------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "S99_", printAll, testAll, fileName); + printf("S99_: readVectorBDummyArray(): -------------- %s", printAll ? "\n": ""); readVectorBDummyArray( "S99_", printAll, testAll, fileName); + printf("S99_: readBClonesArrayDummyArray(): --------- %s", printAll ? "\n": ""); readBClonesArrayDummyArray( "S99_", printAll, testAll, fileName); + + // printf("S101_: readNum(): --------------------------- %s", printAll ? "\n": ""); readNum( "S101_", printAll, testAll, fileName); // Leaflist + printf("S101_: readBObject(): ----------------------- %s", printAll ? "\n": ""); readBObjectBranch( "S101_", printAll, testAll, fileName); + printf("S101_: readBObjectDummy(): ------------------ %s", printAll ? "\n": ""); readBObjectDummy( "S101_", printAll, testAll, fileName); + printf("S101_: readBStar(): ------------------------- %s", printAll ? "\n": ""); readBStar( "S101_", printAll, testAll, fileName); + // printf("S101_: readVectorBValue(): ------------------ %s", printAll ? "\n": ""); readVectorBValue( "S101_", printAll, testAll, fileName); // Branch not created + // printf("S101_: readVectorStarBValue(): -------------- %s", printAll ? "\n": ""); readVectorStarBValue( "S101_", printAll, testAll, fileName); // Branch not created + // printf("S101_: readVectorStarBArray(): -------------- %s", printAll ? "\n": ""); readVectorStarBArray( "S101_", printAll, testAll, fileName); // Branch not created + // printf("S101_: readVectorBArray(): ------------------ %s", printAll ? "\n": ""); readVectorBArray( "S101_", printAll, testAll, fileName); // Branch not created + // printf("S101_: readBArray(): ------------------------ %s", printAll ? "\n": ""); readBArray( "S101_", printAll, testAll, fileName); // Branch not created + // printf("S101_: readBStarArray(): -------------------- %s", printAll ? "\n": ""); readBStarArray( "S101_", printAll, testAll, fileName); // Branch not created + // printf("S101_: readVectorBStarValue(): -------------- %s", printAll ? "\n": ""); readVectorBStarValue( "S101_", printAll, testAll, fileName); // Branch not created + // printf("S101_: readVectorBStarArray(): -------------- %s", printAll ? "\n": ""); readVectorBStarArray( "S101_", printAll, testAll, fileName); // Branch not created + printf("S101_: readBClonesArrayValue(): ------------- %s", printAll ? "\n": ""); readBClonesArrayValue( "S101_", printAll, testAll, fileName); + printf("S101_: readBClonesArrayArray(): ------------- %s", printAll ? "\n": ""); readBClonesArrayArray( "S101_", printAll, testAll, fileName); + // printf("S101_: readVectorBDummyArray(): ------------- %s", printAll ? "\n": ""); readVectorBDummyArray( "S101_", printAll, testAll, fileName); // Branch not created + printf("S101_: readBClonesArrayDummyArray(): -------- %s", printAll ? "\n": ""); readBClonesArrayDummyArray( "S101_", printAll, testAll, fileName); + + printf("readLeafFloatX(): --------------------------- %s", printAll ? "\n": ""); readLeafFloatX( printAll, testAll, fileName); + printf("readLeafFloatY(): --------------------------- %s", printAll ? "\n": ""); readLeafFloatY( printAll, testAll, fileName); + printf("readLeafIntN(): ----------------------------- %s", printAll ? "\n": ""); readLeafIntN( printAll, testAll, fileName); + printf("readLeafDoubleAArray(): --------------------- %s", printAll ? "\n": ""); readLeafDoubleAArray( printAll, testAll, fileName); + printf("readLeafBoolBArray(): ----------------------- %s", printAll ? "\n": ""); readLeafBoolBArray( printAll, testAll, fileName); } void testAll(){ - output(false, true); + output(false, true); } void printAll(){ - output(true, true); + output(true, true); } void testChain(){ - output(false, true, "HardChainFile.root"); + output(false, true, "HardChainFile.root"); } void printChain(){ - output(true, true, "HardChainFile.root"); + output(true, true, "HardChainFile.root"); } From 448e1201cc090d2ed69c5814a49fc58b8e83dc8b Mon Sep 17 00:00:00 2001 From: Anders Eie Date: Thu, 8 Aug 2013 16:24:55 +0200 Subject: [PATCH 20/27] Replaced tabs with spaces in custom classes for tests --- tree/treeplayer/test/A.h | 96 ++++++++++++++++++++-------------------- tree/treeplayer/test/B.h | 12 ++--- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/tree/treeplayer/test/A.h b/tree/treeplayer/test/A.h index 0c6354bea8143..71c18f68dcc28 100644 --- a/tree/treeplayer/test/A.h +++ b/tree/treeplayer/test/A.h @@ -10,63 +10,63 @@ class A { public: - Int_t num; - std::vector vectorB; - std::vector vectorBStar; - std::vector *vectorStarB;//-> - B* BStar;//-> - B BArray [12]; - B BObject; - B* BStarArray;//[num] // Breaks Fill() - TClonesArray BClonesArray; + Int_t num; + std::vector vectorB; + std::vector vectorBStar; + std::vector *vectorStarB;//-> + B* BStar;//-> + B BArray [12]; + B BObject; + B* BStarArray;//[num] // Breaks Fill() + TClonesArray BClonesArray; - A() : - num(0), - vectorStarB(0), - BStar(0), - BStarArray(0), - BClonesArray("B") - { } - A(Int_t nArg) : - num(nArg), - vectorStarB(new std::vector()), - BStar(new B()), - BStarArray(new B[num]), - BClonesArray("B") - { } - virtual ~A() { }; + A() : + num(0), + vectorStarB(0), + BStar(0), + BStarArray(0), + BClonesArray("B") + { } + A(Int_t nArg) : + num(nArg), + vectorStarB(new std::vector()), + BStar(new B()), + BStarArray(new B[num]), + BClonesArray("B") + { } + virtual ~A() { }; - void SetNum(Int_t Num) { num = Num; } - void SetVectorStarB(std::vector *vectorArg) { vectorStarB = vectorArg; } - void SetBStar(B* bArg) { BStar = bArg; } - //void SetBClonesArray(TClonesArray cloneArgs) { BClonesArray = cloneArgs; } + void SetNum(Int_t Num) { num = Num; } + void SetVectorStarB(std::vector *vectorArg) { vectorStarB = vectorArg; } + void SetBStar(B* bArg) { BStar = bArg; } + //void SetBClonesArray(TClonesArray cloneArgs) { BClonesArray = cloneArgs; } - void AddToVectorB(B item) { vectorB.push_back(item); } - void AddToVectorBStar(B *item) { vectorBStar.push_back(item); } - void AddToVectorStarB(B item) { vectorStarB->push_back(item); } + void AddToVectorB(B item) { vectorB.push_back(item); } + void AddToVectorBStar(B *item) { vectorBStar.push_back(item); } + void AddToVectorStarB(B item) { vectorStarB->push_back(item); } - void FillBArray(B *items) { for (int i = 0; i < 12; ++i) BArray[i] = items[i]; } + void FillBArray(B *items) { for (int i = 0; i < 12; ++i) BArray[i] = items[i]; } - void PrintBArray() { for (int i = 0; i < 12; ++i) printf(" %i", BArray[i].GetDummy()); } + void PrintBArray() { for (int i = 0; i < 12; ++i) printf(" %i", BArray[i].GetDummy()); } - Int_t GetNum() const { return num; } - std::vector& GetVectorB() { return vectorB; } - std::vector&GetVectorBStar() { return vectorBStar; } - std::vector* GetVectorStarB() { return vectorStarB; } - B* GetBStar() { return BStar; } - B* GetBArray() { return BArray; } - B* GetBStarArray() { return BStarArray; } - //TClonesArray GetBClonesArray() { return BClonesArray; } + Int_t GetNum() const { return num; } + std::vector& GetVectorB() { return vectorB; } + std::vector&GetVectorBStar() { return vectorBStar; } + std::vector* GetVectorStarB() { return vectorStarB; } + B* GetBStar() { return BStar; } + B* GetBArray() { return BArray; } + B* GetBStarArray() { return BStarArray; } + //TClonesArray GetBClonesArray() { return BClonesArray; } - B GetFromVectorB(Int_t index) { return vectorB.at(index); } - B GetFromVectorStarB(Int_t index) { return vectorStarB->at(index); } - B* GetFromVectorBStar(Int_t index) { return vectorBStar.at(index); } + B GetFromVectorB(Int_t index) { return vectorB.at(index); } + B GetFromVectorStarB(Int_t index) { return vectorStarB->at(index); } + B* GetFromVectorBStar(Int_t index) { return vectorBStar.at(index); } - void ResetVectorB() { vectorB.clear(); } - void ResetVectorStarB() { vectorStarB->clear(); } - void ResetBStarArray() { BStarArray = new B[num]; } + void ResetVectorB() { vectorB.clear(); } + void ResetVectorStarB() { vectorStarB->clear(); } + void ResetBStarArray() { BStarArray = new B[num]; } - ClassDef(A, 1); + ClassDef(A, 1); }; #endif diff --git a/tree/treeplayer/test/B.h b/tree/treeplayer/test/B.h index 1a5b17ff87589..bfc949d74464c 100644 --- a/tree/treeplayer/test/B.h +++ b/tree/treeplayer/test/B.h @@ -6,16 +6,16 @@ class B : public TObject { public: - Int_t dummy; + Int_t dummy; - B() : dummy(0) {} - B(Int_t dummyArg) : dummy(dummyArg) {} + B() : dummy(0) {} + B(Int_t dummyArg) : dummy(dummyArg) {} - void SetDummy(Int_t dummyArg) { dummy = dummyArg; } + void SetDummy(Int_t dummyArg) { dummy = dummyArg; } - Int_t GetDummy() const { return dummy; } + Int_t GetDummy() const { return dummy; } - ClassDef(B, 1); + ClassDef(B, 1); }; #endif From 6c5b2062be885d8794f6edb0289e502c326560c5 Mon Sep 17 00:00:00 2001 From: Anders Eie Date: Thu, 8 Aug 2013 17:14:57 +0200 Subject: [PATCH 21/27] Added comment for one array reader interface --- tree/treeplayer/src/TTreeReaderArray.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/tree/treeplayer/src/TTreeReaderArray.cxx b/tree/treeplayer/src/TTreeReaderArray.cxx index 2ddd478b55bc0..43e37f6d306f4 100644 --- a/tree/treeplayer/src/TTreeReaderArray.cxx +++ b/tree/treeplayer/src/TTreeReaderArray.cxx @@ -219,6 +219,7 @@ namespace { virtual size_t GetSize(ROOT::TBranchProxy* /*proxy*/){ return *indexReader; } }; + // Reader interface for fixed size arrays class TArrayFixedSizeReader : public TObjectArrayReader { private: Int_t size; From 132b8553a006387645a569719026d4708dfd7130 Mon Sep 17 00:00:00 2001 From: Bertrand Bellenot Date: Fri, 9 Aug 2013 15:11:45 +0200 Subject: [PATCH 22/27] Remove a couple of gotos --- gui/gui/src/TGFontDialog.cxx | 4 +--- gui/gui/src/TGListTree.cxx | 3 +-- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/gui/gui/src/TGFontDialog.cxx b/gui/gui/src/TGFontDialog.cxx index a86e8a4f9313a..323986ef55bf5 100644 --- a/gui/gui/src/TGFontDialog.cxx +++ b/gui/gui/src/TGFontDialog.cxx @@ -806,10 +806,8 @@ void TGFontDialog::GetFontName() if (!fLabelFont) { // should not happen fLName = oldFont; - goto out; } - - if (fSample) { + else if (fSample) { fSample->SetTextFont(fLabelFont); } } diff --git a/gui/gui/src/TGListTree.cxx b/gui/gui/src/TGListTree.cxx index f50f3aef345f1..c94c1a7140b6d 100644 --- a/gui/gui/src/TGListTree.cxx +++ b/gui/gui/src/TGListTree.cxx @@ -2338,7 +2338,6 @@ TGListTreeItem *TGListTree::FindItemByPathname(const char *path) TGListTreeItem *diritem = 0; TString fulldir; -start: while (1) { while (*p && *p == '/') p++; if (!*p) break; @@ -2361,7 +2360,7 @@ TGListTreeItem *TGListTree::FindItemByPathname(const char *path) if (!s || !s[0]) return diritem; p = ++s; item = diritem; - goto start; + continue; } } From 504c91e4b7018f3f1a87c6f5a0295c354563ad54 Mon Sep 17 00:00:00 2001 From: Bertrand Bellenot Date: Fri, 9 Aug 2013 15:14:51 +0200 Subject: [PATCH 23/27] Remove forgotten label --- gui/gui/src/TGFontDialog.cxx | 1 - 1 file changed, 1 deletion(-) diff --git a/gui/gui/src/TGFontDialog.cxx b/gui/gui/src/TGFontDialog.cxx index 323986ef55bf5..141316fce9bdc 100644 --- a/gui/gui/src/TGFontDialog.cxx +++ b/gui/gui/src/TGFontDialog.cxx @@ -812,7 +812,6 @@ void TGFontDialog::GetFontName() } } -out: Int_t oldAlign = fTextAlign; Int_t idx = fTextAligns->GetSelected(); From f0473ba1a48f4b48aa82b4e8eec991fa278204e2 Mon Sep 17 00:00:00 2001 From: Bertrand Bellenot Date: Fri, 9 Aug 2013 15:39:33 +0200 Subject: [PATCH 24/27] Remove one more goto --- core/winnt/src/Win32Splash.cxx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/core/winnt/src/Win32Splash.cxx b/core/winnt/src/Win32Splash.cxx index b200adab37410..c3992a0edb062 100644 --- a/core/winnt/src/Win32Splash.cxx +++ b/core/winnt/src/Win32Splash.cxx @@ -358,10 +358,10 @@ void *OpenGraphic(char *name) // get width and height of picture hr = Ipic->get_Width(&sizeInHiMetric.cx); if (!SUCCEEDED(hr)) - goto err; + return 0; Ipic->get_Height(&sizeInHiMetric.cy); if (!SUCCEEDED(hr)) - goto err; + return 0; // convert himetric to pixels sizeInPix.cx = (nPixelsPerInchX * sizeInHiMetric.cx + @@ -374,7 +374,6 @@ void *OpenGraphic(char *name) gImageInfo.Path = name; return Ipic; } -err: return 0; } From ce8dee238a0086d61df875b247dc2401eb314830 Mon Sep 17 00:00:00 2001 From: Anders Eie Date: Fri, 9 Aug 2013 15:46:08 +0200 Subject: [PATCH 25/27] Reverting wrong changes to TTreePlayer --- tree/treeplayer/inc/TTreePlayer.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tree/treeplayer/inc/TTreePlayer.h b/tree/treeplayer/inc/TTreePlayer.h index 21227974241e0..9a93d371a66b3 100644 --- a/tree/treeplayer/inc/TTreePlayer.h +++ b/tree/treeplayer/inc/TTreePlayer.h @@ -36,9 +36,6 @@ #ifndef ROOT_TVirtualTreePlayer #include "TVirtualTreePlayer.h" #endif -#ifndef ROOT_TFileCollection -#include "TFileCollection.h" -#endif class TVirtualIndex; @@ -71,7 +68,6 @@ class TTreePlayer : public TVirtualTreePlayer { public: TTreePlayer(); - TTreePlayer(const char*, TFileCollection*) { printf("Not Implemented!\n");}; virtual ~TTreePlayer(); virtual TVirtualIndex *BuildIndex(const TTree *T, const char *majorname, const char *minorname); virtual TTree *CopyTree(const char *selection, Option_t *option @@ -129,12 +125,10 @@ class TTreePlayer : public TVirtualTreePlayer { Bool_t ScanRedirected() {return fScanRedirect;} virtual TSQLResult *Query(const char *varexp, const char *selection, Option_t *option ,Long64_t nentries, Long64_t firstentry); - void SetChain(const char*, TFileCollection*) { printf("Not Implemented!\n");}; virtual void SetEstimate(Long64_t n); void SetScanRedirect(Bool_t on=kFALSE) {fScanRedirect = on;} void SetScanFileName(const char *name) {fScanFileName=name;} virtual void SetTree(TTree *t) {fTree = t;} - void SetTree(const char*, TDirectory*) { printf("Not Implemented!\n");}; virtual void StartViewer(Int_t ww, Int_t wh); virtual Int_t UnbinnedFit(const char *formula ,const char *varexp, const char *selection,Option_t *option ,Long64_t nentries, Long64_t firstentry); From 3a59f4da36d241f296e1f7703cd84e694f1042a2 Mon Sep 17 00:00:00 2001 From: Anders Eie Date: Fri, 9 Aug 2013 17:15:40 +0200 Subject: [PATCH 26/27] Refactoring interface for incrementing the entry pointer --- tree/treeplayer/inc/TTreeReader.h | 2 +- tree/treeplayer/test/hardTreeReaderTest.cpp | 44 ++++++++++----------- tree/treeplayer/test/tread.C | 4 +- tutorials/tree/TreeReaderSimple.cxx | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/tree/treeplayer/inc/TTreeReader.h b/tree/treeplayer/inc/TTreeReader.h index 3930417dd5528..932386249dbc7 100644 --- a/tree/treeplayer/inc/TTreeReader.h +++ b/tree/treeplayer/inc/TTreeReader.h @@ -73,7 +73,7 @@ class TTreeReader: public TObject { Bool_t IsChain() const { return TestBit(kBitIsChain); } - Bool_t SetNextEntry() { return SetEntry(GetCurrentEntry() + 1) == kEntryValid; } + Bool_t Next() { return SetEntry(GetCurrentEntry() + 1) == kEntryValid; } EEntryStatus SetEntry(Long64_t entry) { return SetEntryBase(entry, kFALSE); } EEntryStatus SetLocalEntry(Long64_t entry) { return SetEntryBase(entry, kTRUE); } diff --git a/tree/treeplayer/test/hardTreeReaderTest.cpp b/tree/treeplayer/test/hardTreeReaderTest.cpp index a87cf0c94c827..0f2c4134ceee5 100644 --- a/tree/treeplayer/test/hardTreeReaderTest.cpp +++ b/tree/treeplayer/test/hardTreeReaderTest.cpp @@ -178,7 +178,7 @@ void readNum(const char* branchName = "A99.", Bool_t printOut = true, Bool_t tes // Bool_t success = !myNum.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (testValues && *myNum != NUM_CONSTANT) success = false; if (printOut) printf("Num: %i\n", *myNum); @@ -198,7 +198,7 @@ void readBObject(const char* branchName = "A99.", Bool_t printOut = true, Bool_t // Bool_t success = !myBObject.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (testValues && myBObject->dummy != i * MULTIPLIER_B_OBJECT) success = false; if (printOut) printf("Dummy: %i\n", myBObject->dummy); @@ -218,7 +218,7 @@ void readBObjectBranch(const char* branchName = "A99.", Bool_t printOut = true, // Bool_t success = !myBObject.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (testValues && myBObject->dummy != i * MULTIPLIER_B_OBJECT) success = false; if (printOut) printf("Dummy: %i\n", myBObject->dummy); @@ -238,7 +238,7 @@ void readBObjectDummy(const char* branchName = "A99.", Bool_t printOut = true, B // Bool_t success = !myDummy.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (testValues && *myDummy != i * MULTIPLIER_B_OBJECT) success = false; if (printOut) printf("Dummy: %i\n", *myDummy); @@ -258,7 +258,7 @@ void readBStar(const char* branchName = "A99.", Bool_t printOut = true, Bool_t t // Bool_t success = !myBStar.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (testValues && myBStar->dummy != i * MULTIPLIER_B_STAR) success = false; if (printOut) printf("Dummy: %i\n", myBStar->dummy); @@ -278,7 +278,7 @@ void readVectorBValue(const char* branchName = "A99.", Bool_t printOut = true, B // Bool_t success = !myVectorB.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("vectorB dummies:"); @@ -304,7 +304,7 @@ void readVectorStarBValue(const char* branchName = "A99.", Bool_t printOut = tru // Bool_t success = !myVectorStarB.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("vectorB dummies(%lu):", myVectorStarB->size()); @@ -330,7 +330,7 @@ void readVectorStarBArray(const char* branchName = "A99.", Bool_t printOut = tru // Bool_t success = !myVectorStarB.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("vectorB dummies(%lu):", myVectorStarB.GetSize()); @@ -356,7 +356,7 @@ void readVectorBArray(const char* branchName = "A99.", Bool_t printOut = true, B // Bool_t success = !myVectorB.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("vectorB dummies(%lu):", myVectorB.GetSize()); @@ -382,7 +382,7 @@ void readBArray(const char* branchName = "A99.", Bool_t printOut = true, Bool_t // Bool_t success = !myBArray.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("BArray dummies(%lu):", myBArray.GetSize()); @@ -408,7 +408,7 @@ void readBStarArray(const char* branchName = "A99.", Bool_t printOut = true, Boo // Bool_t success = !myBStarArray.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("BStarArray dummies(%lu):", myBStarArray.GetSize()); @@ -434,7 +434,7 @@ void readVectorBStarValue(const char* branchName = "A99.", Bool_t printOut = tru // Bool_t success = !myVectorBStar.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("vectorBStar dummies(%lu):", myVectorBStar->size()); @@ -460,7 +460,7 @@ void readVectorBStarArray(const char* branchName = "A99.", Bool_t printOut = tru // Bool_t success = !myVectorBStar.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("vectorBStar dummies(%lu):", myVectorBStar.GetSize()); @@ -486,7 +486,7 @@ void readBClonesArrayValue(const char* branchName = "A99.", Bool_t printOut = tr // Bool_t success = !myBClonesArray.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("BClonesArray dummies(%i):", myBClonesArray->GetEntries()); @@ -512,7 +512,7 @@ void readBClonesArrayArray(const char* branchName = "A99.", Bool_t printOut = tr // Bool_t success = !myBClonesArray.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("BClonesArray dummies(%lu):", myBClonesArray.GetSize()); @@ -538,7 +538,7 @@ void readVectorBDummyArray(const char* branchName = "A99.", Bool_t printOut = tr // Bool_t success = !myVectorBDummyArray.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("vectorB.dummies(%lu):", myVectorBDummyArray.GetSize()); @@ -564,7 +564,7 @@ void readBClonesArrayDummyArray(const char* branchName = "A99.", Bool_t printOut // Bool_t success = !myBClonesArrayDummy.GetSetupStatus(); Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("BClonesArray.dummies(%lu):", myBClonesArrayDummy.GetSize()); @@ -588,7 +588,7 @@ void readLeafFloatX(Bool_t printOut = true, Bool_t testValues = false, const cha Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (testValues && *myFloat - (Float_t)i > 0.0001f) success = false; if (printOut) printf("MyLeafList.x: %f\n", *myFloat); @@ -607,7 +607,7 @@ void readLeafFloatY(Bool_t printOut = true, Bool_t testValues = false, const cha Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (testValues && *myFloat - ((Float_t)i / 10.0f) > 0.0001f) success = false; if (printOut) printf("MyLeafList.y: %f\n", *myFloat); @@ -626,7 +626,7 @@ void readLeafIntN(Bool_t printOut = true, Bool_t testValues = false, const char* Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (testValues && *myInt != MYDOUBLEARRAY_SIZE) success = false; if (printOut) printf("MyLeafList.n: %i\n", *myInt); @@ -645,7 +645,7 @@ void readLeafDoubleAArray(Bool_t printOut = true, Bool_t testValues = false, con Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("MyLeafList.a(%lu):", myDoubles.GetSize()); @@ -670,7 +670,7 @@ void readLeafBoolBArray(Bool_t printOut = true, Bool_t testValues = false, const Bool_t success = true; Bool_t read = false; - for (int i = 1; myTreeReader.SetNextEntry(); ++i){ + for (int i = 1; myTreeReader.Next(); ++i){ read = true; if (printOut) printf("MyLeafList.b(%lu):", myBools.GetSize()); diff --git a/tree/treeplayer/test/tread.C b/tree/treeplayer/test/tread.C index 34570d229cd73..22a09b6d0209a 100644 --- a/tree/treeplayer/test/tread.C +++ b/tree/treeplayer/test/tread.C @@ -18,7 +18,7 @@ void tread_obj() { TFile* f = TFile::Open("tr.root"); TTreeReader tr("T"); TTreeReaderValue< MyParticle > p(tr, "p"); - while (tr.SetNextEntry()) { + while (tr.Next()) { printf("Particle momentum: %g\n", *p->P()); } delete f; @@ -29,7 +29,7 @@ void tread_makeclass() { TFile* f = TFile::Open("tr.root"); TTreeReader tr("T"); TTreeReaderArray e(tr, "v.fPos.fY"); - while (tr.SetNextEntry()) { + while (tr.Next()) { if (!e.IsEmpty()) printf("lead muon energy: %g\n", e.At(0)); } diff --git a/tutorials/tree/TreeReaderSimple.cxx b/tutorials/tree/TreeReaderSimple.cxx index 0d046afce8554..d6afab4f3caff 100644 --- a/tutorials/tree/TreeReaderSimple.cxx +++ b/tutorials/tree/TreeReaderSimple.cxx @@ -12,7 +12,7 @@ void TreeReaderSimple() { TTreeReaderValue myPx(myHSimpleReader, "px"); TTreeReaderValue myPy(myHSimpleReader, "py"); - while (myHSimpleReader.SetNextEntry()){ + while (myHSimpleReader.Next()){ myHistogram->Fill(*myPx + *myPy); } From 1ec1a2e61af280ff3743846e6788eac800514c37 Mon Sep 17 00:00:00 2001 From: CristinaCristescu Date: Mon, 12 Aug 2013 11:12:31 +0200 Subject: [PATCH 27/27] Fix unchecked NULL return in HandleEnumDecl. --- core/meta/src/TCling.cxx | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/core/meta/src/TCling.cxx b/core/meta/src/TCling.cxx index 43a3d1c15738c..552c414fa1909 100644 --- a/core/meta/src/TCling.cxx +++ b/core/meta/src/TCling.cxx @@ -278,39 +278,39 @@ void TCling::HandleEnumDecl(const clang::Decl* D, bool isGlobal, TClass *cl) con } // Add the constants to the enum type. - const EnumDecl* ED = llvm::dyn_cast(D); - for (EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(), - EDE = ED->enumerator_end(); EDI != EDE; ++EDI) { - // Get name of the enum type. - std::string constbuf; - if (const NamedDecl* END = llvm::dyn_cast(*EDI)) { - PrintingPolicy Policy((*EDI)->getASTContext().getPrintingPolicy()); - llvm::raw_string_ostream stream(constbuf); - (END)->getNameForDiagnostic(stream, Policy, /*Qualified=*/false); - } - const char* constantName = constbuf.c_str(); + if (const EnumDecl* ED = llvm::dyn_cast(D)) { + for (EnumDecl::enumerator_iterator EDI = ED->enumerator_begin(), + EDE = ED->enumerator_end(); EDI != EDE; ++EDI) { + // Get name of the enum type. + std::string constbuf; + if (const NamedDecl* END = llvm::dyn_cast(*EDI)) { + PrintingPolicy Policy((*EDI)->getASTContext().getPrintingPolicy()); + llvm::raw_string_ostream stream(constbuf); + (END)->getNameForDiagnostic(stream, Policy, /*Qualified=*/false); + } + const char* constantName = constbuf.c_str(); - // Get value of the constant. - Long64_t value; - const llvm::APSInt valAPSInt = (*EDI)->getInitVal(); - if (valAPSInt.isSigned()) { - value = valAPSInt.getSExtValue(); - } else { - value = valAPSInt.getZExtValue(); - } + // Get value of the constant. + Long64_t value; + const llvm::APSInt valAPSInt = (*EDI)->getInitVal(); + if (valAPSInt.isSigned()) { + value = valAPSInt.getSExtValue(); + } else { + value = valAPSInt.getZExtValue(); + } - // Create the TEnumConstant. - TEnumConstant* enumConstant = new TEnumConstant(new TClingDataMemberInfo(fInterpreter, *EDI) + // Create the TEnumConstant. + TEnumConstant* enumConstant = new TEnumConstant(new TClingDataMemberInfo(fInterpreter, *EDI) , constantName, value, enumType); - // Check that the constant was created. - if (!enumConstant) { - Error ("HandleEnumDecl", "The enum constant %s was not created.", constantName); - } else { - // Add the global constants to the list of Globals. - if (isGlobal) { - gROOT->GetListOfGlobals()->Add(enumConstant); + // Check that the constant was created. + if (!enumConstant) { + Error ("HandleEnumDecl", "The enum constant %s was not created.", constantName); + } else { + // Add the global constants to the list of Globals. + if (isGlobal) { + gROOT->GetListOfGlobals()->Add(enumConstant); + } } - } } }