Logo ROOT   6.14/05
Reference Guide
Cppyy.h
Go to the documentation of this file.
1 #ifndef PYROOT_CPPYY_H
2 #define PYROOT_CPPYY_H
3 
4 // Standard
5 #include <string>
6 #include <vector>
7 #include <stddef.h>
8 
9 
10 namespace Cppyy {
11 
12  typedef ptrdiff_t TCppScope_t;
13  typedef TCppScope_t TCppType_t;
14  typedef void* TCppObject_t;
15  typedef ptrdiff_t TCppMethod_t;
16 
18  typedef void* (*TCppMethPtrGetter_t)( TCppObject_t );
19 
20 // name to opaque C++ scope representation -----------------------------------
21  TCppIndex_t GetNumScopes( TCppScope_t parent );
22  std::string GetScopeName( TCppScope_t parent, TCppIndex_t iscope );
23  std::string ResolveName( const std::string& cppitem_name );
24  TCppScope_t GetScope( const std::string& scope_name );
25  std::string GetName( const std::string& scope_name );
26  TCppType_t GetTemplate( const std::string& template_name );
27  TCppType_t GetActualClass( TCppType_t klass, TCppObject_t obj );
28  size_t SizeOf( TCppType_t klass );
29 
30  Bool_t IsBuiltin( const std::string& type_name );
31  Bool_t IsComplete( const std::string& type_name );
32 
33  extern TCppScope_t gGlobalScope; // for fast access
34 
35 // memory management ---------------------------------------------------------
36  TCppObject_t Allocate( TCppType_t type );
37  void Deallocate( TCppType_t type, TCppObject_t instance );
38  TCppObject_t Construct( TCppType_t type );
39  void Destruct( TCppType_t type, TCppObject_t instance );
40 
41 // method/function dispatching -----------------------------------------------
42  void CallV( TCppMethod_t method, TCppObject_t self, void* args );
43  UChar_t CallB( TCppMethod_t method, TCppObject_t self, void* args );
44  Char_t CallC( TCppMethod_t method, TCppObject_t self, void* args );
45  Short_t CallH( TCppMethod_t method, TCppObject_t self, void* args );
46  Int_t CallI( TCppMethod_t method, TCppObject_t self, void* args );
47  Long_t CallL( TCppMethod_t method, TCppObject_t self, void* args );
48  Long64_t CallLL( TCppMethod_t method, TCppObject_t self, void* args );
49  Float_t CallF( TCppMethod_t method, TCppObject_t self, void* args );
50  Double_t CallD( TCppMethod_t method, TCppObject_t self, void* args );
51  LongDouble_t CallLD( TCppMethod_t method, TCppObject_t self, void* args );
52  void* CallR( TCppMethod_t method, TCppObject_t self, void* args );
53  Char_t* CallS( TCppMethod_t method, TCppObject_t self, void* args );
54  TCppObject_t CallConstructor( TCppMethod_t method, TCppType_t type, void* args );
55  void CallDestructor( TCppType_t type, TCppObject_t self );
56  TCppObject_t CallO( TCppMethod_t method, TCppObject_t self, void* args, TCppType_t result_type );
57 
58  TCppMethPtrGetter_t GetMethPtrGetter( TCppScope_t scope, TCppIndex_t imeth );
59 
60 // handling of function argument buffer --------------------------------------
61  void* AllocateFunctionArgs( size_t nargs );
62  void DeallocateFunctionArgs( void* args );
63  size_t GetFunctionArgSizeof();
64  size_t GetFunctionArgTypeoffset();
65 
66 // scope reflection information ----------------------------------------------
67  Bool_t IsNamespace( TCppScope_t scope );
68  Bool_t IsAbstract( TCppType_t type );
69  Bool_t IsEnum( const std::string& type_name );
70 
71 // class reflection information ----------------------------------------------
72  std::string GetFinalName( TCppType_t type );
73  std::string GetScopedFinalName( TCppType_t type );
74  Bool_t HasComplexHierarchy( TCppType_t type );
75  TCppIndex_t GetNumBases( TCppType_t type );
76  std::string GetBaseName( TCppType_t type, TCppIndex_t ibase );
77  Bool_t IsSubtype( TCppType_t derived, TCppType_t base );
78  void AddSmartPtrType( const std::string& );
79  Bool_t IsSmartPtr( const std::string& );
80 
81 // calculate offsets between declared and actual type, up-cast: direction > 0; down-cast: direction < 0
82  ptrdiff_t GetBaseOffset(
83  TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror = false );
84 
85 // method/function reflection information ------------------------------------
86  TCppIndex_t GetNumMethods( TCppScope_t scope );
87  TCppIndex_t GetMethodIndexAt( TCppScope_t scope, TCppIndex_t imeth );
88  std::vector< TCppMethod_t > GetMethodsFromName( TCppScope_t scope, const std::string& name );
89 
90  TCppMethod_t GetMethod( TCppScope_t scope, TCppIndex_t imeth );
91 
92  std::string GetMethodName( TCppMethod_t );
93  std::string GetMethodResultType( TCppMethod_t );
94  TCppIndex_t GetMethodNumArgs( TCppMethod_t );
95  TCppIndex_t GetMethodReqArgs( TCppMethod_t );
96  std::string GetMethodArgName( TCppMethod_t, int iarg );
97  std::string GetMethodArgType( TCppMethod_t, int iarg );
98  std::string GetMethodArgDefault( TCppMethod_t, int iarg );
99  std::string GetMethodSignature( TCppScope_t scope, TCppIndex_t imeth );
100  Bool_t IsConstMethod( TCppMethod_t );
101 
102  Bool_t IsMethodTemplate( TCppMethod_t );
103  TCppIndex_t GetMethodNumTemplateArgs( TCppScope_t scope, TCppIndex_t imeth );
104  std::string GetMethodTemplateArgName( TCppScope_t scope, TCppIndex_t imeth, TCppIndex_t iarg );
105 
106  TCppIndex_t GetGlobalOperator(
107  TCppType_t scope, TCppType_t lc, TCppScope_t rc, const std::string& op );
108 
109 // method properties ---------------------------------------------------------
110  Bool_t IsConstructor( TCppMethod_t method );
111  Bool_t IsPublicMethod( TCppMethod_t method );
112  Bool_t IsStaticMethod( TCppMethod_t method );
113 
114 // data member reflection information ----------------------------------------
115  TCppIndex_t GetNumDatamembers( TCppScope_t scope );
116  std::string GetDatamemberName( TCppScope_t scope, TCppIndex_t idata );
117  std::string GetDatamemberType( TCppScope_t scope, TCppIndex_t idata );
118  ptrdiff_t GetDatamemberOffset( TCppScope_t scope, TCppIndex_t idata );
119  TCppIndex_t GetDatamemberIndex( TCppScope_t scope, const std::string& name );
120 
121 // data member properties ----------------------------------------------------
122  Bool_t IsPublicData( TCppScope_t scope, TCppIndex_t idata );
123  Bool_t IsStaticData( TCppScope_t scope, TCppIndex_t idata );
124  Bool_t IsConstData( TCppScope_t scope, TCppIndex_t idata );
125  Bool_t IsEnumData( TCppScope_t scope, TCppIndex_t idata );
126  Int_t GetDimensionSize( TCppScope_t scope, TCppIndex_t idata, int dimension );
127 
128 } // namespace Cppyy
129 
130 #endif // ifndef PYROOT_CPPYY_H
Double_t CallD(TCppMethod_t method, TCppObject_t self, void *args)
std::string GetName(const std::string &scope_name)
Definition: Cppyy.cxx:145
TCppScope_t TCppType_t
Definition: Cppyy.h:13
size_t GetFunctionArgSizeof()
Definition: Cppyy.cxx:527
std::string GetScopedFinalName(TCppType_t type)
Definition: Cppyy.cxx:570
long long Long64_t
Definition: RtypesCore.h:69
Bool_t IsNamespace(TCppScope_t scope)
Definition: Cppyy.cxx:539
float Float_t
Definition: RtypesCore.h:53
Bool_t IsBuiltin(const std::string &type_name)
Definition: Cppyy.cxx:225
TCppIndex_t GetGlobalOperator(TCppType_t scope, TCppType_t lc, TCppScope_t rc, const std::string &op)
Definition: Cppyy.cxx:841
Bool_t IsMethodTemplate(TCppMethod_t)
Definition: Cppyy.cxx:819
ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
Definition: Cppyy.cxx:620
Bool_t IsPublicMethod(TCppMethod_t method)
Definition: Cppyy.cxx:857
LongDouble_t CallLD(TCppMethod_t method, TCppObject_t self, void *args)
TCppIndex_t GetNumBases(TCppType_t type)
Definition: Cppyy.cxx:583
Int_t CallI(TCppMethod_t method, TCppObject_t self, void *args)
TCppIndex_t GetMethodReqArgs(TCppMethod_t)
Definition: Cppyy.cxx:762
std::vector< TCppMethod_t > GetMethodsFromName(TCppScope_t scope, const std::string &name)
Definition: Cppyy.cxx:690
Bool_t IsAbstract(TCppType_t type)
Definition: Cppyy.cxx:547
std::string GetFinalName(TCppType_t type)
Definition: Cppyy.cxx:561
std::string GetMethodSignature(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:804
Float_t CallF(TCppMethod_t method, TCppObject_t self, void *args)
ptrdiff_t GetDatamemberOffset(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:946
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Bool_t IsEnumData(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:1022
std::string GetDatamemberType(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:911
TCppIndex_t GetNumScopes(TCppScope_t parent)
Definition: Cppyy.cxx:125
TCppObject_t CallO(TCppMethod_t method, TCppObject_t self, void *args, TCppType_t result_type)
Definition: Cppyy.cxx:498
Int_t GetDimensionSize(TCppScope_t scope, TCppIndex_t idata, int dimension)
Definition: Cppyy.cxx:1036
TCppObject_t CallConstructor(TCppMethod_t method, TCppType_t type, void *args)
Definition: Cppyy.cxx:484
std::string GetBaseName(TCppType_t type, TCppIndex_t ibase)
Definition: Cppyy.cxx:592
Char_t * CallS(TCppMethod_t method, TCppObject_t self, void *args)
Definition: Cppyy.cxx:476
TCppIndex_t GetMethodIndexAt(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:685
Definition: Cppyy.h:10
TCppIndex_t GetMethodNumTemplateArgs(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:829
TCppType_t GetTemplate(const std::string &template_name)
Definition: Cppyy.cxx:202
std::string ResolveName(const std::string &cppitem_name)
Definition: Cppyy.cxx:166
Long64_t CallLL(TCppMethod_t method, TCppObject_t self, void *args)
Char_t CallC(TCppMethod_t method, TCppObject_t self, void *args)
UChar_t CallB(TCppMethod_t method, TCppObject_t self, void *args)
Bool_t HasComplexHierarchy(TCppType_t type)
Definition: Cppyy.cxx:577
TCppMethPtrGetter_t GetMethPtrGetter(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:509
TCppIndex_t GetNumDatamembers(TCppScope_t scope)
Definition: Cppyy.cxx:876
Bool_t IsConstData(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:1008
void CallDestructor(TCppType_t type, TCppObject_t self)
Definition: Cppyy.cxx:492
Bool_t IsComplete(const std::string &type_name)
Definition: Cppyy.cxx:232
TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:727
size_t GetFunctionArgTypeoffset()
Definition: Cppyy.cxx:532
std::string GetMethodTemplateArgName(TCppScope_t scope, TCppIndex_t imeth, TCppIndex_t iarg)
Definition: Cppyy.cxx:835
Bool_t IsConstructor(TCppMethod_t method)
Definition: Cppyy.cxx:848
TCppType_t GetActualClass(TCppType_t klass, TCppObject_t obj)
Definition: Cppyy.cxx:207
void AddSmartPtrType(const std::string &)
Definition: Cppyy.cxx:607
ptrdiff_t TCppMethod_t
Definition: Cppyy.h:15
TCppScope_t gGlobalScope
Definition: Cppyy.cxx:63
Bool_t IsPublicData(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:986
std::string GetMethodName(TCppMethod_t)
Definition: Cppyy.cxx:733
void * AllocateFunctionArgs(size_t nargs)
Definition: Cppyy.cxx:517
short Short_t
Definition: RtypesCore.h:35
TCppIndex_t GetDatamemberIndex(TCppScope_t scope, const std::string &name)
Definition: Cppyy.cxx:962
long double LongDouble_t
Definition: RtypesCore.h:57
Short_t CallH(TCppMethod_t method, TCppObject_t self, void *args)
void * TCppObject_t
Definition: Cppyy.h:14
void * CallR(TCppMethod_t method, TCppObject_t self, void *args)
Definition: Cppyy.cxx:468
long Long_t
Definition: RtypesCore.h:50
Bool_t IsSubtype(TCppType_t derived, TCppType_t base)
Definition: Cppyy.cxx:598
TCppScope_t GetScope(const std::string &scope_name)
Definition: Cppyy.cxx:176
double Double_t
Definition: RtypesCore.h:55
std::string GetMethodResultType(TCppMethod_t)
Definition: Cppyy.cxx:744
int type
Definition: TGX11.cxx:120
Long_t CallL(TCppMethod_t method, TCppObject_t self, void *args)
TCppIndex_t GetMethodNumArgs(TCppMethod_t)
Definition: Cppyy.cxx:755
std::string GetMethodArgName(TCppMethod_t, int iarg)
Definition: Cppyy.cxx:771
void Deallocate(TCppType_t type, TCppObject_t instance)
Definition: Cppyy.cxx:260
TCppObject_t Allocate(TCppType_t type)
Definition: Cppyy.cxx:254
std::string GetMethodArgType(TCppMethod_t, int iarg)
Definition: Cppyy.cxx:781
Bool_t IsSmartPtr(const std::string &)
Definition: Cppyy.cxx:611
Bool_t IsStaticMethod(TCppMethod_t method)
Definition: Cppyy.cxx:866
std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:899
char Char_t
Definition: RtypesCore.h:29
Bool_t IsStaticData(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:997
size_t SizeOf(TCppType_t klass)
Definition: Cppyy.cxx:218
Long_t TCppIndex_t
Definition: Cppyy.h:17
Bool_t IsConstMethod(TCppMethod_t)
Definition: Cppyy.cxx:809
TCppIndex_t GetNumMethods(TCppScope_t scope)
Definition: Cppyy.cxx:659
void CallV(TCppMethod_t method, TCppObject_t self, void *args)
Definition: Cppyy.cxx:452
unsigned char UChar_t
Definition: RtypesCore.h:34
TCppObject_t Construct(TCppType_t type)
Definition: Cppyy.cxx:265
void Destruct(TCppType_t type, TCppObject_t instance)
Definition: Cppyy.cxx:271
void *(* TCppMethPtrGetter_t)(TCppObject_t)
Definition: Cppyy.h:18
std::string GetMethodArgDefault(TCppMethod_t, int iarg)
Definition: Cppyy.cxx:791
ptrdiff_t TCppScope_t
Definition: Cppyy.h:12
void DeallocateFunctionArgs(void *args)
Definition: Cppyy.cxx:522
Bool_t IsEnum(const std::string &type_name)
Definition: Cppyy.cxx:555
std::string GetScopeName(TCppScope_t parent, TCppIndex_t iscope)
Definition: Cppyy.cxx:133
char name[80]
Definition: TGX11.cxx:109