ROOT  6.06/09
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  TCppType_t GetTemplate( const std::string& template_name );
26  TCppType_t GetActualClass( TCppType_t klass, TCppObject_t obj );
27  size_t SizeOf( TCppType_t klass );
28 
29  Bool_t IsBuiltin( const std::string& type_name );
30  Bool_t IsComplete( const std::string& type_name );
31 
32  extern TCppScope_t gGlobalScope; // for fast access
33 
34 // memory management ---------------------------------------------------------
35  TCppObject_t Allocate( TCppType_t type );
36  void Deallocate( TCppType_t type, TCppObject_t instance );
37  TCppObject_t Construct( TCppType_t type );
38  void Destruct( TCppType_t type, TCppObject_t instance );
39 
40 // method/function dispatching -----------------------------------------------
41  void CallV( TCppMethod_t method, TCppObject_t self, void* args );
42  UChar_t CallB( TCppMethod_t method, TCppObject_t self, void* args );
43  Char_t CallC( TCppMethod_t method, TCppObject_t self, void* args );
44  Short_t CallH( TCppMethod_t method, TCppObject_t self, void* args );
45  Int_t CallI( TCppMethod_t method, TCppObject_t self, void* args );
46  Long_t CallL( TCppMethod_t method, TCppObject_t self, void* args );
47  Long64_t CallLL( TCppMethod_t method, TCppObject_t self, void* args );
48  Float_t CallF( TCppMethod_t method, TCppObject_t self, void* args );
49  Double_t CallD( TCppMethod_t method, TCppObject_t self, void* args );
50  LongDouble_t CallLD( TCppMethod_t method, TCppObject_t self, void* args );
51  void* CallR( TCppMethod_t method, TCppObject_t self, void* args );
52  Char_t* CallS( TCppMethod_t method, TCppObject_t self, void* args );
53  TCppObject_t CallConstructor( TCppMethod_t method, TCppType_t type, void* args );
54  void CallDestructor( TCppType_t type, TCppObject_t self );
55  TCppObject_t CallO( TCppMethod_t method, TCppObject_t self, void* args, TCppType_t result_type );
56 
57  TCppMethPtrGetter_t GetMethPtrGetter( TCppScope_t scope, TCppIndex_t imeth );
58 
59 // handling of function argument buffer --------------------------------------
60  void* AllocateFunctionArgs( size_t nargs );
61  void DeallocateFunctionArgs( void* args );
62  size_t GetFunctionArgSizeof();
63  size_t GetFunctionArgTypeoffset();
64 
65 // scope reflection information ----------------------------------------------
66  Bool_t IsNamespace( TCppScope_t scope );
67  Bool_t IsAbstract( TCppType_t type );
68  Bool_t IsEnum( const std::string& type_name );
69 
70 // class reflection information ----------------------------------------------
71  std::string GetFinalName( TCppType_t type );
72  std::string GetScopedFinalName( TCppType_t type );
73  Bool_t HasComplexHierarchy( TCppType_t type );
74  TCppIndex_t GetNumBases( TCppType_t type );
75  std::string GetBaseName( TCppType_t type, TCppIndex_t ibase );
76  Bool_t IsSubtype( TCppType_t derived, TCppType_t base );
77  void AddSmartPtrType( const std::string& );
78  Bool_t IsSmartPtr( const std::string& );
79 
80 // calculate offsets between declared and actual type, up-cast: direction > 0; down-cast: direction < 0
81  ptrdiff_t GetBaseOffset(
82  TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror = false );
83 
84 // method/function reflection information ------------------------------------
85  TCppIndex_t GetNumMethods( TCppScope_t scope );
86  TCppIndex_t GetMethodIndexAt( TCppScope_t scope, TCppIndex_t imeth );
87  std::vector< TCppMethod_t > GetMethodsFromName( TCppScope_t scope, const std::string& name );
88 
89  TCppMethod_t GetMethod( TCppScope_t scope, TCppIndex_t imeth );
90 
91  std::string GetMethodName( TCppMethod_t );
92  std::string GetMethodResultType( TCppMethod_t );
93  TCppIndex_t GetMethodNumArgs( TCppMethod_t );
94  TCppIndex_t GetMethodReqArgs( TCppMethod_t );
95  std::string GetMethodArgName( TCppMethod_t, int iarg );
96  std::string GetMethodArgType( TCppMethod_t, int iarg );
97  std::string GetMethodArgDefault( TCppMethod_t, int iarg );
98  std::string GetMethodSignature( TCppScope_t scope, TCppIndex_t imeth );
99  Bool_t IsConstMethod( TCppMethod_t );
100 
101  Bool_t IsMethodTemplate( TCppMethod_t );
102  TCppIndex_t GetMethodNumTemplateArgs( TCppScope_t scope, TCppIndex_t imeth );
103  std::string GetMethodTemplateArgName( TCppScope_t scope, TCppIndex_t imeth, TCppIndex_t iarg );
104 
105  TCppIndex_t GetGlobalOperator(
106  TCppType_t scope, TCppType_t lc, TCppScope_t rc, const std::string& op );
107 
108 // method properties ---------------------------------------------------------
109  Bool_t IsConstructor( TCppMethod_t method );
110  Bool_t IsPublicMethod( TCppMethod_t method );
111  Bool_t IsStaticMethod( TCppMethod_t method );
112 
113 // data member reflection information ----------------------------------------
114  TCppIndex_t GetNumDatamembers( TCppScope_t scope );
115  std::string GetDatamemberName( TCppScope_t scope, TCppIndex_t idata );
116  std::string GetDatamemberType( TCppScope_t scope, TCppIndex_t idata );
117  ptrdiff_t GetDatamemberOffset( TCppScope_t scope, TCppIndex_t idata );
118  TCppIndex_t GetDatamemberIndex( TCppScope_t scope, const std::string& name );
119 
120 // data member properties ----------------------------------------------------
121  Bool_t IsPublicData( TCppScope_t scope, TCppIndex_t idata );
122  Bool_t IsStaticData( TCppScope_t scope, TCppIndex_t idata );
123  Bool_t IsConstData( TCppScope_t scope, TCppIndex_t idata );
124  Bool_t IsEnumData( TCppScope_t scope, TCppIndex_t idata );
125  Int_t GetDimensionSize( TCppScope_t scope, TCppIndex_t idata, int dimension );
126 
127 } // namespace Cppyy
128 
129 #endif // ifndef PYROOT_CPPYY_H
Double_t CallD(TCppMethod_t method, TCppObject_t self, void *args)
TCppScope_t TCppType_t
Definition: Cppyy.h:13
size_t GetFunctionArgSizeof()
Definition: Cppyy.cxx:501
std::string GetScopedFinalName(TCppType_t type)
Definition: Cppyy.cxx:544
long long Long64_t
Definition: RtypesCore.h:69
Bool_t IsNamespace(TCppScope_t scope)
Definition: Cppyy.cxx:513
float Float_t
Definition: RtypesCore.h:53
Bool_t IsBuiltin(const std::string &type_name)
Definition: Cppyy.cxx:199
TCppIndex_t GetGlobalOperator(TCppType_t scope, TCppType_t lc, TCppScope_t rc, const std::string &op)
Definition: Cppyy.cxx:815
Bool_t IsMethodTemplate(TCppMethod_t)
Definition: Cppyy.cxx:793
ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
Definition: Cppyy.cxx:594
Bool_t IsPublicMethod(TCppMethod_t method)
Definition: Cppyy.cxx:831
LongDouble_t CallLD(TCppMethod_t method, TCppObject_t self, void *args)
TCppIndex_t GetNumBases(TCppType_t type)
Definition: Cppyy.cxx:557
Int_t CallI(TCppMethod_t method, TCppObject_t self, void *args)
TCppIndex_t GetMethodReqArgs(TCppMethod_t)
Definition: Cppyy.cxx:736
std::vector< TCppMethod_t > GetMethodsFromName(TCppScope_t scope, const std::string &name)
Definition: Cppyy.cxx:664
Bool_t IsAbstract(TCppType_t type)
Definition: Cppyy.cxx:521
std::string GetFinalName(TCppType_t type)
Definition: Cppyy.cxx:535
std::string GetMethodSignature(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:778
Float_t CallF(TCppMethod_t method, TCppObject_t self, void *args)
ptrdiff_t GetDatamemberOffset(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:920
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:996
std::string GetDatamemberType(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:885
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:472
Int_t GetDimensionSize(TCppScope_t scope, TCppIndex_t idata, int dimension)
Definition: Cppyy.cxx:1010
TCppObject_t CallConstructor(TCppMethod_t method, TCppType_t type, void *args)
Definition: Cppyy.cxx:458
std::string GetBaseName(TCppType_t type, TCppIndex_t ibase)
Definition: Cppyy.cxx:566
Char_t * CallS(TCppMethod_t method, TCppObject_t self, void *args)
Definition: Cppyy.cxx:450
TCppIndex_t GetMethodIndexAt(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:659
Definition: Cppyy.h:10
TCppIndex_t GetMethodNumTemplateArgs(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:803
TCppType_t GetTemplate(const std::string &template_name)
Definition: Cppyy.cxx:176
std::string ResolveName(const std::string &cppitem_name)
Definition: Cppyy.cxx:140
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:551
TCppMethPtrGetter_t GetMethPtrGetter(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:483
TCppIndex_t GetNumDatamembers(TCppScope_t scope)
Definition: Cppyy.cxx:850
Bool_t IsConstData(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:982
void CallDestructor(TCppType_t type, TCppObject_t self)
Definition: Cppyy.cxx:466
Bool_t IsComplete(const std::string &type_name)
Definition: Cppyy.cxx:206
TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:701
size_t GetFunctionArgTypeoffset()
Definition: Cppyy.cxx:506
std::string GetMethodTemplateArgName(TCppScope_t scope, TCppIndex_t imeth, TCppIndex_t iarg)
Definition: Cppyy.cxx:809
Bool_t IsConstructor(TCppMethod_t method)
Definition: Cppyy.cxx:822
TCppType_t GetActualClass(TCppType_t klass, TCppObject_t obj)
Definition: Cppyy.cxx:181
void AddSmartPtrType(const std::string &)
Definition: Cppyy.cxx:581
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:960
std::string GetMethodName(TCppMethod_t)
Definition: Cppyy.cxx:707
void * AllocateFunctionArgs(size_t nargs)
Definition: Cppyy.cxx:491
short Short_t
Definition: RtypesCore.h:35
TCppIndex_t GetDatamemberIndex(TCppScope_t scope, const std::string &name)
Definition: Cppyy.cxx:936
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:442
long Long_t
Definition: RtypesCore.h:50
Bool_t IsSubtype(TCppType_t derived, TCppType_t base)
Definition: Cppyy.cxx:572
TCppScope_t GetScope(const std::string &scope_name)
Definition: Cppyy.cxx:150
double Double_t
Definition: RtypesCore.h:55
std::string GetMethodResultType(TCppMethod_t)
Definition: Cppyy.cxx:718
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:729
std::string GetMethodArgName(TCppMethod_t, int iarg)
Definition: Cppyy.cxx:745
void Deallocate(TCppType_t type, TCppObject_t instance)
Definition: Cppyy.cxx:234
TCppObject_t Allocate(TCppType_t type)
Definition: Cppyy.cxx:228
std::string GetMethodArgType(TCppMethod_t, int iarg)
Definition: Cppyy.cxx:755
Bool_t IsSmartPtr(const std::string &)
Definition: Cppyy.cxx:585
#define name(a, b)
Definition: linkTestLib0.cpp:5
Bool_t IsStaticMethod(TCppMethod_t method)
Definition: Cppyy.cxx:840
std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:873
char Char_t
Definition: RtypesCore.h:29
Bool_t IsStaticData(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:971
size_t SizeOf(TCppType_t klass)
Definition: Cppyy.cxx:192
Long_t TCppIndex_t
Definition: Cppyy.h:17
Bool_t IsConstMethod(TCppMethod_t)
Definition: Cppyy.cxx:783
TCppIndex_t GetNumMethods(TCppScope_t scope)
Definition: Cppyy.cxx:633
void CallV(TCppMethod_t method, TCppObject_t self, void *args)
Definition: Cppyy.cxx:426
unsigned char UChar_t
Definition: RtypesCore.h:34
TCppObject_t Construct(TCppType_t type)
Definition: Cppyy.cxx:239
void Destruct(TCppType_t type, TCppObject_t instance)
Definition: Cppyy.cxx:245
void *(* TCppMethPtrGetter_t)(TCppObject_t)
Definition: Cppyy.h:18
TObject * obj
std::string GetMethodArgDefault(TCppMethod_t, int iarg)
Definition: Cppyy.cxx:765
ptrdiff_t TCppScope_t
Definition: Cppyy.h:12
void DeallocateFunctionArgs(void *args)
Definition: Cppyy.cxx:496
Bool_t IsEnum(const std::string &type_name)
Definition: Cppyy.cxx:529
std::string GetScopeName(TCppScope_t parent, TCppIndex_t iscope)
Definition: Cppyy.cxx:128