Skip to content

Commit e06d376

Browse files
committed
[ntuple] fix collection proxy with [U]Long64_t template arg
1 parent 051e95b commit e06d376

File tree

5 files changed

+22
-5
lines changed

5 files changed

+22
-5
lines changed

tree/ntuple/inc/ROOT/RField/RFieldProxiedCollection.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ template <typename T>
255255
class RField<T, typename std::enable_if<IsCollectionProxy<T>::value>::type> final : public RProxiedCollectionField {
256256
public:
257257
static std::string TypeName() { return ROOT::Internal::GetRenormalizedTypeName(typeid(T)); }
258-
RField(std::string_view name) : RProxiedCollectionField(name, TypeName())
258+
RField(std::string_view name) : RProxiedCollectionField(name, Internal::GetDemangledTypeName(typeid(T)))
259259
{
260260
static_assert(std::is_class<T>::value, "collection proxy unsupported for fundamental types");
261261
}

tree/ntuple/src/RFieldMeta.cxx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ ROOT::RProxiedCollectionField::RProxiedCollectionField(std::string_view fieldNam
748748
fNWritten(0)
749749
{
750750
if (!classp->GetCollectionProxy())
751-
throw RException(R__FAIL(std::string(GetTypeName()) + " has no associated collection proxy"));
751+
throw RException(R__FAIL(std::string(classp->GetName()) + " has no associated collection proxy"));
752752
if (classp->Property() & kIsDefinedInStd) {
753753
static const std::vector<std::string> supportedStdTypes = {
754754
"std::set<", "std::unordered_set<", "std::multiset<", "std::unordered_multiset<",
@@ -764,6 +764,10 @@ ROOT::RProxiedCollectionField::RProxiedCollectionField(std::string_view fieldNam
764764
throw RException(R__FAIL(std::string(GetTypeName()) + " is not supported"));
765765
}
766766

767+
std::string renormalizedAlias;
768+
if (Internal::NeedsMetaNameAsAlias(classp->GetName(), renormalizedAlias))
769+
fTypeAlias = renormalizedAlias;
770+
767771
fProxy.reset(classp->GetCollectionProxy()->Generate());
768772
fProperties = fProxy->GetProperties();
769773
fCollectionType = fProxy->GetCollectionType();
@@ -801,7 +805,7 @@ ROOT::RProxiedCollectionField::RProxiedCollectionField(std::string_view fieldNam
801805
case EDataType::kFloat_t: itemField = std::make_unique<RField<Float_t>>("_0"); break;
802806
case EDataType::kDouble_t: itemField = std::make_unique<RField<Double_t>>("_0"); break;
803807
case EDataType::kBool_t: itemField = std::make_unique<RField<Bool_t>>("_0"); break;
804-
default: throw RException(R__FAIL("unsupported value type"));
808+
default: throw RException(R__FAIL("unsupported value type: " + std::to_string(fProxy->GetType())));
805809
}
806810
}
807811

tree/ntuple/test/CustomStructLinkDef.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
#pragma link C++ class StructUsingCollectionProxy<CustomStruct> + ;
6868
#pragma link C++ class StructUsingCollectionProxy<StructUsingCollectionProxy<float>> + ;
6969
#pragma link C++ class StructUsingCollectionProxy<int> + ;
70+
#pragma link C++ class StructUsingCollectionProxy<Long64_t>+;
7071

7172
#pragma link C++ class TrivialTraitsBase + ;
7273
#pragma link C++ class TrivialTraits + ;

tree/ntuple/test/SimpleCollectionProxy.hxx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ public:
7272
return EDataType::kInt_t;
7373
if constexpr (std::is_same<typename CollectionT::ValueType, float>::value)
7474
return EDataType::kFloat_t;
75+
if constexpr (std::is_same<typename CollectionT::ValueType, Long64_t>::value)
76+
return EDataType::kLong64_t;
7577
return EDataType::kOther_t;
7678
}
7779

@@ -122,8 +124,9 @@ template <>
122124
struct IsCollectionProxy<StructUsingCollectionProxy<float>> : std::true_type {
123125
};
124126
template <>
125-
struct IsCollectionProxy<StructUsingCollectionProxy<CustomStruct>> : std::true_type {
126-
};
127+
struct IsCollectionProxy<StructUsingCollectionProxy<Long64_t>> : std::true_type {};
128+
template <>
129+
struct IsCollectionProxy<StructUsingCollectionProxy<CustomStruct>> : std::true_type {};
127130

128131
template <>
129132
struct IsCollectionProxy<StructUsingCollectionProxy<StructUsingCollectionProxy<float>>> : std::true_type {

tree/ntuple/test/rfield_class.cxx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "ntuple_test.hxx"
2+
#include "SimpleCollectionProxy.hxx"
23

34
#include <TMath.h>
45
#include <TObject.h>
@@ -391,6 +392,14 @@ TEST(RNTuple, TClassMetaName)
391392
auto f4 = RFieldBase::Create("f", "EdmContainer").Unwrap();
392393
EXPECT_STREQ("EdmWrapper<Long64_t>",
393394
static_cast<const ROOT::RClassField *>(f4->GetConstSubfields()[0])->GetClass()->GetName());
395+
396+
SimpleCollectionProxy<StructUsingCollectionProxy<Long64_t>> proxy;
397+
auto cl = TClass::GetClass("StructUsingCollectionProxy<Long64_t>");
398+
cl->CopyCollectionProxy(proxy);
399+
400+
auto f5 = std::make_unique<ROOT::RField<StructUsingCollectionProxy<Long64_t>>>("f");
401+
EXPECT_TRUE(dynamic_cast<ROOT::RProxiedCollectionField *>(f5.get()));
402+
EXPECT_EQ("StructUsingCollectionProxy<Long64_t>", f5->GetTypeAlias());
394403
}
395404

396405
TEST(RNTuple, StreamerInfoRecords)

0 commit comments

Comments
 (0)