Skip to content

Commit

Permalink
Merge pull request #72 from Dr15Jones/fixBugInLoadingEnums
Browse files Browse the repository at this point in the history
Fix bug in loading of enums into TClass
  • Loading branch information
ktf committed Mar 3, 2015
2 parents 49c149d + 2eee65d commit 709cec3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
3 changes: 2 additions & 1 deletion core/meta/inc/TInterpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class TInterpreterValue;
class TMethod;
class TObjArray;
class TEnum;
class TListOfEnums;

R__EXTERN TVirtualMutex *gInterpreterMutex;

Expand Down Expand Up @@ -245,7 +246,7 @@ class TInterpreter : public TNamed {
virtual DeclId_t GetEnum(TClass *cl, const char *name) const = 0;
virtual TEnum* CreateEnum(void *VD, TClass *cl) const = 0;
virtual void UpdateEnumConstants(TEnum* enumObj, TClass* cl) const = 0;
virtual void LoadEnums(TClass* cl) const = 0;
virtual void LoadEnums(TListOfEnums& cl) const = 0;
virtual DeclId_t GetFunction(ClassInfo_t *cl, const char *funcname) = 0;
virtual DeclId_t GetFunctionWithPrototype(ClassInfo_t *cl, const char* method, const char* proto, Bool_t objectIsConst = kFALSE, ROOT::EFunctionMatchMode mode = ROOT::kConversionMatch) = 0;
virtual DeclId_t GetFunctionWithValues(ClassInfo_t *cl, const char* method, const char* params, Bool_t objectIsConst = kFALSE) = 0;
Expand Down
4 changes: 2 additions & 2 deletions core/meta/src/TClass.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3328,7 +3328,7 @@ TList *TClass::GetListOfEnums(Bool_t load /* = kTRUE */)
}

if(not load) {
if(! ((kIsClass | kIsStruct | kIsUnion) & fProperty) ) {
if(! ((kIsClass | kIsStruct | kIsUnion) & Property()) ) {
R__LOCKGUARD(gInterpreterMutex);
if(fEnums) {
return fEnums.load();
Expand All @@ -3346,7 +3346,7 @@ TList *TClass::GetListOfEnums(Bool_t load /* = kTRUE */)
if(fEnums) {
return fEnums.load();
}
if( (kIsClass | kIsStruct | kIsUnion) & fProperty) {
if( (kIsClass | kIsStruct | kIsUnion) & Property()) {
// For this case, the list will be immutable
temp = new TListOfEnums(this);
} else {
Expand Down
8 changes: 3 additions & 5 deletions core/meta/src/TCling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3167,20 +3167,18 @@ void TCling::CreateListOfBaseClasses(TClass *cl) const
}

//______________________________________________________________________________
void TCling::LoadEnums(TClass* cl) const
void TCling::LoadEnums(TListOfEnums& enumList) const
{
// Create list of pointers to enums for TClass cl.
R__LOCKGUARD2(gInterpreterMutex);

const Decl * D;
TListOfEnums* enumList;
TClass* cl = enumList.GetClass();
if (cl) {
D = ((TClingClassInfo*)cl->GetClassInfo())->GetDecl();
enumList = (TListOfEnums*)cl->GetListOfEnums(false);
}
else {
D = fInterpreter->getCI()->getASTContext().getTranslationUnitDecl();
enumList = (TListOfEnums*)gROOT->GetListOfEnums();
}
// Iterate on the decl of the class and get the enums.
if (const clang::DeclContext* DC = dyn_cast<clang::DeclContext>(D)) {
Expand All @@ -3204,7 +3202,7 @@ void TCling::LoadEnums(TClass* cl) const
if (!buf.empty()) {
const char* name = buf.c_str();
// Add the enum to the list of loaded enums.
enumList->Get(ED, name);
enumList.Get(ED, name);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/meta/src/TCling.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class TCling : public TInterpreter {
virtual DeclId_t GetEnum(TClass *cl, const char *name) const;
virtual TEnum* CreateEnum(void *VD, TClass *cl) const;
virtual void UpdateEnumConstants(TEnum* enumObj, TClass* cl) const;
virtual void LoadEnums(TClass* cl) const;
virtual void LoadEnums(TListOfEnums& cl) const;
TString GetMangledName(TClass* cl, const char* method, const char* params, Bool_t objectIsConst = kFALSE);
TString GetMangledNameWithPrototype(TClass* cl, const char* method, const char* proto, Bool_t objectIsConst = kFALSE, ROOT::EFunctionMatchMode mode = ROOT::kConversionMatch);
void* GetInterfaceMethod(TClass* cl, const char* method, const char* params, Bool_t objectIsConst = kFALSE);
Expand Down
2 changes: 1 addition & 1 deletion core/meta/src/TListOfEnums.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void TListOfEnums::Load()
// We cannot clear the whole unloaded list. It is too much.
// fUnloaded->Clear();

gInterpreter->LoadEnums(fClass);
gInterpreter->LoadEnums(*this);
}

//______________________________________________________________________________
Expand Down

0 comments on commit 709cec3

Please sign in to comment.