Remove "static forward" declaration. Move constructors
after the type objects.
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index e8374c1..c48bee0 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -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;
+}
diff --git a/Objects/setobject.c b/Objects/setobject.c
index 1a28724..edc43df 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -3,7 +3,7 @@
Written and maintained by Raymond D. Hettinger <python@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)
{
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index c0c2056..10b7aaf 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -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;
+}