Logo ROOT   6.08/07
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:140
TCppScope_t TCppType_t
Definition: Cppyy.h:13
size_t GetFunctionArgSizeof()
Definition: Cppyy.cxx:522
std::string GetScopedFinalName(TCppType_t type)
Definition: Cppyy.cxx:565
long long Long64_t
Definition: RtypesCore.h:69
Bool_t IsNamespace(TCppScope_t scope)
Definition: Cppyy.cxx:534
float Float_t
Definition: RtypesCore.h:53
Bool_t IsBuiltin(const std::string &type_name)
Definition: Cppyy.cxx:220
TCppIndex_t GetGlobalOperator(TCppType_t scope, TCppType_t lc, TCppScope_t rc, const std::string &op)
Definition: Cppyy.cxx:836
Bool_t IsMethodTemplate(TCppMethod_t)
Definition: Cppyy.cxx:814
ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
Definition: Cppyy.cxx:615
Bool_t IsPublicMethod(TCppMethod_t method)
Definition: Cppyy.cxx:852
LongDouble_t CallLD(TCppMethod_t method, TCppObject_t self, void *args)
TCppIndex_t GetNumBases(TCppType_t type)
Definition: Cppyy.cxx:578
Int_t CallI(TCppMethod_t method, TCppObject_t self, void *args)
TCppIndex_t GetMethodReqArgs(TCppMethod_t)
Definition: Cppyy.cxx:757
std::vector< TCppMethod_t > GetMethodsFromName(TCppScope_t scope, const std::string &name)
Definition: Cppyy.cxx:685
Bool_t IsAbstract(TCppType_t type)
Definition: Cppyy.cxx:542
std::string GetFinalName(TCppType_t type)
Definition: Cppyy.cxx:556
std::string GetMethodSignature(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:799
Float_t CallF(TCppMethod_t method, TCppObject_t self, void *args)
ptrdiff_t GetDatamemberOffset(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:941
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:1017
std::string GetDatamemberType(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:906
TCppIndex_t GetNumScopes(TCppScope_t parent)
Definition: Cppyy.cxx:120
TCppObject_t CallO(TCppMethod_t method, TCppObject_t self, void *args, TCppType_t result_type)
Definition: Cppyy.cxx:493
Int_t GetDimensionSize(TCppScope_t scope, TCppIndex_t idata, int dimension)
Definition: Cppyy.cxx:1031
TCppObject_t CallConstructor(TCppMethod_t method, TCppType_t type, void *args)
Definition: Cppyy.cxx:479
std::string GetBaseName(TCppType_t type, TCppIndex_t ibase)
Definition: Cppyy.cxx:587
Char_t * CallS(TCppMethod_t method, TCppObject_t self, void *args)
Definition: Cppyy.cxx:471
TCppIndex_t GetMethodIndexAt(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:680
Definition: Cppyy.h:10
TCppIndex_t GetMethodNumTemplateArgs(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:824
TCppType_t GetTemplate(const std::string &template_name)
Definition: Cppyy.cxx:197
std::string ResolveName(const std::string &cppitem_name)
Definition: Cppyy.cxx:161
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:572
TCppMethPtrGetter_t GetMethPtrGetter(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:504
TCppIndex_t GetNumDatamembers(TCppScope_t scope)
Definition: Cppyy.cxx:871
Bool_t IsConstData(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:1003
void CallDestructor(TCppType_t type, TCppObject_t self)
Definition: Cppyy.cxx:487
Bool_t IsComplete(const std::string &type_name)
Definition: Cppyy.cxx:227
TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:722
size_t GetFunctionArgTypeoffset()
Definition: Cppyy.cxx:527
std::string GetMethodTemplateArgName(TCppScope_t scope, TCppIndex_t imeth, TCppIndex_t iarg)
Definition: Cppyy.cxx:830
Bool_t IsConstructor(TCppMethod_t method)
Definition: Cppyy.cxx:843
TCppType_t GetActualClass(TCppType_t klass, TCppObject_t obj)
Definition: Cppyy.cxx:202
void AddSmartPtrType(const std::string &)
Definition: Cppyy.cxx:602
ptrdiff_t TCppMethod_t
Definition: Cppyy.h:15
TCppScope_t gGlobalScope
Definition: Cppyy.cxx:58
Bool_t IsPublicData(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:981
std::string GetMethodName(TCppMethod_t)
Definition: Cppyy.cxx:728
void * AllocateFunctionArgs(size_t nargs)
Definition: Cppyy.cxx:512
short Short_t
Definition: RtypesCore.h:35
TCppIndex_t GetDatamemberIndex(TCppScope_t scope, const std::string &name)
Definition: Cppyy.cxx:957
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:463
long Long_t
Definition: RtypesCore.h:50
Bool_t IsSubtype(TCppType_t derived, TCppType_t base)
Definition: Cppyy.cxx:593
TCppScope_t GetScope(const std::string &scope_name)
Definition: Cppyy.cxx:171
double Double_t
Definition: RtypesCore.h:55
std::string GetMethodResultType(TCppMethod_t)
Definition: Cppyy.cxx:739
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:750
std::string GetMethodArgName(TCppMethod_t, int iarg)
Definition: Cppyy.cxx:766
void Deallocate(TCppType_t type, TCppObject_t instance)
Definition: Cppyy.cxx:255
TCppObject_t Allocate(TCppType_t type)
Definition: Cppyy.cxx:249
std::string GetMethodArgType(TCppMethod_t, int iarg)
Definition: Cppyy.cxx:776
Bool_t IsSmartPtr(const std::string &)
Definition: Cppyy.cxx:606
Bool_t IsStaticMethod(TCppMethod_t method)
Definition: Cppyy.cxx:861
std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:894
char Char_t
Definition: RtypesCore.h:29
Bool_t IsStaticData(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:992
size_t SizeOf(TCppType_t klass)
Definition: Cppyy.cxx:213
Long_t TCppIndex_t
Definition: Cppyy.h:17
Bool_t IsConstMethod(TCppMethod_t)
Definition: Cppyy.cxx:804
TCppIndex_t GetNumMethods(TCppScope_t scope)
Definition: Cppyy.cxx:654
void CallV(TCppMethod_t method, TCppObject_t self, void *args)
Definition: Cppyy.cxx:447
unsigned char UChar_t
Definition: RtypesCore.h:34
TCppObject_t Construct(TCppType_t type)
Definition: Cppyy.cxx:260
void Destruct(TCppType_t type, TCppObject_t instance)
Definition: Cppyy.cxx:266
void *(* TCppMethPtrGetter_t)(TCppObject_t)
Definition: Cppyy.h:18
std::string GetMethodArgDefault(TCppMethod_t, int iarg)
Definition: Cppyy.cxx:786
ptrdiff_t TCppScope_t
Definition: Cppyy.h:12
void DeallocateFunctionArgs(void *args)
Definition: Cppyy.cxx:517
Bool_t IsEnum(const std::string &type_name)
Definition: Cppyy.cxx:550
std::string GetScopeName(TCppScope_t parent, TCppIndex_t iscope)
Definition: Cppyy.cxx:128
char name[80]
Definition: TGX11.cxx:109