Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
21bcc9aa
Commit
21bcc9aa
authored
Jul 14, 2004
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documented the new Py_VISIT macro to simplify implementation of
tp_traverse handlers. (Tim made me do it. ;)
parent
02a8bf9a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
0 deletions
+33
-0
Doc/api/newtypes.tex
Doc/api/newtypes.tex
+23
-0
Include/objimpl.h
Include/objimpl.h
+10
-0
No files found.
Doc/api/newtypes.tex
View file @
21bcc9aa
...
...
@@ -1663,6 +1663,29 @@ The \member{tp_traverse} handler must have the following type:
that value should be returned immediately.
\end{ctypedesc}
To simplify writing
\member
{
tp
_
traverse
}
handlers, a
\cfunction
{
Py
_
VISIT()
}
is provided:
\begin{cfuncdesc}
{
void
}{
Py
_
VISIT
}{
PyObject *o
}
Call the
\var
{
visit
}
for
\var
{
o
}
with
\var
{
arg
}
. If
\var
{
visit
}
returns a non-zero value, then return it. Using this macro,
\member
{
tp
_
traverse
}
handlers look like:
\begin{verbatim}
static int
my
_
traverse(Noddy *self, visitproc visit, void *arg)
{
Py
_
VISIT(self->foo);
Py
_
VISIT(self->bar);
return 0;
}
\end{verbatim}
\versionadded
{
2.4
}
\end{cfuncdesc}
The
\member
{
tp
_
clear
}
handler must be of the
\ctype
{
inquiry
}
type, or
\NULL
{}
if the object is immutable.
...
...
Include/objimpl.h
View file @
21bcc9aa
...
...
@@ -302,6 +302,16 @@ PyAPI_FUNC(void) PyObject_GC_Del(void *);
( (type *) _PyObject_GC_NewVar((typeobj), (n)) )
/* Utility macro to help write tp_traverse functions */
#define Py_VISIT(op) \
do { \
if (op) { \
int vret = visit((op), arg); \
if (vret) \
return vret; \
} \
} while (0)
/* This is here for the sake of backwards compatibility. Extensions that
* use the old GC API will still compile but the objects will not be
* tracked by the GC. */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment