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 _____________________________________________________________________
31
33
38
41
50
53
55
58
61
62
63//-----------------------------------------------------------------------------
64#define CPPYY_INITIALIZE_STRING(var, str) \
65 if (!(PyStrings::var = CPyCppyy_PyText_InternFromString((char*)#str))) \
66 return false
67
69// Build cache of commonly used python strings (the cache is python intern, so
70// all strings are shared python-wide, not just in cppyy).
71 CPPYY_INITIALIZE_STRING(gAssign, __assign__);
72 CPPYY_INITIALIZE_STRING(gBases, __bases__);
73 CPPYY_INITIALIZE_STRING(gBase, __base__);
74 CPPYY_INITIALIZE_STRING(gCppName, __cpp_name__);
75 CPPYY_INITIALIZE_STRING(gDeref, __deref__);
76 CPPYY_INITIALIZE_STRING(gPreInc, __preinc__);
77 CPPYY_INITIALIZE_STRING(gPostInc, __postinc__);
78 CPPYY_INITIALIZE_STRING(gDict, __dict__);
79 if (!(PyStrings::gEmptyString = CPyCppyy_PyText_FromString((char*)"")))
80 return false;
81 CPPYY_INITIALIZE_STRING(gEq, __eq__);
82 CPPYY_INITIALIZE_STRING(gFollow, __follow__);
83 CPPYY_INITIALIZE_STRING(gGetItem, __getitem__);
84 CPPYY_INITIALIZE_STRING(gGetNoCheck, _getitem__unchecked);
85 CPPYY_INITIALIZE_STRING(gSetItem, __setitem__);
86 CPPYY_INITIALIZE_STRING(gInit, __init__);
87 CPPYY_INITIALIZE_STRING(gIter, __iter__);
88 CPPYY_INITIALIZE_STRING(gLen, __len__);
89 CPPYY_INITIALIZE_STRING(gLifeLine, __lifeline);
90 CPPYY_INITIALIZE_STRING(gModule, __module__);
91 CPPYY_INITIALIZE_STRING(gMRO, __mro__);
92 CPPYY_INITIALIZE_STRING(gName, __name__);
93 CPPYY_INITIALIZE_STRING(gNe, __ne__);
94 CPPYY_INITIALIZE_STRING(gTypeCode, typecode);
95 CPPYY_INITIALIZE_STRING(gCTypesType, _type_);
96
97 CPPYY_INITIALIZE_STRING(gUnderlying, __underlying);
98
99 CPPYY_INITIALIZE_STRING(gAdd, __add__);
100 CPPYY_INITIALIZE_STRING(gSub, __sub__);
101 CPPYY_INITIALIZE_STRING(gMul, __mul__);
103
104 CPPYY_INITIALIZE_STRING(gLShift, __lshift__);
105 CPPYY_INITIALIZE_STRING(gLShiftC, __lshiftc__);
106
108 CPPYY_INITIALIZE_STRING(gBegin, begin);
109 CPPYY_INITIALIZE_STRING(gEnd, end);
111 CPPYY_INITIALIZE_STRING(gSecond, second);
113 CPPYY_INITIALIZE_STRING(gTemplate, Template);
114 CPPYY_INITIALIZE_STRING(gVectorAt, _vector__at);
115
116 CPPYY_INITIALIZE_STRING(gCppReal, __cpp_real);
117 CPPYY_INITIALIZE_STRING(gCppImag, __cpp_imag);
118
120
121 CPPYY_INITIALIZE_STRING(gNoImplicit, __cppyy_no_implicit);
122 CPPYY_INITIALIZE_STRING(gDispInit, _init_dispatchptr);
123
124 CPPYY_INITIALIZE_STRING(gExPythonize, __cppyy_explicit_pythonize__);
125 CPPYY_INITIALIZE_STRING(gPythonize, __cppyy_pythonize__);
126
127 return true;
128}
129
130
131//-----------------------------------------------------------------------------
133// Remove all cached python strings.
134 Py_DECREF(PyStrings::gBases); PyStrings::gBases = nullptr;
135 Py_DECREF(PyStrings::gBase); PyStrings::gBase = nullptr;
136 Py_DECREF(PyStrings::gCppName); PyStrings::gCppName = nullptr;
137 Py_DECREF(PyStrings::gDeref); PyStrings::gDeref = nullptr;
138 Py_DECREF(PyStrings::gPreInc); PyStrings::gPreInc = nullptr;
139 Py_DECREF(PyStrings::gPostInc); PyStrings::gPostInc = nullptr;
140 Py_DECREF(PyStrings::gDict); PyStrings::gDict = nullptr;
141 Py_DECREF(PyStrings::gEmptyString); PyStrings::gEmptyString = nullptr;
142 Py_DECREF(PyStrings::gEq); PyStrings::gEq = nullptr;
143 Py_DECREF(PyStrings::gFollow); PyStrings::gFollow = nullptr;
144 Py_DECREF(PyStrings::gGetItem); PyStrings::gGetItem = nullptr;
145 Py_DECREF(PyStrings::gGetNoCheck); PyStrings::gGetNoCheck = nullptr;
146 Py_DECREF(PyStrings::gSetItem); PyStrings::gSetItem = nullptr;
147 Py_DECREF(PyStrings::gInit); PyStrings::gInit = nullptr;
148 Py_DECREF(PyStrings::gIter); PyStrings::gIter = nullptr;
149 Py_DECREF(PyStrings::gLen); PyStrings::gLen = nullptr;
150 Py_DECREF(PyStrings::gLifeLine); PyStrings::gLifeLine = nullptr;
151 Py_DECREF(PyStrings::gModule); PyStrings::gModule = nullptr;
152 Py_DECREF(PyStrings::gMRO); PyStrings::gMRO = nullptr;
153 Py_DECREF(PyStrings::gName); PyStrings::gName = nullptr;
154 Py_DECREF(PyStrings::gNe); PyStrings::gNe = nullptr;
155 Py_DECREF(PyStrings::gTypeCode); PyStrings::gTypeCode = nullptr;
156 Py_DECREF(PyStrings::gCTypesType); PyStrings::gCTypesType = nullptr;
157
158 Py_DECREF(PyStrings::gUnderlying); PyStrings::gUnderlying = nullptr;
159
160 Py_DECREF(PyStrings::gAdd); PyStrings::gAdd = nullptr;
161 Py_DECREF(PyStrings::gSub); PyStrings::gSub = nullptr;
162 Py_DECREF(PyStrings::gMul); PyStrings::gMul = nullptr;
163 Py_DECREF(PyStrings::gDiv); PyStrings::gDiv = nullptr;
164
165 Py_DECREF(PyStrings::gLShift); PyStrings::gLShift = nullptr;
166 Py_DECREF(PyStrings::gLShiftC); PyStrings::gLShiftC = nullptr;
167
168 Py_DECREF(PyStrings::gAt); PyStrings::gAt = nullptr;
169 Py_DECREF(PyStrings::gBegin); PyStrings::gBegin = nullptr;
170 Py_DECREF(PyStrings::gEnd); PyStrings::gEnd = nullptr;
171 Py_DECREF(PyStrings::gFirst); PyStrings::gFirst = nullptr;
172 Py_DECREF(PyStrings::gSecond); PyStrings::gSecond = nullptr;
173 Py_DECREF(PyStrings::gSize); PyStrings::gSize = nullptr;
174 Py_DECREF(PyStrings::gTemplate); PyStrings::gTemplate = nullptr;
175 Py_DECREF(PyStrings::gVectorAt); PyStrings::gVectorAt = nullptr;
176
177 Py_DECREF(PyStrings::gCppReal); PyStrings::gCppReal = nullptr;
178 Py_DECREF(PyStrings::gCppImag); PyStrings::gCppImag = nullptr;
179
180 Py_DECREF(PyStrings::gThisModule); PyStrings::gThisModule = nullptr;
181
182 Py_DECREF(PyStrings::gNoImplicit); PyStrings::gNoImplicit = nullptr;
183 Py_DECREF(PyStrings::gDispInit); PyStrings::gDispInit = nullptr;
184
185 Py_DECREF(PyStrings::gExPythonize); PyStrings::gExPythonize = nullptr;
186 Py_DECREF(PyStrings::gPythonize); PyStrings::gPythonize = nullptr;
187
189}
#define CPPYY__div__
Definition CPyCppyy.h:132
#define Py_RETURN_NONE
Definition CPyCppyy.h:289
#define CPyCppyy_PyText_FromString
Definition CPyCppyy.h:102
_object PyObject
#define CPPYY_INITIALIZE_STRING(var, str)
Definition PyStrings.cxx:64
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
PyObject * gCTypesType
Definition PyStrings.cxx:30
PyObject * gAssign
Definition PyStrings.cxx:7
R__EXTERN PyObject * gName
Definition TPython.cxx:105
PyObject * gExPythonize
Definition PyStrings.cxx:59
PyObject * gLifeLine
Definition PyStrings.cxx:24
PyObject * gGetItem
Definition PyStrings.cxx:18
PyObject * gThisModule
Definition PyStrings.cxx:54
R__EXTERN PyObject * gCppName
Definition TPython.cxx:103
PyObject * gCppReal
Definition PyStrings.cxx:51
PyObject * gVectorAt
Definition PyStrings.cxx:49
PyObject * gLShiftC
Definition PyStrings.cxx:40
PyObject * gPythonize
Definition PyStrings.cxx:60
PyObject * gTypeCode
Definition PyStrings.cxx:29
PyObject * gPostInc
Definition PyStrings.cxx:13
PyObject * gCppImag
Definition PyStrings.cxx:52
PyObject * gNoImplicit
Definition PyStrings.cxx:56
R__EXTERN PyObject * gBases
PyObject * gTemplate
Definition PyStrings.cxx:48
PyObject * gDispInit
Definition PyStrings.cxx:57
R__EXTERN PyObject * gModule
Definition TPython.cxx:104
PyObject * gEmptyString
Definition PyStrings.cxx:15
PyObject * gSetItem
Definition PyStrings.cxx:20
PyObject * gUnderlying
Definition PyStrings.cxx:32
PyObject * gGetNoCheck
Definition PyStrings.cxx:19
PyObject * DestroyPyStrings()
bool CreatePyStrings()
Definition PyStrings.cxx:68
R__EXTERN PyObject * gThisModule
Definition TPython.cxx:100
Definition first.py:1