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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 0 additions & 29 deletions core/cont/inc/TRefArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,33 +161,4 @@ inline Bool_t TRefArray::BoundsOk(const char *where, Int_t at) const
: kTRUE;
}

inline TObject *TRefArray::operator[](Int_t at) const
{
int j = at-fLowerBound;
if (j >= 0 && j < fSize) {
if (!fPID) return nullptr;
if (!TProcessID::IsValid(fPID)) return nullptr;
TObject *obj = fPID->GetObjectWithID(fUIDs[j]);
if (!obj) obj = GetFromTable(j);
return obj;
}
BoundsOk("At", at);
return nullptr;
}

inline TObject *TRefArray::At(Int_t at) const
{
// Return the object at position i. Returns 0 if i is out of bounds.
int j = at-fLowerBound;
if (j >= 0 && j < fSize) {
if (!fPID) return nullptr;
if (!TProcessID::IsValid(fPID)) return nullptr;
TObject *obj = fPID->GetObjectWithID(fUIDs[j]);
if (!obj) obj = GetFromTable(j);
return obj;
}
BoundsOk("At", at);
return nullptr;
}

#endif
28 changes: 28 additions & 0 deletions core/cont/src/TRefArray.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -966,3 +966,31 @@ TObject *TRefArrayIter::operator*() const
return (((fCurCursor >= 0) && (fCurCursor < fArray->Capacity())) ?
fArray->At(fCurCursor) : nullptr);
}

TObject *TRefArray::operator[](Int_t at) const
{
return At(at);
}

TObject *TRefArray::At(Int_t at) const
{
// Return the object at position i. Returns 0 if i is out of bounds.
int j = at - fLowerBound;
if (j >= 0 && j < fSize) {

auto table = TRefTable::GetRefTable();
table->Notify();

if (!fPID || !TProcessID::IsValid(fPID)) return nullptr;

auto obj = fPID->GetObjectWithID(fUIDs[j]);
if (obj) return obj;

if ((obj = GetFromTable(j))) return obj;

return nullptr;

}
BoundsOk("At", at);
return nullptr;
}
59 changes: 59 additions & 0 deletions core/metacling/test/TClingTests.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -274,3 +274,62 @@ TEST_F(TClingTests, ROOT10499) {
EXPECT_EQ((void*)&errno, (void*)gInterpreter->Calc("&errno"));
#endif
}

// ROOT-6913
TEST_F(TClingTests, ClassInfoProperty)
{
gInterpreter->Declare(R"cpp(
class ClassHasExplicitCtor{
public:
ClassHasExplicitCtor(){};
};

class ClassHasExplicitDtor{
public:
~ClassHasExplicitDtor(){};
};

class ClassHasImplicitCtor {
ClassHasExplicitCtor c;
};

class ClassHasImplicitDtor{
ClassHasExplicitDtor c;
};

class ClassHasDefaultCtor{
ClassHasDefaultCtor(){};
};

class ClassIsAbstract{
virtual void PureVirtual() = 0;
};

class ClassHasVirtual{
virtual void Virtual() {};
};

class ClassHasAssignOpr{
ClassHasAssignOpr& operator=(const ClassHasAssignOpr&);
};

// according to the C++ standard, being a POD implies being an aggregate
struct ClassIsAggregate {
int x;
double y;
};
)cpp");

const std::vector<std::pair<std::string, Long_t>> classNPPairs{
{"ClassHasImplicitCtor", kClassHasImplicitCtor}, {"ClassHasExplicitCtor", kClassHasExplicitCtor},
{"ClassHasExplicitDtor", kClassHasExplicitDtor}, {"ClassHasImplicitDtor", kClassHasImplicitDtor},
{"ClassHasDefaultCtor", kClassHasDefaultCtor}, {"ClassHasDefaultCtor", kClassIsValid},
{"ClassIsAbstract", kClassIsAbstract}, {"ClassHasVirtual", kClassHasVirtual},
{"ClassHasAssignOpr", kClassHasAssignOpr}, {"ClassIsAggregate", kClassIsAggregate}};

for (auto &[clName, clPropRef] : classNPPairs) {
auto cl = TClass::GetClass(clName.c_str());
const auto prop = gInterpreter->ClassInfo_ClassProperty(cl->GetClassInfo());
EXPECT_TRUE(prop & clPropRef) << "Error checking property for class " << clName;
}
}