Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[NFC] extend documentation for some of std::pair handling code
  • Loading branch information
pcanal committed Sep 30, 2020
commit 2fb16c95c152883ba174266547d132372efc76e1
1 change: 1 addition & 0 deletions core/foundation/src/TClassEdit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,7 @@ void TClassEdit::GetNormalizedName(std::string &norm_name, std::string_view name
TClassEdit::TSplitType splitname(norm_name.c_str(),(TClassEdit::EModType)(TClassEdit::kLong64 | TClassEdit::kDropStd | TClassEdit::kDropStlDefault | TClassEdit::kKeepOuterConst));
splitname.ShortType(norm_name, TClassEdit::kDropStd | TClassEdit::kDropStlDefault | TClassEdit::kResolveTypedef | TClassEdit::kKeepOuterConst);

// 4 elements expected: "pair", "first type name", "second type name", "trailing stars"
if (splitname.fElements.size() == 4 && (splitname.fElements[0] == "std::pair" || splitname.fElements[0] == "pair" || splitname.fElements[0] == "__pair_base")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you not use IsStdPair here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. The test is also on the base class name (__pair_base) and technically the name can have wild spelling. I.e. the input name (unsplit and unnormalized of course) could be "std :: pair <" and the split name lacks the < that IsStdPair expects.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here I mean that I need to do the test after the call to Split to remove the problem with spelling (and then the name does not have the "<" and thus IsStdPair is not applicable.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can splitname be std::pair when splitname is the result of kDropStd? Or am I misremembering input/output of ShortType?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actually ... that's right .. the test for std::pair is here superfluous ...

// We don't want to lookup the std::pair itself.
std::string first, second;
Expand Down
5 changes: 5 additions & 0 deletions core/meta/src/TClass.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3041,8 +3041,13 @@ TClass *TClass::GetClass(const char *name, Bool_t load, Bool_t silent)
// ::Fatal("TClass::GetClass","The existing name (%s) for %s is different from the normalized name: %s\n",
// altcl->GetName(), name, normalizedName.c_str());
// }

// We want to avoid auto-parsing due to intentionally missing dictionary for std::pair.
// However, we don't need this special treatement in rootcling (there is no auto-parsing)
// and we want to make that the TClass for the pair goes through the regular creation
// mechanism (i.e. in rootcling they should be in kInterpreted state and never in
// kEmulated state) so that they have proper interpreter (ClassInfo) information which
// will be used to create the TProtoClass (if one is requested for the pair).
const bool ispair = TClassEdit::IsStdPair(normalizedName) && !IsFromRootCling();

TClass *loadedcl = 0;
Expand Down
3 changes: 3 additions & 0 deletions tree/treeplayer/src/TTreeGeneratorBase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ namespace Internal {
directive = Form("#include \"%s\"\n",filename);
} else if (TClassEdit::IsStdPair(cl->GetName())) {
TClassEdit::TSplitType split(cl->GetName());
// 4 elements expected: "pair", "first type name", "second type name", "trailing stars"
// However legacy code had a test for 3, we will leave it here until
// a test is developed (or found :) ) that exercise these lines of code.
if (split.fElements.size() == 3 || split.fElements.size() == 4) {
for (int arg = 1; arg < 3; ++arg) {
TClass* clArg = TClass::GetClass(split.fElements[arg].c_str());
Expand Down