Mercurial > vim
comparison src/if_py_both.h @ 4625:cb5c1e37ad4d v7.3.1060
updated for version 7.3.1060
Problem: Python: can't repr() a function.
Solution: Python patch 19: add FunctionRepr(). (ZyX)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Thu, 30 May 2013 12:43:54 +0200 |
parents | 548b889fe3cf |
children | 18ba89e06fab |
comparison
equal
deleted
inserted
replaced
4624:37268588e917 | 4625:cb5c1e37ad4d |
---|---|
1580 clear_tv(&rettv); | 1580 clear_tv(&rettv); |
1581 if (selfdict != NULL) | 1581 if (selfdict != NULL) |
1582 clear_tv(&selfdicttv); | 1582 clear_tv(&selfdicttv); |
1583 | 1583 |
1584 return result; | 1584 return result; |
1585 } | |
1586 | |
1587 static PyObject * | |
1588 FunctionRepr(FunctionObject *self) | |
1589 { | |
1590 return PyString_FromFormat("<vim.Function '%s'>", self->name); | |
1585 } | 1591 } |
1586 | 1592 |
1587 static struct PyMethodDef FunctionMethods[] = { | 1593 static struct PyMethodDef FunctionMethods[] = { |
1588 {"__call__",(PyCFunction)FunctionCall, METH_VARARGS|METH_KEYWORDS, ""}, | 1594 {"__call__",(PyCFunction)FunctionCall, METH_VARARGS|METH_KEYWORDS, ""}, |
1589 {"__dir__", (PyCFunction)FunctionDir, METH_NOARGS, ""}, | 1595 {"__dir__", (PyCFunction)FunctionDir, METH_NOARGS, ""}, |
4638 FunctionType.tp_dealloc = (destructor)FunctionDestructor; | 4644 FunctionType.tp_dealloc = (destructor)FunctionDestructor; |
4639 FunctionType.tp_call = (ternaryfunc)FunctionCall; | 4645 FunctionType.tp_call = (ternaryfunc)FunctionCall; |
4640 FunctionType.tp_flags = Py_TPFLAGS_DEFAULT; | 4646 FunctionType.tp_flags = Py_TPFLAGS_DEFAULT; |
4641 FunctionType.tp_doc = "object that calls vim function"; | 4647 FunctionType.tp_doc = "object that calls vim function"; |
4642 FunctionType.tp_methods = FunctionMethods; | 4648 FunctionType.tp_methods = FunctionMethods; |
4649 FunctionType.tp_repr = (reprfunc)FunctionRepr; | |
4643 #if PY_MAJOR_VERSION >= 3 | 4650 #if PY_MAJOR_VERSION >= 3 |
4644 FunctionType.tp_getattro = (getattrofunc)FunctionGetattro; | 4651 FunctionType.tp_getattro = (getattrofunc)FunctionGetattro; |
4645 #else | 4652 #else |
4646 FunctionType.tp_getattr = (getattrfunc)FunctionGetattr; | 4653 FunctionType.tp_getattr = (getattrfunc)FunctionGetattr; |
4647 #endif | 4654 #endif |