summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-08-15 18:18:58 (GMT)
committerGuido van Rossum <guido@python.org>2001-08-15 18:18:58 (GMT)
commit88dcf03068929a8f7de023dfd9cb131cc5fbad78 (patch)
tree00b9c753f66a68ced666af95911897762e5a0980 /Modules
parente6b90eaea1d04953238b3b1603e9bccc2ba4500b (diff)
downloadcpython-88dcf03068929a8f7de023dfd9cb131cc5fbad78.zip
cpython-88dcf03068929a8f7de023dfd9cb131cc5fbad78.tar.gz
cpython-88dcf03068929a8f7de023dfd9cb131cc5fbad78.tar.bz2
Add 'state' as a get/set attribute to spamlist. This serves as an
example.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/xxsubtype.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/Modules/xxsubtype.c b/Modules/xxsubtype.c
index 1b9648c..5dadc74 100644
--- a/Modules/xxsubtype.c
+++ b/Modules/xxsubtype.c
@@ -49,6 +49,17 @@ spamlist_init(spamlistobject *self, PyObject *args, PyObject *kwds)
return 0;
}
+static PyObject *
+spamlist_state_get(spamlistobject *self)
+{
+ return PyInt_FromLong(self->state);
+}
+
+static struct getsetlist spamlist_getsets[] = {
+ {"state", (getter)spamlist_state_get, NULL, NULL},
+ {0}
+};
+
static PyTypeObject spamlist_type = {
PyObject_HEAD_INIT(&PyType_Type)
0,
@@ -80,7 +91,7 @@ static PyTypeObject spamlist_type = {
0, /* tp_iternext */
spamlist_methods, /* tp_methods */
0, /* tp_members */
- 0, /* tp_getset */
+ spamlist_getsets, /* tp_getset */
&PyList_Type, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */