-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Fix Issue #6443: spurrious auto-parsing due to @ class, pair, __pair_base and enums #6445
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
8d2567b
9ca6572
72c723b
cd04b64
2787835
c7930cf
fe77942
d51fa31
19f417d
94b5a72
e311a8a
84cb8a5
2c274dc
9b1058a
2fb16c9
3936c2f
0005d17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…oForPair
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -180,6 +180,14 @@ class TVirtualStreamerInfo : public TNamed { | |||||||||||||||||||||
| static void SetCanDelete(Bool_t opt=kTRUE); | ||||||||||||||||||||||
| static void SetFactory(TVirtualStreamerInfo *factory); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // \brief Generate the TClass and TStreamerInfo for the requested pair. | ||||||||||||||||||||||
| // This creates a TVirtualStreamerInfo for the pair and trigger the BuildCheck/Old to | ||||||||||||||||||||||
| // provokes the creation of the corresponding TClass. This relies on the dictionary for | ||||||||||||||||||||||
| // std::pair<const int, int> to already exist (or the interpreter information being available) | ||||||||||||||||||||||
| // as it is used as a template. | ||||||||||||||||||||||
|
Comment on lines
+183
to
+187
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
| virtual TVirtualStreamerInfo *GenerateInfoForPair(const std::string &pairclassname) = 0; | ||||||||||||||||||||||
| virtual TVirtualStreamerInfo *GenerateInfoForPair(const std::string &firstname, const std::string &secondname) = 0; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| virtual TVirtualCollectionProxy *GenEmulatedProxy(const char* class_name, Bool_t silent) = 0; | ||||||||||||||||||||||
| virtual TClassStreamer *GenEmulatedClassStreamer(const char* class_name, Bool_t silent) = 0; | ||||||||||||||||||||||
| virtual TVirtualCollectionProxy *GenExplicitProxy( const ::ROOT::Detail::TCollectionProxyInfo &info, TClass *cl ) = 0; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -5547,3 +5547,129 @@ TStreamerInfo::GenExplicitClassStreamer( const ::ROOT::TCollectionProxyInfo &inf | |||||||||
| { | ||||||||||
| return TCollectionProxyFactory::GenExplicitClassStreamer(info, cl); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // | ||||||||||
| // Utility functions | ||||||||||
| // | ||||||||||
| static TStreamerElement* R__CreateEmulatedElement(const char *dmName, const std::string &dmFull, Int_t offset) | ||||||||||
| { | ||||||||||
| // Create a TStreamerElement for the type 'dmFull' and whose data member name is 'dmName'. | ||||||||||
|
|
||||||||||
| TString s1( TClassEdit::ShortType(dmFull.c_str(),0) ); | ||||||||||
| TString dmType( TClassEdit::ShortType(dmFull.c_str(),1) ); | ||||||||||
| Bool_t dmIsPtr = (s1 != dmType); | ||||||||||
| const char *dmTitle = "Emulation"; | ||||||||||
|
|
||||||||||
| TDataType *dt = gROOT->GetType(dmType); | ||||||||||
| if (dt && dt->GetType() > 0 ) { // found a basic type | ||||||||||
| Int_t dsize,dtype; | ||||||||||
| dtype = dt->GetType(); | ||||||||||
| dsize = dt->Size(); | ||||||||||
| if (dmIsPtr && dtype != kCharStar) { | ||||||||||
| Error("Pair Emulation Building","%s is not yet supported in pair emulation", | ||||||||||
| dmFull.c_str()); | ||||||||||
| return 0; | ||||||||||
| } else { | ||||||||||
| TStreamerElement *el = new TStreamerBasicType(dmName,dmTitle,offset,dtype,dmFull.c_str()); | ||||||||||
| el->SetSize(dsize); | ||||||||||
| return el; | ||||||||||
| } | ||||||||||
| } else { | ||||||||||
|
|
||||||||||
| static const char *full_string_name = "basic_string<char,char_traits<char>,allocator<char> >"; | ||||||||||
| if (strcmp(dmType,"string") == 0 || strcmp(dmType,"std::string") == 0 || strcmp(dmType,full_string_name)==0 ) { | ||||||||||
| return new TStreamerSTLstring(dmName,dmTitle,offset,dmFull.c_str(),dmIsPtr); | ||||||||||
| } | ||||||||||
| if (TClassEdit::IsSTLCont(dmType)) { | ||||||||||
| return new TStreamerSTL(dmName,dmTitle,offset,dmFull.c_str(),dmFull.c_str(),dmIsPtr); | ||||||||||
| } | ||||||||||
| TClass *clm = TClass::GetClass(dmType); | ||||||||||
| if (!clm) { | ||||||||||
| // either we have an Emulated enum or a really unknown class! | ||||||||||
| // let's just claim its an enum :( | ||||||||||
| Int_t dtype = kInt_t; | ||||||||||
| return new TStreamerBasicType(dmName,dmTitle,offset,dtype,dmFull.c_str()); | ||||||||||
| } | ||||||||||
| // a pointer to a class | ||||||||||
| if ( dmIsPtr ) { | ||||||||||
| if (clm->IsTObject()) { | ||||||||||
| return new TStreamerObjectPointer(dmName,dmTitle,offset,dmFull.c_str()); | ||||||||||
| } else { | ||||||||||
| return new TStreamerObjectAnyPointer(dmName,dmTitle,offset,dmFull.c_str()); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| // a class | ||||||||||
| if (clm->IsTObject()) { | ||||||||||
| return new TStreamerObject(dmName,dmTitle,offset,dmFull.c_str()); | ||||||||||
| } else if(clm == TString::Class() && !dmIsPtr) { | ||||||||||
| return new TStreamerString(dmName,dmTitle,offset); | ||||||||||
| } else { | ||||||||||
| return new TStreamerObjectAny(dmName,dmTitle,offset,dmFull.c_str()); | ||||||||||
| } | ||||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| // \brief Generate the TClass and TStreamerInfo for the requested pair. | ||||||||||
| // This creates a TVirtualStreamerInfo for the pair and trigger the BuildCheck/Old to | ||||||||||
| // provoke the creation of the corresponding TClass. This relies on the dictionary for | ||||||||||
| // std::pair<const int, int> to already exist (or the interpreter information being available) | ||||||||||
| // as it is used as a template. | ||||||||||
| TVirtualStreamerInfo *TStreamerInfo::GenerateInfoForPair(const std::string &firstname, const std::string &secondname) | ||||||||||
| { | ||||||||||
| // Generate a TStreamerInfo for a std::pair<fname,sname> | ||||||||||
| // This TStreamerInfo is then used as if it was read from a file to generate | ||||||||||
| // and emulated TClass. | ||||||||||
|
|
||||||||||
| TStreamerInfo *i = (TStreamerInfo*)TClass::GetClass("pair<const int,int>")->GetStreamerInfo()->Clone(); | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you |
||||||||||
| std::string pname = "pair<" + firstname + "," + secondname; | ||||||||||
| pname += (pname[pname.length()-1]=='>') ? " >" : ">"; | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry - I realize now that this is just moved from
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically the existing version is (slightly) faster and, in my humble opinion (aka "for me") is at least as readable. |
||||||||||
| i->SetName(pname.c_str()); | ||||||||||
| i->SetClass(nullptr); | ||||||||||
| i->GetElements()->Delete(); | ||||||||||
| TStreamerElement *fel = R__CreateEmulatedElement("first", firstname, 0); | ||||||||||
| Int_t size = 0; | ||||||||||
| if (fel) { | ||||||||||
| i->GetElements()->Add( fel ); | ||||||||||
|
|
||||||||||
| size = fel->GetSize(); | ||||||||||
| Int_t sp = sizeof(void *); | ||||||||||
| //align the non-basic data types (required on alpha and IRIX!!) | ||||||||||
| if (size%sp != 0) size = size - size%sp + sp; | ||||||||||
| } else { | ||||||||||
| delete i; | ||||||||||
| return 0; | ||||||||||
| } | ||||||||||
| TStreamerElement *second = R__CreateEmulatedElement("second", secondname, size); | ||||||||||
| if (second) { | ||||||||||
| i->GetElements()->Add( second ); | ||||||||||
| } else { | ||||||||||
| delete i; | ||||||||||
| return 0; | ||||||||||
| } | ||||||||||
| Int_t oldlevel = gErrorIgnoreLevel; | ||||||||||
| // Hide the warning about the missing pair dictionary. | ||||||||||
| gErrorIgnoreLevel = kError; | ||||||||||
| i->BuildCheck(); | ||||||||||
| gErrorIgnoreLevel = oldlevel; | ||||||||||
| i->BuildOld(); | ||||||||||
| return i; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| TVirtualStreamerInfo *TStreamerInfo::GenerateInfoForPair(const std::string &pairclassname) | ||||||||||
| { | ||||||||||
| const static int pairlen = strlen("pair<"); | ||||||||||
| if (pairclassname.compare(0, pairlen, "pair<") != 0) { | ||||||||||
| Error("GenerateInfoForPair", "The class name passed is not a pair: %s", pairclassname.c_str()); | ||||||||||
| return nullptr; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| std::vector<std::string> inside; | ||||||||||
| int nested = 0; | ||||||||||
| int num = TClassEdit::GetSplit(pairclassname.c_str(), inside, nested); | ||||||||||
| if (num != 4) { | ||||||||||
| Error("GenerateInfoForPair", "Could not find the pair arguments in %s", pairclassname.c_str()); | ||||||||||
| return nullptr; | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return GenerateInfoForPair(inside[1], inside[2]); | ||||||||||
| } | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Implementation detail; this should be asserted by
GenerateInfoForPair, not be part of the doc.