Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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// some more types; assumes Cppyy.h follows Python.h
19#ifndef PY_LONG_LONG
20#ifdef _WIN32
21typedef __int64 PY_LONG_LONG;
22#else
23typedef long long PY_LONG_LONG;
24#endif
25#endif
26
27#ifndef PY_ULONG_LONG
28#ifdef _WIN32
29typedef unsigned __int64 PY_ULONG_LONG;
30#else
31typedef unsigned long long PY_ULONG_LONG;
32#endif
33#endif
34
35#ifndef PY_LONG_DOUBLE
36typedef long double PY_LONG_DOUBLE;
37#endif
38
39
40namespace Cppyy {
41
42 typedef size_t TCppScope_t;
43 typedef TCppScope_t TCppType_t;
44 typedef void* TCppEnum_t;
45 typedef void* TCppObject_t;
46 typedef intptr_t TCppMethod_t;
47
48 typedef size_t TCppIndex_t;
49 typedef void* TCppFuncAddr_t;
50
51// direct interpreter access -------------------------------------------------
53 bool Compile(const std::string& code, bool silent = false);
55 std::string ToString(TCppType_t klass, TCppObject_t obj);
56
57// name to opaque C++ scope representation -----------------------------------
59 std::string ResolveName(const std::string& cppitem_name);
61 std::string ResolveEnum(const std::string& enum_type);
63 TCppScope_t GetScope(const std::string& scope_name);
67 size_t SizeOf(TCppType_t klass);
69 size_t SizeOf(const std::string& type_name);
70
72 bool IsBuiltin(const std::string& type_name);
74 bool IsComplete(const std::string& type_name);
75
77 TCppScope_t gGlobalScope; // for fast access
78
79// memory management ---------------------------------------------------------
85 TCppObject_t Construct(TCppType_t type, void* arena = nullptr);
88
89// method/function dispatching -----------------------------------------------
91 void CallV(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
93 unsigned char CallB(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
95 char CallC(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
97 short CallH(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
99 int CallI(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
101 long CallL(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
103 PY_LONG_LONG CallLL(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
105 float CallF(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
107 double CallD(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
109 PY_LONG_DOUBLE CallLD(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
111 void* CallR(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args);
113 char* CallS(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args, size_t* length);
115 TCppObject_t CallConstructor(TCppMethod_t method, TCppType_t type, size_t nargs, void* args);
119 TCppObject_t CallO(TCppMethod_t method, TCppObject_t self, size_t nargs, void* args, TCppType_t result_type);
120
122 TCppFuncAddr_t GetFunctionAddress(TCppMethod_t method, bool check_enabled=true);
123
124// handling of function argument buffer --------------------------------------
126 void* AllocateFunctionArgs(size_t nargs);
128 void DeallocateFunctionArgs(void* args);
130 size_t GetFunctionArgSizeof();
133
134// scope reflection information ----------------------------------------------
136 bool IsNamespace(TCppScope_t scope);
138 bool IsTemplate(const std::string& template_name);
142 bool IsEnum(const std::string& type_name);
147
149 void GetAllCppNames(TCppScope_t scope, std::set<std::string>& cppnames);
150
151// namespace reflection information ------------------------------------------
153 std::vector<TCppScope_t> GetUsingNamespaces(TCppScope_t);
154
155// class reflection information ----------------------------------------------
157 std::string GetFinalName(TCppType_t type);
169 std::string GetBaseName(TCppType_t type, TCppIndex_t ibase);
171 bool IsSubtype(TCppType_t derived, TCppType_t base);
175 bool GetSmartPtrInfo(const std::string&, TCppType_t* raw, TCppMethod_t* deref);
177 void AddSmartPtrType(const std::string&);
178
180 void AddTypeReducer(const std::string& reducable, const std::string& reduced);
181
182// calculate offsets between declared and actual type, up-cast: direction > 0; down-cast: direction < 0
184 ptrdiff_t GetBaseOffset(
185 TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror = false);
186
187// method/function reflection information ------------------------------------
189 TCppIndex_t GetNumMethods(TCppScope_t scope, bool accept_namespace = false);
191 std::vector<TCppIndex_t> GetMethodIndicesFromName(TCppScope_t scope, const std::string& name);
192
195
197 std::string GetMethodName(TCppMethod_t);
199 std::string GetMethodFullName(TCppMethod_t);
209 std::string GetMethodArgName(TCppMethod_t, TCppIndex_t iarg);
211 std::string GetMethodArgType(TCppMethod_t, TCppIndex_t iarg);
217 std::string GetMethodSignature(TCppMethod_t, bool show_formalargs, TCppIndex_t maxargs = (TCppIndex_t)-1);
219 std::string GetMethodPrototype(TCppScope_t scope, TCppMethod_t, bool show_formalargs);
222
224 TCppIndex_t GetNumTemplatedMethods(TCppScope_t scope, bool accept_namespace = false);
226 std::string GetTemplatedMethodName(TCppScope_t scope, TCppIndex_t imeth);
230 bool ExistsMethodTemplate(TCppScope_t scope, const std::string& name);
232 bool IsMethodTemplate(TCppScope_t scope, TCppIndex_t imeth);
235 TCppScope_t scope, const std::string& name, const std::string& proto);
236
239 TCppType_t scope, const std::string& lc, const std::string& rc, const std::string& op);
240
241// method properties ---------------------------------------------------------
243 bool IsPublicMethod(TCppMethod_t method);
245 bool IsProtectedMethod(TCppMethod_t method);
247 bool IsConstructor(TCppMethod_t method);
249 bool IsDestructor(TCppMethod_t method);
251 bool IsStaticMethod(TCppMethod_t method);
252
253// data member reflection information ----------------------------------------
255 TCppIndex_t GetNumDatamembers(TCppScope_t scope, bool accept_namespace = false);
257 std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata);
259 std::string GetDatamemberType(TCppScope_t scope, TCppIndex_t idata);
261 intptr_t GetDatamemberOffset(TCppScope_t scope, TCppIndex_t idata);
263 TCppIndex_t GetDatamemberIndex(TCppScope_t scope, const std::string& name);
264
265// data member properties ----------------------------------------------------
267 bool IsPublicData(TCppScope_t scope, TCppIndex_t idata);
269 bool IsProtectedData(TCppScope_t scope, TCppIndex_t idata);
271 bool IsStaticData(TCppScope_t scope, TCppIndex_t idata);
273 bool IsConstData(TCppScope_t scope, TCppIndex_t idata);
275 bool IsEnumData(TCppScope_t scope, TCppIndex_t idata);
277 int GetDimensionSize(TCppScope_t scope, TCppIndex_t idata, int dimension);
278
279// enum properties -----------------------------------------------------------
281 TCppEnum_t GetEnum(TCppScope_t scope, const std::string& enum_name);
285 std::string GetEnumDataName(TCppEnum_t, TCppIndex_t idata);
287 long long GetEnumDataValue(TCppEnum_t, TCppIndex_t idata);
288
289} // namespace Cppyy
290
291#endif // !CPYCPPYY_CPPYY_H
long double PY_LONG_DOUBLE
Definition Cppyy.h:36
unsigned long long PY_ULONG_LONG
Definition Cppyy.h:31
long long PY_LONG_LONG
Definition Cppyy.h:23
#define CPPYY_IMPORT
Definition Cppyy.h:15
static Roo_reg_AGKInteg1D instance
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h req_type
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char name[80]
Definition TGX11.cxx:110
const char * proto
Definition civetweb.c:17535
size_t TCppIndex_t
Definition cpp_cppyy.h:24
RPY_EXPORTED TCppIndex_t GetNumTemplatedMethods(TCppScope_t scope, bool accept_namespace=false)
RPY_EXPORTED std::string GetMethodMangledName(TCppMethod_t)
RPY_EXPORTED TCppObject_t CallO(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args, TCppType_t result_type)
RPY_EXPORTED int CallI(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
RPY_EXPORTED TCppIndex_t CompareMethodArgType(TCppMethod_t, TCppIndex_t iarg, const std::string &req_type)
RPY_EXPORTED ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
RPY_EXPORTED void DeallocateFunctionArgs(void *args)
RPY_EXPORTED bool IsEnumData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED unsigned char CallB(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
RPY_EXPORTED Long64_t CallLL(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
RPY_EXPORTED bool IsAbstract(TCppType_t type)
RPY_EXPORTED size_t SizeOf(TCppType_t klass)
RPY_EXPORTED TCppObject_t CallConstructor(TCppMethod_t method, TCppType_t type, size_t nargs, void *args)
intptr_t TCppMethod_t
Definition cpp_cppyy.h:22
RPY_EXPORTED void * AllocateFunctionArgs(size_t nargs)
RPY_EXPORTED bool IsDefaultConstructable(TCppType_t type)
RPY_EXPORTED bool IsTemplate(const std::string &template_name)
RPY_EXPORTED TCppIndex_t GetMethodReqArgs(TCppMethod_t)
RPY_EXPORTED bool IsEnum(const std::string &type_name)
RPY_EXPORTED std::vector< TCppIndex_t > GetMethodIndicesFromName(TCppScope_t scope, const std::string &name)
RPY_EXPORTED bool ExistsMethodTemplate(TCppScope_t scope, const std::string &name)
RPY_EXPORTED TCppIndex_t GetNumDatamembers(TCppScope_t scope, bool accept_namespace=false)
RPY_EXPORTED std::string ToString(TCppType_t klass, TCppObject_t obj)
RPY_EXPORTED std::string GetMethodName(TCppMethod_t)
RPY_EXPORTED bool IsConstData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED void AddSmartPtrType(const std::string &)
RPY_EXPORTED bool Compile(const std::string &code, bool silent=false)
RPY_EXPORTED void CallDestructor(TCppType_t type, TCppObject_t self)
RPY_EXPORTED TCppScope_t gGlobalScope
Definition cpp_cppyy.h:53
RPY_EXPORTED bool IsProtectedData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED std::string GetMethodSignature(TCppMethod_t, bool show_formalargs, TCppIndex_t maxargs=(TCppIndex_t) -1)
RPY_EXPORTED int GetDimensionSize(TCppScope_t scope, TCppIndex_t idata, int dimension)
RPY_EXPORTED bool IsSubtype(TCppType_t derived, TCppType_t base)
RPY_EXPORTED TCppMethod_t GetMethodTemplate(TCppScope_t scope, const std::string &name, const std::string &proto)
void * TCppObject_t
Definition cpp_cppyy.h:21
RPY_EXPORTED bool IsConstructor(TCppMethod_t method)
RPY_EXPORTED TCppIndex_t GetNumMethods(TCppScope_t scope, bool accept_namespace=false)
RPY_EXPORTED TCppObject_t Construct(TCppType_t type, void *arena=nullptr)
RPY_EXPORTED bool GetSmartPtrInfo(const std::string &, TCppType_t *raw, TCppMethod_t *deref)
RPY_EXPORTED char CallC(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
RPY_EXPORTED std::string GetMethodArgName(TCppMethod_t, TCppIndex_t iarg)
RPY_EXPORTED double CallD(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
RPY_EXPORTED size_t GetFunctionArgTypeoffset()
RPY_EXPORTED TCppObject_t Allocate(TCppType_t type)
RPY_EXPORTED void Destruct(TCppType_t type, TCppObject_t instance)
RPY_EXPORTED std::string ResolveName(const std::string &cppitem_name)
TCppScope_t TCppType_t
Definition cpp_cppyy.h:19
RPY_EXPORTED void AddTypeReducer(const std::string &reducable, const std::string &reduced)
RPY_EXPORTED std::string ResolveEnum(const std::string &enum_type)
RPY_EXPORTED long long GetEnumDataValue(TCppEnum_t, TCppIndex_t idata)
RPY_EXPORTED bool IsAggregate(TCppType_t type)
RPY_EXPORTED TCppIndex_t GetMethodNumArgs(TCppMethod_t)
RPY_EXPORTED TCppType_t GetActualClass(TCppType_t klass, TCppObject_t obj)
RPY_EXPORTED std::string GetBaseName(TCppType_t type, TCppIndex_t ibase)
RPY_EXPORTED bool IsNamespace(TCppScope_t scope)
void * TCppEnum_t
Definition cpp_cppyy.h:20
RPY_EXPORTED float CallF(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
RPY_EXPORTED std::string GetScopedFinalName(TCppType_t type)
RPY_EXPORTED void Deallocate(TCppType_t type, TCppObject_t instance)
RPY_EXPORTED bool IsPublicData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED std::string GetMethodArgType(TCppMethod_t, TCppIndex_t iarg)
RPY_EXPORTED long CallL(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
RPY_EXPORTED void * CallR(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
RPY_EXPORTED std::string GetEnumDataName(TCppEnum_t, TCppIndex_t idata)
RPY_EXPORTED void GetAllCppNames(TCppScope_t scope, std::set< std::string > &cppnames)
RPY_EXPORTED bool IsComplete(const std::string &type_name)
RPY_EXPORTED bool IsBuiltin(const std::string &type_name)
RPY_EXPORTED bool IsStaticMethod(TCppMethod_t method)
RPY_EXPORTED TCppIndex_t GetDatamemberIndex(TCppScope_t scope, const std::string &name)
RPY_EXPORTED void CallV(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
RPY_EXPORTED LongDouble_t CallLD(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
RPY_EXPORTED bool IsStaticData(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED std::string GetDatamemberType(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
RPY_EXPORTED bool IsDestructor(TCppMethod_t method)
RPY_EXPORTED bool IsSmartPtr(TCppType_t type)
RPY_EXPORTED std::string GetTemplatedMethodName(TCppScope_t scope, TCppIndex_t imeth)
RPY_EXPORTED size_t GetFunctionArgSizeof()
RPY_EXPORTED TCppScope_t GetScope(const std::string &scope_name)
RPY_EXPORTED bool HasVirtualDestructor(TCppType_t type)
RPY_EXPORTED bool IsConstMethod(TCppMethod_t)
RPY_EXPORTED bool HasComplexHierarchy(TCppType_t type)
RPY_EXPORTED std::vector< TCppScope_t > GetUsingNamespaces(TCppScope_t)
size_t TCppScope_t
Definition cpp_cppyy.h:18
RPY_EXPORTED bool IsTemplatedConstructor(TCppScope_t scope, TCppIndex_t imeth)
RPY_EXPORTED TCppIndex_t GetGlobalOperator(TCppType_t scope, const std::string &lc, const std::string &rc, const std::string &op)
RPY_EXPORTED TCppFuncAddr_t GetFunctionAddress(TCppMethod_t method, bool check_enabled=true)
RPY_EXPORTED TCppIndex_t GetNumEnumData(TCppEnum_t)
RPY_EXPORTED TCppIndex_t GetNumBases(TCppType_t type)
RPY_EXPORTED TCppIndex_t GetNumBasesLongestBranch(TCppType_t type)
Retrieve number of base classes in the longest branch of the inheritance tree.
RPY_EXPORTED std::string GetMethodPrototype(TCppScope_t scope, TCppMethod_t, bool show_formalargs)
RPY_EXPORTED std::string GetMethodResultType(TCppMethod_t)
RPY_EXPORTED std::string GetFinalName(TCppType_t type)
RPY_EXPORTED char * CallS(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args, size_t *length)
RPY_EXPORTED std::string GetMethodArgDefault(TCppMethod_t, TCppIndex_t iarg)
RPY_EXPORTED bool IsMethodTemplate(TCppScope_t scope, TCppIndex_t imeth)
RPY_EXPORTED std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata)
RPY_EXPORTED bool IsPublicMethod(TCppMethod_t method)
RPY_EXPORTED intptr_t GetDatamemberOffset(TCppScope_t scope, TCppIndex_t idata)
void * TCppFuncAddr_t
Definition cpp_cppyy.h:25
RPY_EXPORTED std::string GetMethodFullName(TCppMethod_t)
RPY_EXPORTED short CallH(TCppMethod_t method, TCppObject_t self, size_t nargs, void *args)
RPY_EXPORTED bool IsProtectedMethod(TCppMethod_t method)
RPY_EXPORTED TCppEnum_t GetEnum(TCppScope_t scope, const std::string &enum_name)