mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
updated for version 7.3.1047
Problem: Python: dir() does not work properly. Solution: Python patch 8. Add __dir__ method to all objects with custom tp_getattr supplemented by __members__ attribute for at least python-2* versions. __members__ is not mentioned in python-3* dir() output even if it is accessible. (ZyX)
This commit is contained in:
parent
432b09c84d
commit
dd8aca664d
188
src/if_py_both.h
188
src/if_py_both.h
@ -117,6 +117,59 @@ StringToChars(PyObject *object, PyObject **todecref)
|
|||||||
return (char_u *) p;
|
return (char_u *) p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
add_string(PyObject *list, char *s)
|
||||||
|
{
|
||||||
|
PyObject *string;
|
||||||
|
|
||||||
|
if (!(string = PyString_FromString(s)))
|
||||||
|
return -1;
|
||||||
|
if (PyList_Append(list, string))
|
||||||
|
{
|
||||||
|
Py_DECREF(string);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_DECREF(string);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
ObjectDir(PyObject *self, char **attributes)
|
||||||
|
{
|
||||||
|
PyMethodDef *method;
|
||||||
|
char **attr;
|
||||||
|
PyObject *r;
|
||||||
|
|
||||||
|
if (!(r = PyList_New(0)))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
if (self)
|
||||||
|
for (method = self->ob_type->tp_methods ; method->ml_name != NULL ; ++method)
|
||||||
|
if (add_string(r, (char *) method->ml_name))
|
||||||
|
{
|
||||||
|
Py_DECREF(r);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (attr = attributes ; *attr ; ++attr)
|
||||||
|
if (add_string(r, *attr))
|
||||||
|
{
|
||||||
|
Py_DECREF(r);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if PY_MAJOR_VERSION < 3
|
||||||
|
if (add_string(r, "__members__"))
|
||||||
|
{
|
||||||
|
Py_DECREF(r);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
/* Output buffer management
|
/* Output buffer management
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -132,6 +185,17 @@ typedef struct
|
|||||||
long error;
|
long error;
|
||||||
} OutputObject;
|
} OutputObject;
|
||||||
|
|
||||||
|
static char *OutputAttrs[] = {
|
||||||
|
"softspace",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
OutputDir(PyObject *self)
|
||||||
|
{
|
||||||
|
return ObjectDir(self, OutputAttrs);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
OutputSetattr(OutputObject *self, char *name, PyObject *val)
|
OutputSetattr(OutputObject *self, char *name, PyObject *val)
|
||||||
{
|
{
|
||||||
@ -291,6 +355,7 @@ static struct PyMethodDef OutputMethods[] = {
|
|||||||
{"write", (PyCFunction)OutputWrite, METH_VARARGS, ""},
|
{"write", (PyCFunction)OutputWrite, METH_VARARGS, ""},
|
||||||
{"writelines", (PyCFunction)OutputWritelines, METH_VARARGS, ""},
|
{"writelines", (PyCFunction)OutputWritelines, METH_VARARGS, ""},
|
||||||
{"flush", (PyCFunction)OutputFlush, METH_NOARGS, ""},
|
{"flush", (PyCFunction)OutputFlush, METH_NOARGS, ""},
|
||||||
|
{"__dir__", (PyCFunction)OutputDir, METH_NOARGS, ""},
|
||||||
{ NULL, NULL, 0, NULL}
|
{ NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -826,6 +891,17 @@ DictionaryDestructor(DictionaryObject *self)
|
|||||||
DESTRUCTOR_FINISH(self);
|
DESTRUCTOR_FINISH(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *DictionaryAttrs[] = {
|
||||||
|
"locked", "scope",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
DictionaryDir(PyObject *self)
|
||||||
|
{
|
||||||
|
return ObjectDir(self, DictionaryAttrs);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
DictionarySetattr(DictionaryObject *self, char *name, PyObject *val)
|
DictionarySetattr(DictionaryObject *self, char *name, PyObject *val)
|
||||||
{
|
{
|
||||||
@ -985,6 +1061,7 @@ static PyMappingMethods DictionaryAsMapping = {
|
|||||||
|
|
||||||
static struct PyMethodDef DictionaryMethods[] = {
|
static struct PyMethodDef DictionaryMethods[] = {
|
||||||
{"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""},
|
{"keys", (PyCFunction)DictionaryListKeys, METH_NOARGS, ""},
|
||||||
|
{"__dir__", (PyCFunction)DictionaryDir, METH_NOARGS, ""},
|
||||||
{ NULL, NULL, 0, NULL}
|
{ NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1331,6 +1408,17 @@ ListConcatInPlace(ListObject *self, PyObject *obj)
|
|||||||
return (PyObject *)(self);
|
return (PyObject *)(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *ListAttrs[] = {
|
||||||
|
"locked",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
ListDir(PyObject *self)
|
||||||
|
{
|
||||||
|
return ObjectDir(self, ListAttrs);
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ListSetattr(ListObject *self, char *name, PyObject *val)
|
ListSetattr(ListObject *self, char *name, PyObject *val)
|
||||||
{
|
{
|
||||||
@ -1369,6 +1457,7 @@ ListSetattr(ListObject *self, char *name, PyObject *val)
|
|||||||
|
|
||||||
static struct PyMethodDef ListMethods[] = {
|
static struct PyMethodDef ListMethods[] = {
|
||||||
{"extend", (PyCFunction)ListConcatInPlace, METH_O, ""},
|
{"extend", (PyCFunction)ListConcatInPlace, METH_O, ""},
|
||||||
|
{"__dir__", (PyCFunction)ListDir, METH_NOARGS, ""},
|
||||||
{ NULL, NULL, 0, NULL}
|
{ NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1408,6 +1497,17 @@ FunctionDestructor(FunctionObject *self)
|
|||||||
DESTRUCTOR_FINISH(self);
|
DESTRUCTOR_FINISH(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *FunctionAttrs[] = {
|
||||||
|
"softspace",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
FunctionDir(PyObject *self)
|
||||||
|
{
|
||||||
|
return ObjectDir(self, FunctionAttrs);
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
FunctionCall(FunctionObject *self, PyObject *argsObject, PyObject *kwargs)
|
FunctionCall(FunctionObject *self, PyObject *argsObject, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
@ -1473,6 +1573,7 @@ FunctionCall(FunctionObject *self, PyObject *argsObject, PyObject *kwargs)
|
|||||||
|
|
||||||
static struct PyMethodDef FunctionMethods[] = {
|
static struct PyMethodDef FunctionMethods[] = {
|
||||||
{"__call__",(PyCFunction)FunctionCall, METH_VARARGS|METH_KEYWORDS, ""},
|
{"__call__",(PyCFunction)FunctionCall, METH_VARARGS|METH_KEYWORDS, ""},
|
||||||
|
{"__dir__", (PyCFunction)FunctionDir, METH_NOARGS, ""},
|
||||||
{ NULL, NULL, 0, NULL}
|
{ NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1842,6 +1943,17 @@ TabPageDestructor(TabPageObject *self)
|
|||||||
DESTRUCTOR_FINISH(self);
|
DESTRUCTOR_FINISH(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *TabPageAttrs[] = {
|
||||||
|
"windows", "number", "vars", "window", "valid",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
TabPageDir(PyObject *self)
|
||||||
|
{
|
||||||
|
return ObjectDir(self, TabPageAttrs);
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
TabPageAttrValid(TabPageObject *self, char *name)
|
TabPageAttrValid(TabPageObject *self, char *name)
|
||||||
{
|
{
|
||||||
@ -1873,6 +1985,8 @@ TabPageAttr(TabPageObject *self, char *name)
|
|||||||
else
|
else
|
||||||
return WindowNew(self->tab->tp_curwin, self->tab);
|
return WindowNew(self->tab->tp_curwin, self->tab);
|
||||||
}
|
}
|
||||||
|
else if (strcmp(name, "__members__") == 0)
|
||||||
|
return ObjectDir(NULL, TabPageAttrs);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1902,6 +2016,7 @@ TabPageRepr(TabPageObject *self)
|
|||||||
|
|
||||||
static struct PyMethodDef TabPageMethods[] = {
|
static struct PyMethodDef TabPageMethods[] = {
|
||||||
/* name, function, calling, documentation */
|
/* name, function, calling, documentation */
|
||||||
|
{"__dir__", (PyCFunction)TabPageDir, METH_NOARGS, ""},
|
||||||
{ NULL, NULL, 0, NULL}
|
{ NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -2049,6 +2164,17 @@ get_firstwin(TabPageObject *tabObject)
|
|||||||
else
|
else
|
||||||
return firstwin;
|
return firstwin;
|
||||||
}
|
}
|
||||||
|
static char *WindowAttrs[] = {
|
||||||
|
"buffer", "cursor", "height", "vars", "options", "number", "row", "col",
|
||||||
|
"tabpage", "valid",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
WindowDir(PyObject *self)
|
||||||
|
{
|
||||||
|
return ObjectDir(self, WindowAttrs);
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
WindowAttrValid(WindowObject *self, char *name)
|
WindowAttrValid(WindowObject *self, char *name)
|
||||||
@ -2104,8 +2230,7 @@ WindowAttr(WindowObject *self, char *name)
|
|||||||
return (PyObject *)(self->tabObject);
|
return (PyObject *)(self->tabObject);
|
||||||
}
|
}
|
||||||
else if (strcmp(name, "__members__") == 0)
|
else if (strcmp(name, "__members__") == 0)
|
||||||
return Py_BuildValue("[ssssssssss]", "buffer", "cursor", "height",
|
return ObjectDir(NULL, WindowAttrs);
|
||||||
"vars", "options", "number", "row", "col", "tabpage", "valid");
|
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -2229,6 +2354,7 @@ WindowRepr(WindowObject *self)
|
|||||||
|
|
||||||
static struct PyMethodDef WindowMethods[] = {
|
static struct PyMethodDef WindowMethods[] = {
|
||||||
/* name, function, calling, documentation */
|
/* name, function, calling, documentation */
|
||||||
|
{"__dir__", (PyCFunction)WindowDir, METH_NOARGS, ""},
|
||||||
{ NULL, NULL, 0, NULL}
|
{ NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3122,6 +3248,17 @@ RangeSlice(RangeObject *self, PyInt lo, PyInt hi)
|
|||||||
return RBSlice(self->buf, lo, hi, self->start, self->end);
|
return RBSlice(self->buf, lo, hi, self->start, self->end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *RangeAttrs[] = {
|
||||||
|
"start", "end",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
RangeDir(PyObject *self)
|
||||||
|
{
|
||||||
|
return ObjectDir(self, RangeAttrs);
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
RangeAppend(RangeObject *self, PyObject *args)
|
RangeAppend(RangeObject *self, PyObject *args)
|
||||||
{
|
{
|
||||||
@ -3162,6 +3299,7 @@ RangeRepr(RangeObject *self)
|
|||||||
static struct PyMethodDef RangeMethods[] = {
|
static struct PyMethodDef RangeMethods[] = {
|
||||||
/* name, function, calling, documentation */
|
/* name, function, calling, documentation */
|
||||||
{"append", (PyCFunction)RangeAppend, METH_VARARGS, "Append data to the Vim range" },
|
{"append", (PyCFunction)RangeAppend, METH_VARARGS, "Append data to the Vim range" },
|
||||||
|
{"__dir__", (PyCFunction)RangeDir, METH_NOARGS, ""},
|
||||||
{ NULL, NULL, 0, NULL}
|
{ NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3239,6 +3377,17 @@ BufferSlice(BufferObject *self, PyInt lo, PyInt hi)
|
|||||||
return RBSlice(self, lo, hi, 1, -1);
|
return RBSlice(self, lo, hi, 1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static char *BufferAttrs[] = {
|
||||||
|
"name", "number", "vars", "options", "valid",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
BufferDir(PyObject *self)
|
||||||
|
{
|
||||||
|
return ObjectDir(self, BufferAttrs);
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
BufferAttrValid(BufferObject *self, char *name)
|
BufferAttrValid(BufferObject *self, char *name)
|
||||||
{
|
{
|
||||||
@ -3266,8 +3415,7 @@ BufferAttr(BufferObject *self, char *name)
|
|||||||
return OptionsNew(SREQ_BUF, self->buf, (checkfun) CheckBuffer,
|
return OptionsNew(SREQ_BUF, self->buf, (checkfun) CheckBuffer,
|
||||||
(PyObject *) self);
|
(PyObject *) self);
|
||||||
else if (strcmp(name, "__members__") == 0)
|
else if (strcmp(name, "__members__") == 0)
|
||||||
return Py_BuildValue("[sssss]", "name", "number", "vars", "options",
|
return ObjectDir(NULL, BufferAttrs);
|
||||||
"valid");
|
|
||||||
else
|
else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -3403,9 +3551,7 @@ static struct PyMethodDef BufferMethods[] = {
|
|||||||
{"append", (PyCFunction)BufferAppend, METH_VARARGS, "Append data to Vim buffer" },
|
{"append", (PyCFunction)BufferAppend, METH_VARARGS, "Append data to Vim buffer" },
|
||||||
{"mark", (PyCFunction)BufferMark, METH_VARARGS, "Return (row,col) representing position of named mark" },
|
{"mark", (PyCFunction)BufferMark, METH_VARARGS, "Return (row,col) representing position of named mark" },
|
||||||
{"range", (PyCFunction)BufferRange, METH_VARARGS, "Return a range object which represents the part of the given buffer between line numbers s and e" },
|
{"range", (PyCFunction)BufferRange, METH_VARARGS, "Return a range object which represents the part of the given buffer between line numbers s and e" },
|
||||||
#if PY_VERSION_HEX >= 0x03000000
|
{"__dir__", (PyCFunction)BufferDir, METH_NOARGS, ""},
|
||||||
{"__dir__", (PyCFunction)BufferDir, METH_NOARGS, "List buffer attributes" },
|
|
||||||
#endif
|
|
||||||
{ NULL, NULL, 0, NULL}
|
{ NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -3538,6 +3684,17 @@ static PyMappingMethods BufMapAsMapping = {
|
|||||||
/* Current items object
|
/* Current items object
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static char *CurrentAttrs[] = {
|
||||||
|
"buffer", "window", "line", "range", "tabpage",
|
||||||
|
NULL
|
||||||
|
};
|
||||||
|
|
||||||
|
static PyObject *
|
||||||
|
CurrentDir(PyObject *self)
|
||||||
|
{
|
||||||
|
return ObjectDir(self, CurrentAttrs);
|
||||||
|
}
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
CurrentGetattr(PyObject *self UNUSED, char *name)
|
CurrentGetattr(PyObject *self UNUSED, char *name)
|
||||||
{
|
{
|
||||||
@ -3552,13 +3709,13 @@ CurrentGetattr(PyObject *self UNUSED, char *name)
|
|||||||
else if (strcmp(name, "range") == 0)
|
else if (strcmp(name, "range") == 0)
|
||||||
return RangeNew(curbuf, RangeStart, RangeEnd);
|
return RangeNew(curbuf, RangeStart, RangeEnd);
|
||||||
else if (strcmp(name, "__members__") == 0)
|
else if (strcmp(name, "__members__") == 0)
|
||||||
return Py_BuildValue("[sssss]", "buffer", "window", "line", "range",
|
return ObjectDir(NULL, CurrentAttrs);
|
||||||
"tabpage");
|
|
||||||
else
|
else
|
||||||
{
|
#if PY_MAJOR_VERSION < 3
|
||||||
PyErr_SetString(PyExc_AttributeError, name);
|
return Py_FindMethod(WindowMethods, self, name);
|
||||||
|
#else
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -3661,6 +3818,12 @@ CurrentSetattr(PyObject *self UNUSED, char *name, PyObject *value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct PyMethodDef CurrentMethods[] = {
|
||||||
|
/* name, function, calling, documentation */
|
||||||
|
{"__dir__", (PyCFunction)CurrentDir, METH_NOARGS, ""},
|
||||||
|
{ NULL, NULL, 0, NULL}
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
init_range_cmd(exarg_T *eap)
|
init_range_cmd(exarg_T *eap)
|
||||||
{
|
{
|
||||||
@ -4397,6 +4560,7 @@ init_structs(void)
|
|||||||
CurrentType.tp_basicsize = sizeof(CurrentObject);
|
CurrentType.tp_basicsize = sizeof(CurrentObject);
|
||||||
CurrentType.tp_flags = Py_TPFLAGS_DEFAULT;
|
CurrentType.tp_flags = Py_TPFLAGS_DEFAULT;
|
||||||
CurrentType.tp_doc = "vim current object";
|
CurrentType.tp_doc = "vim current object";
|
||||||
|
CurrentType.tp_methods = CurrentMethods;
|
||||||
#if PY_MAJOR_VERSION >= 3
|
#if PY_MAJOR_VERSION >= 3
|
||||||
CurrentType.tp_getattro = (getattrofunc)CurrentGetattro;
|
CurrentType.tp_getattro = (getattrofunc)CurrentGetattro;
|
||||||
CurrentType.tp_setattro = (setattrofunc)CurrentSetattro;
|
CurrentType.tp_setattro = (setattrofunc)CurrentSetattro;
|
||||||
|
@ -1066,6 +1066,8 @@ OutputGetattr(PyObject *self, char *name)
|
|||||||
{
|
{
|
||||||
if (strcmp(name, "softspace") == 0)
|
if (strcmp(name, "softspace") == 0)
|
||||||
return PyInt_FromLong(((OutputObject *)(self))->softspace);
|
return PyInt_FromLong(((OutputObject *)(self))->softspace);
|
||||||
|
else if (strcmp(name, "__members__") == 0)
|
||||||
|
return ObjectDir(NULL, OutputAttrs);
|
||||||
|
|
||||||
return Py_FindMethod(OutputMethods, self, name);
|
return Py_FindMethod(OutputMethods, self, name);
|
||||||
}
|
}
|
||||||
@ -1177,6 +1179,8 @@ RangeGetattr(PyObject *self, char *name)
|
|||||||
return Py_BuildValue(Py_ssize_t_fmt, ((RangeObject *)(self))->start - 1);
|
return Py_BuildValue(Py_ssize_t_fmt, ((RangeObject *)(self))->start - 1);
|
||||||
else if (strcmp(name, "end") == 0)
|
else if (strcmp(name, "end") == 0)
|
||||||
return Py_BuildValue(Py_ssize_t_fmt, ((RangeObject *)(self))->end - 1);
|
return Py_BuildValue(Py_ssize_t_fmt, ((RangeObject *)(self))->end - 1);
|
||||||
|
else if (strcmp(name, "__members__") == 0)
|
||||||
|
return ObjectDir(NULL, RangeAttrs);
|
||||||
else
|
else
|
||||||
return Py_FindMethod(RangeMethods, self, name);
|
return Py_FindMethod(RangeMethods, self, name);
|
||||||
}
|
}
|
||||||
@ -1396,6 +1400,8 @@ DictionaryGetattr(PyObject *self, char *name)
|
|||||||
return PyInt_FromLong(this->dict->dv_lock);
|
return PyInt_FromLong(this->dict->dv_lock);
|
||||||
else if (strcmp(name, "scope") == 0)
|
else if (strcmp(name, "scope") == 0)
|
||||||
return PyInt_FromLong(this->dict->dv_scope);
|
return PyInt_FromLong(this->dict->dv_scope);
|
||||||
|
else if (strcmp(name, "__members__") == 0)
|
||||||
|
return ObjectDir(NULL, DictionaryAttrs);
|
||||||
|
|
||||||
return Py_FindMethod(DictionaryMethods, self, name);
|
return Py_FindMethod(DictionaryMethods, self, name);
|
||||||
}
|
}
|
||||||
@ -1420,6 +1426,8 @@ ListGetattr(PyObject *self, char *name)
|
|||||||
{
|
{
|
||||||
if (strcmp(name, "locked") == 0)
|
if (strcmp(name, "locked") == 0)
|
||||||
return PyInt_FromLong(((ListObject *)(self))->list->lv_lock);
|
return PyInt_FromLong(((ListObject *)(self))->list->lv_lock);
|
||||||
|
else if (strcmp(name, "__members__") == 0)
|
||||||
|
return ObjectDir(NULL, ListAttrs);
|
||||||
|
|
||||||
return Py_FindMethod(ListMethods, self, name);
|
return Py_FindMethod(ListMethods, self, name);
|
||||||
}
|
}
|
||||||
@ -1431,6 +1439,8 @@ FunctionGetattr(PyObject *self, char *name)
|
|||||||
|
|
||||||
if (strcmp(name, "name") == 0)
|
if (strcmp(name, "name") == 0)
|
||||||
return PyString_FromString((char *)(this->name));
|
return PyString_FromString((char *)(this->name));
|
||||||
|
else if (strcmp(name, "__members__") == 0)
|
||||||
|
return ObjectDir(NULL, FunctionAttrs);
|
||||||
else
|
else
|
||||||
return Py_FindMethod(FunctionMethods, self, name);
|
return Py_FindMethod(FunctionMethods, self, name);
|
||||||
}
|
}
|
||||||
|
@ -666,7 +666,6 @@ call_PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems)
|
|||||||
return PyType_GenericAlloc(type,nitems);
|
return PyType_GenericAlloc(type,nitems);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *BufferDir(PyObject *);
|
|
||||||
static PyObject *OutputGetattro(PyObject *, PyObject *);
|
static PyObject *OutputGetattro(PyObject *, PyObject *);
|
||||||
static int OutputSetattro(PyObject *, PyObject *, PyObject *);
|
static int OutputSetattro(PyObject *, PyObject *, PyObject *);
|
||||||
static PyObject *BufferGetattro(PyObject *, PyObject *);
|
static PyObject *BufferGetattro(PyObject *, PyObject *);
|
||||||
@ -1094,14 +1093,6 @@ BufferSetattro(PyObject *self, PyObject *nameobj, PyObject *val)
|
|||||||
return BufferSetattr((BufferObject *)(self), name, val);
|
return BufferSetattr((BufferObject *)(self), name, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
static PyObject *
|
|
||||||
BufferDir(PyObject *self UNUSED)
|
|
||||||
{
|
|
||||||
return Py_BuildValue("[ssssssss]",
|
|
||||||
"name", "number", "vars", "options", "valid",
|
|
||||||
"append", "mark", "range");
|
|
||||||
}
|
|
||||||
|
|
||||||
/******************/
|
/******************/
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
@ -1368,8 +1359,11 @@ static PySequenceMethods WinListAsSeq = {
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
CurrentGetattro(PyObject *self, PyObject *nameobj)
|
CurrentGetattro(PyObject *self, PyObject *nameobj)
|
||||||
{
|
{
|
||||||
|
PyObject *r;
|
||||||
GET_ATTR_STRING(name, nameobj);
|
GET_ATTR_STRING(name, nameobj);
|
||||||
return CurrentGetattr(self, name);
|
if (!(r = CurrentGetattr(self, name)))
|
||||||
|
return PyObject_GenericGetAttr(self, nameobj);
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -691,6 +691,24 @@ for expr, attr in (
|
|||||||
cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr)))
|
cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr)))
|
||||||
EOF
|
EOF
|
||||||
:"
|
:"
|
||||||
|
:" Test __dir__() method
|
||||||
|
py << EOF
|
||||||
|
for name, o in (
|
||||||
|
('current', vim.current),
|
||||||
|
('buffer', vim.current.buffer),
|
||||||
|
('window', vim.current.window),
|
||||||
|
('tabpage', vim.current.tabpage),
|
||||||
|
('range', vim.current.range),
|
||||||
|
('dictionary', vim.bindeval('{}')),
|
||||||
|
('list', vim.bindeval('[]')),
|
||||||
|
('function', vim.bindeval('function("tr")')),
|
||||||
|
('output', sys.stdout),
|
||||||
|
):
|
||||||
|
cb.append(name + ':' + ','.join(dir(o)))
|
||||||
|
del name
|
||||||
|
del o
|
||||||
|
EOF
|
||||||
|
:"
|
||||||
:" Test exceptions
|
:" Test exceptions
|
||||||
:fun Exe(e)
|
:fun Exe(e)
|
||||||
: execute a:e
|
: execute a:e
|
||||||
|
@ -382,6 +382,15 @@ vim.current.buffer:Buffer:True
|
|||||||
vim.current.range:Range:True
|
vim.current.range:Range:True
|
||||||
vim.current.window:Window:True
|
vim.current.window:Window:True
|
||||||
vim.current.tabpage:TabPage:True
|
vim.current.tabpage:TabPage:True
|
||||||
|
current:__dir__,__members__,buffer,line,range,tabpage,window
|
||||||
|
buffer:__dir__,__members__,append,mark,name,number,options,range,valid,vars
|
||||||
|
window:__dir__,__members__,buffer,col,cursor,height,number,options,row,tabpage,valid,vars
|
||||||
|
tabpage:__dir__,__members__,number,valid,vars,window,windows
|
||||||
|
range:__dir__,__members__,append,end,start
|
||||||
|
dictionary:__dir__,__members__,keys,locked,scope
|
||||||
|
list:__dir__,__members__,extend,locked
|
||||||
|
function:__call__,__dir__,__members__,softspace
|
||||||
|
output:__dir__,__members__,flush,softspace,write,writelines
|
||||||
(<class 'vim.error'>, error('abc',))
|
(<class 'vim.error'>, error('abc',))
|
||||||
(<class 'vim.error'>, error('def',))
|
(<class 'vim.error'>, error('def',))
|
||||||
(<class 'vim.error'>, error('ghi',))
|
(<class 'vim.error'>, error('ghi',))
|
||||||
|
@ -669,6 +669,24 @@ for expr, attr in (
|
|||||||
cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr)))
|
cb.append(expr + ':' + attr + ':' + repr(type(eval(expr)) is getattr(vim, attr)))
|
||||||
EOF
|
EOF
|
||||||
:"
|
:"
|
||||||
|
:" Test __dir__() method
|
||||||
|
py3 << EOF
|
||||||
|
for name, o in (
|
||||||
|
('current', vim.current),
|
||||||
|
('buffer', vim.current.buffer),
|
||||||
|
('window', vim.current.window),
|
||||||
|
('tabpage', vim.current.tabpage),
|
||||||
|
('range', vim.current.range),
|
||||||
|
('dictionary', vim.bindeval('{}')),
|
||||||
|
('list', vim.bindeval('[]')),
|
||||||
|
('function', vim.bindeval('function("tr")')),
|
||||||
|
('output', sys.stdout),
|
||||||
|
):
|
||||||
|
cb.append(name + ':' + ','.join(dir(o)))
|
||||||
|
del name
|
||||||
|
del o
|
||||||
|
EOF
|
||||||
|
:"
|
||||||
:" Test exceptions
|
:" Test exceptions
|
||||||
:fun Exe(e)
|
:fun Exe(e)
|
||||||
: execute a:e
|
: execute a:e
|
||||||
|
@ -371,6 +371,15 @@ vim.current.buffer:Buffer:True
|
|||||||
vim.current.range:Range:True
|
vim.current.range:Range:True
|
||||||
vim.current.window:Window:True
|
vim.current.window:Window:True
|
||||||
vim.current.tabpage:TabPage:True
|
vim.current.tabpage:TabPage:True
|
||||||
|
current:__dir__,buffer,line,range,tabpage,window
|
||||||
|
buffer:__dir__,append,mark,name,number,options,range,valid,vars
|
||||||
|
window:__dir__,buffer,col,cursor,height,number,options,row,tabpage,valid,vars
|
||||||
|
tabpage:__dir__,number,valid,vars,window,windows
|
||||||
|
range:__dir__,append,end,start
|
||||||
|
dictionary:__dir__,keys,locked,scope
|
||||||
|
list:__dir__,extend,locked
|
||||||
|
function:__call__,__dir__,softspace
|
||||||
|
output:__dir__,flush,softspace,write,writelines
|
||||||
(<class 'vim.error'>, error('abc',))
|
(<class 'vim.error'>, error('abc',))
|
||||||
(<class 'vim.error'>, error('def',))
|
(<class 'vim.error'>, error('def',))
|
||||||
(<class 'vim.error'>, error('ghi',))
|
(<class 'vim.error'>, error('ghi',))
|
||||||
|
@ -728,6 +728,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1047,
|
||||||
/**/
|
/**/
|
||||||
1046,
|
1046,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user