[Python-checkins] r45275 - python/trunk/Objects/rangeobject.c python/trunk/Objects/setobject.c python/trunk/Objects/tupleobject.c
martin.v.loewis
python-checkins at python.org
Tue Apr 11 11:04:13 CEST 2006
Author: martin.v.loewis
Date: Tue Apr 11 11:04:12 2006
New Revision: 45275
Modified:
python/trunk/Objects/rangeobject.c
python/trunk/Objects/setobject.c
python/trunk/Objects/tupleobject.c
Log:
Remove "static forward" declaration. Move constructors
after the type objects.
Modified: python/trunk/Objects/rangeobject.c
==============================================================================
--- python/trunk/Objects/rangeobject.c (original)
+++ python/trunk/Objects/rangeobject.c Tue Apr 11 11:04:12 2006
@@ -200,53 +200,6 @@
long len;
} rangeiterobject;
-static PyTypeObject Pyrangeiter_Type;
-
-static PyObject *
-range_iter(PyObject *seq)
-{
- rangeiterobject *it;
-
- if (!PyRange_Check(seq)) {
- PyErr_BadInternalCall();
- return NULL;
- }
- it = PyObject_New(rangeiterobject, &Pyrangeiter_Type);
- if (it == NULL)
- return NULL;
- it->index = 0;
- it->start = ((rangeobject *)seq)->start;
- it->step = ((rangeobject *)seq)->step;
- it->len = ((rangeobject *)seq)->len;
- return (PyObject *)it;
-}
-
-static PyObject *
-range_reverse(PyObject *seq)
-{
- rangeiterobject *it;
- long start, step, len;
-
- if (!PyRange_Check(seq)) {
- PyErr_BadInternalCall();
- return NULL;
- }
- it = PyObject_New(rangeiterobject, &Pyrangeiter_Type);
- if (it == NULL)
- return NULL;
-
- start = ((rangeobject *)seq)->start;
- step = ((rangeobject *)seq)->step;
- len = ((rangeobject *)seq)->len;
-
- it->index = 0;
- it->start = start + (len-1) * step;
- it->step = -step;
- it->len = len;
-
- return (PyObject *)it;
-}
-
static PyObject *
rangeiter_next(rangeiterobject *r)
{
@@ -301,3 +254,48 @@
rangeiter_methods, /* tp_methods */
0,
};
+
+static PyObject *
+range_iter(PyObject *seq)
+{
+ rangeiterobject *it;
+
+ if (!PyRange_Check(seq)) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
+ it = PyObject_New(rangeiterobject, &Pyrangeiter_Type);
+ if (it == NULL)
+ return NULL;
+ it->index = 0;
+ it->start = ((rangeobject *)seq)->start;
+ it->step = ((rangeobject *)seq)->step;
+ it->len = ((rangeobject *)seq)->len;
+ return (PyObject *)it;
+}
+
+static PyObject *
+range_reverse(PyObject *seq)
+{
+ rangeiterobject *it;
+ long start, step, len;
+
+ if (!PyRange_Check(seq)) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
+ it = PyObject_New(rangeiterobject, &Pyrangeiter_Type);
+ if (it == NULL)
+ return NULL;
+
+ start = ((rangeobject *)seq)->start;
+ step = ((rangeobject *)seq)->step;
+ len = ((rangeobject *)seq)->len;
+
+ it->index = 0;
+ it->start = start + (len-1) * step;
+ it->step = -step;
+ it->len = len;
+
+ return (PyObject *)it;
+}
Modified: python/trunk/Objects/setobject.c
==============================================================================
--- python/trunk/Objects/setobject.c (original)
+++ python/trunk/Objects/setobject.c Tue Apr 11 11:04:12 2006
@@ -3,7 +3,7 @@
Written and maintained by Raymond D. Hettinger <python at rcn.com>
Derived from Lib/sets.py and Objects/dictobject.c.
- Copyright (c) 2003-5 Python Software Foundation.
+ Copyright (c) 2003-6 Python Software Foundation.
All rights reserved.
*/
@@ -719,8 +719,6 @@
/***** Set iterator type ***********************************************/
-static PyTypeObject PySetIter_Type; /* Forward */
-
typedef struct {
PyObject_HEAD
PySetObject *si_set; /* Set to NULL when iterator is exhausted */
@@ -729,20 +727,6 @@
long len;
} setiterobject;
-static PyObject *
-set_iter(PySetObject *so)
-{
- setiterobject *si = PyObject_New(setiterobject, &PySetIter_Type);
- if (si == NULL)
- return NULL;
- Py_INCREF(so);
- si->si_set = so;
- si->si_used = so->used;
- si->si_pos = 0;
- si->len = so->used;
- return (PyObject *)si;
-}
-
static void
setiter_dealloc(setiterobject *si)
{
@@ -838,6 +822,20 @@
0,
};
+static PyObject *
+set_iter(PySetObject *so)
+{
+ setiterobject *si = PyObject_New(setiterobject, &PySetIter_Type);
+ if (si == NULL)
+ return NULL;
+ Py_INCREF(so);
+ si->si_set = so;
+ si->si_used = so->used;
+ si->si_pos = 0;
+ si->len = so->used;
+ return (PyObject *)si;
+}
+
static int
set_update_internal(PySetObject *so, PyObject *other)
{
Modified: python/trunk/Objects/tupleobject.c
==============================================================================
--- python/trunk/Objects/tupleobject.c (original)
+++ python/trunk/Objects/tupleobject.c Tue Apr 11 11:04:12 2006
@@ -791,27 +791,6 @@
PyTupleObject *it_seq; /* Set to NULL when iterator is exhausted */
} tupleiterobject;
-PyTypeObject PyTupleIter_Type;
-
-static PyObject *
-tuple_iter(PyObject *seq)
-{
- tupleiterobject *it;
-
- if (!PyTuple_Check(seq)) {
- PyErr_BadInternalCall();
- return NULL;
- }
- it = PyObject_GC_New(tupleiterobject, &PyTupleIter_Type);
- if (it == NULL)
- return NULL;
- it->it_index = 0;
- Py_INCREF(seq);
- it->it_seq = (PyTupleObject *)seq;
- _PyObject_GC_TRACK(it);
- return (PyObject *)it;
-}
-
static void
tupleiter_dealloc(tupleiterobject *it)
{
@@ -901,3 +880,22 @@
tupleiter_methods, /* tp_methods */
0,
};
+
+static PyObject *
+tuple_iter(PyObject *seq)
+{
+ tupleiterobject *it;
+
+ if (!PyTuple_Check(seq)) {
+ PyErr_BadInternalCall();
+ return NULL;
+ }
+ it = PyObject_GC_New(tupleiterobject, &PyTupleIter_Type);
+ if (it == NULL)
+ return NULL;
+ it->it_index = 0;
+ Py_INCREF(seq);
+ it->it_seq = (PyTupleObject *)seq;
+ _PyObject_GC_TRACK(it);
+ return (PyObject *)it;
+}
More information about the Python-checkins
mailing list