Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
CustomPyTypes.h
Go to the documentation of this file.
1#ifndef CPYCPPYY_CUSTOMPYTYPES_H
2#define CPYCPPYY_CUSTOMPYTYPES_H
3
4namespace CPyCppyy {
5
6/** Custom "builtins," detectable by type, for pass by ref and improved
7 performance.
8 */
9
10#if PY_VERSION_HEX < 0x03000000
11//- reference float object type and type verification ------------------------
12extern PyTypeObject RefFloat_Type;
13
14template<typename T>
15inline bool RefFloat_Check(T* object)
16{
17 return object && PyObject_TypeCheck(object, &RefFloat_Type);
18}
19
20template<typename T>
21inline bool RefFloat_CheckExact(T* object)
22{
23 return object && Py_TYPE(object) == &RefFloat_Type;
24}
25
26//- reference long object type and type verification -------------------------
27extern PyTypeObject RefInt_Type;
28
29template<typename T>
30inline bool RefInt_Check(T* object)
31{
32 return object && PyObject_TypeCheck(object, &RefInt_Type);
33}
34
35template<typename T>
36inline bool RefInt_CheckExact(T* object)
37{
38 return object && Py_TYPE(object) == &RefInt_Type;
39}
40#endif
41
42//- custom type representing typedef to pointer of class ---------------------
44 PyObject_HEAD
47
49 Py_DECREF(fDict);
50 }
51};
52
53extern PyTypeObject TypedefPointerToClass_Type;
54
55template<typename T>
56inline bool TypedefPointerToClass_Check(T* object)
57{
58 return object && PyObject_TypeCheck(object, &TypedefPointerToClass_Type);
59}
60
61template<typename T>
63{
64 return object && Py_TYPE(object) == &TypedefPointerToClass_Type;
65}
66
67//- custom instance method object type and type verification -----------------
68extern PyTypeObject CustomInstanceMethod_Type;
69
70template<typename T>
71inline bool CustomInstanceMethod_Check(T* object)
72{
73 return object && PyObject_TypeCheck(object, &CustomInstanceMethod_Type);
74}
75
76template<typename T>
77inline bool CustomInstanceMethod_CheckExact(T* object)
78{
79 return object && Py_TYPE(object) == &CustomInstanceMethod_Type;
80}
81
83
84//- custom iterator for high performance std::vector iteration ---------------
86 PyObject_HEAD
90};
91
92extern PyTypeObject IndexIter_Type;
93
94class Converter;
96 void* vi_data;
101
102 enum EFlags {
103 kDefault = 0x0000,
106 };
107};
108
109extern PyTypeObject VectorIter_Type;
110
111} // namespace CPyCppyy
112
113#endif // !CPYCPPYY_CUSTOMPYTYPES_H
#define Py_TYPE(ob)
Definition CPyCppyy.h:196
_object PyObject
PyObject * CustomInstanceMethod_New(PyObject *func, PyObject *self, PyObject *pyclass)
PyTypeObject VectorIter_Type
bool RefFloat_Check(T *object)
PyTypeObject CustomInstanceMethod_Type
bool RefFloat_CheckExact(T *object)
PyTypeObject RefFloat_Type
Custom "builtins," detectable by type, for pass by ref and improved performance.
PyTypeObject TypedefPointerToClass_Type
bool RefInt_CheckExact(T *object)
bool CustomInstanceMethod_CheckExact(T *object)
bool RefInt_Check(T *object)
bool TypedefPointerToClass_CheckExact(T *object)
PyTypeObject IndexIter_Type
bool TypedefPointerToClass_Check(T *object)
PyTypeObject RefInt_Type
bool CustomInstanceMethod_Check(T *object)
TCppScope_t TCppType_t
Definition cpp_cppyy.h:19
PyObject_HEAD PyObject * ii_container
PyObject_HEAD Cppyy::TCppType_t fCppType
Cppyy::TCppType_t vi_klass
CPyCppyy::Converter * vi_converter