Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
PyStrings.cxx
Go to the documentation of this file.
1// Bindings
2#include "CPyCppyy.h"
3#include "PyStrings.h"
4
5
6//- data _____________________________________________________________________
40
43
48
51
63
66
68
71
74
78
79
80//-----------------------------------------------------------------------------
81#define CPPYY_INITIALIZE_STRING(var, str) \
82 if (!(PyStrings::var = CPyCppyy_PyText_InternFromString((char*)#str))) \
83 return false
84
86// Build cache of commonly used python strings (the cache is python intern, so
87// all strings are shared python-wide, not just in cppyy).
88 CPPYY_INITIALIZE_STRING(gAssign, __assign__);
89 CPPYY_INITIALIZE_STRING(gBases, __bases__);
90 CPPYY_INITIALIZE_STRING(gBase, __base__);
91 CPPYY_INITIALIZE_STRING(gCopy, copy);
92#if PY_VERSION_HEX < 0x03000000
93 CPPYY_INITIALIZE_STRING(gCppBool, __cpp_nonzero__);
94#else
95 CPPYY_INITIALIZE_STRING(gCppBool, __cpp_bool__);
96#endif
97 CPPYY_INITIALIZE_STRING(gCppName, __cpp_name__);
98 CPPYY_INITIALIZE_STRING(gAnnotations, __annotations__);
99 CPPYY_INITIALIZE_STRING(gCastCpp, __cast_cpp__);
100 CPPYY_INITIALIZE_STRING(gCType, __ctype__);
101 CPPYY_INITIALIZE_STRING(gDeref, __deref__);
102 CPPYY_INITIALIZE_STRING(gPreInc, __preinc__);
103 CPPYY_INITIALIZE_STRING(gPostInc, __postinc__);
104 CPPYY_INITIALIZE_STRING(gDict, __dict__);
105 if (!(PyStrings::gEmptyString = CPyCppyy_PyText_FromString((char*)"")))
106 return false;
107 CPPYY_INITIALIZE_STRING(gEq, __eq__);
108 CPPYY_INITIALIZE_STRING(gFollow, __follow__);
109 CPPYY_INITIALIZE_STRING(gGetItem, __getitem__);
110 CPPYY_INITIALIZE_STRING(gGetNoCheck, _getitem__unchecked);
111 CPPYY_INITIALIZE_STRING(gSetItem, __setitem__);
112 CPPYY_INITIALIZE_STRING(gInit, __init__);
113 CPPYY_INITIALIZE_STRING(gIter, __iter__);
114 CPPYY_INITIALIZE_STRING(gLen, __len__);
115 CPPYY_INITIALIZE_STRING(gLifeLine, __lifeline);
116 CPPYY_INITIALIZE_STRING(gModule, __module__);
117 CPPYY_INITIALIZE_STRING(gMRO, __mro__);
118 CPPYY_INITIALIZE_STRING(gName, __name__);
119 CPPYY_INITIALIZE_STRING(gNe, __ne__);
120 CPPYY_INITIALIZE_STRING(gRepr, __repr__);
121 CPPYY_INITIALIZE_STRING(gCppRepr, __cpp_repr);
122 CPPYY_INITIALIZE_STRING(gStr, __str__);
123 CPPYY_INITIALIZE_STRING(gCppStr, __cpp_str);
124 CPPYY_INITIALIZE_STRING(gTypeCode, typecode);
125 CPPYY_INITIALIZE_STRING(gCTypesType, _type_);
126
127 CPPYY_INITIALIZE_STRING(gUnderlying, __underlying);
128 CPPYY_INITIALIZE_STRING(gRealInit, __real_init);
129
130 CPPYY_INITIALIZE_STRING(gAdd, __add__);
131 CPPYY_INITIALIZE_STRING(gSub, __sub__);
132 CPPYY_INITIALIZE_STRING(gMul, __mul__);
134
135 CPPYY_INITIALIZE_STRING(gLShift, __lshift__);
136 CPPYY_INITIALIZE_STRING(gLShiftC, __lshiftc__);
137
139 CPPYY_INITIALIZE_STRING(gBegin, begin);
140 CPPYY_INITIALIZE_STRING(gEnd, end);
141 CPPYY_INITIALIZE_STRING(gFirst, first);
142 CPPYY_INITIALIZE_STRING(gSecond, second);
144 CPPYY_INITIALIZE_STRING(gTemplate, Template);
145 CPPYY_INITIALIZE_STRING(gVectorAt, _vector__at);
146 CPPYY_INITIALIZE_STRING(gInsert, insert);
147 CPPYY_INITIALIZE_STRING(gValueType, value_type);
148 CPPYY_INITIALIZE_STRING(gValueSize, value_size);
149
150 CPPYY_INITIALIZE_STRING(gCppReal, __cpp_real);
151 CPPYY_INITIALIZE_STRING(gCppImag, __cpp_imag);
152
154
155 CPPYY_INITIALIZE_STRING(gDispInit, _init_dispatchptr);
156 CPPYY_INITIALIZE_STRING(gDispGet, _get_dispatch);
157
158 CPPYY_INITIALIZE_STRING(gExPythonize, __cppyy_explicit_pythonize__);
159 CPPYY_INITIALIZE_STRING(gPythonize, __cppyy_pythonize__);
160
161 CPPYY_INITIALIZE_STRING(gArray, __array__);
162 CPPYY_INITIALIZE_STRING(gDType, dtype);
163 CPPYY_INITIALIZE_STRING(gFromBuffer, frombuffer);
164
165 return true;
166}
167
168
169//-----------------------------------------------------------------------------
171// Remove all cached python strings.
172 Py_DECREF(PyStrings::gBases); PyStrings::gBases = nullptr;
173 Py_DECREF(PyStrings::gBase); PyStrings::gBase = nullptr;
174 Py_DECREF(PyStrings::gCopy); PyStrings::gCopy = nullptr;
175 Py_DECREF(PyStrings::gCppBool); PyStrings::gCppBool = nullptr;
176 Py_DECREF(PyStrings::gCppName); PyStrings::gCppName = nullptr;
177 Py_DECREF(PyStrings::gAnnotations); PyStrings::gAnnotations = nullptr;
178 Py_DECREF(PyStrings::gCType); PyStrings::gCType = nullptr;
179 Py_DECREF(PyStrings::gDeref); PyStrings::gDeref = nullptr;
180 Py_DECREF(PyStrings::gPreInc); PyStrings::gPreInc = nullptr;
181 Py_DECREF(PyStrings::gPostInc); PyStrings::gPostInc = nullptr;
182 Py_DECREF(PyStrings::gDict); PyStrings::gDict = nullptr;
183 Py_DECREF(PyStrings::gEmptyString); PyStrings::gEmptyString = nullptr;
184 Py_DECREF(PyStrings::gEq); PyStrings::gEq = nullptr;
185 Py_DECREF(PyStrings::gFollow); PyStrings::gFollow = nullptr;
186 Py_DECREF(PyStrings::gGetItem); PyStrings::gGetItem = nullptr;
187 Py_DECREF(PyStrings::gGetNoCheck); PyStrings::gGetNoCheck = nullptr;
188 Py_DECREF(PyStrings::gSetItem); PyStrings::gSetItem = nullptr;
189 Py_DECREF(PyStrings::gInit); PyStrings::gInit = nullptr;
190 Py_DECREF(PyStrings::gIter); PyStrings::gIter = nullptr;
191 Py_DECREF(PyStrings::gLen); PyStrings::gLen = nullptr;
192 Py_DECREF(PyStrings::gLifeLine); PyStrings::gLifeLine = nullptr;
193 Py_DECREF(PyStrings::gModule); PyStrings::gModule = nullptr;
194 Py_DECREF(PyStrings::gMRO); PyStrings::gMRO = nullptr;
195 Py_DECREF(PyStrings::gName); PyStrings::gName = nullptr;
196 Py_DECREF(PyStrings::gNe); PyStrings::gNe = nullptr;
197 Py_DECREF(PyStrings::gTypeCode); PyStrings::gTypeCode = nullptr;
198 Py_DECREF(PyStrings::gCTypesType); PyStrings::gCTypesType = nullptr;
199
200 Py_DECREF(PyStrings::gUnderlying); PyStrings::gUnderlying = nullptr;
201 Py_DECREF(PyStrings::gRealInit); PyStrings::gRealInit = nullptr;
202
203 Py_DECREF(PyStrings::gAdd); PyStrings::gAdd = nullptr;
204 Py_DECREF(PyStrings::gSub); PyStrings::gSub = nullptr;
205 Py_DECREF(PyStrings::gMul); PyStrings::gMul = nullptr;
206 Py_DECREF(PyStrings::gDiv); PyStrings::gDiv = nullptr;
207
208 Py_DECREF(PyStrings::gLShift); PyStrings::gLShift = nullptr;
209 Py_DECREF(PyStrings::gLShiftC); PyStrings::gLShiftC = nullptr;
210
211 Py_DECREF(PyStrings::gAt); PyStrings::gAt = nullptr;
212 Py_DECREF(PyStrings::gBegin); PyStrings::gBegin = nullptr;
213 Py_DECREF(PyStrings::gEnd); PyStrings::gEnd = nullptr;
214 Py_DECREF(PyStrings::gFirst); PyStrings::gFirst = nullptr;
215 Py_DECREF(PyStrings::gSecond); PyStrings::gSecond = nullptr;
216 Py_DECREF(PyStrings::gSize); PyStrings::gSize = nullptr;
217 Py_DECREF(PyStrings::gTemplate); PyStrings::gTemplate = nullptr;
218 Py_DECREF(PyStrings::gVectorAt); PyStrings::gVectorAt = nullptr;
219 Py_DECREF(PyStrings::gInsert); PyStrings::gInsert = nullptr;
220 Py_DECREF(PyStrings::gValueType); PyStrings::gValueType = nullptr;
221 Py_DECREF(PyStrings::gValueSize); PyStrings::gValueSize = nullptr;
222
223 Py_DECREF(PyStrings::gCppReal); PyStrings::gCppReal = nullptr;
224 Py_DECREF(PyStrings::gCppImag); PyStrings::gCppImag = nullptr;
225
226 Py_DECREF(PyStrings::gThisModule); PyStrings::gThisModule = nullptr;
227
228 Py_DECREF(PyStrings::gDispInit); PyStrings::gDispInit = nullptr;
229 Py_DECREF(PyStrings::gDispGet); PyStrings::gDispGet = nullptr;
230
231 Py_DECREF(PyStrings::gExPythonize); PyStrings::gExPythonize = nullptr;
232 Py_DECREF(PyStrings::gPythonize); PyStrings::gPythonize = nullptr;
233
234 Py_DECREF(PyStrings::gArray); PyStrings::gArray = nullptr;
235 Py_DECREF(PyStrings::gDType); PyStrings::gDType = nullptr;
236 Py_DECREF(PyStrings::gFromBuffer); PyStrings::gFromBuffer = nullptr;
237
239}
#define CPPYY__div__
Definition CPyCppyy.h:111
#define Py_RETURN_NONE
Definition CPyCppyy.h:268
#define CPyCppyy_PyText_FromString
Definition CPyCppyy.h:81
_object PyObject
#define CPPYY_INITIALIZE_STRING(var, str)
Definition PyStrings.cxx:81
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
PyObject * gCTypesType
Definition PyStrings.cxx:39
PyObject * gDispGet
Definition PyStrings.cxx:70
PyObject * gCastCpp
Definition PyStrings.cxx:14
PyObject * gAssign
Definition PyStrings.cxx:7
PyObject * gRealInit
Definition PyStrings.cxx:42
PyObject * gExPythonize
Definition PyStrings.cxx:72
PyObject * gLifeLine
Definition PyStrings.cxx:29
PyObject * gGetItem
Definition PyStrings.cxx:23
PyObject * gThisModule
Definition PyStrings.cxx:67
PyObject * gCppBool
Definition PyStrings.cxx:11
PyObject * gCppName
Definition PyStrings.cxx:12
PyObject * gFromBuffer
Definition PyStrings.cxx:77
PyObject * gCppReal
Definition PyStrings.cxx:64
PyObject * gVectorAt
Definition PyStrings.cxx:59
PyObject * gLShiftC
Definition PyStrings.cxx:50
PyObject * gPythonize
Definition PyStrings.cxx:73
PyObject * gTypeCode
Definition PyStrings.cxx:38
PyObject * gPostInc
Definition PyStrings.cxx:18
PyObject * gCppImag
Definition PyStrings.cxx:65
PyObject * gBases
Definition PyStrings.cxx:8
PyObject * gValueSize
Definition PyStrings.cxx:62
PyObject * gTemplate
Definition PyStrings.cxx:58
PyObject * gAnnotations
Definition PyStrings.cxx:13
PyObject * gDispInit
Definition PyStrings.cxx:69
PyObject * gEmptyString
Definition PyStrings.cxx:20
PyObject * gSetItem
Definition PyStrings.cxx:25
PyObject * gUnderlying
Definition PyStrings.cxx:41
PyObject * gGetNoCheck
Definition PyStrings.cxx:24
PyObject * gCppRepr
Definition PyStrings.cxx:35
PyObject * gValueType
Definition PyStrings.cxx:61
PyObject * DestroyPyStrings()
bool CreatePyStrings()
Definition PyStrings.cxx:85
PyObject * gThisModule
Definition CPPMethod.cxx:30