diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-09-14 20:08:07 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-09-14 20:08:07 (GMT) |
commit | c785f4841c24ff912ab5cc1ab34da4b9d64205e5 (patch) | |
tree | a021e0fc0a9dc4492dccca30aac9da495094d443 /Python/compile.c | |
parent | a8c60f478cfadf9d75d605816f3962fbe588640a (diff) | |
download | cpython-c785f4841c24ff912ab5cc1ab34da4b9d64205e5.zip cpython-c785f4841c24ff912ab5cc1ab34da4b9d64205e5.tar.gz cpython-c785f4841c24ff912ab5cc1ab34da4b9d64205e5.tar.bz2 |
Supply code objects a new-style tp_members slot and tp_getattr impl.
The chief effects are to make dir() do something useful and supply
them with an __class__.
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 50 |
1 files changed, 34 insertions, 16 deletions
diff --git a/Python/compile.c b/Python/compile.c index ec7daaf..0f10dbe 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -91,12 +91,6 @@ static struct memberlist code_memberlist[] = { {NULL} /* Sentinel */ }; -static PyObject * -code_getattr(PyCodeObject *co, char *name) -{ - return PyMember_Get((char *)co, code_memberlist, name); -} - static void code_dealloc(PyCodeObject *co) { @@ -189,16 +183,40 @@ PyTypeObject PyCode_Type = { "code", sizeof(PyCodeObject), 0, - (destructor)code_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - (getattrfunc)code_getattr, /*tp_getattr*/ - 0, /*tp_setattr*/ - (cmpfunc)code_compare, /*tp_compare*/ - (reprfunc)code_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)code_hash, /*tp_hash*/ + (destructor)code_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + (cmpfunc)code_compare, /* tp_compare */ + (reprfunc)code_repr, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + (hashfunc)code_hash, /* tp_hash */ + 0, /* tp_call */ + 0, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + 0, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + 0, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + code_memberlist, /* tp_members */ + 0, /* tp_getset */ + 0, /* tp_base */ + 0, /* tp_dict */ + 0, /* tp_descr_get */ + 0, /* tp_descr_set */ + 0, /* tp_dictoffset */ + 0, /* tp_init */ + 0, /* tp_alloc */ + 0, /* tp_new */ }; #define NAME_CHARS \ |