ROOT
Version master
v6.34
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
Reference Guide
▼
ROOT
ROOT Reference Documentation
Tutorials
►
Functional Parts
►
Namespaces
►
All Classes
▼
Files
▼
File List
▼
bindings
▼
pyroot
▼
cppyy
►
cppyy
►
cppyy-backend
▼
CPyCppyy
►
include
▼
src
►
API.cxx
CallContext.cxx
►
CallContext.h
►
Converters.cxx
►
Converters.h
CPPClassMethod.cxx
►
CPPClassMethod.h
CPPConstructor.cxx
►
CPPConstructor.h
►
CPPDataMember.cxx
►
CPPDataMember.h
►
CPPEnum.cxx
►
CPPEnum.h
►
CPPExcInstance.cxx
►
CPPExcInstance.h
CPPFunction.cxx
►
CPPFunction.h
►
CPPGetSetItem.cxx
►
CPPGetSetItem.h
►
CPPInstance.cxx
►
CPPInstance.h
►
CPPMethod.cxx
►
CPPMethod.h
CPPOperator.cxx
►
CPPOperator.h
►
CPPOverload.cxx
►
CPPOverload.h
►
CPPScope.cxx
►
CPPScope.h
►
Cppyy.h
►
CPyCppyy.h
►
CPyCppyyModule.cxx
►
CustomPyTypes.cxx
►
CustomPyTypes.h
►
DeclareConverters.h
►
DeclareExecutors.h
►
Dimensions.h
►
Dispatcher.cxx
►
Dispatcher.h
►
DispatchPtr.cxx
►
Executors.cxx
►
Executors.h
►
LowLevelViews.cxx
►
LowLevelViews.h
►
MemoryRegulator.cxx
►
MemoryRegulator.h
►
ProxyWrappers.cxx
►
ProxyWrappers.h
►
PyCallable.h
►
PyException.cxx
PyObjectDir27.inc
►
PyResult.cxx
►
PyStrings.cxx
►
PyStrings.h
►
Pythonize.cxx
►
Pythonize.h
►
SignalTryCatch.h
►
TemplateProxy.cxx
►
TemplateProxy.h
►
TPyArg.cxx
TPyClassGenerator.cxx
TPyClassGenerator.h
►
TupleOfInstances.cxx
►
TupleOfInstances.h
►
TypeManip.cxx
►
TypeManip.h
►
Utility.cxx
►
Utility.h
►
pythonizations
►
r
►
tpython
►
core
►
documentation
►
geom
►
graf2d
►
graf3d
►
gui
►
hist
►
io
►
main
►
master
►
math
►
montecarlo
►
net
►
proof
►
roofit
►
sql
►
tmva
►
tree
►
tutorials
►
File Members
Release Notes
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
PyObjectDir27.inc
Go to the documentation of this file.
1
/* Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
2
2011, 2012, 2013, 2014 Python Software Foundation; All Rights Reserved
3
4
Copied from Objects/object.c under the PSF License Version 2.
5
6
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
7
--------------------------------------------
8
9
1. This LICENSE AGREEMENT is between the Python Software Foundation
10
("PSF"), and the Individual or Organization ("Licensee") accessing and
11
otherwise using this software ("Python") in source or binary form and
12
its associated documentation.
13
14
2. Subject to the terms and conditions of this License Agreement, PSF hereby
15
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
16
analyze, test, perform and/or display publicly, prepare derivative works,
17
distribute, and otherwise use Python alone or in any derivative version,
18
provided, however, that PSF's License Agreement and PSF's notice of copyright,
19
i.e., "Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
20
2011, 2012, 2013, 2014 Python Software Foundation; All Rights Reserved" are retained
21
in Python alone or in any derivative version prepared by Licensee.
22
23
3. In the event Licensee prepares a derivative work that is based on
24
or incorporates Python or any part thereof, and wants to make
25
the derivative work available to others as provided herein, then
26
Licensee hereby agrees to include in any such work a brief summary of
27
the changes made to Python.
28
29
4. PSF is making Python available to Licensee on an "AS IS"
30
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
31
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
32
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
33
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
34
INFRINGE ANY THIRD PARTY RIGHTS.
35
36
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
37
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
38
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
39
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
40
41
6. This License Agreement will automatically terminate upon a material
42
breach of its terms and conditions.
43
44
7. Nothing in this License Agreement shall be deemed to create any
45
relationship of agency, partnership, or joint venture between PSF and
46
Licensee. This License Agreement does not grant permission to use PSF
47
trademarks or trade name in a trademark sense to endorse or promote
48
products or services of Licensee, or any third party.
49
50
8. By copying, installing or otherwise using Python, Licensee
51
agrees to be bound by the terms and conditions of this License
52
Agreement.
53
54
*/
55
56
/* Helper for PyObject_Dir.
57
Merge the __dict__ of aclass into dict, and recursively also all
58
the __dict__s of aclass's base classes. The order of merging isn't
59
defined, as it's expected that only the final set of dict keys is
60
interesting.
61
Return 0 on success, -1 on error.
62
*/
63
64
static
int
merge_class_dict
(
PyObject
* dict,
PyObject
*
aclass
)
65
{
66
PyObject
*
classdict
;
67
PyObject
*
bases
;
68
69
assert
(
PyDict_Check
(dict));
70
assert
(
aclass
);
71
72
/* Merge in the type's dict (if any). */
73
classdict
=
PyObject_GetAttrString
(
aclass
,
"__dict__"
);
74
if
(
classdict
==
NULL
)
75
PyErr_Clear
();
76
else
{
77
int
status =
PyDict_Update
(dict,
classdict
);
78
Py_DECREF
(
classdict
);
79
if
(status < 0)
80
return
-1;
81
}
82
83
/* Recursively merge in the base types' (if any) dicts. */
84
bases
=
PyObject_GetAttrString
(
aclass
,
"__bases__"
);
85
if
(
bases
==
NULL
)
86
PyErr_Clear
();
87
else
{
88
/* We have no guarantee that bases is a real tuple */
89
Py_ssize_t
i,
n
;
90
n
=
PySequence_Size
(
bases
);
/* This better be right */
91
if
(
n
< 0)
92
PyErr_Clear
();
93
else
{
94
for
(i = 0; i <
n
; i++) {
95
int
status;
96
PyObject
*base =
PySequence_GetItem
(
bases
, i);
97
if
(base ==
NULL
) {
98
Py_DECREF
(
bases
);
99
return
-1;
100
}
101
status =
merge_class_dict
(dict, base);
102
Py_DECREF
(base);
103
if
(status < 0) {
104
Py_DECREF
(
bases
);
105
return
-1;
106
}
107
}
108
}
109
Py_DECREF
(
bases
);
110
}
111
return
0;
112
}
113
114
#if PY_VERSION_HEX < 0x03000000
115
116
/* Helper for PyObject_Dir.
117
If obj has an attr named attrname that's a list, merge its string
118
elements into keys of dict.
119
Return 0 on success, -1 on error. Errors due to not finding the attr,
120
or the attr not being a list, are suppressed.
121
*/
122
123
static
int
124
merge_list_attr
(
PyObject
* dict,
PyObject
* obj,
const
char
*
attrname
)
125
{
126
PyObject
*list;
127
int
result
= 0;
128
129
assert
(
PyDict_Check
(dict));
130
assert
(obj);
131
assert
(
attrname
);
132
133
list =
PyObject_GetAttrString
(obj,
attrname
);
134
if
(list ==
NULL
)
135
PyErr_Clear
();
136
137
else
if
(
PyList_Check
(list)) {
138
int
i;
139
for
(i = 0; i <
PyList_GET_SIZE
(list); ++i) {
140
PyObject
*item =
PyList_GET_ITEM
(list, i);
141
if
(
PyString_Check
(item)) {
142
result
=
PyDict_SetItem
(dict, item,
Py_None
);
143
if
(
result
< 0)
144
break
;
145
}
146
}
147
if
(
Py_Py3kWarningFlag
&&
148
(
strcmp
(
attrname
,
"__members__"
) == 0 ||
149
strcmp
(
attrname
,
"__methods__"
) == 0)) {
150
if
(
PyErr_WarnEx
(
PyExc_DeprecationWarning
,
151
"__members__ and __methods__ not "
152
"supported in 3.x"
, 1) < 0) {
153
Py_XDECREF
(list);
154
return
-1;
155
}
156
}
157
}
158
159
Py_XDECREF
(list);
160
return
result
;
161
}
162
163
#endif
164
165
/* Helper for PyObject_Dir of type objects: returns __dict__ and __bases__.
166
We deliberately don't suck up its __class__, as methods belonging to the
167
metaclass would probably be more confusing than helpful.
168
*/
169
static
PyObject
*
170
_specialized_dir_type
(
PyObject
*obj)
171
{
172
PyObject
*
result
=
NULL
;
173
PyObject
*dict =
PyDict_New
();
174
175
if
(dict !=
NULL
&&
merge_class_dict
(dict, obj) == 0)
176
result
=
PyDict_Keys
(dict);
177
178
Py_XDECREF
(dict);
179
return
result
;
180
}
181
182
static
PyObject
*
_generic_dir
(
PyObject
*obj)
183
{
184
if
(
PyType_Check
(obj) ||
PyClass_Check
(obj))
185
return
_specialized_dir_type
(obj);
186
187
PyObject
*
result
=
NULL
;
188
PyObject
*dict =
NULL
;
189
PyObject
*
itsclass
=
NULL
;
190
191
/* Get __dict__ (which may or may not be a real dict...) */
192
dict =
PyObject_GetAttrString
(obj,
"__dict__"
);
193
if
(dict ==
NULL
) {
194
PyErr_Clear
();
195
dict =
PyDict_New
();
196
}
197
else
if
(!
PyDict_Check
(dict)) {
198
Py_DECREF
(dict);
199
dict =
PyDict_New
();
200
}
201
else
{
202
/* Copy __dict__ to avoid mutating it. */
203
PyObject
*temp =
PyDict_Copy
(dict);
204
Py_DECREF
(dict);
205
dict = temp;
206
}
207
208
if
(dict ==
NULL
)
209
goto
error;
210
211
#if PY_VERSION_HEX < 0x03000000
212
/* Merge in __members__ and __methods__ (if any).
213
* This is removed in Python 3000. */
214
if
(
merge_list_attr
(dict, obj,
"__members__"
) < 0)
215
goto
error;
216
if
(
merge_list_attr
(dict, obj,
"__methods__"
) < 0)
217
goto
error;
218
#endif
219
220
/* Merge in attrs reachable from its class. */
221
itsclass
=
PyObject_GetAttrString
(obj,
"__class__"
);
222
if
(
itsclass
==
NULL
)
223
/* XXX(tomer): Perhaps fall back to obj->ob_type if no
224
__class__ exists? */
225
PyErr_Clear
();
226
else
{
227
if
(
merge_class_dict
(dict,
itsclass
) != 0)
228
goto
error;
229
}
230
231
result
=
PyDict_Keys
(dict);
232
/* fall through */
233
error:
234
Py_XDECREF
(
itsclass
);
235
Py_XDECREF
(dict);
236
return
result
;
237
}
Py_ssize_t
int Py_ssize_t
Definition
CPyCppyy.h:215
PyObject
_object PyObject
Definition
PyMethodBase.h:43
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Definition
TGWin32VirtualXProxy.cxx:174
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
n
const Int_t n
Definition
legend1.C:16
bindings
pyroot
cppyy
CPyCppyy
src
PyObjectDir27.inc
ROOT master - Reference Guide Generated on Wed Apr 2 2025 07:35:00 (GVA Time) using Doxygen 1.10.0