summaryrefslogtreecommitdiffstats
path: root/Mac/Modules/list/listsupport.py
diff options
context:
space:
mode:
authorJust van Rossum <just@letterror.com>2001-11-05 11:12:12 (GMT)
committerJust van Rossum <just@letterror.com>2001-11-05 11:12:12 (GMT)
commit3b5074b0fba839326b914b0bfbcbc6d5e33e8f7c (patch)
tree623a529810f615877d34f5a0c24133cb26dedff8 /Mac/Modules/list/listsupport.py
parentb26fbc644751f615158c1aea33086b1fb58ec20f (diff)
downloadcpython-3b5074b0fba839326b914b0bfbcbc6d5e33e8f7c.zip
cpython-3b5074b0fba839326b914b0bfbcbc6d5e33e8f7c.tar.gz
cpython-3b5074b0fba839326b914b0bfbcbc6d5e33e8f7c.tar.bz2
added acces to the cellSize field, rewrote setattr code
Diffstat (limited to 'Mac/Modules/list/listsupport.py')
-rw-r--r--Mac/Modules/list/listsupport.py28
1 files changed, 16 insertions, 12 deletions
diff --git a/Mac/Modules/list/listsupport.py b/Mac/Modules/list/listsupport.py
index 78ab494..1d0223f 100644
--- a/Mac/Modules/list/listsupport.py
+++ b/Mac/Modules/list/listsupport.py
@@ -137,11 +137,12 @@ class ListMethodGenerator(MethodGenerator):
self.argumentList.append(self.itself)
getattrHookCode = """{
- /* XXXX Should we HLock() here?? */
if ( strcmp(name, "listFlags") == 0 )
return Py_BuildValue("l", (long)GetListFlags(self->ob_itself) & 0xff);
if ( strcmp(name, "selFlags") == 0 )
return Py_BuildValue("l", (long)GetListSelectionFlags(self->ob_itself) & 0xff);
+ if ( strcmp(name, "cellSize") == 0 )
+ return Py_BuildValue("O&", PyMac_BuildPoint, (*self->ob_itself)->cellSize);
}"""
setattrCode = """
@@ -149,19 +150,22 @@ static int
ListObj_setattr(ListObject *self, char *name, PyObject *value)
{
long intval;
-
- if ( value == NULL || !PyInt_Check(value) )
+ int err = 0;
+
+ if ( value == NULL ) {
+ PyErr_SetString(PyExc_AttributeError, "Cannot delete attribute");
return -1;
- intval = PyInt_AsLong(value);
- if (strcmp(name, "listFlags") == 0 ) {
- SetListFlags(self->ob_itself, intval);
- return 0;
- }
- if (strcmp(name, "selFlags") == 0 ) {
- SetListSelectionFlags(self->ob_itself, intval);
- return 0;
}
- return -1;
+ if (strcmp(name, "listFlags") == 0 )
+ err = PyArg_Parse(value, "B", &(*self->ob_itself)->listFlags);
+ else if (strcmp(name, "selFlags") == 0 )
+ err = PyArg_Parse(value, "B", &(*self->ob_itself)->selFlags);
+ else if (strcmp(name, "cellSize") == 0 )
+ err = PyArg_Parse(value, "O&", PyMac_GetPoint, &(*self->ob_itself)->cellSize);
+ else
+ PyErr_SetString(PyExc_AttributeError, "No such attribute");
+ if (err) return 0;
+ else return -1;
}
"""