]> granicus.if.org Git - python/commitdiff
Added access to selFlags and listFlags members (both read and write)
authorJack Jansen <jack.jansen@cwi.nl>
Fri, 26 Jul 1996 16:03:16 +0000 (16:03 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Fri, 26 Jul 1996 16:03:16 +0000 (16:03 +0000)
Mac/Modules/list/Listmodule.c
Mac/Modules/list/listsupport.py

index a276ea3247c255c32475ce63f8efb81d67fb0c21..b0ce515b0b8b36f6f23c4140f2ac81ff1aad4a18 100644 (file)
@@ -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 <Lists.h>
@@ -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)
index 5d0c950176ef95d4850c97442e2eb9786babe9c5..026953c09b02e4829bd3178140e477a135a40333 100644 (file)
@@ -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...