Skip to content

Commit d6ea30d

Browse files
committed
TClass Real Data: proper tracking of transientness.
We do want to record as transient a real data member that is inside a nested object that is itself marked as transient. However, the `isTransient` parameter to `TBuildRealData::Inspect` is set to true in the case where the object is really nested and the real data is being added to the current class (what we want) and in the case where we want to setup a related class but the real data will not be added to the current class (eg. collection or pointer to a class).
1 parent 74384ed commit d6ea30d

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

core/base/inc/TMemberInspector.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class TMemberInspector {
3939
class TParentBuf;
4040
TParentBuf* fParent; // current inspection "path"
4141
EObjectPointerState fObjectPointerState; // whether the address is valid or only an offset
42+
UInt_t fNestedTransient;
4243

4344
TMemberInspector(const TMemberInspector &) = delete;
4445
TMemberInspector &operator=(const TMemberInspector &) = delete;
@@ -76,6 +77,10 @@ class TMemberInspector {
7677
void GenericShowMembers(const char *topClassName, const void *obj,
7778
Bool_t transientMember);
7879

80+
void DecrementNestedTransient() { --fNestedTransient; }
81+
void IncrementNestedTransient() { ++fNestedTransient; }
82+
bool IsNestedTransient() { return fNestedTransient != 0; }
83+
7984
ClassDef(TMemberInspector,0) //ABC for inspecting class data members
8085
};
8186

core/base/src/TMemberInspector.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void TMemberInspector::TParentBuf::Remove(Ssiz_t startingAt)
6060
ClassImp(TMemberInspector);
6161

6262
TMemberInspector::TMemberInspector():
63-
fObjectPointerState(kUnset)
63+
fObjectPointerState(kUnset), fNestedTransient(0)
6464
{
6565
// Construct a member inspector
6666

core/meta/src/TClass.cxx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ void TBuildRealData::Inspect(TClass* cl, const char* pname, const char* mname, c
775775
return;
776776
}
777777

778-
Bool_t isTransientMember = isTransient;
778+
Bool_t isTransientMember = kFALSE;
779779

780780
if (!dm->IsPersistent()) {
781781
// For the DataModelEvolution we need access to the transient member.
@@ -824,6 +824,8 @@ void TBuildRealData::Inspect(TClass* cl, const char* pname, const char* mname, c
824824
TRealData::GetName(rdName,dm);
825825
rname += rdName;
826826
TRealData* rd = new TRealData(rname.Data(), offset, dm);
827+
if (isTransientMember || IsNestedTransient())
828+
rd->SetBit(TRealData::kTransient);
827829
fRealDataClass->GetListOfRealData()->Add(rd);
828830
return;
829831
}
@@ -833,12 +835,14 @@ void TBuildRealData::Inspect(TClass* cl, const char* pname, const char* mname, c
833835
if (dm->IsaPointer()) {
834836
// Data member is a pointer.
835837
TRealData* rd = new TRealData(rname, offset, dm);
836-
if (isTransientMember) { rd->SetBit(TRealData::kTransient); };
838+
if (isTransientMember || IsNestedTransient())
839+
rd->SetBit(TRealData::kTransient);
837840
fRealDataClass->GetListOfRealData()->Add(rd);
838841
} else {
839842
// Data Member is a basic data type.
840843
TRealData* rd = new TRealData(rname, offset, dm);
841-
if (isTransientMember) { rd->SetBit(TRealData::kTransient); };
844+
if (isTransientMember || IsNestedTransient())
845+
rd->SetBit(TRealData::kTransient);
842846
if (!dm->IsBasic()) {
843847
rd->SetIsObject(kTRUE);
844848

core/metacling/src/TCling.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2980,9 +2980,12 @@ void TCling::InspectMembers(TMemberInspector& insp, const void* obj,
29802980
// if we can not find the member (which should not really happen),
29812981
// let's consider it transient.
29822982
Bool_t transient = isTransient || !mbr || !mbr->IsPersistent();
2983-
2983+
if (transient)
2984+
insp.IncrementNestedTransient();
29842985
insp.InspectMember(sFieldRecName.c_str(), cobj + fieldOffset,
29852986
(fieldName + '.').c_str(), transient);
2987+
if (transient)
2988+
insp.DecrementNestedTransient();
29862989

29872990
}
29882991
}

0 commit comments

Comments
 (0)