Logo ROOT  
Reference Guide
CustomPyTypes.h
Go to the documentation of this file.
1 #ifndef CPYCPPYY_CUSTOMPYTYPES_H
2 #define CPYCPPYY_CUSTOMPYTYPES_H
3 
4 namespace CPyCppyy {
5 
6 /** Custom "builtins," detectable by type, for pass by ref and improved
7  performance.
8  */
9 
10 //- reference float object type and type verification ------------------------
11 extern PyTypeObject RefFloat_Type;
12 
13 template<typename T>
14 inline bool RefFloat_Check(T* object)
15 {
16  return object && PyObject_TypeCheck(object, &RefFloat_Type);
17 }
18 
19 template<typename T>
20 inline bool RefFloat_CheckExact(T* object)
21 {
22  return object && Py_TYPE(object) == &RefFloat_Type;
23 }
24 
25 //- reference long object type and type verification -------------------------
26 extern PyTypeObject RefInt_Type;
27 
28 template<typename T>
29 inline bool RefInt_Check(T* object)
30 {
31  return object && PyObject_TypeCheck(object, &RefInt_Type);
32 }
33 
34 template<typename T>
35 inline bool RefInt_CheckExact(T* object)
36 {
37  return object && Py_TYPE(object) == &RefInt_Type;
38 }
39 
40 //- custom type representing typedef to pointer of class ---------------------
42  PyObject_HEAD
44 };
45 
46 extern PyTypeObject TypedefPointerToClass_Type;
47 
48 template<typename T>
49 inline bool TypedefPointerToClass_Check(T* object)
50 {
51  return object && PyObject_TypeCheck(object, &TypedefPointerToClass_Type);
52 }
53 
54 template<typename T>
55 inline bool TypedefPointerToClass_CheckExact(T* object)
56 {
57  return object && Py_TYPE(object) == &TypedefPointerToClass_Type;
58 }
59 
60 //- custom instance method object type and type verification -----------------
61 extern PyTypeObject CustomInstanceMethod_Type;
62 
63 template<typename T>
64 inline bool CustomInstanceMethod_Check(T* object)
65 {
66  return object && PyObject_TypeCheck(object, &CustomInstanceMethod_Type);
67 }
68 
69 template<typename T>
70 inline bool CustomInstanceMethod_CheckExact(T* object)
71 {
72  return object && Py_TYPE(object) == &CustomInstanceMethod_Type;
73 }
74 
76 
77 //- custom iterator for high performance std::vector iteration ---------------
79  PyObject_HEAD
83 };
84 
85 extern PyTypeObject IndexIter_Type;
86 
87 class Converter;
89  void* vi_data;
93  int vi_flags;
94 };
95 
96 extern PyTypeObject VectorIter_Type;
97 
98 } // namespace CPyCppyy
99 
100 #endif // !CPYCPPYY_CUSTOMPYTYPES_H
CPyCppyy
Definition: TPython.cxx:99
CPyCppyy::vectoriterobject::vi_klass
Cppyy::TCppType_t vi_klass
Definition: CustomPyTypes.h:92
CPyCppyy::IndexIter_Type
PyTypeObject IndexIter_Type
Definition: CustomPyTypes.cxx:284
CPyCppyy::CustomInstanceMethod_CheckExact
bool CustomInstanceMethod_CheckExact(T *object)
Definition: CustomPyTypes.h:70
CPyCppyy::RefInt_Type
PyTypeObject RefInt_Type
Definition: CustomPyTypes.cxx:40
CPyCppyy::TypedefPointerToClass_Check
bool TypedefPointerToClass_Check(T *object)
Definition: CustomPyTypes.h:49
CPyCppyy::RefFloat_CheckExact
bool RefFloat_CheckExact(T *object)
Definition: CustomPyTypes.h:20
PyObject
_object PyObject
Definition: PyMethodBase.h:41
CPyCppyy::TypedefPointerToClass_Type
PyTypeObject TypedefPointerToClass_Type
Definition: CustomPyTypes.cxx:74
CPyCppyy::vectoriterobject::vi_converter
CPyCppyy::Converter * vi_converter
Definition: CustomPyTypes.h:91
CPyCppyy::RefFloat_Check
bool RefFloat_Check(T *object)
Definition: CustomPyTypes.h:14
CPyCppyy::CustomInstanceMethod_New
PyObject * CustomInstanceMethod_New(PyObject *func, PyObject *self, PyObject *pyclass)
Definition: CustomPyTypes.cxx:103
CPyCppyy::CustomInstanceMethod_Type
PyTypeObject CustomInstanceMethod_Type
Definition: CustomPyTypes.cxx:233
CPyCppyy::vectoriterobject::vi_stride
Py_ssize_t vi_stride
Definition: CustomPyTypes.h:90
CPyCppyy::TypedefPointerToClass_CheckExact
bool TypedefPointerToClass_CheckExact(T *object)
Definition: CustomPyTypes.h:55
CPyCppyy::RefInt_CheckExact
bool RefInt_CheckExact(T *object)
Definition: CustomPyTypes.h:35
CPyCppyy::indexiterobject::ii_container
PyObject_HEAD PyObject * ii_container
Definition: CustomPyTypes.h:80
CPyCppyy::CustomInstanceMethod_Check
bool CustomInstanceMethod_Check(T *object)
Definition: CustomPyTypes.h:64
CPyCppyy::typedefpointertoclassobject::fType
PyObject_HEAD Cppyy::TCppType_t fType
Definition: CustomPyTypes.h:43
CPyCppyy::RefFloat_Type
PyTypeObject RefFloat_Type
Custom "builtins," detectable by type, for pass by ref and improved performance.
Definition: CustomPyTypes.cxx:18
CPyCppyy::RefInt_Check
bool RefInt_Check(T *object)
Definition: CustomPyTypes.h:29
CPyCppyy::indexiterobject::ii_pos
Py_ssize_t ii_pos
Definition: CustomPyTypes.h:81
CPyCppyy::vectoriterobject::vi_flags
int vi_flags
Definition: CustomPyTypes.h:93
Cppyy::TCppType_t
TCppScope_t TCppType_t
Definition: cpp_cppyy.h:19
CPyCppyy::indexiterobject::ii_len
Py_ssize_t ii_len
Definition: CustomPyTypes.h:82
CPyCppyy::VectorIter_Type
PyTypeObject VectorIter_Type
Definition: CustomPyTypes.cxx:343
CPyCppyy::Converter
Definition: API.h:91
CPyCppyy::typedefpointertoclassobject
Definition: CustomPyTypes.h:41
ROOT::Math::Chebyshev::T
double T(double x)
Definition: ChebyshevPol.h:34
CPyCppyy::indexiterobject
Definition: CustomPyTypes.h:78
CPyCppyy::vectoriterobject
Definition: CustomPyTypes.h:88
Py_TYPE
#define Py_TYPE(ob)
Definition: CPyCppyy.h:209
CPyCppyy::vectoriterobject::vi_data
void * vi_data
Definition: CustomPyTypes.h:89
int