35 #define TParameter PyROOT::TParameter
68 {
"auto_ptr",
"shared_ptr",
"weak_ptr",
"unique_ptr" };
74class ApplicationStarter {
76 ApplicationStarter() {
92 ~ApplicationStarter() {
105 assert( (ClassRefs_t::size_type) scope <
g_classrefs.size() );
106 return g_classrefs[ (ClassRefs_t::size_type)scope ];
145 if (
name.find(
"::") == std::string::npos )
155 for ( std::string::size_type pos =
name.size() - 1; pos > 0; pos-- ) {
156 std::string::value_type
c =
name[pos];
163 else if ( tpl_open == 0 &&
c ==
':'&&
name[ pos - 1 ] ==
':' ) {
165 return name.substr( pos+1 );
199 std::string scope_name;
200 if ( sname.find(
"std::", 0, 5 ) == 0 )
201 scope_name = sname.substr( 5, std::string::npos );
232 if ( clActual && clActual != cr.
GetClass() ) {
264 ClassInfo_t* ci =
gInterpreter->ClassInfo_Factory( type_name.c_str() );
302 static ClassInfo_t* gcl =
gInterpreter->ClassInfo_Factory();
312 CallFunc_t* callf =
nullptr;
314 std::string callString =
"";
325 TIter iarg( method_args );
330 if ( callString.empty() )
331 callString = fullType;
333 callString +=
", " + fullType;
366 if ( !( callf &&
gInterpreter->CallFunc_IsValid( callf ) ) ) {
367 PyErr_Format( PyExc_RuntimeError,
"could not resolve %s::%s(%s)",
368 const_cast<TClassRef&
>(klass).GetClassName(),
370 callString.c_str() );
379static inline void copy_args(
void* args_,
void** vargs ) {
380 std::vector<TParameter>& args = *(std::vector<TParameter>*)args_;
381 for ( std::vector<TParameter>::size_type i = 0; i < args.size(); ++i ) {
382 switch ( args[i].fTypeCode ) {
384 vargs[i] = (
void*)&args[i].
fValue.fLong;
387 vargs[i] = (
void*)&args[i].fValue.fFloat;
390 vargs[i] = (
void*)&args[i].
fValue.fDouble;
393 vargs[i] = (
void*)&args[i].fValue.fLongDouble;
399 vargs[i] = (
void*)&args[i].
fValue.fVoidp;
402 vargs[i] = args[i].fValue.fVoidp;
405 vargs[i] = args[i].fRef;
408 std::cerr <<
"unknown type code: " << args[i].fTypeCode << std::endl;
417 const std::vector<TParameter>& args = *(std::vector<TParameter>*)args_;
428 faceptr.
fGeneric( self, args.size(), smallbuf, result );
430 std::vector<void*> buf( args.size() );
432 faceptr.
fGeneric( self, args.size(), buf.data(), result );
441 faceptr.
fCtor( (
void**)smallbuf, result, args.size() );
443 std::vector<void*> buf( args.size() );
445 faceptr.
fCtor( buf.data(), result, args.size() );
451 std::cerr <<
" DESTRUCTOR NOT IMPLEMENTED YET! " << std::endl;
458template<
typename T >
462 if (
FastCall( method, args, (
void*)self, &t ) )
467#define CPPYY_IMP_CALL( typecode, rtype ) \
468rtype Cppyy::Call##typecode( TCppMethod_t method, TCppObject_t self, void* args )\
470 return CallT< rtype >( method, self, args ); \
475 if ( !
FastCall( method, args, (
void*)self,
nullptr ) )
492 if (
FastCall( method, args, (
void*)self, &
r ) )
500 if (
FastCall( method, args, (
void*)self, &
s ) )
508 if (
FastCall( method, args,
nullptr, &obj ) )
525 if (
FastCall( method, args, self, obj ) )
580 return gInterpreter->ClassInfo_IsEnum( type_name.c_str() );
624 if ( derived == base )
638 const std::string& real_name =
ResolveName( type_name );
640 real_name.substr( 0,real_name.find(
"<" ) ) ) !=
gSmartPtrTypes.end();
648 if ( derived == base || !(base && derived) )
664 std::ostringstream msg;
665 msg <<
"failed offset calculation between " << cb->
GetName() <<
" and " << cd->
GetName();
666 PyErr_Warn( PyExc_RuntimeWarning,
const_cast<char*
>( msg.str().c_str() ) );
670 return rerror ? (ptrdiff_t)offset : 0;
676 return rerror ? (ptrdiff_t)offset : 0;
678 return (ptrdiff_t)(direction < 0 ? -offset : offset);
690 if ( clName.find(
'<' ) != std::string::npos ) {
693 clName =
"std::" + clName;
694 std::ostringstream stmt;
695 stmt <<
"template class " << clName <<
";";
720 std::vector< TCppMethod_t > methods;
730 std::string fn = func->
GetName();
731 if ( fn.rfind(
name, 0 ) == 0 ) {
733 if ( (
name.size() == fn.size()) ||
734 (
name.size() < fn.size() && fn[
name.size()] ==
'<') ) {
773 return "constructor";
774 return f->GetReturnTypeNormalizedName();
846 return (
bool)
gROOT->GetFunctionTemplate(
name.c_str());
874 std::string
name =
f->GetName();
875 return (
name[
name.size()-1] ==
'>') && (
name.find(
'<') != std::string::npos);
933 std::cerr <<
" global data should be retrieved lazily " << std::endl;
967 if ( fullType[fullType.size()-1] ==
'*' && \
968 fullType.find(
"char", 0, 4 ) == std::string::npos )
969 fullType.append(
"*" );
971 fullType.append(
"*" );
973 std::ostringstream
s;
975 fullType.append(
s.str() );
983 std::string fullType =
m->GetTrueTypeName();
984 if ( (
int)
m->GetArrayDim() > 1 || (!
m->IsBasic() &&
m->IsaPointer()) )
985 fullType.append(
"*" );
986 else if ( (
int)
m->GetArrayDim() == 1 ) {
987 std::ostringstream
s;
988 s <<
'[' <<
m->GetMaxIndex( 0 ) <<
']' << std::ends;
989 fullType.append(
s.str() );
1007 return (ptrdiff_t)
m->GetOffsetCint();
1010 return (ptrdiff_t)0;
1096 return m->GetMaxIndex( dimension );
1127 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.
static void Initialize()
Initialize ROOT explicitly.
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)
static Roo_reg_AGKInteg1D instance
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