diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-07-02 21:47:18 (GMT) |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2008-07-02 21:47:18 (GMT) |
commit | 55b69e794c16d9ec201a9408f35f8fcbbae60324 (patch) | |
tree | b96d53f0bac3b6d5fb3ee3558415afc65f6e51bf /Objects/methodobject.c | |
parent | ba4105c1335503e3d441abbd7a3e74d255ead1a5 (diff) | |
download | cpython-55b69e794c16d9ec201a9408f35f8fcbbae60324.zip cpython-55b69e794c16d9ec201a9408f35f8fcbbae60324.tar.gz cpython-55b69e794c16d9ec201a9408f35f8fcbbae60324.tar.bz2 |
Oops, forgot that there are modules outside the win32 world.
Diffstat (limited to 'Objects/methodobject.c')
-rw-r--r-- | Objects/methodobject.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Objects/methodobject.c b/Objects/methodobject.c index cb6f1ba..3d208c1 100644 --- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -280,6 +280,43 @@ PyTypeObject PyCFunction_Type = { 0, /* tp_dict */ }; +/* Find a method in a method chain */ + +PyObject * +Py_FindMethodInChain(PyMethodChain *chain, PyObject *self, const char *name) +{ + if (name[0] == '_' && name[1] == '_') { + if (strcmp(name, "__doc__") == 0) { + const char *doc = self->ob_type->tp_doc; + if (doc != NULL) + return PyUnicode_FromString(doc); + } + } + while (chain != NULL) { + PyMethodDef *ml = chain->methods; + for (; ml->ml_name != NULL; ml++) { + if (name[0] == ml->ml_name[0] && + strcmp(name+1, ml->ml_name+1) == 0) + /* XXX */ + return PyCFunction_New(ml, self); + } + chain = chain->link; + } + PyErr_SetString(PyExc_AttributeError, name); + return NULL; +} + +/* Find a method in a single method list */ + +PyObject * +Py_FindMethod(PyMethodDef *methods, PyObject *self, const char *name) +{ + PyMethodChain chain; + chain.methods = methods; + chain.link = NULL; + return Py_FindMethodInChain(&chain, self, name); +} + /* Clear out the free list */ int |