Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3b5074b0
Commit
3b5074b0
authored
Nov 05, 2001
by
Just van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added acces to the cellSize field, rewrote setattr code
parent
b26fbc64
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
24 deletions
+32
-24
Mac/Modules/list/_Listmodule.c
Mac/Modules/list/_Listmodule.c
+16
-12
Mac/Modules/list/listsupport.py
Mac/Modules/list/listsupport.py
+16
-12
No files found.
Mac/Modules/list/_Listmodule.c
View file @
3b5074b0
...
...
@@ -607,11 +607,12 @@ PyMethodChain ListObj_chain = { ListObj_methods, NULL };
static
PyObject
*
ListObj_getattr
(
ListObject
*
self
,
char
*
name
)
{
{
/* 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
);
}
return
Py_FindMethodInChain
(
&
ListObj_chain
,
(
PyObject
*
)
self
,
name
);
}
...
...
@@ -620,19 +621,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
;
}
...
...
Mac/Modules/list/listsupport.py
View file @
3b5074b0
...
...
@@ -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;
}
"""
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment