summaryrefslogtreecommitdiffstats
path: root/Objects/funcobject.c
diff options
context:
space:
mode:
authorJeremy Hylton <jeremy@alum.mit.edu>2000-06-23 14:18:11 (GMT)
committerJeremy Hylton <jeremy@alum.mit.edu>2000-06-23 14:18:11 (GMT)
commit8caad49c30d2f9ecd09c8838bb691360e40c2665 (patch)
tree367db742417367edaea6a4dee1eea3ff2885d3db /Objects/funcobject.c
parenta392dcb2117739ad0dc7f67bd550083ee860226b (diff)
downloadcpython-8caad49c30d2f9ecd09c8838bb691360e40c2665.zip
cpython-8caad49c30d2f9ecd09c8838bb691360e40c2665.tar.gz
cpython-8caad49c30d2f9ecd09c8838bb691360e40c2665.tar.bz2
Round 1 of Neil Schemenauer's GC patches:
This patch adds the type methods traverse and clear necessary for GC implementation.
Diffstat (limited to 'Objects/funcobject.c')
-rw-r--r--Objects/funcobject.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index a5e15cc..142c7e7 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -239,6 +239,38 @@ func_hash(f)
return h;
}
+static int
+func_traverse(PyFunctionObject *f, visitproc visit, void *arg)
+{
+ int err;
+ if (f->func_code) {
+ err = visit(f->func_code, arg);
+ if (err)
+ return err;
+ }
+ if (f->func_globals) {
+ err = visit(f->func_globals, arg);
+ if (err)
+ return err;
+ }
+ if (f->func_defaults) {
+ err = visit(f->func_defaults, arg);
+ if (err)
+ return err;
+ }
+ if (f->func_doc) {
+ err = visit(f->func_doc, arg);
+ if (err)
+ return err;
+ }
+ if (f->func_name) {
+ err = visit(f->func_name, arg);
+ if (err)
+ return err;
+ }
+ return 0;
+}
+
PyTypeObject PyFunction_Type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
@@ -255,4 +287,12 @@ PyTypeObject PyFunction_Type = {
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
(hashfunc)func_hash, /*tp_hash*/
+ 0, /*tp_call*/
+ 0, /*tp_str*/
+ 0, /*tp_getattro*/
+ 0, /*tp_setattro*/
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /*tp_flags*/
+ 0, /* tp_doc */
+ (traverseproc)func_traverse, /* tp_traverse */
};