62 {
"auto_ptr",
"shared_ptr",
"weak_ptr",
"unique_ptr" };
68 class ApplicationStarter {
70 ApplicationStarter() {
82 ~ApplicationStarter() {
86 } _applicationStarter;
95 assert( (ClassRefs_t::size_type) scope <
g_classrefs.size() );
96 return g_classrefs[ (ClassRefs_t::size_type)scope ];
135 if ( name.find(
"::") == std::string::npos )
142 if( name.size() == 0)
return name;
145 for ( std::string::size_type pos = name.size() - 1; pos > 0; pos-- ) {
146 std::string::value_type
c = name[pos];
153 else if ( tpl_open == 0 && c ==
':'&& name[ pos - 1 ] ==
':' ) {
155 return name.substr( pos+1 );
167 if ( dt )
return dt->GetFullTypeName();
173 std::string scope_name;
174 if ( sname.find(
"std::", 0, 5 ) == 0 )
175 scope_name = sname.substr( 5, std::string::npos );
206 if ( clActual && clActual != cr.
GetClass() ) {
238 ClassInfo_t* ci =
gInterpreter->ClassInfo_Factory( type_name.c_str() );
276 static ClassInfo_t* gcl =
gInterpreter->ClassInfo_Factory();
286 CallFunc_t* callf =
nullptr;
288 std::string callString =
"";
299 TIter iarg( method_args );
304 if ( callString.empty() )
305 callString = fullType;
307 callString +=
", " + fullType;
340 if ( !( callf &&
gInterpreter->CallFunc_IsValid( callf ) ) ) {
341 PyErr_Format( PyExc_RuntimeError,
"could not resolve %s::%s(%s)",
342 const_cast<TClassRef&>(klass).GetClassName(),
344 callString.c_str() );
353 static inline void copy_args(
void* args_,
void** vargs ) {
354 std::vector<TParameter>& args = *(std::vector<TParameter>*)args_;
355 for ( std::vector<TParameter>::size_type i = 0; i < args.size(); ++i ) {
356 switch ( args[i].fTypeCode ) {
358 vargs[i] = (
void*)&args[i].
fValue.fLong;
361 vargs[i] = (
void*)&args[i].fValue.fFloat;
364 vargs[i] = (
void*)&args[i].
fValue.fDouble;
367 vargs[i] = (
void*)&args[i].fValue.fLongDouble;
373 vargs[i] = (
void*)&args[i].
fValue.fVoidp;
376 vargs[i] = args[i].fValue.fVoidp;
379 vargs[i] = args[i].fRef;
382 std::cerr <<
"unknown type code: " << args[i].fTypeCode << std::endl;
391 const std::vector<TParameter>& args = *(std::vector<TParameter>*)args_;
404 std::vector<void*> buf( args.size() );
415 faceptr.
fCtor( (
void**)smallbuf, result, args.size() );
417 std::vector<void*> buf( args.size() );
425 std::cerr <<
" DESTRUCTOR NOT IMPLEMENTED YET! " << std::endl;
432 template<
typename T >
436 if (
FastCall( method, args, (
void*)
self, &t ) )
441 #define CPPYY_IMP_CALL( typecode, rtype ) \ 442 rtype Cppyy::Call##typecode( TCppMethod_t method, TCppObject_t self, void* args )\ 444 return CallT< rtype >( method, self, args ); \ 449 if ( !
FastCall( method, args, (
void*)
self,
nullptr ) )
466 if (
FastCall( method, args, (
void*)
self, &
r ) )
474 if (
FastCall( method, args, (
void*)
self, &s ) )
482 if (
FastCall( method, args,
nullptr, &obj ) )
499 if (
FastCall( method, args,
self, obj ) )
551 return gInterpreter->ClassInfo_IsEnum( type_name.c_str() );
595 if ( derived == base )
609 const std::string& real_name =
ResolveName( type_name );
610 return gSmartPtrTypes.find(
611 real_name.substr( 0,real_name.find(
"<" ) ) ) != gSmartPtrTypes.end();
619 if ( derived == base || !(base && derived) )
635 std::ostringstream msg;
636 msg <<
"failed offset calculation between " << cb->
GetName() <<
" and " << cd->
GetName();
637 PyErr_Warn( PyExc_RuntimeWarning, const_cast<char*>( msg.str().c_str() ) );
641 return rerror ? (ptrdiff_t)offset : 0;
647 return rerror ? (ptrdiff_t)offset : 0;
649 return (ptrdiff_t)(direction < 0 ? -offset : offset);
661 if ( clName.find(
'<' ) != std::string::npos ) {
664 clName =
"std::" + clName;
665 std::ostringstream stmt;
666 stmt <<
"template class " << clName <<
";";
691 std::vector< TCppMethod_t > methods;
701 std::string fn = func->
GetName();
702 if ( fn.rfind( name, 0 ) == 0 ) {
704 if ( (name.size() == fn.size()) ||
705 (name.size() < fn.size() && fn[name.size()] ==
'<') ) {
744 return "constructor";
819 return (name[name.size()-1] ==
'>') && (name.find(
'<') != std::string::npos);
877 std::cerr <<
" global data should be retrieved lazily " << std::endl;
911 if ( fullType[fullType.size()-1] ==
'*' && \
912 fullType.find(
"char", 0, 4 ) == std::string::npos )
913 fullType.append(
"*" );
915 fullType.append(
"*" );
917 std::ostringstream s;
918 s <<
'[' << gbl->
GetMaxIndex( 0 ) <<
']' << std::ends;
919 fullType.append( s.str() );
929 fullType.append(
"*" );
931 std::ostringstream s;
932 s <<
'[' << m->
GetMaxIndex( 0 ) <<
']' << std::ends;
933 fullType.append( s.str() );
virtual const char * GetName() const
Returns name of object.
std::map< std::string, ClassRefs_t::size_type > Name2ClassRefIndex_t
std::string GetName(const std::string &scope_name)
size_t GetFunctionArgSizeof()
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
std::string GetScopedFinalName(TCppType_t type)
std::vector< TClassRef > ClassRefs_t
virtual Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
R__EXTERN Int_t gErrorIgnoreLevel
std::vector< TGlobal *> GlobalVars_t
virtual const char * GetFullTypeName() const
Get full type description of global variable, e,g.: "class TDirectory*".
virtual CallFuncIFacePtr_t CallFunc_IFacePtr(CallFunc_t *) const
static ClassRefs_t g_classrefs(1)
Bool_t IsNamespace(TCppScope_t scope)
Long_t GetOffsetCint() const
Get offset from "this" using the information in CINT only.
R__EXTERN TClassTable * gClassTable
RooArgList L(const RooAbsArg &v1)
Bool_t IsBuiltin(const std::string &type_name)
TCppIndex_t GetGlobalOperator(TCppType_t scope, TCppType_t lc, TCppScope_t rc, const std::string &op)
All ROOT classes may have RTTI (run time type identification) support added.
Bool_t IsMethodTemplate(TCppMethod_t)
ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
Bool_t IsPublicMethod(TCppMethod_t method)
static void copy_args(void *args_, void **vargs)
TCppIndex_t GetNumBases(TCppType_t type)
TCppIndex_t GetMethodReqArgs(TCppMethod_t)
std::vector< TCppMethod_t > GetMethodsFromName(TCppScope_t scope, const std::string &name)
TList * GetListOfDataMembers(Bool_t load=kTRUE)
Return list containing the TDataMembers of a class.
Bool_t IsAbstract(TCppType_t type)
std::string GetFinalName(TCppType_t type)
std::string GetMethodSignature(TCppScope_t scope, TCppIndex_t imeth)
std::string CleanType(const char *typeDesc, int mode=0, const char **tail=0)
Cleanup type description, redundant blanks removed and redundant tail ignored return *tail = pointer ...
virtual void * GetAddress() const
Return address of global.
ptrdiff_t GetDatamemberOffset(TCppScope_t scope, TCppIndex_t idata)
struct staticInitHelper gbl
static GlobalFuncs_t g_globalfuncs
Bool_t IsEnumData(TCppScope_t scope, TCppIndex_t idata)
std::string GetDatamemberType(TCppScope_t scope, TCppIndex_t idata)
Each ROOT method (see TMethod) has a linked list of its arguments.
TCppIndex_t GetNumScopes(TCppScope_t parent)
Bool_t FastCall(Cppyy::TCppMethod_t method, void *args_, void *self, void *result)
TCppObject_t CallO(TCppMethod_t method, TCppObject_t self, void *args, TCppType_t result_type)
Int_t GetDimensionSize(TCppScope_t scope, TCppIndex_t idata, int dimension)
virtual Long_t Property() const
Get property description word. For meaning of bits see EProperty.
#define CPPYY_IMP_CALL(typecode, rtype)
TCppObject_t CallConstructor(TCppMethod_t method, TCppType_t type, void *args)
std::string GetBaseName(TCppType_t type, TCppIndex_t ibase)
TClass * GetClass() const
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Char_t * CallS(TCppMethod_t method, TCppObject_t self, void *args)
TCppIndex_t GetMethodIndexAt(TCppScope_t scope, TCppIndex_t imeth)
static TFunction * type_get_method(Cppyy::TCppType_t klass, Cppyy::TCppIndex_t idx)
TCppIndex_t GetMethodNumTemplateArgs(TCppScope_t scope, TCppIndex_t imeth)
TCppType_t GetTemplate(const std::string &template_name)
Bool_t IsBasic() const
Return true if data member is a basic type, e.g. char, int, long...
std::string ResolveName(const std::string &cppitem_name)
Bool_t HasComplexHierarchy(TCppType_t type)
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
std::string GetReturnTypeNormalizedName() const
Get the normalized name of the return type.
TCppMethPtrGetter_t GetMethPtrGetter(TCppScope_t scope, TCppIndex_t imeth)
std::string ResolveTypedef(const char *tname, bool resolveAll=false)
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
TCppIndex_t GetNumDatamembers(TCppScope_t scope)
ClassInfo_t * GetClassInfo() const
Bool_t IsConstData(TCppScope_t scope, TCppIndex_t idata)
static Method2CallFunc_t g_method2callfunc
void CallDestructor(TCppType_t type, TCppObject_t self)
static std::set< std::string > gSmartPtrTypes
std::string GetTypeNormalizedName() const
Get the normalized name of the return type.
Bool_t IsComplete(const std::string &type_name)
TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
size_t GetFunctionArgTypeoffset()
std::string GetMethodTemplateArgName(TCppScope_t scope, TCppIndex_t imeth, TCppIndex_t iarg)
Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
TClass * GetBaseClass(const char *classname)
Return pointer to the base class "classname".
Bool_t IsConstructor(TCppMethod_t method)
TCppType_t GetActualClass(TCppType_t klass, TCppObject_t obj)
PyROOT::TParameter TParameter
Named parameter, streamable and storable.
void AddSmartPtrType(const std::string &)
Int_t GetNargs() const
Number of function arguments.
Bool_t IsPublicData(TCppScope_t scope, TCppIndex_t idata)
std::string GetMethodName(TCppMethod_t)
Basic data type descriptor (datatype information is obtained from CINT).
TClass * GetActualClass(const void *object) const
Return a pointer the the real class of the object.
Collection abstract base class.
void Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
void * AllocateFunctionArgs(size_t nargs)
Int_t Size() const
Return size of object of this class.
static CallFunc_t * GetCallFunc(Cppyy::TCppMethod_t method)
static GlobalVars_t g_globalvars
TCppIndex_t GetDatamemberIndex(TCppScope_t scope, const std::string &name)
Int_t GetArrayDim() const
Return number of array dimensions.
The ROOT global object gROOT contains a list of all defined classes.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Global variables class (global variables are obtained from CINT).
virtual Int_t GetArrayDim() const
Return number of array dimensions.
static const ClassRefs_t::size_type GLOBAL_HANDLE
Long_t Property() const
Set TObject::fBits and fStreamerType to cache information about the class.
Each class (see TClass) has a linked list of its base class(es).
const char * GetTrueTypeName() const
Get full type description of data member, e,g.: "class TDirectory*".
void * CallR(TCppMethod_t method, TCppObject_t self, void *args)
Bool_t IsSubtype(TCppType_t derived, TCppType_t base)
static TClassRef & type_from_handle(Cppyy::TCppScope_t scope)
static T CallT(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, void *args)
TCppScope_t GetScope(const std::string &scope_name)
TList * GetListOfMethodArgs()
Return list containing the TMethodArgs of a TFunction.
std::string GetMethodResultType(TCppMethod_t)
double func(double *x, double *p)
TCppIndex_t GetMethodNumArgs(TCppMethod_t)
std::string GetMethodArgName(TCppMethod_t, int iarg)
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
void Deallocate(TCppType_t type, TCppObject_t instance)
TCppObject_t Allocate(TCppType_t type)
std::string GetMethodArgType(TCppMethod_t, int iarg)
Bool_t IsSmartPtr(const std::string &)
Long_t ExtraProperty() const
Get property description word. For meaning of bits see EProperty.
Bool_t IsStaticMethod(TCppMethod_t method)
std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata)
Global functions class (global functions are obtained from CINT).
TClassRef is used to implement a permanent reference to a TClass object.
typedef void((*Func_t)())
Bool_t IsStaticData(TCppScope_t scope, TCppIndex_t idata)
static Name2ClassRefIndex_t g_name2classrefidx
static ClassInfo_t * GetGlobalNamespaceInfo()
size_t SizeOf(TCppType_t klass)
const char * GetDefault() const
Get default value of method argument.
Bool_t IsConstMethod(TCppMethod_t)
TCppIndex_t GetNumMethods(TCppScope_t scope)
Each ROOT class (see TClass) has a linked list of methods.
std::string ShortType(const char *typeDesc, int mode)
Return the absolute type of typeDesc.
void CallV(TCppMethod_t method, TCppObject_t self, void *args)
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
TClass * GetClass() const
static Cppyy::TCppScope_t declaring_scope(Cppyy::TCppMethod_t method)
std::map< Cppyy::TCppMethod_t, CallFunc_t *> Method2CallFunc_t
TCppObject_t Construct(TCppType_t type)
void Destruct(TCppType_t type, TCppObject_t instance)
TMethod * GetMethodAny(const char *method)
Return pointer to method without looking at parameters.
void *(* TCppMethPtrGetter_t)(TCppObject_t)
R__EXTERN TInterpreter * gCling
virtual Int_t GetSize() const
TList * GetListOfMethods(Bool_t load=kTRUE)
Return list containing the TMethods of a class.
Bool_t IsaPointer() const
Return true if data member is a pointer.
std::string GetMethodArgDefault(TCppMethod_t, int iarg)
static char * At(UInt_t index)
Returns class at index from sorted class table.
void DeallocateFunctionArgs(void *args)
Bool_t IsEnum(const std::string &type_name)
Int_t GetNargsOpt() const
Number of function optional (default) arguments.
std::string GetScopeName(TCppScope_t parent, TCppIndex_t iscope)
std::vector< TFunction > GlobalFuncs_t
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
virtual Int_t IndexOf(const TObject *obj) const
Return index of object in collection.