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
3 changes: 2 additions & 1 deletion core/base/inc/TROOT.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class TClassGenerator;
class TVirtualMutex;
class TROOT;
class TListOfDataMembers;
class TListOfEnums;
class TListOfFunctions;
class TFunctionTemplate;

Expand Down Expand Up @@ -221,7 +222,7 @@ friend TROOT *ROOT::GetROOT2();
TSeqCollection *GetListOfProofs() const { return fProofs; }
TSeqCollection *GetClipboard() const { return fClipboard; }
TSeqCollection *GetListOfDataSets() const { return fDataSets; }
TCollection *GetListOfEnums() const { return fEnums; }
TCollection *GetListOfEnums();
TList *GetListOfBrowsables() const { return fBrowsables; }
TDataType *GetType(const char *name, Bool_t load = kFALSE) const;
TFile *GetFile() const { if (gDirectory != this) return gDirectory->GetFile(); else return 0;}
Expand Down
11 changes: 10 additions & 1 deletion core/base/src/TROOT.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
#include "TInterpreter.h"
#include "TListOfTypes.h"
#include "TListOfDataMembers.h"
#include "TListOfEnums.h"
#include "TListOfFunctions.h"
#include "TFunctionTemplate.h"

Expand Down Expand Up @@ -422,7 +423,6 @@ TROOT::TROOT(const char *name, const char *title, VoidFuncPtr_t *initfunc)
//fIdMap = new IdMap_t;
fStreamerInfo = new TObjArray(100);
fClassGenerators = new TList;
fEnums = new THashTable(200, 3); // FIXME: should be 1.2 * number of ROOT global enums at startup

// initialize plugin manager early
fPluginManager->LoadHandlersFromEnv(gEnv);
Expand Down Expand Up @@ -1359,6 +1359,15 @@ TObject *TROOT::GetGeometry(const char *name) const
return GetListOfGeometries()->FindObject(name);
}

//______________________________________________________________________________
TCollection *TROOT::GetListOfEnums()
{
if(!fEnums) {
fEnums = new TListOfEnums(0);
}
return fEnums;
}

//______________________________________________________________________________
TCollection *TROOT::GetListOfGlobals(Bool_t load)
{
Expand Down
1 change: 1 addition & 0 deletions core/meta/inc/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@
#pragma link C++ class TFileMergeInfo;
#pragma link C++ class TListOfFunctions+;
#pragma link C++ class TListOfDataMembers;
#pragma link C++ class TListOfEnums+;

#endif
5 changes: 3 additions & 2 deletions core/meta/inc/TClass.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ class TVirtualRefProxy;
class THashTable;
class TListOfFunctions;
class TListOfDataMembers;
class TListOfEnums;
class TViewPubFunctions;
class TViewPubDataMembers;
class TFunctionTemplate;
Expand Down Expand Up @@ -114,7 +115,7 @@ friend class ROOT::TGenericClassInfo;
TList *fRealData; //linked list for persistent members including base classes
TList *fBase; //linked list for base classes
TListOfDataMembers*fData; //linked list for data members
TList *fEnums; //linked list for the enums
TListOfEnums *fEnums; //linked list for the enums
TList *fFuncTemplate; //linked list for function templates [Not public until implemented as active list]
TListOfFunctions *fMethod; //linked list for methods
TViewPubDataMembers*fAllPubData; //all public data members (including from base classes)
Expand Down Expand Up @@ -296,7 +297,7 @@ friend class ROOT::TGenericClassInfo;
else return (fCurrentInfo=(TVirtualStreamerInfo*)(fStreamerInfo->At(fClassVersion)));
}
TList *GetListOfDataMembers(Bool_t load = kTRUE);
TList *GetListOfEnums();
TList *GetListOfEnums(Bool_t load = kTRUE);
TList *GetListOfBases();
TList *GetListOfMethods(Bool_t load = kTRUE);
TCollection *GetListOfMethodOverloads(const char* name) const;
Expand Down
17 changes: 13 additions & 4 deletions core/meta/inc/TEnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,19 @@
#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef ROOT_TDictionary
#include "TDictionary.h"
#endif



class TClass;
class TEnumConstant;

class TEnum : public TNamed {

typedef TDictionary::DeclId_t DeclId_t;

private:
THashList fConstantList; //list of constants the enum type
void* fInfo; //interpreter implementation provided declaration
Expand All @@ -43,15 +50,17 @@ class TEnum : public TNamed {
public:

TEnum(): fInfo(0) {}
TEnum(const char* name, bool isGlobal, void* info, TClass* cls);
TEnum(const char* name, void* info, TClass* cls);
virtual ~TEnum();

void AddConstant(TEnumConstant* constant);
TClass* GetClass() const { return fClass; }
void AddConstant(TEnumConstant* constant);
TClass* GetClass() const { return fClass; }
const TSeqCollection* GetConstants() const { return &fConstantList; }
const TEnumConstant* GetConstant(const char* name) const {
const TEnumConstant* GetConstant(const char* name) const {
return (TEnumConstant*) fConstantList.FindObject(name);
}
DeclId_t GetDeclId() const { return (DeclId_t)fInfo; }
void Update(DeclId_t id);

ClassDef(TEnum,2) //Enum type class
};
Expand Down
1 change: 0 additions & 1 deletion core/meta/inc/TEnumConstant.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class TEnumConstant : public TGlobal {

Long64_t GetValue() const { return fValue; }
const TEnum *GetType() const { return fEnum; }
virtual bool Update(DataMemberInfo_t *info);

ClassDef(TEnumConstant,1) //Enum type constant
};
Expand Down
6 changes: 5 additions & 1 deletion core/meta/inc/TInterpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class TInterpreterValue;
class TMethod;
class TObjArray;
class TVirtualMutex;
class TEnum;

R__EXTERN TVirtualMutex *gInterpreterMutex;

Expand Down Expand Up @@ -160,7 +161,6 @@ class TInterpreter : public TNamed {
virtual Bool_t CheckClassTemplate(const char *name) = 0;
virtual Long_t Calc(const char *line, EErrorCode* error = 0) = 0;
virtual void CreateListOfBaseClasses(TClass *cl) const = 0;
virtual void CreateListOfEnums(TClass *cl) const = 0;
virtual void CreateListOfDataMembers(TClass *cl) const = 0;
virtual void CreateListOfMethods(TClass *cl) const = 0;
virtual void CreateListOfMethodArgs(TFunction *m) const = 0;
Expand Down Expand Up @@ -226,6 +226,10 @@ class TInterpreter : public TNamed {
virtual DeclId_t GetDataMember(ClassInfo_t *cl, const char *name) const = 0;
virtual DeclId_t GetDataMemberAtAddr(const void *addr) const = 0;
virtual DeclId_t GetDataMemberWithValue(const void *ptrvalue) const = 0;
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 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
84 changes: 84 additions & 0 deletions core/meta/inc/TListOfEnums.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// @(#)root/cont
// Author: Bianca-Cristina Cristescu February 2014

/*************************************************************************
* Copyright (C) 1995-2013, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/

#ifndef ROOT_TListOfEnums
#define ROOT_TListOfEnums

//////////////////////////////////////////////////////////////////////////
// //
// TListOfEnums //
// //
// A collection of TEnum objects designed for fast access given a //
// DeclId_t and for keep track of TEnum that were described //
// unloaded enum. //
// //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_THastList
#include "THashList.h"
#endif

#ifndef ROOT_TDictionary
#include "TDictionary.h"
#endif

class TExMap;
class TEnum;

class TListOfEnums : public THashList
{
private:
typedef TDictionary::DeclId_t DeclId_t;
TClass *fClass; // Context of this list. Not owned.

TExMap *fIds; // Map from DeclId_t to TEnum*
THashList *fUnloaded; // Holder of TEnum for unloaded Enums.
Bool_t fIsLoaded; // Mark whether Load was executed.

TListOfEnums(const TListOfEnums&); // not implemented
TListOfEnums& operator=(const TListOfEnums&); // not implemented

public:

TListOfEnums(TClass *cl);
~TListOfEnums();

virtual void Clear(Option_t *option);
virtual void Delete(Option_t *option="");

using THashList::FindObject;
virtual TObject *FindObject(const char *name) const;

TEnum *Get(DeclId_t id, const char *name);

Bool_t IsLoaded() const { return fIsLoaded; }
void AddFirst(TObject *obj);
void AddFirst(TObject *obj, Option_t *opt);
void AddLast(TObject *obj);
void AddLast(TObject *obj, Option_t *opt);
void AddAt(TObject *obj, Int_t idx);
void AddAfter(const TObject *after, TObject *obj);
void AddAfter(TObjLink *after, TObject *obj);
void AddBefore(const TObject *before, TObject *obj);
void AddBefore(TObjLink *before, TObject *obj);

void RecursiveRemove(TObject *obj);
TObject *Remove(TObject *obj);
TObject *Remove(TObjLink *lnk);

void Load();
void Unload();
void Unload(TEnum *e);

ClassDef(TListOfEnums,0); // List of TDataMembers for a class
};

#endif // ROOT_TListOfEnums
18 changes: 7 additions & 11 deletions core/meta/src/TClass.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

#include "TListOfDataMembers.h"
#include "TListOfFunctions.h"
#include "TListOfEnums.h"
#include "TViewPubDataMembers.h"
#include "TViewPubFunctions.h"

Expand Down Expand Up @@ -3133,22 +3134,14 @@ TList *TClass::GetListOfBases()
}

//______________________________________________________________________________
TList *TClass::GetListOfEnums()
TList *TClass::GetListOfEnums(Bool_t load /* = kTRUE */)
{
// Return list containing the TEnums of a class.

R__LOCKGUARD(gInterpreterMutex);
if (!fClassInfo) {
if (!fEnums) fEnums = new TList;
return fEnums;
}

if (!fEnums) {
if (!gInterpreter)
Fatal("GetListOfEnums", "gInterpreter not initialized");

gInterpreter->CreateListOfEnums(this);
}
if (!fEnums) fEnums = new TListOfEnums(this);
if (load) fEnums->Load();
return fEnums;
}

Expand Down Expand Up @@ -5010,6 +5003,9 @@ void TClass::SetUnloaded()
if (fData) {
fData->Unload();
}
if (fEnums) {
fEnums->Unload();
}

if (fState <= kForwardDeclared && fStreamerInfo->GetEntries() != 0) {
fState = kEmulated;
Expand Down
Loading