26 ClassImp(TListOfFunctions);
31 TListOfFunctions::TListOfFunctions(TClass *cl) : fClass(cl),fIds(0),fUnloaded(0),fLastLoadMarker(0)
34 fUnloaded =
new THashList;
40 TListOfFunctions::~TListOfFunctions()
51 void TListOfFunctions::MapObject(TObject *obj)
53 TFunction *f =
dynamic_cast<TFunction*
>(obj);
55 fIds->Add((Long64_t)f->GetDeclId(),(Long64_t)f);
62 void TListOfFunctions::AddFirst(TObject *obj)
64 THashList::AddFirst(obj);
75 void TListOfFunctions::AddFirst(TObject *obj, Option_t *opt)
77 THashList::AddFirst(obj,opt);
84 void TListOfFunctions::AddLast(TObject *obj)
86 THashList::AddLast(obj);
97 void TListOfFunctions::AddLast(TObject *obj, Option_t *opt)
99 THashList::AddLast(obj, opt);
106 void TListOfFunctions::AddAt(TObject *obj, Int_t idx)
108 THashList::AddAt(obj, idx);
115 void TListOfFunctions::AddAfter(
const TObject *after, TObject *obj)
117 THashList::AddAfter(after, obj);
124 void TListOfFunctions::AddAfter(TObjLink *after, TObject *obj)
126 THashList::AddAfter(after, obj);
133 void TListOfFunctions::AddBefore(
const TObject *before, TObject *obj)
135 THashList::AddBefore(before, obj);
142 void TListOfFunctions::AddBefore(TObjLink *before, TObject *obj)
144 THashList::AddBefore(before, obj);
152 void TListOfFunctions::Clear(Option_t *option)
154 fUnloaded->Clear(option);
156 THashList::Clear(option);
162 void TListOfFunctions::Delete(Option_t *option )
164 fUnloaded->Delete(option);
166 THashList::Delete(option);
173 TObject *TListOfFunctions::FindObject(
const char *name)
const
175 R__LOCKGUARD(gInterpreterMutex);
176 TObject *result = THashList::FindObject(name);
179 TInterpreter::DeclId_t decl;
180 if (fClass) decl = gInterpreter->GetFunction(fClass->GetClassInfo(),name);
181 else decl = gInterpreter->GetFunction(0,name);
182 if (decl) result =
const_cast<TListOfFunctions*
>(
this)->Get(decl);
191 TList* TListOfFunctions::GetListForObjectNonConst(
const char* name)
193 R__LOCKGUARD(gInterpreterMutex);
195 TList* overloads = (TList*)fOverloads.FindObject(name);
197 Bool_t wasEmpty =
true;
199 overloads =
new TList();
200 overloads->SetName(name);
201 fOverloads.Add(overloads);
203 TIter iOverload(overloads);
204 while (TFunction* over = (TFunction*)iOverload()) {
206 overloadsSet.Add((Long64_t)(ULong64_t)over->GetDeclId(),
207 (Long64_t)(ULong64_t)over);
212 std::vector<DeclId_t> overloadDecls;
213 ClassInfo_t* ci = fClass ? fClass->GetClassInfo() : 0;
214 gInterpreter->GetFunctionOverloads(ci, name, overloadDecls);
215 for (std::vector<DeclId_t>::const_iterator iD = overloadDecls.begin(),
216 eD = overloadDecls.end(); iD != eD; ++iD) {
217 TFunction* over = Get(*iD);
218 if (wasEmpty || !overloadsSet.GetValue((Long64_t)(ULong64_t)over->GetDeclId())) {
219 overloads->Add(over);
230 TList* TListOfFunctions::GetListForObject(
const char* name)
const
232 return const_cast<TListOfFunctions*
>(
this)->GetListForObjectNonConst(name);
239 TList* TListOfFunctions::GetListForObject(
const TObject* obj)
const
242 return const_cast<TListOfFunctions*
>(
this)
243 ->GetListForObjectNonConst(obj->GetName());
250 TFunction *TListOfFunctions::Find(DeclId_t
id)
const
254 R__LOCKGUARD(gInterpreterMutex);
255 return (TFunction*)fIds->GetValue((Long64_t)
id);
262 TFunction *TListOfFunctions::Get(DeclId_t
id)
266 R__LOCKGUARD(gInterpreterMutex);
268 TFunction *f = Find(
id);
272 if (!gInterpreter->ClassInfo_Contains(fClass->GetClassInfo(),id))
return 0;
274 if (!gInterpreter->ClassInfo_Contains(0,
id))
return 0;
277 MethodInfo_t *m = gInterpreter->MethodInfo_Factory(
id);
280 const char *name = gInterpreter->MethodInfo_Name(m);
281 if (
const TList* bucketForMethod = fUnloaded->GetListForObject(name)) {
282 TString mangledName( gInterpreter->MethodInfo_GetMangledName(m) );
283 TIter next(bucketForMethod);
285 while ((uf = (TFunction *) next())) {
286 if (uf->GetMangledName() == mangledName) {
288 fUnloaded->Remove(uf);
297 if (fClass) f =
new TMethod(m, fClass);
298 else f =
new TFunction(m);
302 THashList::AddLast(f);
303 fIds->Add((Long64_t)
id,(Long64_t)f);
311 void TListOfFunctions::UnmapObject(TObject *obj)
313 TFunction *f =
dynamic_cast<TFunction*
>(obj);
315 fIds->Remove((Long64_t)f->GetDeclId());
328 void TListOfFunctions::RecursiveRemove(TObject *obj)
332 THashList::RecursiveRemove(obj);
333 fUnloaded->RecursiveRemove(obj);
341 TObject* TListOfFunctions::Remove(TObject *obj)
345 found = THashList::Remove(obj);
347 found = fUnloaded->Remove(obj);
350 if (found)
return obj;
357 TObject* TListOfFunctions::Remove(TObjLink *lnk)
361 TObject *obj = lnk->GetObject();
363 THashList::Remove(lnk);
364 fUnloaded->Remove(obj);
374 void TListOfFunctions::Load()
376 if (fClass && fClass->GetClassInfo() == 0)
return;
378 R__LOCKGUARD(gInterpreterMutex);
380 ULong64_t currentTransaction = gInterpreter->GetInterpreterStateMarker();
381 if (currentTransaction == fLastLoadMarker) {
384 fLastLoadMarker = currentTransaction;
387 if (fClass) info = fClass->GetClassInfo();
388 else info = gInterpreter->ClassInfo_Factory();
390 MethodInfo_t *t = gInterpreter->MethodInfo_Factory(info);
391 while (gInterpreter->MethodInfo_Next(t)) {
392 if (gInterpreter->MethodInfo_IsValid(t)) {
393 TDictionary::DeclId_t mid = gInterpreter->GetDeclId(t);
399 gInterpreter->MethodInfo_Delete(t);
400 if (!fClass) gInterpreter->ClassInfo_Delete(info);
409 void TListOfFunctions::Unload()
411 TObjLink *lnk = FirstLink();
413 TFunction *func = (TFunction*)lnk->GetObject();
415 fIds->Remove((Long64_t)func->GetDeclId());
416 fUnloaded->Add(func);
430 void TListOfFunctions::Unload(TFunction *func)
432 if (THashList::Remove(func)) {
436 fIds->Remove((Long64_t)func->GetDeclId());
437 fUnloaded->Add(func);
443 TObject* TListOfFunctions::FindObject(
const TObject* obj)
const
445 R__LOCKGUARD(gInterpreterMutex);
446 return THashList::FindObject(obj);
451 TIterator* TListOfFunctions::MakeIterator(Bool_t dir )
const
453 R__LOCKGUARD(gInterpreterMutex);
454 return new TListOfFunctionsIter(
this,dir);
459 TObject* TListOfFunctions::At(Int_t idx)
const
461 R__LOCKGUARD(gInterpreterMutex);
462 return THashList::At(idx);
467 TObject* TListOfFunctions::After(
const TObject *obj)
const
469 R__LOCKGUARD(gInterpreterMutex);
470 return THashList::After(obj);
475 TObject* TListOfFunctions::Before(
const TObject *obj)
const
477 R__LOCKGUARD(gInterpreterMutex);
478 return THashList::Before(obj);
483 TObject* TListOfFunctions::First()
const
485 R__LOCKGUARD(gInterpreterMutex);
486 return THashList::First();
491 TObjLink* TListOfFunctions::FirstLink()
const
493 R__LOCKGUARD(gInterpreterMutex);
494 return THashList::FirstLink();
499 TObject** TListOfFunctions::GetObjectRef(
const TObject *obj)
const
501 R__LOCKGUARD(gInterpreterMutex);
502 return THashList::GetObjectRef(obj);
507 TObject* TListOfFunctions::Last()
const
509 R__LOCKGUARD(gInterpreterMutex);
510 return THashList::Last();
515 TObjLink* TListOfFunctions::LastLink()
const
517 R__LOCKGUARD(gInterpreterMutex);
518 return THashList::LastLink();
524 Int_t TListOfFunctions::GetLast()
const
526 R__LOCKGUARD(gInterpreterMutex);
527 return THashList::GetLast();
532 Int_t TListOfFunctions::IndexOf(
const TObject *obj)
const
534 R__LOCKGUARD(gInterpreterMutex);
535 return THashList::IndexOf(obj);
541 Int_t TListOfFunctions::GetSize()
const
543 R__LOCKGUARD(gInterpreterMutex);
544 return THashList::GetSize();
551 ClassImp(TListOfFunctionsIter);
555 TListOfFunctionsIter::TListOfFunctionsIter(
const TListOfFunctions *l, Bool_t dir ):
560 TObject *TListOfFunctionsIter::Next()
562 R__LOCKGUARD(gInterpreterMutex);
563 return TListIter::Next();