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