ROOT
v6-22
Reference Guide
PyStrings.cxx
Go to the documentation of this file.
1
// Bindings
2
#include "
CPyCppyy.h
"
3
#include "
PyStrings.h
"
4
5
6
//- data _____________________________________________________________________
7
PyObject
*
CPyCppyy::PyStrings::gAssign
=
nullptr
;
8
PyObject
*
CPyCppyy::PyStrings::gBases
=
nullptr
;
9
PyObject
*
CPyCppyy::PyStrings::gBase
=
nullptr
;
10
PyObject
*
CPyCppyy::PyStrings::gCppName
=
nullptr
;
11
PyObject
*
CPyCppyy::PyStrings::gDeref
=
nullptr
;
12
PyObject
*
CPyCppyy::PyStrings::gPreInc
=
nullptr
;
13
PyObject
*
CPyCppyy::PyStrings::gPostInc
=
nullptr
;
14
PyObject
*
CPyCppyy::PyStrings::gDict
=
nullptr
;
15
PyObject
*
CPyCppyy::PyStrings::gEmptyString
=
nullptr
;
16
PyObject
*
CPyCppyy::PyStrings::gEq
=
nullptr
;
17
PyObject
*
CPyCppyy::PyStrings::gFollow
=
nullptr
;
18
PyObject
*
CPyCppyy::PyStrings::gGetItem
=
nullptr
;
19
PyObject
*
CPyCppyy::PyStrings::gGetNoCheck
=
nullptr
;
20
PyObject
*
CPyCppyy::PyStrings::gInit
=
nullptr
;
21
PyObject
*
CPyCppyy::PyStrings::gIter
=
nullptr
;
22
PyObject
*
CPyCppyy::PyStrings::gLen
=
nullptr
;
23
PyObject
*
CPyCppyy::PyStrings::gLifeLine
=
nullptr
;
24
PyObject
*
CPyCppyy::PyStrings::gModule
=
nullptr
;
25
PyObject
*
CPyCppyy::PyStrings::gMRO
=
nullptr
;
26
PyObject
*
CPyCppyy::PyStrings::gName
=
nullptr
;
27
PyObject
*
CPyCppyy::PyStrings::gNe
=
nullptr
;
28
PyObject
*
CPyCppyy::PyStrings::gTypeCode
=
nullptr
;
29
PyObject
*
CPyCppyy::PyStrings::gCTypesType
=
nullptr
;
30
31
PyObject
*
CPyCppyy::PyStrings::gUnderlying
=
nullptr
;
32
33
PyObject
*
CPyCppyy::PyStrings::gAdd
=
nullptr
;
34
PyObject
*
CPyCppyy::PyStrings::gSub
=
nullptr
;
35
PyObject
*
CPyCppyy::PyStrings::gMul
=
nullptr
;
36
PyObject
*
CPyCppyy::PyStrings::gDiv
=
nullptr
;
37
38
PyObject
*
CPyCppyy::PyStrings::gLShift
=
nullptr
;
39
PyObject
*
CPyCppyy::PyStrings::gLShiftC
=
nullptr
;
40
41
PyObject
*
CPyCppyy::PyStrings::gAt
=
nullptr
;
42
PyObject
*
CPyCppyy::PyStrings::gBegin
=
nullptr
;
43
PyObject
*
CPyCppyy::PyStrings::gEnd
=
nullptr
;
44
PyObject
*
CPyCppyy::PyStrings::gFirst
=
nullptr
;
45
PyObject
*
CPyCppyy::PyStrings::gSecond
=
nullptr
;
46
PyObject
*
CPyCppyy::PyStrings::gSize
=
nullptr
;
47
PyObject
*
CPyCppyy::PyStrings::gTemplate
=
nullptr
;
48
PyObject
*
CPyCppyy::PyStrings::gVectorAt
=
nullptr
;
49
50
PyObject
*
CPyCppyy::PyStrings::gCppReal
=
nullptr
;
51
PyObject
*
CPyCppyy::PyStrings::gCppImag
=
nullptr
;
52
53
PyObject
*
CPyCppyy::PyStrings::gThisModule
=
nullptr
;
54
55
PyObject
*
CPyCppyy::PyStrings::gNoImplicit
=
nullptr
;
56
57
PyObject
*
CPyCppyy::PyStrings::gExPythonize
=
nullptr
;
58
PyObject
*
CPyCppyy::PyStrings::gPythonize
=
nullptr
;
59
60
61
//-----------------------------------------------------------------------------
62
#define CPPYY_INITIALIZE_STRING(var, str) \
63
if (!(PyStrings::var = CPyCppyy_PyText_InternFromString((char*)#str))) \
64
return false
65
66
bool
CPyCppyy::CreatePyStrings
() {
67
// Build cache of commonly used python strings (the cache is python intern, so
68
// all strings are shared python-wide, not just in cppyy).
69
CPPYY_INITIALIZE_STRING
(
gAssign
, __assign__);
70
CPPYY_INITIALIZE_STRING
(
gBases
, __bases__);
71
CPPYY_INITIALIZE_STRING
(
gBase
, __base__);
72
CPPYY_INITIALIZE_STRING
(
gCppName
, __cpp_name__);
73
CPPYY_INITIALIZE_STRING
(
gDeref
, __deref__);
74
CPPYY_INITIALIZE_STRING
(
gPreInc
, __preinc__);
75
CPPYY_INITIALIZE_STRING
(
gPostInc
, __postinc__);
76
CPPYY_INITIALIZE_STRING
(
gDict
, __dict__);
77
if
(!(
PyStrings::gEmptyString
=
CPyCppyy_PyText_FromString
((
char
*)
""
)))
78
return
false
;
79
CPPYY_INITIALIZE_STRING
(
gEq
, __eq__);
80
CPPYY_INITIALIZE_STRING
(
gFollow
, __follow__);
81
CPPYY_INITIALIZE_STRING
(
gGetItem
, __getitem__);
82
CPPYY_INITIALIZE_STRING
(
gGetNoCheck
, _getitem__unchecked);
83
CPPYY_INITIALIZE_STRING
(
gInit
, __init__);
84
CPPYY_INITIALIZE_STRING
(
gIter
, __iter__);
85
CPPYY_INITIALIZE_STRING
(
gLen
, __len__);
86
CPPYY_INITIALIZE_STRING
(
gLifeLine
, __lifeline);
87
CPPYY_INITIALIZE_STRING
(
gModule
, __module__);
88
CPPYY_INITIALIZE_STRING
(
gMRO
, __mro__);
89
CPPYY_INITIALIZE_STRING
(
gName
, __name__);
90
CPPYY_INITIALIZE_STRING
(
gNe
, __ne__);
91
CPPYY_INITIALIZE_STRING
(
gTypeCode
, typecode);
92
CPPYY_INITIALIZE_STRING
(
gCTypesType
, _type_);
93
94
CPPYY_INITIALIZE_STRING
(
gUnderlying
, __underlying);
95
96
CPPYY_INITIALIZE_STRING
(
gAdd
, __add__);
97
CPPYY_INITIALIZE_STRING
(
gSub
, __sub__);
98
CPPYY_INITIALIZE_STRING
(
gMul
, __mul__);
99
CPPYY_INITIALIZE_STRING
(
gDiv
,
CPPYY__div__
);
100
101
CPPYY_INITIALIZE_STRING
(
gLShift
, __lshift__);
102
CPPYY_INITIALIZE_STRING
(
gLShiftC
, __lshiftc__);
103
104
CPPYY_INITIALIZE_STRING
(
gAt
, at);
105
CPPYY_INITIALIZE_STRING
(
gBegin
, begin);
106
CPPYY_INITIALIZE_STRING
(
gEnd
, end);
107
CPPYY_INITIALIZE_STRING
(
gFirst
,
first
);
108
CPPYY_INITIALIZE_STRING
(
gSecond
,
second
);
109
CPPYY_INITIALIZE_STRING
(
gSize
, size);
110
CPPYY_INITIALIZE_STRING
(
gTemplate
, Template);
111
CPPYY_INITIALIZE_STRING
(
gVectorAt
, _vector__at);
112
113
CPPYY_INITIALIZE_STRING
(
gCppReal
, __cpp_real);
114
CPPYY_INITIALIZE_STRING
(
gCppImag
, __cpp_imag);
115
116
CPPYY_INITIALIZE_STRING
(
gThisModule
, cppyy);
117
118
CPPYY_INITIALIZE_STRING
(
gNoImplicit
, __cppyy_no_implicit);
119
120
CPPYY_INITIALIZE_STRING
(
gExPythonize
, __cppyy_explicit_pythonize__);
121
CPPYY_INITIALIZE_STRING
(
gPythonize
, __cppyy_pythonize__);
122
123
return
true
;
124
}
125
126
127
//-----------------------------------------------------------------------------
128
PyObject
*
CPyCppyy::DestroyPyStrings
() {
129
// Remove all cached python strings.
130
Py_DECREF(
PyStrings::gBases
);
PyStrings::gBases
=
nullptr
;
131
Py_DECREF(
PyStrings::gBase
);
PyStrings::gBase
=
nullptr
;
132
Py_DECREF(
PyStrings::gCppName
);
PyStrings::gCppName
=
nullptr
;
133
Py_DECREF(
PyStrings::gDeref
);
PyStrings::gDeref
=
nullptr
;
134
Py_DECREF(
PyStrings::gPreInc
);
PyStrings::gPreInc
=
nullptr
;
135
Py_DECREF(
PyStrings::gPostInc
);
PyStrings::gPostInc
=
nullptr
;
136
Py_DECREF(
PyStrings::gDict
);
PyStrings::gDict
=
nullptr
;
137
Py_DECREF(
PyStrings::gEmptyString
);
PyStrings::gEmptyString
=
nullptr
;
138
Py_DECREF(
PyStrings::gEq
);
PyStrings::gEq
=
nullptr
;
139
Py_DECREF(
PyStrings::gFollow
);
PyStrings::gFollow
=
nullptr
;
140
Py_DECREF(
PyStrings::gGetItem
);
PyStrings::gGetItem
=
nullptr
;
141
Py_DECREF(
PyStrings::gGetNoCheck
);
PyStrings::gGetNoCheck
=
nullptr
;
142
Py_DECREF(
PyStrings::gInit
);
PyStrings::gInit
=
nullptr
;
143
Py_DECREF(
PyStrings::gIter
);
PyStrings::gIter
=
nullptr
;
144
Py_DECREF(
PyStrings::gLen
);
PyStrings::gLen
=
nullptr
;
145
Py_DECREF(
PyStrings::gLifeLine
);
PyStrings::gLifeLine
=
nullptr
;
146
Py_DECREF(
PyStrings::gModule
);
PyStrings::gModule
=
nullptr
;
147
Py_DECREF(
PyStrings::gMRO
);
PyStrings::gMRO
=
nullptr
;
148
Py_DECREF(
PyStrings::gName
);
PyStrings::gName
=
nullptr
;
149
Py_DECREF(
PyStrings::gNe
);
PyStrings::gNe
=
nullptr
;
150
Py_DECREF(
PyStrings::gTypeCode
);
PyStrings::gTypeCode
=
nullptr
;
151
Py_DECREF(
PyStrings::gCTypesType
);
PyStrings::gCTypesType
=
nullptr
;
152
153
Py_DECREF(
PyStrings::gUnderlying
);
PyStrings::gUnderlying
=
nullptr
;
154
155
Py_DECREF(
PyStrings::gAdd
);
PyStrings::gAdd
=
nullptr
;
156
Py_DECREF(
PyStrings::gSub
);
PyStrings::gSub
=
nullptr
;
157
Py_DECREF(
PyStrings::gMul
);
PyStrings::gMul
=
nullptr
;
158
Py_DECREF(
PyStrings::gDiv
);
PyStrings::gDiv
=
nullptr
;
159
160
Py_DECREF(
PyStrings::gLShift
);
PyStrings::gLShift
=
nullptr
;
161
Py_DECREF(
PyStrings::gLShiftC
);
PyStrings::gLShiftC
=
nullptr
;
162
163
Py_DECREF(
PyStrings::gAt
);
PyStrings::gAt
=
nullptr
;
164
Py_DECREF(
PyStrings::gBegin
);
PyStrings::gBegin
=
nullptr
;
165
Py_DECREF(
PyStrings::gEnd
);
PyStrings::gEnd
=
nullptr
;
166
Py_DECREF(
PyStrings::gFirst
);
PyStrings::gFirst
=
nullptr
;
167
Py_DECREF(
PyStrings::gSecond
);
PyStrings::gSecond
=
nullptr
;
168
Py_DECREF(
PyStrings::gSize
);
PyStrings::gSize
=
nullptr
;
169
Py_DECREF(
PyStrings::gTemplate
);
PyStrings::gTemplate
=
nullptr
;
170
Py_DECREF(
PyStrings::gVectorAt
);
PyStrings::gVectorAt
=
nullptr
;
171
172
Py_DECREF(
PyStrings::gCppReal
);
PyStrings::gCppReal
=
nullptr
;
173
Py_DECREF(
PyStrings::gCppImag
);
PyStrings::gCppImag
=
nullptr
;
174
175
Py_DECREF(
PyStrings::gThisModule
);
PyStrings::gThisModule
=
nullptr
;
176
177
Py_DECREF(
PyStrings::gNoImplicit
);
PyStrings::gNoImplicit
=
nullptr
;
178
179
Py_DECREF(
PyStrings::gExPythonize
);
PyStrings::gExPythonize
=
nullptr
;
180
Py_DECREF(
PyStrings::gPythonize
);
PyStrings::gPythonize
=
nullptr
;
181
182
Py_RETURN_NONE
;
183
}
CPyCppyy.h
CPPYY__div__
#define CPPYY__div__
Definition:
CPyCppyy.h:130
Py_RETURN_NONE
#define Py_RETURN_NONE
Definition:
CPyCppyy.h:281
CPyCppyy_PyText_FromString
#define CPyCppyy_PyText_FromString
Definition:
CPyCppyy.h:102
PyObject
_object PyObject
Definition:
PyMethodBase.h:41
CPPYY_INITIALIZE_STRING
#define CPPYY_INITIALIZE_STRING(var, str)
Definition:
PyStrings.cxx:62
PyStrings.h
CPyCppyy::PyStrings::gDict
PyObject * gDict
Definition:
PyStrings.cxx:14
CPyCppyy::PyStrings::gSub
PyObject * gSub
Definition:
PyStrings.cxx:34
CPyCppyy::PyStrings::gCTypesType
PyObject * gCTypesType
Definition:
PyStrings.cxx:29
CPyCppyy::PyStrings::gDeref
PyObject * gDeref
Definition:
PyStrings.cxx:11
CPyCppyy::PyStrings::gLen
PyObject * gLen
Definition:
PyStrings.cxx:22
CPyCppyy::PyStrings::gAssign
PyObject * gAssign
Definition:
PyStrings.cxx:7
CPyCppyy::PyStrings::gName
PyObject * gName
Definition:
PyStrings.cxx:26
CPyCppyy::PyStrings::gExPythonize
PyObject * gExPythonize
Definition:
PyStrings.cxx:57
CPyCppyy::PyStrings::gLifeLine
PyObject * gLifeLine
Definition:
PyStrings.cxx:23
CPyCppyy::PyStrings::gGetItem
PyObject * gGetItem
Definition:
PyStrings.cxx:18
CPyCppyy::PyStrings::gThisModule
PyObject * gThisModule
Definition:
PyStrings.cxx:53
CPyCppyy::PyStrings::gCppName
PyObject * gCppName
Definition:
PyStrings.cxx:10
CPyCppyy::PyStrings::gDiv
PyObject * gDiv
Definition:
PyStrings.cxx:36
CPyCppyy::PyStrings::gInit
PyObject * gInit
Definition:
PyStrings.cxx:20
CPyCppyy::PyStrings::gCppReal
PyObject * gCppReal
Definition:
PyStrings.cxx:50
CPyCppyy::PyStrings::gNe
PyObject * gNe
Definition:
PyStrings.cxx:27
CPyCppyy::PyStrings::gAdd
PyObject * gAdd
Definition:
PyStrings.cxx:33
CPyCppyy::PyStrings::gBegin
PyObject * gBegin
Definition:
PyStrings.cxx:42
CPyCppyy::PyStrings::gFollow
PyObject * gFollow
Definition:
PyStrings.cxx:17
CPyCppyy::PyStrings::gIter
PyObject * gIter
Definition:
PyStrings.cxx:21
CPyCppyy::PyStrings::gVectorAt
PyObject * gVectorAt
Definition:
PyStrings.cxx:48
CPyCppyy::PyStrings::gLShiftC
PyObject * gLShiftC
Definition:
PyStrings.cxx:39
CPyCppyy::PyStrings::gPreInc
PyObject * gPreInc
Definition:
PyStrings.cxx:12
CPyCppyy::PyStrings::gPythonize
PyObject * gPythonize
Definition:
PyStrings.cxx:58
CPyCppyy::PyStrings::gAt
PyObject * gAt
Definition:
PyStrings.cxx:41
CPyCppyy::PyStrings::gTypeCode
PyObject * gTypeCode
Definition:
PyStrings.cxx:28
CPyCppyy::PyStrings::gSecond
PyObject * gSecond
Definition:
PyStrings.cxx:45
CPyCppyy::PyStrings::gPostInc
PyObject * gPostInc
Definition:
PyStrings.cxx:13
CPyCppyy::PyStrings::gCppImag
PyObject * gCppImag
Definition:
PyStrings.cxx:51
CPyCppyy::PyStrings::gNoImplicit
PyObject * gNoImplicit
Definition:
PyStrings.cxx:55
CPyCppyy::PyStrings::gBases
PyObject * gBases
Definition:
PyStrings.cxx:8
CPyCppyy::PyStrings::gMul
PyObject * gMul
Definition:
PyStrings.cxx:35
CPyCppyy::PyStrings::gBase
PyObject * gBase
Definition:
PyStrings.cxx:9
CPyCppyy::PyStrings::gTemplate
PyObject * gTemplate
Definition:
PyStrings.cxx:47
CPyCppyy::PyStrings::gLShift
PyObject * gLShift
Definition:
PyStrings.cxx:38
CPyCppyy::PyStrings::gSize
PyObject * gSize
Definition:
PyStrings.cxx:46
CPyCppyy::PyStrings::gEq
PyObject * gEq
Definition:
PyStrings.cxx:16
CPyCppyy::PyStrings::gModule
PyObject * gModule
Definition:
PyStrings.cxx:24
CPyCppyy::PyStrings::gEmptyString
PyObject * gEmptyString
Definition:
PyStrings.cxx:15
CPyCppyy::PyStrings::gEnd
PyObject * gEnd
Definition:
PyStrings.cxx:43
CPyCppyy::PyStrings::gUnderlying
PyObject * gUnderlying
Definition:
PyStrings.cxx:31
CPyCppyy::PyStrings::gGetNoCheck
PyObject * gGetNoCheck
Definition:
PyStrings.cxx:19
CPyCppyy::PyStrings::gFirst
PyObject * gFirst
Definition:
PyStrings.cxx:44
CPyCppyy::PyStrings::gMRO
PyObject * gMRO
Definition:
PyStrings.cxx:25
CPyCppyy::DestroyPyStrings
PyObject * DestroyPyStrings()
Definition:
PyStrings.cxx:128
CPyCppyy::CreatePyStrings
bool CreatePyStrings()
Definition:
PyStrings.cxx:66
CPyCppyy::gThisModule
PyObject * gThisModule
Definition:
API.cxx:32
TGeant4Unit::second
static constexpr double second
Definition:
TGeant4SystemOfUnits.h:151
first
Definition:
first.py:1
bindings
pyroot
cppyy
CPyCppyy
src
PyStrings.cxx
ROOT v6-22 - Reference Guide Generated on Fri Apr 1 2022 11:50:22 (GVA Time) using Doxygen 1.9.4