Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6451cff

Browse files
committed
Added access to selFlags and listFlags members (both read and write)
1 parent ded835c commit 6451cff

2 files changed

Lines changed: 68 additions & 4 deletions

File tree

Mac/Modules/list/Listmodule.c

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ extern int GrafObj_Convert(PyObject *, GrafPtr *);
4040
extern PyObject *BMObj_New(BitMapPtr);
4141
extern int BMObj_Convert(PyObject *, BitMapPtr *);
4242

43-
extern PyObject *PMObj_New(PixMapHandle);
44-
extern int PMObj_Convert(PyObject *, PixMapHandle *);
45-
4643
extern PyObject *WinObj_WhichWindow(WindowPtr);
4744

4845
#include <Lists.h>
@@ -563,10 +560,39 @@ static PyObject *ListObj_getattr(self, name)
563560
ListObject *self;
564561
char *name;
565562
{
563+
{
564+
/* XXXX Should we HLock() here?? */
565+
if ( strcmp(name, "listFlags") == 0 )
566+
return Py_BuildValue("l", (long)(*self->ob_itself)->listFlags & 0xff);
567+
if ( strcmp(name, "selFlags") == 0 )
568+
return Py_BuildValue("l", (long)(*self->ob_itself)->selFlags & 0xff);
569+
}
566570
return Py_FindMethodInChain(&ListObj_chain, (PyObject *)self, name);
567571
}
568572

569-
#define ListObj_setattr NULL
573+
static int
574+
ListObj_setattr(self, name, value)
575+
ListObject *self;
576+
char *name;
577+
PyObject *value;
578+
{
579+
long intval;
580+
581+
if ( value == NULL || !PyInt_Check(value) )
582+
return -1;
583+
intval = PyInt_AsLong(value);
584+
if (strcmp(name, "listFlags") == 0 ) {
585+
/* XXXX Should we HLock the handle here?? */
586+
(*self->ob_itself)->listFlags = intval;
587+
return 0;
588+
}
589+
if (strcmp(name, "selFlags") == 0 ) {
590+
(*self->ob_itself)->selFlags = intval;
591+
return 0;
592+
}
593+
return -1;
594+
}
595+
570596

571597
PyTypeObject List_Type = {
572598
PyObject_HEAD_INIT(&PyType_Type)

Mac/Modules/list/listsupport.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,38 @@ def parseArgumentList(self, args):
4545
FunctionGenerator.parseArgumentList(self, args)
4646
self.argumentList.append(self.itself)
4747

48+
getattrHookCode = """{
49+
/* XXXX Should we HLock() here?? */
50+
if ( strcmp(name, "listFlags") == 0 )
51+
return Py_BuildValue("l", (long)(*self->ob_itself)->listFlags & 0xff);
52+
if ( strcmp(name, "selFlags") == 0 )
53+
return Py_BuildValue("l", (long)(*self->ob_itself)->selFlags & 0xff);
54+
}"""
55+
56+
setattrCode = """
57+
static int
58+
ListObj_setattr(self, name, value)
59+
ListObject *self;
60+
char *name;
61+
PyObject *value;
62+
{
63+
long intval;
64+
65+
if ( value == NULL || !PyInt_Check(value) )
66+
return -1;
67+
intval = PyInt_AsLong(value);
68+
if (strcmp(name, "listFlags") == 0 ) {
69+
/* XXXX Should we HLock the handle here?? */
70+
(*self->ob_itself)->listFlags = intval;
71+
return 0;
72+
}
73+
if (strcmp(name, "selFlags") == 0 ) {
74+
(*self->ob_itself)->selFlags = intval;
75+
return 0;
76+
}
77+
return -1;
78+
}
79+
"""
4880

4981

5082
class MyObjectDefinition(GlobalObjectDefinition):
@@ -55,6 +87,12 @@ def outputCheckNewArg(self):
5587
}""")
5688
def outputFreeIt(self, itselfname):
5789
Output("LDispose(%s);", itselfname)
90+
91+
def outputGetattrHook(self):
92+
Output(getattrHookCode)
93+
94+
def outputSetattr(self):
95+
Output(setattrCode)
5896

5997
# From here on it's basically all boiler plate...
6098

0 commit comments

Comments
 (0)