9 #include "TBaseClass.h"
11 #include "TClassEdit.h"
12 #include "TClassTable.h"
13 #include "TDataType.h"
14 #include "TDataMember.h"
15 #include "TDictAttributeMap.h"
17 #include "TFunction.h"
18 #include "TInterpreter.h"
20 #include "TMethodArg.h"
32 static const std::string ResolveTypedef(
const std::string& tname )
41 R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
42 tclean = TClassEdit::CleanType( tname.c_str() );
45 TDataType*
dt = gROOT->GetType( tclean.c_str() );
46 if (
dt )
return dt->GetFullTypeName();
51 R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
52 return TClassEdit::ResolveTypedef( tclean.c_str(),
true );
55 static inline const std::string UnqualifiedTypeName(
const std::string&
name )
60 R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
61 return TClassEdit::ShortType(
62 TClassEdit::CleanType(
name.c_str(), 1 ).c_str(), 5 );
67 static std::string map_property(
const std::string&
key )
69 if (
key ==
"ClassID" )
return "id";
77 return fAttributes->HasKey( map_property(
key ).c_str() );
86 return fAttributes->GetPropertyAsString( map_property(
key ).c_str() );
114 TMemberAdapter::operator TMethod*()
const
117 return dynamic_cast< TMethod*
>(
const_cast< TDictionary*
>( fMember ) );
127 TMemberAdapter::operator TFunction*()
const
130 return dynamic_cast< TFunction*
>(
const_cast< TDictionary*
>( fMember ) );
140 TMemberAdapter::operator TDataMember*()
const
143 return dynamic_cast< TDataMember*
>(
const_cast< TDictionary*
>( fMember ) );
153 TMemberAdapter::operator TMethodArg*()
const
156 return dynamic_cast< TMethodArg*
>(
const_cast< TDictionary*
>( fMember ) );
163 TDataMember* dataMember = (TDataMember*)*
this;
166 TClass *tc = TClass::GetClass( dataMember->GetTypeName() );
178 TMethod*
method = (TMethod*)*
this;
180 return method->GetClass();
190 TMethodArg*
arg = (TMethodArg*)*
this;
194 std::string
name =
arg->GetTypeNormalizedName();
204 return ResolveTypedef(
fMember->GetName() );
215 return gInterpreter->GetClassSharedLibs(
Name().c_str() );
222 TDataMember*
dm = (TDataMember*)*
this;
223 return dm ?
dm->GetOffsetCint() : 0;
230 return fMember->Property() & kIsConstMethod;
237 return ((TFunction*)
fMember) ? (((TFunction*)
fMember)->ExtraProperty() & kIsConstructor) : kFALSE;
244 return fMember->Property() & kIsEnum;
251 return fMember->Property() & kIsPublic;
258 return fMember->Property() & kIsStatic;
265 TDataMember*
dm = (TDataMember*)*
this;
266 return dm ? !
dm->IsPersistent() : kTRUE;
274 TFunction* func = (TFunction*)
fMember;
279 return func->GetNargs() - func->GetNargsOpt();
281 return func->GetNargs();
288 return (TMethodArg*)((TFunction*)
fMember)->GetListOfMethodArgs()->At( nth );
296 ((TMethodArg*)((TFunction*)
fMember)->GetListOfMethodArgs()->At( nth ))->GetName();
307 TMethodArg*
arg = (TMethodArg*)((TFunction*)
fMember)->GetListOfMethodArgs()->At( nth );
308 const char* def =
arg->GetDefault();
314 if ( strstr( ResolveTypedef(
arg->GetTypeNormalizedName() ).c_str(),
"char*" ) ) {
315 std::string sdef =
"\"";
335 TMethod*
method = (TMethod*)*
this;
337 return method->GetClass();
340 TDataMember* dataMember = (TDataMember*)*
this;
342 return dataMember->GetClass();
345 return std::string(
"" );
351 return DeclaringScope();
359 return fBase->GetName();
380 if (
fClass.GetClass() != 0 )
387 const char* typname =
name.c_str();
390 if ( strcmp(typname,
"bool") ==0 )
return true;
393 if ( strcmp(typname,
"char") ==0 )
return true;
396 if ( strncmp(typname,
"lib",3) ==0 )
return true;
397 if ( strcmp(typname,
"long") ==0 )
return true;
398 if ( strcmp(typname,
"long long") ==0 )
return true;
399 if ( strcmp(typname,
"long long int") ==0 )
return true;
402 if ( strcmp(typname,
"Long_t") ==0 )
return true;
403 if ( strcmp(typname,
"Long64_t") ==0 )
return true;
406 if ( strcmp(typname,
"int") ==0 )
return true;
407 if ( strcmp(typname,
"__int64") ==0 )
return true;
410 if ( strcmp(typname,
"Int_t") ==0 )
return true;
413 if ( strncmp(typname,
"enum ",5) ==0 )
return true;
416 if ( strcmp(typname,
"double") ==0 )
return true;
419 if ( strcmp(typname,
"Double_t") ==0 )
return true;
422 if ( strcmp(typname,
"float") ==0 )
return true;
425 if ( strcmp(typname,
"Float_t") ==0 )
return true;
428 if( strcmp(typname,
"short") ==0 )
return true;
429 if( strcmp(typname,
"short int") ==0 )
return true;
432 if ( strcmp(typname,
"Short_t") ==0 )
return true;
435 if ( strncmp(typname,
"unknown",7) ==0 )
return true;
436 if ( strcmp(typname,
"unsigned int") ==0 )
return true;
437 if ( strcmp(typname,
"unsigned short") ==0 )
return true;
438 if ( strcmp(typname,
"unsigned long") ==0 )
return true;
439 if ( strcmp(typname,
"unsigned char") ==0 )
return true;
440 if ( strcmp(typname,
"unsigned long long") ==0 )
return true;
441 if ( strcmp(typname,
"unsigned long long int") ==0 )
return true;
450 const char* typname =
name.c_str();
453 if ( strcmp(typname,
"bool") ==0 )
return typeid(
bool);
456 if ( strcmp(typname,
"char") ==0 )
return typeid(
char);
459 if ( strcmp(typname,
"long") ==0 )
return typeid(
long);
460 if ( strcmp(typname,
"long long") ==0 )
return typeid(
long long);
461 if ( strcmp(typname,
"long long int") ==0 )
return typeid(
long long int);
464 if ( strcmp(typname,
"int") ==0 )
return typeid(
int);
467 if ( strcmp(typname,
"double") ==0 )
return typeid(
double);
470 if ( strcmp(typname,
"float") ==0 )
return typeid(
float);
473 if( strcmp(typname,
"short") ==0 )
return typeid(
short);
474 if( strcmp(typname,
"short int") ==0 )
return typeid(
short int);
477 if ( strcmp(typname,
"unsigned char") ==0 )
return typeid(
unsigned char);
478 if ( strcmp(typname,
"unsigned long") ==0 )
return typeid(
unsigned long);
479 if ( strcmp(typname,
"unsigned long long") ==0 )
return typeid(
unsigned long long);
480 if ( strcmp(typname,
"unsigned long long int") ==0 )
return typeid(
unsigned long long int);
481 if ( strcmp(typname,
"unsigned int") ==0 )
return typeid(
unsigned int);
482 if ( strcmp(typname,
"unsigned short") ==0 )
return typeid(
unsigned short);
483 if ( strcmp(typname,
"unsigned short int") ==0 )
return typeid(
unsigned short int);
486 if ( strcmp(typname,
"void") ==0 )
return typeid(
void);
489 cerr <<
"WARNING! RootType getting typeinfo failed for: " << typname << endl;
516 const string anonnmsp(
"(anonymous)");
528 fClass = TClassRef( scoped_name.c_str() );
535 if( gROOT->GetType(
name.c_str()) ) {
537 }
else if( TEnum::GetEnum(
name.c_str(),
load ? TEnum::kALoadAndInterpLookup : TEnum::kNone) ) {
546 : fClass (TClassRef( TClass::GetClass(typeinfo) ) )
552 if (!
fClass.GetClass()->HasDictionary()) {
553 fClass = TClassRef( TClass::GetClass(typeinfo) );
558 size_t len =
sizeof(
buff);
560 fName = __cxxabiv1::__cxa_demangle(typeinfo.name(),
buff, &len, &
status);
582 const std::string&
name, Bool_t
load )
590 R__READ_LOCKGUARD (ROOT::gCoreMutex);
591 const char *
class_name = gClassTable->At( nth );
601 R__READ_LOCKGUARD (ROOT::gCoreMutex);
603 return tab ? tab->Classes() : 0;
630 for ( std::string::size_type
pos =
name.size() - 1; 0 <
pos; --
pos ) {
631 std::string::value_type
c =
name[
pos ];
638 else if ( tpl_open == 0 &&
c ==
':' && 0 <
pos &&
name[
pos-1 ] ==
':' ) {
653 std::string::size_type
pos =
name.rfind(
"::" );
654 if (
pos == std::string::npos )
656 TClass::GetClass( gInterpreter->ClassInfo_Factory(
"" ) ) );
668 return (place &&
fClass.GetClass())?
fClass.GetClass()->New(place) : 0;
674 if (place &&
fClass.GetClass())
fClass.GetClass()->Destructor(place);
684 return *
fClass.GetClass()->GetTypeInfo();
701 return *
fName.rbegin() ==
'*';
723 return fClass->GetClassInfo() == gInterpreter->ClassInfo_Factory(
"" );
735 return fClass.GetClass()?
fClass.GetClass()->Property() & kIsEnum :
false;
740 return fClass.GetClass()?
fClass.GetClass()->Property() & kIsTypedef :
false;
745 return fClass.GetClass()?
fClass.GetClass()->Property() & kIsArray :
false;
752 if (
fClass.GetClass() &&
fClass->GetListOfBases() != 0 )
753 return fClass->GetListOfBases()->GetSize();
763 return fClass.GetClass()->Size();
765 const TDataType* fundType = gROOT->GetType(
fName.c_str());
767 return fundType->Size();
776 return (TBaseClass*)
fClass->GetListOfBases()->At( nth );
784 return fClass->GetListOfMethods()->GetSize();
793 return (TMethod*)
fClass->GetListOfMethods()->At( nth );
801 return fClass->GetListOfDataMembers()->GetSize();
810 return (TDataMember*)
fClass->GetListOfDataMembers()->At( nth );
819 size_t tpl_open = 0, argcount = 0;
820 std::string::size_type last = 0;
821 for ( std::string::size_type
pos = 0;
pos <
name.size(); ++
pos ) {
822 std::string::value_type
c =
name[
pos];
827 if (tpl_open == 1) last =
pos+1;
829 }
else if (
c ==
'>') {
832 if ((
c ==
',' && tpl_open == 1) || (
c ==
'>' && tpl_open == 0)) {
833 if ( argcount++ == nth ) {
837 R__WRITE_LOCKGUARD(ROOT::gCoreMutex);
839 TClassEdit::CleanType(
name.substr(last,
pos-last).c_str(), 1 );
847 assert( !
"miscount between TemplateArgumentSize() and TemplateArgumentAt()" );
856 size_t tpl_open = 0, argcount = 0;
857 for ( std::string::size_type
pos = 0;
pos <
name.size(); ++
pos ) {
858 std::string::value_type
c =
name[
pos];
864 }
else if (
c ==
'>' )
867 if ((
c ==
',' && tpl_open == 1) || (
c ==
'>' && tpl_open == 0))
874 TScopeAdapter::operator Bool_t()
const
877 if(
fName.empty() )
return false;
878 if( fIsFundamental )
return true;
881 TClass*
klass = fClass.GetClass();
882 if( !
klass )
return false;
883 if(
klass->HasDictionary() )
return true;
895 TClass*
klass = TClass::GetClass( scname.c_str(),
true,
true );
898 b =
klass->HasDictionary();
901 ClassInfo_t* ci = gInterpreter->ClassInfo_Factory( scname.c_str() );
903 b = gInterpreter->ClassInfo_IsLoaded( ci );
904 gInterpreter->ClassInfo_Delete( ci );
914 if (
fClass.GetClass() ) {
917 return (
fClass->Property() & kIsClass) || ! (
fClass->Property() & kIsFundamental);
929 if (
fClass.GetClass() ) {
931 return (
fClass->Property() & kIsStruct) || ! (
fClass->Property() & kIsFundamental);
943 return fClass->Property() & kIsNamespace;
953 return fClass->Property() & kIsAbstract;