Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
CPPScope.h
Go to the documentation of this file.
1#ifndef CPYCPPYY_CPPSCOPE_H
2#define CPYCPPYY_CPPSCOPE_H
3
4#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2
5
6// In p2.2, PyHeapTypeObject is not yet part of the interface
7#include "structmember.h"
8
9typedef struct {
10 PyTypeObject type;
11 PyNumberMethods as_number;
12 PySequenceMethods as_sequence;
13 PyMappingMethods as_mapping;
14 PyBufferProcs as_buffer;
15 PyObject *name, *slots;
16 PyMemberDef members[1];
17} PyHeapTypeObject;
18
19#endif
20
21// Standard
22#include <map>
23
24
25namespace CPyCppyy {
26
27/** Type object to hold class reference (this is only semantically a presentation
28 of CPPScope instances, not in a C++ sense)
29 @author WLAV
30 @date 07/06/2017
31 @version 2.0
32 */
33
34typedef std::map<Cppyy::TCppObject_t, PyObject*> CppToPyMap_t;
35namespace Utility { struct PyOperators; }
36
37class CPPScope {
38public:
39 enum EFlags {
40 kNone = 0x0,
41 kIsMeta = 0x0001,
42 kIsNamespace = 0x0002,
43 kIsException = 0x0004,
44 kIsSmart = 0x0008,
45 kIsPython = 0x0010,
46 kIsInComplete = 0x0020 };
47
48public:
49 PyHeapTypeObject fType;
51 int fFlags;
52 union {
53 CppToPyMap_t* fCppObjects; // classes only
54 std::vector<PyObject*>* fUsing; // namespaces only
58
59private:
60 CPPScope() = delete;
61};
62
64
65class CPPSmartClass : public CPPClass {
66public:
69};
70
71
72//- metatype type and type verification --------------------------------------
73extern PyTypeObject CPPScope_Type;
74
75template<typename T>
76inline bool CPPScope_Check(T* object)
77{
78 return object && PyObject_TypeCheck(object, &CPPScope_Type);
79}
80
81template<typename T>
82inline bool CPPScope_CheckExact(T* object)
83{
84 return object && Py_TYPE(object) == &CPPScope_Type;
85}
86
87//- creation -----------------------------------------------------------------
89{
90// Create and initialize a new scope meta class
91 CPPScope* pymeta = (CPPScope*)PyType_Type.tp_new(&CPPScope_Type, args, nullptr);
92 if (!pymeta) return pymeta;
93
94// set the klass id, for instances and Python-side derived classes to pick up
95 pymeta->fCppType = klass;
96 pymeta->fFlags = CPPScope::kIsMeta;
97 pymeta->fImp.fCppObjects = nullptr;
98 pymeta->fOperators = nullptr;
99 pymeta->fModuleName = nullptr;
100
101 return pymeta;
102}
103
104} // namespace CPyCppyy
105
106#endif // !CPYCPPYY_CPPSCOPE_H
#define Py_TYPE(ob)
Definition CPyCppyy.h:217
_object PyObject
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
Utility::PyOperators * fOperators
Definition CPPScope.h:56
PyHeapTypeObject fType
Definition CPPScope.h:49
Cppyy::TCppType_t fCppType
Definition CPPScope.h:50
std::vector< PyObject * > * fUsing
Definition CPPScope.h:54
union CPyCppyy::CPPScope::@216 fImp
CppToPyMap_t * fCppObjects
Definition CPPScope.h:53
Cppyy::TCppMethod_t fDereferencer
Definition CPPScope.h:68
Cppyy::TCppType_t fUnderlyingType
Definition CPPScope.h:67
Set of helper functions that are invoked from the pythonizors, on the Python side.
std::map< Cppyy::TCppObject_t, PyObject * > CppToPyMap_t
Type object to hold class reference (this is only semantically a presentation of CPPScope instances,...
Definition CPPScope.h:34
bool CPPScope_Check(T *object)
Definition CPPScope.h:76
CPPScope * CPPScopeMeta_New(Cppyy::TCppScope_t klass, PyObject *args)
Definition CPPScope.h:88
CPPScope CPPClass
Definition CPPScope.h:63
bool CPPScope_CheckExact(T *object)
Definition CPPScope.h:82
PyTypeObject CPPScope_Type
Definition CPPScope.cxx:614
intptr_t TCppMethod_t
Definition cpp_cppyy.h:22
TCppScope_t TCppType_t
Definition cpp_cppyy.h:19
size_t TCppScope_t
Definition cpp_cppyy.h:18