Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
Cppyy.h
Go to the documentation of this file.
1 #ifndef PYROOT_CPPYY_H
2 #define PYROOT_CPPYY_H
3 
4 // ROOT
5 #include "TEnum.h"
6 
7 // Standard
8 #include <string>
9 #include <vector>
10 #include <stddef.h>
11 
12 
13 namespace Cppyy {
14 
15  typedef ptrdiff_t TCppScope_t;
16  typedef TCppScope_t TCppType_t;
17  typedef void* TCppObject_t;
18  typedef ptrdiff_t TCppMethod_t;
19  typedef void* TCppEnum_t;
20 
21  typedef Long_t TCppIndex_t;
22  typedef void* (*TCppMethPtrGetter_t)( TCppObject_t );
23 
24 // name to opaque C++ scope representation -----------------------------------
25  TCppIndex_t GetNumScopes( TCppScope_t parent );
26  std::string GetScopeName( TCppScope_t parent, TCppIndex_t iscope );
27  std::string ResolveName( const std::string& cppitem_name );
28  std::string ResolveEnum(const TEnum* en);
29  std::string ResolveEnum(const std::string& enum_type);
30  TCppScope_t GetScope( const std::string& scope_name );
31  std::string GetName( const std::string& scope_name );
32  TCppType_t GetTemplate( const std::string& template_name );
33  TCppType_t GetActualClass( TCppType_t klass, TCppObject_t obj );
34  size_t SizeOf( TCppType_t klass );
35 
36  Bool_t IsBuiltin( const std::string& type_name );
37  Bool_t IsComplete( const std::string& type_name );
38 
39  extern TCppScope_t gGlobalScope; // for fast access
40 
41 // memory management ---------------------------------------------------------
42  TCppObject_t Allocate( TCppType_t type );
43  void Deallocate( TCppType_t type, TCppObject_t instance );
44  TCppObject_t Construct( TCppType_t type );
45  void Destruct( TCppType_t type, TCppObject_t instance );
46 
47 // method/function dispatching -----------------------------------------------
48  void CallV( TCppMethod_t method, TCppObject_t self, void* args );
49  UChar_t CallB( TCppMethod_t method, TCppObject_t self, void* args );
50  Char_t CallC( TCppMethod_t method, TCppObject_t self, void* args );
51  Short_t CallH( TCppMethod_t method, TCppObject_t self, void* args );
52  Int_t CallI( TCppMethod_t method, TCppObject_t self, void* args );
53  Long_t CallL( TCppMethod_t method, TCppObject_t self, void* args );
54  Long64_t CallLL( TCppMethod_t method, TCppObject_t self, void* args );
55  Float_t CallF( TCppMethod_t method, TCppObject_t self, void* args );
56  Double_t CallD( TCppMethod_t method, TCppObject_t self, void* args );
57  LongDouble_t CallLD( TCppMethod_t method, TCppObject_t self, void* args );
58  void* CallR( TCppMethod_t method, TCppObject_t self, void* args );
59  Char_t* CallS( TCppMethod_t method, TCppObject_t self, void* args );
60  TCppObject_t CallConstructor( TCppMethod_t method, TCppType_t type, void* args );
61  void CallDestructor( TCppType_t type, TCppObject_t self );
62  TCppObject_t CallO( TCppMethod_t method, TCppObject_t self, void* args, TCppType_t result_type );
63 
64  TCppMethPtrGetter_t GetMethPtrGetter( TCppScope_t scope, TCppIndex_t imeth );
65 
66 // handling of function argument buffer --------------------------------------
67  void* AllocateFunctionArgs( size_t nargs );
68  void DeallocateFunctionArgs( void* args );
69  size_t GetFunctionArgSizeof();
70  size_t GetFunctionArgTypeoffset();
71 
72 // scope reflection information ----------------------------------------------
73  Bool_t IsNamespace( TCppScope_t scope );
74  Bool_t IsAbstract( TCppType_t type );
75  Bool_t IsEnum( const std::string& type_name );
76 
77 // class reflection information ----------------------------------------------
78  std::string GetFinalName( TCppType_t type );
79  std::string GetScopedFinalName( TCppType_t type );
80  Bool_t HasComplexHierarchy( TCppType_t type );
81  TCppIndex_t GetNumBases( TCppType_t type );
82  std::string GetBaseName( TCppType_t type, TCppIndex_t ibase );
83  Bool_t IsSubtype( TCppType_t derived, TCppType_t base );
84  void AddSmartPtrType( const std::string& );
85  Bool_t IsSmartPtr( const std::string& );
86 
87 // calculate offsets between declared and actual type, up-cast: direction > 0; down-cast: direction < 0
88  ptrdiff_t GetBaseOffset(
89  TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror = false );
90 
91 // method/function reflection information ------------------------------------
92  TCppIndex_t GetNumMethods( TCppScope_t scope );
93  TCppIndex_t GetMethodIndexAt( TCppScope_t scope, TCppIndex_t imeth );
94  std::vector< TCppMethod_t > GetMethodsFromName( TCppScope_t scope, const std::string& name, bool alsoInBases = false);
95 
96  TCppMethod_t GetMethod( TCppScope_t scope, TCppIndex_t imeth );
97 
98  std::string GetMethodName( TCppMethod_t );
99  std::string GetMethodResultType( TCppMethod_t );
100  TCppIndex_t GetMethodNumArgs( TCppMethod_t );
101  TCppIndex_t GetMethodReqArgs( TCppMethod_t );
102  std::string GetMethodArgName( TCppMethod_t, int iarg );
103  std::string GetMethodArgType( TCppMethod_t, int iarg );
104  std::string GetMethodArgDefault( TCppMethod_t, int iarg );
105  std::string GetMethodSignature( TCppScope_t scope, TCppIndex_t imeth );
106  Bool_t IsConstMethod( TCppMethod_t );
107 
108  bool ExistsMethodTemplate(TCppScope_t scope, const std::string& name);
109  TCppMethod_t GetMethodTemplate(TCppScope_t scope, const std::string& name, const std::string& proto);
110  Bool_t IsMethodTemplate( TCppMethod_t );
111  TCppIndex_t GetMethodNumTemplateArgs( TCppScope_t scope, TCppIndex_t imeth );
112  std::string GetMethodTemplateArgName( TCppScope_t scope, TCppIndex_t imeth, TCppIndex_t iarg );
113 
114  TCppIndex_t GetGlobalOperator(
115  TCppType_t scope, TCppType_t lc, TCppScope_t rc, const std::string& op );
116 
117 // method properties ---------------------------------------------------------
118  Bool_t IsConstructor( TCppMethod_t method );
119  Bool_t IsPublicMethod( TCppMethod_t method );
120  Bool_t IsStaticMethod( TCppMethod_t method );
121 
122 // data member reflection information ----------------------------------------
123  TCppIndex_t GetNumDatamembers( TCppScope_t scope );
124  std::string GetDatamemberName( TCppScope_t scope, TCppIndex_t idata );
125  std::string GetDatamemberType( TCppScope_t scope, TCppIndex_t idata );
126  ptrdiff_t GetDatamemberOffset( TCppScope_t scope, TCppIndex_t idata );
127  TCppIndex_t GetDatamemberIndex( TCppScope_t scope, const std::string& name );
128 
129 // data member properties ----------------------------------------------------
130  Bool_t IsPublicData( TCppScope_t scope, TCppIndex_t idata );
131  Bool_t IsStaticData( TCppScope_t scope, TCppIndex_t idata );
132  Bool_t IsConstData( TCppScope_t scope, TCppIndex_t idata );
133  Bool_t IsEnumData( TCppScope_t scope, TCppIndex_t idata );
134  Int_t GetDimensionSize( TCppScope_t scope, TCppIndex_t idata, int dimension );
135 
136 // enum properties -----------------------------------------------------------
137  TCppEnum_t GetEnum(TCppScope_t scope, const std::string& enum_name);
138  TCppIndex_t GetNumEnumData(TCppEnum_t);
139  std::string GetEnumDataName(TCppEnum_t, TCppIndex_t idata);
140  long long GetEnumDataValue(TCppEnum_t, TCppIndex_t idata);
141 
142 } // namespace Cppyy
143 
144 #endif // ifndef PYROOT_CPPYY_H