mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
updated for version 7.3.672
Problem: Not possible to lock/unlock lists in Python interface. Solution: Add .locked and .scope attributes. (ZyX)
This commit is contained in:
@@ -807,6 +807,44 @@ pymap_to_tv(PyObject *obj, typval_T *tv, PyObject *lookupDict)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static PyInt
|
||||
DictionarySetattr(DictionaryObject *self, char *name, PyObject *val)
|
||||
{
|
||||
if (val == NULL)
|
||||
{
|
||||
PyErr_SetString(PyExc_AttributeError, _("Cannot delete DictionaryObject attributes"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strcmp(name, "locked") == 0)
|
||||
{
|
||||
if (self->dict->dv_lock == VAR_FIXED)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, _("Cannot modify fixed dictionary"));
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!PyBool_Check(val))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, _("Only boolean objects are allowed"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (val == Py_True)
|
||||
self->dict->dv_lock = VAR_LOCKED;
|
||||
else
|
||||
self->dict->dv_lock = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_AttributeError, _("Cannot set this attribute"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static PyInt
|
||||
DictionaryLength(PyObject *self)
|
||||
{
|
||||
@@ -1271,6 +1309,44 @@ ListConcatInPlace(PyObject *self, PyObject *obj)
|
||||
return self;
|
||||
}
|
||||
|
||||
static int
|
||||
ListSetattr(ListObject *self, char *name, PyObject *val)
|
||||
{
|
||||
if (val == NULL)
|
||||
{
|
||||
PyErr_SetString(PyExc_AttributeError, _("Cannot delete DictionaryObject attributes"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (strcmp(name, "locked") == 0)
|
||||
{
|
||||
if (self->list->lv_lock == VAR_FIXED)
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, _("Cannot modify fixed list"));
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!PyBool_Check(val))
|
||||
{
|
||||
PyErr_SetString(PyExc_TypeError, _("Only boolean objects are allowed"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (val == Py_True)
|
||||
self->list->lv_lock = VAR_LOCKED;
|
||||
else
|
||||
self->list->lv_lock = 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
PyErr_SetString(PyExc_AttributeError, _("Cannot set this attribute"));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static struct PyMethodDef ListMethods[] = {
|
||||
{"extend", (PyCFunction)ListConcatInPlace, METH_O, ""},
|
||||
{ NULL, NULL, 0, NULL }
|
||||
|
Reference in New Issue
Block a user