34 #define TParameter PyROOT::TParameter 67 {
"auto_ptr",
"shared_ptr",
"weak_ptr",
"unique_ptr" };
73 class ApplicationStarter {
75 ApplicationStarter() {
87 ~ApplicationStarter() {
91 } _applicationStarter;
100 assert( (ClassRefs_t::size_type) scope <
g_classrefs.size() );
101 return g_classrefs[ (ClassRefs_t::size_type)scope ];
140 if ( name.find(
"::") == std::string::npos )
147 if( name.size() == 0)
return name;
150 for ( std::string::size_type pos = name.size() - 1; pos > 0; pos-- ) {
151 std::string::value_type
c = name[pos];
158 else if ( tpl_open == 0 && c ==
':'&& name[ pos - 1 ] ==
':' ) {
160 return name.substr( pos+1 );
172 if ( dt )
return dt->GetFullTypeName();
178 std::string scope_name;
179 if ( sname.find(
"std::", 0, 5 ) == 0 )
180 scope_name = sname.substr( 5, std::string::npos );
211 if ( clActual && clActual != cr.
GetClass() ) {
243 ClassInfo_t* ci =
gInterpreter->ClassInfo_Factory( type_name.c_str() );
281 static ClassInfo_t* gcl =
gInterpreter->ClassInfo_Factory();
291 CallFunc_t* callf =
nullptr;
293 std::string callString =
"";
303 TCollection* method_args = func->GetListOfMethodArgs();
304 TIter iarg( method_args );
309 if ( callString.empty() )
310 callString = fullType;
312 callString +=
", " + fullType;
321 func ? func->GetName() : klass->
GetName(),
336 func ? func->GetName() : klass->
GetName(),
345 if ( !( callf &&
gInterpreter->CallFunc_IsValid( callf ) ) ) {
346 PyErr_Format( PyExc_RuntimeError,
"could not resolve %s::%s(%s)",
347 const_cast<TClassRef&>(klass).GetClassName(),
348 func ? func->GetName() :
const_cast<TClassRef&
>(klass).GetClassName(),
349 callString.c_str() );
358 static inline void copy_args(
void* args_,
void** vargs ) {
359 std::vector<TParameter>& args = *(std::vector<TParameter>*)args_;
360 for ( std::vector<TParameter>::size_type i = 0; i < args.size(); ++i ) {
361 switch ( args[i].fTypeCode ) {
363 vargs[i] = (
void*)&args[i].
fValue.fLong;
366 vargs[i] = (
void*)&args[i].fValue.fFloat;
369 vargs[i] = (
void*)&args[i].
fValue.fDouble;
372 vargs[i] = (
void*)&args[i].fValue.fLongDouble;
378 vargs[i] = (
void*)&args[i].
fValue.fVoidp;
381 vargs[i] = args[i].fValue.fVoidp;
384 vargs[i] = args[i].fRef;
387 std::cerr <<
"unknown type code: " << args[i].fTypeCode << std::endl;
396 const std::vector<TParameter>& args = *(std::vector<TParameter>*)args_;
407 faceptr.
fGeneric(
self, args.size(), smallbuf, result );
409 std::vector<void*> buf( args.size() );
411 faceptr.
fGeneric(
self, args.size(), buf.data(), result );
420 faceptr.
fCtor( (
void**)smallbuf, result, args.size() );
422 std::vector<void*> buf( args.size() );
424 faceptr.
fCtor( buf.data(), result, args.size() );
430 std::cerr <<
" DESTRUCTOR NOT IMPLEMENTED YET! " << std::endl;
437 template<
typename T >
441 if (
FastCall( method, args, (
void*)
self, &t ) )
446 #define CPPYY_IMP_CALL( typecode, rtype ) \ 447 rtype Cppyy::Call##typecode( TCppMethod_t method, TCppObject_t self, void* args )\ 449 return CallT< rtype >( method, self, args ); \ 454 if ( !
FastCall( method, args, (
void*)
self,
nullptr ) )
471 if (
FastCall( method, args, (
void*)
self, &
r ) )
479 if (
FastCall( method, args, (
void*)
self, &s ) )
487 if (
FastCall( method, args,
nullptr, &obj ) )
504 if (
FastCall( method, args,
self, obj ) )
556 return gInterpreter->ClassInfo_IsEnum( type_name.c_str() );
600 if ( derived == base )
614 const std::string& real_name =
ResolveName( type_name );
615 return gSmartPtrTypes.find(
616 real_name.substr( 0,real_name.find(
"<" ) ) ) != gSmartPtrTypes.end();
624 if ( derived == base || !(base && derived) )
640 std::ostringstream msg;
641 msg <<
"failed offset calculation between " << cb->
GetName() <<
" and " << cd->
GetName();
642 PyErr_Warn( PyExc_RuntimeWarning, const_cast<char*>( msg.str().c_str() ) );
646 return rerror ? (ptrdiff_t)offset : 0;
652 return rerror ? (ptrdiff_t)offset : 0;
654 return (ptrdiff_t)(direction < 0 ? -offset : offset);
666 if ( clName.find(
'<' ) != std::string::npos ) {
669 clName =
"std::" + clName;
670 std::ostringstream stmt;
671 stmt <<
"template class " << clName <<
";";
696 std::vector< TCppMethod_t > methods;
706 std::string fn = func->
GetName();
707 if ( fn.rfind( name, 0 ) == 0 ) {
709 if ( (name.size() == fn.size()) ||
710 (name.size() < fn.size() && fn[name.size()] ==
'<') ) {
749 return "constructor";
824 return (name[name.size()-1] ==
'>') && (name.find(
'<') != std::string::npos);
882 std::cerr <<
" global data should be retrieved lazily " << std::endl;
916 if ( fullType[fullType.size()-1] ==
'*' && \
917 fullType.find(
"char", 0, 4 ) == std::string::npos )
918 fullType.append(
"*" );
920 fullType.append(
"*" );
922 std::ostringstream
s;
923 s <<
'[' << gbl->
GetMaxIndex( 0 ) <<
']' << std::ends;
924 fullType.append( s.str() );
934 fullType.append(
"*" );
936 std::ostringstream
s;
937 s <<
'[' << m->
GetMaxIndex( 0 ) <<
']' << std::ends;
938 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
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)
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
Delete a TObjLink object.
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.
static constexpr double L
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)
static constexpr double s
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
Return the capacity of the collection, i.e.
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.