From 6451cff2c3339dfc579c0e5833174e6109490c7b Mon Sep 17 00:00:00 2001 From: Jack Jansen Date: Fri, 26 Jul 1996 16:03:16 +0000 Subject: Added access to selFlags and listFlags members (both read and write) --- Mac/Modules/list/Listmodule.c | 34 ++++++++++++++++++++++++++++++---- Mac/Modules/list/listsupport.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/Mac/Modules/list/Listmodule.c b/Mac/Modules/list/Listmodule.c index a276ea3..b0ce515 100644 --- a/Mac/Modules/list/Listmodule.c +++ b/Mac/Modules/list/Listmodule.c @@ -40,9 +40,6 @@ extern int GrafObj_Convert(PyObject *, GrafPtr *); extern PyObject *BMObj_New(BitMapPtr); extern int BMObj_Convert(PyObject *, BitMapPtr *); -extern PyObject *PMObj_New(PixMapHandle); -extern int PMObj_Convert(PyObject *, PixMapHandle *); - extern PyObject *WinObj_WhichWindow(WindowPtr); #include @@ -563,10 +560,39 @@ static PyObject *ListObj_getattr(self, name) ListObject *self; char *name; { + { + /* XXXX Should we HLock() here?? */ + if ( strcmp(name, "listFlags") == 0 ) + return Py_BuildValue("l", (long)(*self->ob_itself)->listFlags & 0xff); + if ( strcmp(name, "selFlags") == 0 ) + return Py_BuildValue("l", (long)(*self->ob_itself)->selFlags & 0xff); + } return Py_FindMethodInChain(&ListObj_chain, (PyObject *)self, name); } -#define ListObj_setattr NULL +static int +ListObj_setattr(self, name, value) + ListObject *self; + char *name; + PyObject *value; +{ + long intval; + + if ( value == NULL || !PyInt_Check(value) ) + return -1; + intval = PyInt_AsLong(value); + if (strcmp(name, "listFlags") == 0 ) { + /* XXXX Should we HLock the handle here?? */ + (*self->ob_itself)->listFlags = intval; + return 0; + } + if (strcmp(name, "selFlags") == 0 ) { + (*self->ob_itself)->selFlags = intval; + return 0; + } + return -1; +} + PyTypeObject List_Type = { PyObject_HEAD_INIT(&PyType_Type) diff --git a/Mac/Modules/list/listsupport.py b/Mac/Modules/list/listsupport.py index 5d0c950..026953c 100644 --- a/Mac/Modules/list/listsupport.py +++ b/Mac/Modules/list/listsupport.py @@ -45,6 +45,38 @@ class ListMethodGenerator(MethodGenerator): FunctionGenerator.parseArgumentList(self, args) self.argumentList.append(self.itself) +getattrHookCode = """{ + /* XXXX Should we HLock() here?? */ + if ( strcmp(name, "listFlags") == 0 ) + return Py_BuildValue("l", (long)(*self->ob_itself)->listFlags & 0xff); + if ( strcmp(name, "selFlags") == 0 ) + return Py_BuildValue("l", (long)(*self->ob_itself)->selFlags & 0xff); +}""" + +setattrCode = """ +static int +ListObj_setattr(self, name, value) + ListObject *self; + char *name; + PyObject *value; +{ + long intval; + + if ( value == NULL || !PyInt_Check(value) ) + return -1; + intval = PyInt_AsLong(value); + if (strcmp(name, "listFlags") == 0 ) { + /* XXXX Should we HLock the handle here?? */ + (*self->ob_itself)->listFlags = intval; + return 0; + } + if (strcmp(name, "selFlags") == 0 ) { + (*self->ob_itself)->selFlags = intval; + return 0; + } + return -1; +} +""" class MyObjectDefinition(GlobalObjectDefinition): @@ -55,6 +87,12 @@ class MyObjectDefinition(GlobalObjectDefinition): }""") def outputFreeIt(self, itselfname): Output("LDispose(%s);", itselfname) + + def outputGetattrHook(self): + Output(getattrHookCode) + + def outputSetattr(self): + Output(setattrCode) # From here on it's basically all boiler plate... -- cgit v0.12