36 TListOfTypes::TListOfTypes() : THashTable(100, 3)
39 TDataType::AddBuiltins(
this);
42 TObject *TListOfTypes::FindObject(
const char *name)
const
47 return FindType(name);
50 static bool NameExistsElsewhere(
const char* name){
55 if (gROOT->GetListOfClasses()->FindObject(name) ||
56 TClassTable::GetDictNorm(name) ||
57 TClassTable::GetProtoNorm(name))
return true;
60 TObject* theEnum =
nullptr;
61 const auto lastPos = strrchr(name,
':');
62 if (lastPos !=
nullptr) {
64 const auto enName = lastPos + 1;
65 const auto scopeNameSize = ((Long64_t)lastPos - (Long64_t)name) /
sizeof(decltype(*lastPos)) - 1;
67 char *scopeName =
new char[scopeNameSize + 1];
69 char scopeName[scopeNameSize + 1];
71 strncpy(scopeName, name, scopeNameSize);
72 scopeName[scopeNameSize] =
'\0';
75 if(
auto scope = dynamic_cast<TClass*>(gROOT->GetListOfClasses()->FindObject(scopeName))){
76 theEnum = ((TListOfEnums*)scope->GetListOfEnums(
false))->THashList::FindObject(enName);
80 if (
auto scope = TClassTable::GetProtoNorm(scopeName)){
81 if (
auto listOfEnums = (TListOfEnums*)scope->GetListOfEnums())
82 theEnum = listOfEnums->THashList::FindObject(enName);
89 theEnum = ((TListOfEnums*)gROOT->GetListOfEnums())->THashList::FindObject(name);
92 return nullptr != theEnum;
96 TDataType *TListOfTypes::FindType(
const char *name)
const
101 R__COLLECTION_READ_GUARD();
103 TDataType *result =
static_cast<TDataType*
>(THashTable::FindObject(name));
106 if (NameExistsElsewhere(name)) {
112 R__LOCKGUARD(gInterpreterMutex);
114 TypedefInfo_t *info = gInterpreter->TypedefInfo_Factory(name);
115 if (gInterpreter->TypedefInfo_IsValid(info)) {
116 result =
new TDataType(info);
119 if (strcmp(name,result->GetName()) != 0) {
120 TDataType *alt =
static_cast<TDataType*
>(THashTable::FindObject(result->GetName()));
122 const_cast<TListOfTypes*
>(
this)->Add(result);
128 const_cast<TListOfTypes*
>(
this)->Add(result);
131 gInterpreter->TypedefInfo_Delete(info);