root-project / root

The official repository for ROOT: analyzing, storing and visualizing big data, scientifically
https://root.cern
Other
2.7k stars 1.28k forks source link

`TEnum::GetEnum` does NOT process typedefs #12685

Closed pcanal closed 6 months ago

pcanal commented 1 year ago

Currently if the parameter to TEnum::GetEnums ends in a typedef/alias, it can not find the enums. With the example:

enum EFruit {kApple=78, kBanana=29, kCitrus=34};
// std::vector<EFruit> vec;
using EFruit_t = EFruit;

void repro()
{
    auto type = "std::vector<EFruit>::value_type";
    cout << gInterpreter->ClassInfo_IsEnum(type) << endl;
    cout << TEnum::GetEnum(type) << endl;
    auto resolved = TClassEdit::ResolveTypedef (type, kTRUE);
    cout << TEnum::GetEnum(resolved.c_str()) << endl;
    cout << TEnum::GetEnum("EFruit_t") << endl;
}

We get:

1
0
0x267f2a0
0

Where the two '0' indicates that the lookup failed.

This is seen in https://github.com/root-project/root/issues/10454 and holds up (per se) https://github.com/root-project/root/pull/11412

jblomer commented 1 year ago

The problem extends to the specification of the underlying integer type, e.g.

enum A : int {};
TEnum::GetEnum("A")->GetUnderlyingType()  // --> (EDataType) (kInt_t) : (int) 3

but

enum B : std::int32_t {};
TEnum::GetEnum("B")->GetUnderlyingType()  // --> (EDataType) (kNumDataTypes) : (int) 23

Do you want to keep it as part of this issue or should I open a new one?

pcanal commented 1 year ago

This should be enough.

pcanal commented 6 months ago

We need to open a new issue for https://github.com/root-project/root/issues/12685#issuecomment-1630944070 it is: https://github.com/root-project/root/issues/15460