summaryrefslogtreecommitdiffstats
path: root/Objects/sliceobject.c
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-08-02 04:15:00 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-08-02 04:15:00 (GMT)
commit6d6c1a35e08b95a83dbe47dbd9e6474daff00354 (patch)
tree542089077b9c2650dcf5c52d6bfcef1baf12d176 /Objects/sliceobject.c
parent52d55a392600011d3edfe85c694744ec550ad1fe (diff)
downloadcpython-6d6c1a35e08b95a83dbe47dbd9e6474daff00354.zip
cpython-6d6c1a35e08b95a83dbe47dbd9e6474daff00354.tar.gz
cpython-6d6c1a35e08b95a83dbe47dbd9e6474daff00354.tar.bz2
Merge of descr-branch back into trunk.
Diffstat (limited to 'Objects/sliceobject.c')
-rw-r--r--Objects/sliceobject.c70
1 files changed, 35 insertions, 35 deletions
diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c
index 6f7a6d8..8f52f9e 100644
--- a/Objects/sliceobject.c
+++ b/Objects/sliceobject.c
@@ -14,6 +14,7 @@ this type and there is exactly one in existence.
*/
#include "Python.h"
+#include "structmember.h"
static PyObject *
ellipsis_repr(PyObject *op)
@@ -128,32 +129,12 @@ slice_repr(PySliceObject *r)
return s;
}
-
-static PyObject *slice_getattr(PySliceObject *self, char *name)
-{
- PyObject *ret;
-
- ret = NULL;
- if (strcmp(name, "start") == 0) {
- ret = self->start;
- }
- else if (strcmp(name, "stop") == 0) {
- ret = self->stop;
- }
- else if (strcmp(name, "step") == 0) {
- ret = self->step;
- }
- else if (strcmp(name, "__members__") == 0) {
- return Py_BuildValue("[sss]",
- "start", "stop", "step");
- }
- else {
- PyErr_SetString(PyExc_AttributeError, name);
- return NULL;
- }
- Py_INCREF(ret);
- return ret;
-}
+static struct memberlist slice_members[] = {
+ {"start", T_OBJECT, offsetof(PySliceObject, start), READONLY},
+ {"stop", T_OBJECT, offsetof(PySliceObject, stop), READONLY},
+ {"step", T_OBJECT, offsetof(PySliceObject, step), READONLY},
+ {0}
+};
static int
slice_compare(PySliceObject *v, PySliceObject *w)
@@ -182,13 +163,32 @@ PyTypeObject PySlice_Type = {
"slice", /* Name of this type */
sizeof(PySliceObject), /* Basic object size */
0, /* Item size for varobject */
- (destructor)slice_dealloc, /*tp_dealloc*/
- 0, /*tp_print*/
- (getattrfunc)slice_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
- (cmpfunc)slice_compare, /*tp_compare*/
- (reprfunc)slice_repr, /*tp_repr*/
- 0, /*tp_as_number*/
- 0, /*tp_as_sequence*/
- 0, /*tp_as_mapping*/
+ (destructor)slice_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ (cmpfunc)slice_compare, /* tp_compare */
+ (reprfunc)slice_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ PyObject_GenericGetAttr, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ 0, /* tp_methods */
+ slice_members, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
};