Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In TStreamerInfo::GenerateInfoForPair use a non-zero size enums. #6729

Merged
merged 6 commits into from
Nov 2, 2020
Merged
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
1 change: 0 additions & 1 deletion core/dictgen/src/BaseSelectionRule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ BaseSelectionRule::EMatchType BaseSelectionRule::Match(const clang::NamedDecl *d
* isLinkdef - if the selection rules were generating from a linkdef.h file
*/


const std::string& name_value = fName;
const std::string& pattern_value = fPattern;

Expand Down
19 changes: 13 additions & 6 deletions core/meta/inc/TEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ class TEnumConstant;
class TEnum : public TDictionary {

private:
THashList fConstantList; //list of constants the enum type
ClassInfo_t *fInfo; //!interpreter information, owned by TEnum
TClass *fClass; //!owning class
std::string fQualName; // fully qualified type name
THashList fConstantList; // List of constants the enum type
ClassInfo_t *fInfo = nullptr; //!Interpreter information, owned by TEnum
TClass *fClass = nullptr; //!Owning class
std::string fQualName; // Fully qualified type name
EDataType fUnderlyingType = kInt_t; // Type (size) used to store the enum in memory

enum EBits {
kBitIsScopedEnum = BIT(14) ///< The enum is an enum class.
Expand All @@ -50,7 +51,7 @@ class TEnum : public TDictionary {
kALoadAndInterpLookup = 3
};

TEnum(): fInfo(nullptr), fClass(nullptr) {}
TEnum() = default;
TEnum(const char *name, DeclId_t declid, TClass *cls);
virtual ~TEnum();

Expand All @@ -59,7 +60,13 @@ class TEnum : public TDictionary {
const TSeqCollection *GetConstants() const { return &fConstantList; }
const TEnumConstant *GetConstant(const char *name) const { return (TEnumConstant *)fConstantList.FindObject(name); }
DeclId_t GetDeclId() const;
EDataType GetUnderlyingType() const;

/// Get the unterlying integer type of the enum:
/// enum E { kOne }; // ==> int
/// enum F: long; // ==> long
/// Returns kNumDataTypes if the enum is unknown / invalid.
EDataType GetUnderlyingType() const { return fUnderlyingType; };

Bool_t IsValid();
Long_t Property() const;
void SetClass(TClass *cl) { fClass = cl; }
Expand Down
2 changes: 2 additions & 0 deletions core/meta/src/TClass.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3141,6 +3141,8 @@ TClass *TClass::GetClass(const char *name, Bool_t load, Bool_t silent)
// to get the part to add or drop the default arguments as requested by the user)
std::string alternative;
gInterpreter->GetInterpreterTypeName(normalizedName.c_str(), alternative, kTRUE);
if (alternative.empty())
return nullptr;
const char *altname = alternative.c_str();
if (strncmp(altname, "std::", 5) == 0) {
// For namespace (for example std::__1), GetInterpreterTypeName does
Expand Down
2 changes: 1 addition & 1 deletion core/meta/src/TDataType.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,6 @@ void TDataType::AddBuiltins(TCollection* types)

TDataType* TDataType::GetDataType(EDataType type)
{
if (type == kOther_t) return 0;
if (type == kOther_t || type >= kNumDataTypes) return 0;
return fgBuiltins[(int)type];
}
19 changes: 4 additions & 15 deletions core/meta/src/TEnum.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ClassImp(TEnum);
/// in TROOT::GetListOfGlobals).

TEnum::TEnum(const char *name, DeclId_t declid, TClass *cls)
: fInfo(nullptr), fClass(cls)
: fClass(cls)
{
SetName(name);
if (cls) {
Expand Down Expand Up @@ -98,19 +98,6 @@ Long_t TEnum::Property() const
return kIsEnum | (TestBit(kBitIsScopedEnum) ? kIsScopedEnum : 0);
}

////////////////////////////////////////////////////////////////////////////////
/// Get the unterlying integer type of the enum:
/// enum E { kOne }; // ==> int
/// enum F: long; // ==> long
/// Returns kNumDataTypes if the enum is unknown / invalid.

EDataType TEnum::GetUnderlyingType() const
{
if (fInfo)
return gInterpreter->ClassInfo_GetUnderlyingType(fInfo);
return kNumDataTypes;
}

////////////////////////////////////////////////////////////////////////////////

TDictionary::DeclId_t TEnum::GetDeclId() const
Expand All @@ -134,8 +121,10 @@ void TEnum::Update(DeclId_t id)

fInfo = gInterpreter->ClassInfo_Factory(id);

if (fInfo)
if (fInfo) {
SetBit(kBitIsScopedEnum, gInterpreter->ClassInfo_IsScopedEnum(fInfo));
fUnderlyingType = gInterpreter->ClassInfo_GetUnderlyingType(fInfo);
}
}

////////////////////////////////////////////////////////////////////////////////
Expand Down
17 changes: 10 additions & 7 deletions io/io/src/TStreamerInfo.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5589,15 +5589,18 @@ static TStreamerElement* R__CreateEmulatedElement(const char *dmName, const std:
}
TClass *clm = TClass::GetClass(dmType);
if (!clm) {
if (TEnum::GetEnum(dmType, TEnum::kNone)) {
Int_t dtype = kInt_t;
return new TStreamerBasicType(dmName,dmTitle,offset,dtype,dmFull.c_str());
auto enumdesc = TEnum::GetEnum(dmType, TEnum::kNone);
if (enumdesc) {
auto dtype = enumdesc->GetUnderlyingType();
auto el = new TStreamerBasicType(dmName, dmTitle, offset, dtype, dmFull.c_str());
auto datatype = TDataType::GetDataType(dtype);
if (datatype)
el->SetSize(datatype->Size());
else
el->SetSize(sizeof(int)); // Default size of enums.
return el;
}
return nullptr;
// either we have an Emulated enum or a really unknown class!
// let's just claim its an enum :(
//Int_t dtype = kInt_t;
//return new TStreamerBasicType(dmName,dmTitle,offset,dtype,dmFull.c_str());
}
// a pointer to a class
if ( dmIsPtr ) {
Expand Down