Logo ROOT  
Reference Guide
Cppyy.h
Go to the documentation of this file.
1 #ifndef CPYCPPYY_CPPYY_H
2 #define CPYCPPYY_CPPYY_H
3 
4 // Standard
5 #include <set>
6 #include <string>
7 #include <vector>
8 #include <stddef.h>
9 #include <stdint.h>
10 
11 // import/export (after precommondefs.h from PyPy)
12 #ifdef _MSC_VER
13 #define CPPYY_IMPORT extern __declspec(dllimport)
14 #else
15 #define CPPYY_IMPORT extern
16 #endif
17 
18 
19 namespace Cppyy {
20 
21  typedef size_t TCppScope_t;
22  typedef TCppScope_t TCppType_t;
23  typedef void* TCppEnum_t;
24  typedef void* TCppObject_t;
25  typedef intptr_t TCppMethod_t;
26 
27  typedef size_t TCppIndex_t;
28  typedef void* TCppFuncAddr_t;
29 
30 // direct interpreter access -------------------------------------------------
32  bool Compile(const std::string& code);
33 
34 // name to opaque C++ scope representation -----------------------------------
36  std::string ResolveName(const std::string& cppitem_name);
38  std::string ResolveEnum(const std::string& enum_type);
40  TCppScope_t GetScope(const std::string& scope_name);
44  size_t SizeOf(TCppType_t klass);
46  size_t SizeOf(const std::string& type_name);
47 
49  bool IsBuiltin(const std::string& type_name);
51  bool IsComplete(const std::string& type_name);
52 
54  TCppScope_t gGlobalScope; // for fast access
55 
56 // memory management ---------------------------------------------------------
65 
66 // method/function dispatching -----------------------------------------------
68  void CallV(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
70  unsigned char CallB(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
72  char CallC(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
74  short CallH(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
76  int CallI(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
78  long CallL(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
80  Long64_t CallLL(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
82  float CallF(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
84  double CallD(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
86  LongDouble_t CallLD(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
88  void* CallR(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
90  char* CallS(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args, size_t* length);
92  TCppObject_t CallConstructor(TCppMethod_t method, TCppType_t type, size_t nargs, void* args);
96  TCppObject_t CallO(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args, TCppType_t result_type);
97 
99  TCppFuncAddr_t GetFunctionAddress(TCppMethod_t method, bool check_enabled=true);
100 
101 // handling of function argument buffer --------------------------------------
103  void* AllocateFunctionArgs(size_t nargs);
105  void DeallocateFunctionArgs(void* args);
107  size_t GetFunctionArgSizeof();
109  size_t GetFunctionArgTypeoffset();
110 
111 // scope reflection information ----------------------------------------------
113  bool IsNamespace(TCppScope_t scope);
115  bool IsTemplate(const std::string& template_name);
117  bool IsAbstract(TCppType_t type);
119  bool IsEnum(const std::string& type_name);
120 
122  void GetAllCppNames(TCppScope_t scope, std::set<std::string>& cppnames);
123 
124 // namespace reflection information ------------------------------------------
126  std::vector<TCppScope_t> GetUsingNamespaces(TCppScope_t);
127 
128 // class reflection information ----------------------------------------------
130  std::string GetFinalName(TCppType_t type);
132  std::string GetScopedFinalName(TCppType_t type);
140  std::string GetBaseName(TCppType_t type, TCppIndex_t ibase);
142  bool IsSubtype(TCppType_t derived, TCppType_t base);
144  bool IsSmartPtr(TCppType_t type);
146  bool GetSmartPtrInfo(const std::string&, TCppType_t* raw, TCppMethod_t* deref);
148  void AddSmartPtrType(const std::string&);
149 
150 // calculate offsets between declared and actual type, up-cast: direction > 0; down-cast: direction < 0
152  ptrdiff_t GetBaseOffset(
153  TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror = false);
154 
155 // method/function reflection information ------------------------------------
159  std::vector<TCppIndex_t> GetMethodIndicesFromName(TCppScope_t scope, const std::string& name);
160 
163 
165  std::string GetMethodName(TCppMethod_t);
167  std::string GetMethodFullName(TCppMethod_t);
169  std::string GetMethodMangledName(TCppMethod_t);
171  std::string GetMethodResultType(TCppMethod_t);
177  std::string GetMethodArgName(TCppMethod_t, TCppIndex_t iarg);
179  std::string GetMethodArgType(TCppMethod_t, TCppIndex_t iarg);
181  std::string GetMethodArgDefault(TCppMethod_t, TCppIndex_t iarg);
183  std::string GetMethodSignature(TCppMethod_t, bool show_formalargs, TCppIndex_t maxargs = (TCppIndex_t)-1);
185  std::string GetMethodPrototype(TCppScope_t scope, TCppMethod_t, bool show_formalargs);
188 
192  std::string GetTemplatedMethodName(TCppScope_t scope, TCppIndex_t imeth);
196  bool ExistsMethodTemplate(TCppScope_t scope, const std::string& name);
198  bool IsMethodTemplate(TCppScope_t scope, TCppIndex_t imeth);
201  TCppScope_t scope, const std::string& name, const std::string& proto);
202 
205  TCppType_t scope, const std::string& lc, const std::string& rc, const std::string& op);
206 
207 // method properties ---------------------------------------------------------
209  bool IsPublicMethod(TCppMethod_t method);
211  bool IsProtectedMethod(TCppMethod_t method);
213  bool IsConstructor(TCppMethod_t method);
215  bool IsDestructor(TCppMethod_t method);
217  bool IsStaticMethod(TCppMethod_t method);
218 
219 // data member reflection information ----------------------------------------
223  std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata);
225  std::string GetDatamemberType(TCppScope_t scope, TCppIndex_t idata);
227  intptr_t GetDatamemberOffset(TCppScope_t scope, TCppIndex_t idata);
229  TCppIndex_t GetDatamemberIndex(TCppScope_t scope, const std::string& name);
230 
231 // data member properties ----------------------------------------------------
233  bool IsPublicData(TCppScope_t scope, TCppIndex_t idata);
235  bool IsProtectedData(TCppScope_t scope, TCppIndex_t idata);
237  bool IsStaticData(TCppScope_t scope, TCppIndex_t idata);
239  bool IsConstData(TCppScope_t scope, TCppIndex_t idata);
241  bool IsEnumData(TCppScope_t scope, TCppIndex_t idata);
243  int GetDimensionSize(TCppScope_t scope, TCppIndex_t idata, int dimension);
244 
245 // enum properties -----------------------------------------------------------
247  TCppEnum_t GetEnum(TCppScope_t scope, const std::string& enum_name);
251  std::string GetEnumDataName(TCppEnum_t, TCppIndex_t idata);
253  long long GetEnumDataValue(TCppEnum_t, TCppIndex_t idata);
254 
255 } // namespace Cppyy
256 
257 #endif // !CPYCPPYY_CPPYY_H
Cppyy::GetNumTemplatedMethods
RPY_EXPORTED TCppIndex_t GetNumTemplatedMethods(TCppScope_t scope)
Definition: clingwrapper.cxx:1558
Cppyy::TCppEnum_t
void * TCppEnum_t
Definition: cpp_cppyy.h:20
Cppyy::IsStaticData
RPY_EXPORTED bool IsStaticData(TCppScope_t scope, TCppIndex_t idata)
Definition: clingwrapper.cxx:1989
Cppyy::CallV
RPY_EXPORTED void CallV(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
Definition: clingwrapper.cxx:827
Cppyy::GetMethodFullName
RPY_EXPORTED std::string GetMethodFullName(TCppMethod_t)
Definition: clingwrapper.cxx:1412
Cppyy::IsEnumData
RPY_EXPORTED bool IsEnumData(TCppScope_t scope, TCppIndex_t idata)
Definition: clingwrapper.cxx:2014
Cppyy::ResolveEnum
RPY_EXPORTED std::string ResolveEnum(const std::string &enum_type)
Definition: clingwrapper.cxx:444
Cppyy::GetDatamemberIndex
RPY_EXPORTED TCppIndex_t GetDatamemberIndex(TCppScope_t scope, const std::string &name)
Definition: clingwrapper.cxx:1911
Cppyy::GetDatamemberType
RPY_EXPORTED std::string GetDatamemberType(TCppScope_t scope, TCppIndex_t idata)
Definition: clingwrapper.cxx:1835
Cppyy::GetMethodTemplate
RPY_EXPORTED TCppMethod_t GetMethodTemplate(TCppScope_t scope, const std::string &name, const std::string &proto)
Definition: clingwrapper.cxx:1635
Cppyy::Compile
RPY_EXPORTED bool Compile(const std::string &code)
Definition: clingwrapper.cxx:374
Cppyy::GetMethodArgType
RPY_EXPORTED std::string GetMethodArgType(TCppMethod_t, TCppIndex_t iarg)
Definition: clingwrapper.cxx:1487
Cppyy::GetSmartPtrInfo
RPY_EXPORTED bool GetSmartPtrInfo(const std::string &, TCppType_t *raw, TCppMethod_t *deref)
Definition: clingwrapper.cxx:1245
Cppyy::SizeOf
RPY_EXPORTED size_t SizeOf(TCppType_t klass)
Definition: clingwrapper.cxx:618
Cppyy
Definition: cpp_cppyy.h:17
Cppyy::TCppScope_t
size_t TCppScope_t
Definition: cpp_cppyy.h:18
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
Cppyy::GetFunctionAddress
RPY_EXPORTED TCppFuncAddr_t GetFunctionAddress(TCppMethod_t method, bool check_enabled=true)
Definition: clingwrapper.cxx:892
Cppyy::IsStaticMethod
RPY_EXPORTED bool IsStaticMethod(TCppMethod_t method)
Definition: clingwrapper.cxx:1784
Cppyy::IsSubtype
RPY_EXPORTED bool IsSubtype(TCppType_t derived, TCppType_t base)
Definition: clingwrapper.cxx:1227
Cppyy::GetUsingNamespaces
RPY_EXPORTED std::vector< TCppScope_t > GetUsingNamespaces(TCppScope_t)
Definition: clingwrapper.cxx:1119
Cppyy::GetMethodArgName
RPY_EXPORTED std::string GetMethodArgName(TCppMethod_t, TCppIndex_t iarg)
Definition: clingwrapper.cxx:1477
Cppyy::GetMethodReqArgs
RPY_EXPORTED TCppIndex_t GetMethodReqArgs(TCppMethod_t)
Definition: clingwrapper.cxx:1468
Cppyy::ResolveName
RPY_EXPORTED std::string ResolveName(const std::string &cppitem_name)
Definition: clingwrapper.cxx:381
Cppyy::GetTemplatedMethodName
RPY_EXPORTED std::string GetTemplatedMethodName(TCppScope_t scope, TCppIndex_t imeth)
Definition: clingwrapper.cxx:1575
Cppyy::CallL
RPY_EXPORTED long CallL(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
Cppyy::IsDestructor
RPY_EXPORTED bool IsDestructor(TCppMethod_t method)
Definition: clingwrapper.cxx:1775
Cppyy::TCppFuncAddr_t
void * TCppFuncAddr_t
Definition: cpp_cppyy.h:25
Cppyy::AddSmartPtrType
RPY_EXPORTED void AddSmartPtrType(const std::string &)
Definition: clingwrapper.cxx:1271
Cppyy::GetDimensionSize
RPY_EXPORTED int GetDimensionSize(TCppScope_t scope, TCppIndex_t idata, int dimension)
Definition: clingwrapper.cxx:2054
Cppyy::GetMethodSignature
RPY_EXPORTED std::string GetMethodSignature(TCppMethod_t, bool show_formalargs, TCppIndex_t maxargs=(TCppIndex_t) -1)
Definition: clingwrapper.cxx:1510
Cppyy::IsSmartPtr
RPY_EXPORTED bool IsSmartPtr(TCppType_t type)
Definition: clingwrapper.cxx:1236
Cppyy::GetMethodNumArgs
RPY_EXPORTED TCppIndex_t GetMethodNumArgs(TCppMethod_t)
Definition: clingwrapper.cxx:1461
Cppyy::IsConstData
RPY_EXPORTED bool IsConstData(TCppScope_t scope, TCppIndex_t idata)
Definition: clingwrapper.cxx:2000
Cppyy::GetActualClass
RPY_EXPORTED TCppType_t GetActualClass(TCppType_t klass, TCppObject_t obj)
Definition: clingwrapper.cxx:565
Cppyy::GetAllCppNames
RPY_EXPORTED void GetAllCppNames(TCppScope_t scope, std::set< std::string > &cppnames)
Definition: clingwrapper.cxx:1027
Cppyy::IsProtectedData
RPY_EXPORTED bool IsProtectedData(TCppScope_t scope, TCppIndex_t idata)
Definition: clingwrapper.cxx:1978
Cppyy::IsBuiltin
RPY_EXPORTED bool IsBuiltin(const std::string &type_name)
Definition: clingwrapper.cxx:633
Cppyy::IsConstructor
RPY_EXPORTED bool IsConstructor(TCppMethod_t method)
Definition: clingwrapper.cxx:1766
Cppyy::GetBaseName
RPY_EXPORTED std::string GetBaseName(TCppType_t type, TCppIndex_t ibase)
Definition: clingwrapper.cxx:1221
Cppyy::Allocate
RPY_EXPORTED TCppObject_t Allocate(TCppType_t type)
Definition: clingwrapper.cxx:662
Cppyy::HasVirtualDestructor
RPY_EXPORTED bool HasVirtualDestructor(TCppType_t type)
Definition: clingwrapper.cxx:1175
Cppyy::IsProtectedMethod
RPY_EXPORTED bool IsProtectedMethod(TCppMethod_t method)
Definition: clingwrapper.cxx:1757
Cppyy::GetScope
RPY_EXPORTED TCppScope_t GetScope(const std::string &scope_name)
Definition: clingwrapper.cxx:497
Cppyy::ExistsMethodTemplate
RPY_EXPORTED bool ExistsMethodTemplate(TCppScope_t scope, const std::string &name)
Definition: clingwrapper.cxx:1604
Cppyy::GetMethodIndicesFromName
RPY_EXPORTED std::vector< TCppIndex_t > GetMethodIndicesFromName(TCppScope_t scope, const std::string &name)
Definition: clingwrapper.cxx:1351
Cppyy::TCppIndex_t
size_t TCppIndex_t
Definition: cpp_cppyy.h:24
CPPYY_IMPORT
#define CPPYY_IMPORT
Definition: Cppyy.h:15
Cppyy::GetDatamemberOffset
RPY_EXPORTED intptr_t GetDatamemberOffset(TCppScope_t scope, TCppIndex_t idata)
Definition: clingwrapper.cxx:1878
Cppyy::IsPublicMethod
RPY_EXPORTED bool IsPublicMethod(TCppMethod_t method)
Definition: clingwrapper.cxx:1748
Cppyy::GetEnumDataValue
RPY_EXPORTED long long GetEnumDataValue(TCppEnum_t, TCppIndex_t idata)
Definition: clingwrapper.cxx:2092
Cppyy::HasComplexHierarchy
RPY_EXPORTED bool HasComplexHierarchy(TCppType_t type)
Definition: clingwrapper.cxx:1188
Cppyy::CallR
RPY_EXPORTED void * CallR(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
Definition: clingwrapper.cxx:843
Cppyy::IsTemplate
RPY_EXPORTED bool IsTemplate(const std::string &template_name)
Definition: clingwrapper.cxx:553
Cppyy::GetMethodArgDefault
RPY_EXPORTED std::string GetMethodArgDefault(TCppMethod_t, TCppIndex_t iarg)
Definition: clingwrapper.cxx:1497
Cppyy::gGlobalScope
RPY_EXPORTED TCppScope_t gGlobalScope
Definition: cpp_cppyy.h:51
Cppyy::IsNamespace
RPY_EXPORTED bool IsNamespace(TCppScope_t scope)
Definition: clingwrapper.cxx:923
Cppyy::CallB
RPY_EXPORTED unsigned char CallB(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
Cppyy::CallDestructor
RPY_EXPORTED void CallDestructor(TCppType_t type, TCppObject_t self)
Definition: clingwrapper.cxx:876
Cppyy::IsTemplatedConstructor
RPY_EXPORTED bool IsTemplatedConstructor(TCppScope_t scope, TCppIndex_t imeth)
Definition: clingwrapper.cxx:1590
Cppyy::GetMethodPrototype
RPY_EXPORTED std::string GetMethodPrototype(TCppScope_t scope, TCppMethod_t, bool show_formalargs)
Definition: clingwrapper.cxx:1535
Cppyy::IsPublicData
RPY_EXPORTED bool IsPublicData(TCppScope_t scope, TCppIndex_t idata)
Definition: clingwrapper.cxx:1967
Cppyy::CallO
RPY_EXPORTED TCppObject_t CallO(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args, TCppType_t result_type)
Definition: clingwrapper.cxx:882
Cppyy::GetNumDatamembers
RPY_EXPORTED TCppIndex_t GetNumDatamembers(TCppScope_t scope)
Definition: clingwrapper.cxx:1794
Cppyy::Destruct
RPY_EXPORTED void Destruct(TCppType_t type, TCppObject_t instance)
Definition: clingwrapper.cxx:680
Cppyy::GetScopedFinalName
RPY_EXPORTED std::string GetScopedFinalName(TCppType_t type)
Definition: clingwrapper.cxx:1161
Cppyy::CallC
RPY_EXPORTED char CallC(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
Cppyy::CallF
RPY_EXPORTED float CallF(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
Cppyy::CallLL
RPY_EXPORTED Long64_t CallLL(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
Cppyy::IsConstMethod
RPY_EXPORTED bool IsConstMethod(TCppMethod_t)
Definition: clingwrapper.cxx:1549
Cppyy::GetNumEnumData
RPY_EXPORTED TCppIndex_t GetNumEnumData(TCppEnum_t)
Definition: clingwrapper.cxx:2082
Cppyy::GetNumBases
RPY_EXPORTED TCppIndex_t GetNumBases(TCppType_t type)
Definition: clingwrapper.cxx:1212
Cppyy::TCppType_t
TCppScope_t TCppType_t
Definition: cpp_cppyy.h:19
Cppyy::TCppObject_t
void * TCppObject_t
Definition: cpp_cppyy.h:21
RooFit_internal::instance
static Roo_reg_AGKInteg1D instance
Definition: RooAdaptiveGaussKronrodIntegrator1D.cxx:153
Cppyy::CallH
RPY_EXPORTED short CallH(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
Cppyy::CallI
RPY_EXPORTED int CallI(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
Cppyy::Deallocate
RPY_EXPORTED void Deallocate(TCppType_t type, TCppObject_t instance)
Definition: clingwrapper.cxx:668
proto
const char * proto
Definition: civetweb.c:16604
Cppyy::GetFinalName
RPY_EXPORTED std::string GetFinalName(TCppType_t type)
Definition: clingwrapper.cxx:1148
Cppyy::TCppMethod_t
intptr_t TCppMethod_t
Definition: cpp_cppyy.h:22
LongDouble_t
long double LongDouble_t
Definition: RtypesCore.h:61
Cppyy::CallLD
RPY_EXPORTED LongDouble_t CallLD(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
Cppyy::GetMethod
RPY_EXPORTED TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
Definition: clingwrapper.cxx:1386
Cppyy::GetEnum
RPY_EXPORTED TCppEnum_t GetEnum(TCppScope_t scope, const std::string &enum_name)
Definition: clingwrapper.cxx:2070
Cppyy::CallD
RPY_EXPORTED double CallD(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
Cppyy::IsEnum
RPY_EXPORTED bool IsEnum(const std::string &type_name)
Definition: clingwrapper.cxx:943
Cppyy::GetEnumDataName
RPY_EXPORTED std::string GetEnumDataName(TCppEnum_t, TCppIndex_t idata)
Definition: clingwrapper.cxx:2087
Cppyy::GetBaseOffset
RPY_EXPORTED ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
Definition: clingwrapper.cxx:1278
Cppyy::DeallocateFunctionArgs
RPY_EXPORTED void DeallocateFunctionArgs(void *args)
Definition: clingwrapper.cxx:906
Cppyy::GetGlobalOperator
RPY_EXPORTED TCppIndex_t GetGlobalOperator(TCppType_t scope, const std::string &lc, const std::string &rc, const std::string &op)
Definition: clingwrapper.cxx:1717
name
char name[80]
Definition: TGX11.cxx:110
Cppyy::Construct
RPY_EXPORTED TCppObject_t Construct(TCppType_t type)
Definition: clingwrapper.cxx:673
Cppyy::IsMethodTemplate
RPY_EXPORTED bool IsMethodTemplate(TCppScope_t scope, TCppIndex_t imeth)
Definition: clingwrapper.cxx:1618
Cppyy::IsAbstract
RPY_EXPORTED bool IsAbstract(TCppType_t type)
Definition: clingwrapper.cxx:934
Cppyy::GetMethodName
RPY_EXPORTED std::string GetMethodName(TCppMethod_t)
Definition: clingwrapper.cxx:1399
Cppyy::GetDatamemberName
RPY_EXPORTED std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata)
Definition: clingwrapper.cxx:1823
Cppyy::CallConstructor
RPY_EXPORTED TCppObject_t CallConstructor(TCppMethod_t method, TCppType_t type, size_t nargs, void *args)
Definition: clingwrapper.cxx:867
Cppyy::GetNumMethods
RPY_EXPORTED TCppIndex_t GetNumMethods(TCppScope_t scope)
Definition: clingwrapper.cxx:1319
type
int type
Definition: TGX11.cxx:121
Cppyy::GetMethodMangledName
RPY_EXPORTED std::string GetMethodMangledName(TCppMethod_t)
Definition: clingwrapper.cxx:1422
Cppyy::GetMethodResultType
RPY_EXPORTED std::string GetMethodResultType(TCppMethod_t)
Definition: clingwrapper.cxx:1429
Cppyy::IsComplete
RPY_EXPORTED bool IsComplete(const std::string &type_name)
Definition: clingwrapper.cxx:640
Cppyy::GetFunctionArgTypeoffset
RPY_EXPORTED size_t GetFunctionArgTypeoffset()
Definition: clingwrapper.cxx:916
Cppyy::GetFunctionArgSizeof
RPY_EXPORTED size_t GetFunctionArgSizeof()
Definition: clingwrapper.cxx:911
Cppyy::AllocateFunctionArgs
RPY_EXPORTED void * AllocateFunctionArgs(size_t nargs)
Definition: clingwrapper.cxx:901
Cppyy::CallS
RPY_EXPORTED char * CallS(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args, size_t *length)
Definition: clingwrapper.cxx:851