Mercurial > vim
comparison src/if_py_both.h @ 3828:fd6ef931aa77 v7.3.672
updated for version 7.3.672
Problem: Not possible to lock/unlock lists in Python interface.
Solution: Add .locked and .scope attributes. (ZyX)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Fri, 21 Sep 2012 14:00:35 +0200 |
parents | 530f5a903031 |
children | 0f5ee2629635 |
comparison
equal
deleted
inserted
replaced
3827:72c860159c0f | 3828:fd6ef931aa77 |
---|---|
806 Py_DECREF(list); | 806 Py_DECREF(list); |
807 return 0; | 807 return 0; |
808 } | 808 } |
809 | 809 |
810 static PyInt | 810 static PyInt |
811 DictionarySetattr(DictionaryObject *self, char *name, PyObject *val) | |
812 { | |
813 if (val == NULL) | |
814 { | |
815 PyErr_SetString(PyExc_AttributeError, _("Cannot delete DictionaryObject attributes")); | |
816 return -1; | |
817 } | |
818 | |
819 if (strcmp(name, "locked") == 0) | |
820 { | |
821 if (self->dict->dv_lock == VAR_FIXED) | |
822 { | |
823 PyErr_SetString(PyExc_TypeError, _("Cannot modify fixed dictionary")); | |
824 return -1; | |
825 } | |
826 else | |
827 { | |
828 if (!PyBool_Check(val)) | |
829 { | |
830 PyErr_SetString(PyExc_TypeError, _("Only boolean objects are allowed")); | |
831 return -1; | |
832 } | |
833 | |
834 if (val == Py_True) | |
835 self->dict->dv_lock = VAR_LOCKED; | |
836 else | |
837 self->dict->dv_lock = 0; | |
838 } | |
839 return 0; | |
840 } | |
841 else | |
842 { | |
843 PyErr_SetString(PyExc_AttributeError, _("Cannot set this attribute")); | |
844 return -1; | |
845 } | |
846 } | |
847 | |
848 static PyInt | |
811 DictionaryLength(PyObject *self) | 849 DictionaryLength(PyObject *self) |
812 { | 850 { |
813 return ((PyInt) ((((DictionaryObject *)(self))->dict->dv_hashtab.ht_used))); | 851 return ((PyInt) ((((DictionaryObject *)(self))->dict->dv_hashtab.ht_used))); |
814 } | 852 } |
815 | 853 |
1267 } | 1305 } |
1268 Py_DECREF(lookup_dict); | 1306 Py_DECREF(lookup_dict); |
1269 | 1307 |
1270 Py_INCREF(self); | 1308 Py_INCREF(self); |
1271 return self; | 1309 return self; |
1310 } | |
1311 | |
1312 static int | |
1313 ListSetattr(ListObject *self, char *name, PyObject *val) | |
1314 { | |
1315 if (val == NULL) | |
1316 { | |
1317 PyErr_SetString(PyExc_AttributeError, _("Cannot delete DictionaryObject attributes")); | |
1318 return -1; | |
1319 } | |
1320 | |
1321 if (strcmp(name, "locked") == 0) | |
1322 { | |
1323 if (self->list->lv_lock == VAR_FIXED) | |
1324 { | |
1325 PyErr_SetString(PyExc_TypeError, _("Cannot modify fixed list")); | |
1326 return -1; | |
1327 } | |
1328 else | |
1329 { | |
1330 if (!PyBool_Check(val)) | |
1331 { | |
1332 PyErr_SetString(PyExc_TypeError, _("Only boolean objects are allowed")); | |
1333 return -1; | |
1334 } | |
1335 | |
1336 if (val == Py_True) | |
1337 self->list->lv_lock = VAR_LOCKED; | |
1338 else | |
1339 self->list->lv_lock = 0; | |
1340 } | |
1341 return 0; | |
1342 } | |
1343 else | |
1344 { | |
1345 PyErr_SetString(PyExc_AttributeError, _("Cannot set this attribute")); | |
1346 return -1; | |
1347 } | |
1272 } | 1348 } |
1273 | 1349 |
1274 static struct PyMethodDef ListMethods[] = { | 1350 static struct PyMethodDef ListMethods[] = { |
1275 {"extend", (PyCFunction)ListConcatInPlace, METH_O, ""}, | 1351 {"extend", (PyCFunction)ListConcatInPlace, METH_O, ""}, |
1276 { NULL, NULL, 0, NULL } | 1352 { NULL, NULL, 0, NULL } |