35 #define TParameter PyROOT::TParameter
68 {
"auto_ptr",
"shared_ptr",
"weak_ptr",
"unique_ptr" };
74class ApplicationStarter {
76 ApplicationStarter() {
88 ~ApplicationStarter() {
101 assert( (ClassRefs_t::size_type) scope <
g_classrefs.size() );
102 return g_classrefs[ (ClassRefs_t::size_type)scope ];
141 if (
name.find(
"::") == std::string::npos )
151 for ( std::string::size_type pos =
name.size() - 1; pos > 0; pos-- ) {
152 std::string::value_type
c =
name[pos];
159 else if ( tpl_open == 0 &&
c ==
':'&&
name[ pos - 1 ] ==
':' ) {
161 return name.substr( pos+1 );
195 std::string scope_name;
196 if ( sname.find(
"std::", 0, 5 ) == 0 )
197 scope_name = sname.substr( 5, std::string::npos );
228 if ( clActual && clActual != cr.
GetClass() ) {
260 ClassInfo_t* ci =
gInterpreter->ClassInfo_Factory( type_name.c_str() );
298 static ClassInfo_t* gcl =
gInterpreter->ClassInfo_Factory();
308 CallFunc_t* callf =
nullptr;
310 std::string callString =
"";
321 TIter iarg( method_args );
326 if ( callString.empty() )
327 callString = fullType;
329 callString +=
", " + fullType;
362 if ( !( callf &&
gInterpreter->CallFunc_IsValid( callf ) ) ) {
363 PyErr_Format( PyExc_RuntimeError,
"could not resolve %s::%s(%s)",
364 const_cast<TClassRef&
>(klass).GetClassName(),
366 callString.c_str() );
375static inline void copy_args(
void* args_,
void** vargs ) {
376 std::vector<TParameter>& args = *(std::vector<TParameter>*)args_;
377 for ( std::vector<TParameter>::size_type i = 0; i < args.size(); ++i ) {
378 switch ( args[i].fTypeCode ) {
380 vargs[i] = (
void*)&args[i].
fValue.fLong;
383 vargs[i] = (
void*)&args[i].fValue.fFloat;
386 vargs[i] = (
void*)&args[i].
fValue.fDouble;
389 vargs[i] = (
void*)&args[i].fValue.fLongDouble;
395 vargs[i] = (
void*)&args[i].
fValue.fVoidp;
398 vargs[i] = args[i].fValue.fVoidp;
401 vargs[i] = args[i].fRef;
404 std::cerr <<
"unknown type code: " << args[i].fTypeCode << std::endl;
413 const std::vector<TParameter>& args = *(std::vector<TParameter>*)args_;
424 faceptr.
fGeneric( self, args.size(), smallbuf, result );
426 std::vector<void*> buf( args.size() );
428 faceptr.
fGeneric( self, args.size(), buf.data(), result );
437 faceptr.
fCtor( (
void**)smallbuf, result, args.size() );
439 std::vector<void*> buf( args.size() );
441 faceptr.
fCtor( buf.data(), result, args.size() );
447 std::cerr <<
" DESTRUCTOR NOT IMPLEMENTED YET! " << std::endl;
454template<
typename T >
458 if (
FastCall( method, args, (
void*)self, &t ) )
463#define CPPYY_IMP_CALL( typecode, rtype ) \
464rtype Cppyy::Call##typecode( TCppMethod_t method, TCppObject_t self, void* args )\
466 return CallT< rtype >( method, self, args ); \
471 if ( !
FastCall( method, args, (
void*)self,
nullptr ) )
488 if (
FastCall( method, args, (
void*)self, &
r ) )
496 if (
FastCall( method, args, (
void*)self, &
s ) )
504 if (
FastCall( method, args,
nullptr, &obj ) )
521 if (
FastCall( method, args, self, obj ) )
576 return gInterpreter->ClassInfo_IsEnum( type_name.c_str() );
620 if ( derived == base )
634 const std::string& real_name =
ResolveName( type_name );
636 real_name.substr( 0,real_name.find(
"<" ) ) ) !=
gSmartPtrTypes.end();
644 if ( derived == base || !(base && derived) )
660 std::ostringstream msg;
661 msg <<
"failed offset calculation between " << cb->
GetName() <<
" and " << cd->
GetName();
662 PyErr_Warn( PyExc_RuntimeWarning,
const_cast<char*
>( msg.str().c_str() ) );
666 return rerror ? (ptrdiff_t)offset : 0;
672 return rerror ? (ptrdiff_t)offset : 0;
674 return (ptrdiff_t)(direction < 0 ? -offset : offset);
686 if ( clName.find(
'<' ) != std::string::npos ) {
689 clName =
"std::" + clName;
690 std::ostringstream stmt;
691 stmt <<
"template class " << clName <<
";";
716 std::vector< TCppMethod_t > methods;
726 std::string fn = func->
GetName();
727 if ( fn.rfind(
name, 0 ) == 0 ) {
729 if ( (
name.size() == fn.size()) ||
730 (
name.size() < fn.size() && fn[
name.size()] ==
'<') ) {
769 return "constructor";
770 return f->GetReturnTypeNormalizedName();
842 return (
bool)
gROOT->GetFunctionTemplate(
name.c_str());
870 std::string
name =
f->GetName();
871 return (
name[
name.size()-1] ==
'>') && (
name.find(
'<') != std::string::npos);
929 std::cerr <<
" global data should be retrieved lazily " << std::endl;
963 if ( fullType[fullType.size()-1] ==
'*' && \
964 fullType.find(
"char", 0, 4 ) == std::string::npos )
965 fullType.append(
"*" );
967 fullType.append(
"*" );
969 std::ostringstream
s;
971 fullType.append(
s.str() );
979 std::string fullType =
m->GetTrueTypeName();
980 if ( (
int)
m->GetArrayDim() > 1 || (!
m->IsBasic() &&
m->IsaPointer()) )
981 fullType.append(
"*" );
982 else if ( (
int)
m->GetArrayDim() == 1 ) {
983 std::ostringstream
s;
984 s <<
'[' <<
m->GetMaxIndex( 0 ) <<
']' << std::ends;
985 fullType.append(
s.str() );
1003 return (ptrdiff_t)
m->GetOffsetCint();
1006 return (ptrdiff_t)0;
1092 return m->GetMaxIndex( dimension );
1123 return (
long long)ecst->
GetValue();
static T CallT(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, void *args)
Bool_t FastCall(Cppyy::TCppMethod_t method, void *args_, void *self, void *result)
static Name2ClassRefIndex_t g_name2classrefidx
static TFunction * type_get_method(Cppyy::TCppType_t klass, Cppyy::TCppIndex_t idx)
static GlobalFuncs_t g_globalfuncs
static TClassRef & type_from_handle(Cppyy::TCppScope_t scope)
static CallFunc_t * GetCallFunc(Cppyy::TCppMethod_t method)
static Cppyy::TCppScope_t declaring_scope(Cppyy::TCppMethod_t method)
std::map< std::string, ClassRefs_t::size_type > Name2ClassRefIndex_t
static GlobalVars_t g_globalvars
static void copy_args(void *args_, void **vargs)
static std::set< std::string > gSmartPtrTypes
static ClassInfo_t * GetGlobalNamespaceInfo()
std::map< Cppyy::TCppMethod_t, CallFunc_t * > Method2CallFunc_t
std::vector< TFunction > GlobalFuncs_t
std::vector< TGlobal * > GlobalVars_t
static ClassRefs_t g_classrefs(1)
PyROOT::TParameter TParameter
static const ClassRefs_t::size_type GLOBAL_HANDLE
static Method2CallFunc_t g_method2callfunc
#define CPPYY_IMP_CALL(typecode, rtype)
std::vector< TClassRef > ClassRefs_t
R__EXTERN TClassTable * gClassTable
R__EXTERN Int_t gErrorIgnoreLevel
R__EXTERN TInterpreter * gCling
typedef void((*Func_t)())
Each class (see TClass) has a linked list of its base class(es).
TClassRef is used to implement a permanent reference to a TClass object.
TClass * GetClass() const
const char * GetClassName()
static char * At(UInt_t index)
Returns class at index from sorted class table.
TClass instances represent classes, structs and namespaces in the ROOT type system.
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
TMethod * GetMethodWithPrototype(const char *method, const char *proto, Bool_t objectIsConst=kFALSE, ROOT::EFunctionMatchMode mode=ROOT::kConversionMatch)
Find the method with a given prototype.
void Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
TList * GetListOfEnums(Bool_t load=kTRUE)
Return a list containing the TEnums of a class.
TList * GetListOfMethods(Bool_t load=kTRUE)
Return list containing the TMethods of a class.
TClass * GetBaseClass(const char *classname)
Return pointer to the base class "classname".
TList * GetListOfDataMembers(Bool_t load=kTRUE)
Return list containing the TDataMembers of a class.
Int_t Size() const
Return size of object of this class.
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process's memory.
ClassInfo_t * GetClassInfo() const
Long_t Property() const
Set TObject::fBits and fStreamerType to cache information about the class.
TMethod * GetMethodAllAny(const char *method)
Return pointer to method without looking at parameters.
TMethod * GetMethodAny(const char *method)
Return pointer to method without looking at parameters.
TClass * GetActualClass(const void *object) const
Return a pointer the the real class of the object.
TFunctionTemplate * GetFunctionTemplate(const char *name)
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.
Collection abstract base class.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
All ROOT classes may have RTTI (run time type identification) support added.
Basic data type descriptor (datatype information is obtained from CINT).
const char * GetFullTypeName() const
Get full type description of typedef, e,g.: "class TDirectory*".
TString GetTypeName()
Get basic type of typedef, e,g.
The TEnumConstant class implements the constants of the enum type.
Long64_t GetValue() const
The TEnum class implements the enum type.
EDataType GetUnderlyingType() const
Get the unterlying integer type of the enum: enum E { kOne }; // ==> int enum F: long; // ==> long Re...
static TEnum * GetEnum(const std::type_info &ti, ESearchAction sa=kALoadAndInterpLookup)
Global functions class (global functions are obtained from CINT).
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
TList * GetListOfMethodArgs()
Return list containing the TMethodArgs of a TFunction.
Global variables class (global variables are obtained from CINT).
virtual Int_t GetArrayDim() const
Return number of array dimensions.
virtual Long_t Property() const
Get property description word. For meaning of bits see EProperty.
virtual Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
virtual void * GetAddress() const
Return address of global.
virtual const char * GetFullTypeName() const
Get full type description of global variable, e,g.: "class TDirectory*".
virtual CallFuncIFacePtr_t CallFunc_IFacePtr(CallFunc_t *) const
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Each ROOT method (see TMethod) has a linked list of its arguments.
const char * GetDefault() const
Get default value of method argument.
std::string GetTypeNormalizedName() const
Get the normalized name of the return type.
Each ROOT class (see TClass) has a linked list of methods.
virtual const char * GetName() const
Returns name of object.
Named parameter, streamable and storable.
virtual Int_t IndexOf(const TObject *obj) const
Return index of object in collection.
TCppObject_t CallConstructor(TCppMethod_t method, TCppType_t type, void *args)
ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
void DeallocateFunctionArgs(void *args)
Bool_t IsConstructor(TCppMethod_t method)
TCppMethod_t GetMethodTemplate(TCppScope_t scope, const std::string &name, const std::string &proto)
Bool_t IsPublicMethod(TCppMethod_t method)
size_t SizeOf(TCppType_t klass)
TCppMethPtrGetter_t GetMethPtrGetter(TCppScope_t scope, TCppIndex_t imeth)
void * AllocateFunctionArgs(size_t nargs)
std::string GetMethodArgType(TCppMethod_t, int iarg)
Bool_t IsNamespace(TCppScope_t scope)
void *(* TCppMethPtrGetter_t)(TCppObject_t)
bool ExistsMethodTemplate(TCppScope_t scope, const std::string &name)
std::string GetMethodName(TCppMethod_t)
TCppIndex_t GetNumMethods(TCppScope_t scope)
void AddSmartPtrType(const std::string &)
TCppObject_t CallO(TCppMethod_t method, TCppObject_t self, void *args, TCppType_t result_type)
TCppIndex_t GetNumScopes(TCppScope_t parent)
TCppIndex_t GetNumDatamembers(TCppScope_t scope)
Char_t * CallS(TCppMethod_t method, TCppObject_t self, void *args)
void CallDestructor(TCppType_t type, TCppObject_t self)
TCppObject_t Allocate(TCppType_t type)
void * CallR(TCppMethod_t method, TCppObject_t self, void *args)
TCppIndex_t GetMethodReqArgs(TCppMethod_t)
Bool_t IsPublicData(TCppScope_t scope, TCppIndex_t idata)
std::string GetName(const std::string &scope_name)
size_t GetFunctionArgTypeoffset()
void Destruct(TCppType_t type, TCppObject_t instance)
std::string ResolveName(const std::string &cppitem_name)
Int_t GetDimensionSize(TCppScope_t scope, TCppIndex_t idata, int dimension)
TCppType_t GetTemplate(const std::string &template_name)
TCppType_t GetActualClass(TCppType_t klass, TCppObject_t obj)
std::string GetMethodSignature(TCppScope_t scope, TCppIndex_t imeth)
long long GetEnumDataValue(TCppEnum_t, TCppIndex_t idata)
TCppIndex_t GetMethodIndexAt(TCppScope_t scope, TCppIndex_t imeth)
Bool_t IsComplete(const std::string &type_name)
std::string GetBaseName(TCppType_t type, TCppIndex_t ibase)
TCppIndex_t GetMethodNumTemplateArgs(TCppScope_t scope, TCppIndex_t imeth)
std::string GetScopedFinalName(TCppType_t type)
void Deallocate(TCppType_t type, TCppObject_t instance)
Bool_t IsEnumData(TCppScope_t scope, TCppIndex_t idata)
Bool_t IsEnum(const std::string &type_name)
Bool_t IsStaticData(TCppScope_t scope, TCppIndex_t idata)
std::string GetEnumDataName(TCppEnum_t, TCppIndex_t idata)
Bool_t HasComplexHierarchy(TCppType_t type)
Bool_t IsConstMethod(TCppMethod_t)
std::string GetMethodArgDefault(TCppMethod_t, int iarg)
TCppIndex_t GetMethodNumArgs(TCppMethod_t)
TCppIndex_t GetDatamemberIndex(TCppScope_t scope, const std::string &name)
std::string GetMethodTemplateArgName(TCppScope_t scope, TCppIndex_t imeth, TCppIndex_t iarg)
std::string GetDatamemberType(TCppScope_t scope, TCppIndex_t idata)
TCppScope_t GetScope(const std::string &scope_name)
size_t GetFunctionArgSizeof()
Bool_t IsAbstract(TCppType_t type)
Bool_t IsStaticMethod(TCppMethod_t method)
TCppEnum_t GetEnum(TCppScope_t scope, const std::string &enum_name)
std::vector< TCppMethod_t > GetMethodsFromName(TCppScope_t scope, const std::string &name, bool alsoInBases=false)
std::string GetMethodArgName(TCppMethod_t, int iarg)
Bool_t IsMethodTemplate(TCppMethod_t)
ptrdiff_t GetDatamemberOffset(TCppScope_t scope, TCppIndex_t idata)
TCppIndex_t GetGlobalOperator(TCppType_t scope, TCppType_t lc, TCppScope_t rc, const std::string &op)
Bool_t IsBuiltin(const std::string &type_name)
std::string GetMethodResultType(TCppMethod_t)
std::string GetFinalName(TCppType_t type)
TCppIndex_t GetNumBases(TCppType_t type)
TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
Bool_t IsSmartPtr(const std::string &)
std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata)
TCppIndex_t GetNumEnumData(TCppEnum_t)
std::string ResolveEnum(const TEnum *en)
Bool_t IsConstData(TCppScope_t scope, TCppIndex_t idata)
TCppObject_t Construct(TCppType_t type)
void CallV(TCppMethod_t method, TCppObject_t self, void *args)
std::string GetScopeName(TCppScope_t parent, TCppIndex_t iscope)
Bool_t IsSubtype(TCppType_t derived, TCppType_t base)
std::string ResolveTypedef(const char *tname, bool resolveAll=false)
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 ...
std::string ShortType(const char *typeDesc, int mode)
Return the absolute type of typeDesc.
static constexpr double s
static constexpr double L