diff options
author | Christian Heimes <christian@cheimes.de> | 2007-12-19 02:45:37 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-12-19 02:45:37 (GMT) |
commit | 90aa7646affbaee9628ca6ea6a702aec17b3b550 (patch) | |
tree | e820962e9658a92c7147b686f8aa88c7658c5949 /Objects/tupleobject.c | |
parent | 99170a5dbf4cfee78b578672b6821e855f92594b (diff) | |
download | cpython-90aa7646affbaee9628ca6ea6a702aec17b3b550.zip cpython-90aa7646affbaee9628ca6ea6a702aec17b3b550.tar.gz cpython-90aa7646affbaee9628ca6ea6a702aec17b3b550.tar.bz2 |
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Diffstat (limited to 'Objects/tupleobject.c')
-rw-r--r-- | Objects/tupleobject.c | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index f1e8057..c9d91e5 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -49,8 +49,8 @@ PyTuple_New(register Py_ssize_t size) #endif /* Inline PyObject_InitVar */ #ifdef Py_TRACE_REFS - Py_Size(op) = size; - Py_Type(op) = &PyTuple_Type; + Py_SIZE(op) = size; + Py_TYPE(op) = &PyTuple_Type; #endif _Py_NewReference((PyObject *)op); } @@ -90,7 +90,7 @@ PyTuple_Size(register PyObject *op) return -1; } else - return Py_Size(op); + return Py_SIZE(op); } PyObject * @@ -100,7 +100,7 @@ PyTuple_GetItem(register PyObject *op, register Py_ssize_t i) PyErr_BadInternalCall(); return NULL; } - if (i < 0 || i >= Py_Size(op)) { + if (i < 0 || i >= Py_SIZE(op)) { PyErr_SetString(PyExc_IndexError, "tuple index out of range"); return NULL; } @@ -117,7 +117,7 @@ PyTuple_SetItem(register PyObject *op, register Py_ssize_t i, PyObject *newitem) PyErr_BadInternalCall(); return -1; } - if (i < 0 || i >= Py_Size(op)) { + if (i < 0 || i >= Py_SIZE(op)) { Py_XDECREF(newitem); PyErr_SetString(PyExc_IndexError, "tuple assignment index out of range"); @@ -160,7 +160,7 @@ static void tupledealloc(register PyTupleObject *op) { register Py_ssize_t i; - register Py_ssize_t len = Py_Size(op); + register Py_ssize_t len = Py_SIZE(op); PyObject_GC_UnTrack(op); Py_TRASHCAN_SAFE_BEGIN(op) if (len > 0) { @@ -170,7 +170,7 @@ tupledealloc(register PyTupleObject *op) #if MAXSAVESIZE > 0 if (len < MAXSAVESIZE && num_free_tuples[len] < MAXSAVEDTUPLES && - Py_Type(op) == &PyTuple_Type) + Py_TYPE(op) == &PyTuple_Type) { op->ob_item[0] = (PyObject *) free_tuples[len]; num_free_tuples[len]++; @@ -179,7 +179,7 @@ tupledealloc(register PyTupleObject *op) } #endif } - Py_Type(op)->tp_free((PyObject *)op); + Py_TYPE(op)->tp_free((PyObject *)op); done: Py_TRASHCAN_SAFE_END(op) } @@ -191,7 +191,7 @@ tuplerepr(PyTupleObject *v) PyObject *s, *temp; PyObject *pieces, *result = NULL; - n = Py_Size(v); + n = Py_SIZE(v); if (n == 0) return PyUnicode_FromString("()"); @@ -264,7 +264,7 @@ static long tuplehash(PyTupleObject *v) { register long x, y; - register Py_ssize_t len = Py_Size(v); + register Py_ssize_t len = Py_SIZE(v); register PyObject **p; long mult = 1000003L; x = 0x345678L; @@ -286,7 +286,7 @@ tuplehash(PyTupleObject *v) static Py_ssize_t tuplelength(PyTupleObject *a) { - return Py_Size(a); + return Py_SIZE(a); } static int @@ -295,7 +295,7 @@ tuplecontains(PyTupleObject *a, PyObject *el) Py_ssize_t i; int cmp; - for (i = 0, cmp = 0 ; cmp == 0 && i < Py_Size(a); ++i) + for (i = 0, cmp = 0 ; cmp == 0 && i < Py_SIZE(a); ++i) cmp = PyObject_RichCompareBool(el, PyTuple_GET_ITEM(a, i), Py_EQ); return cmp; @@ -304,7 +304,7 @@ tuplecontains(PyTupleObject *a, PyObject *el) static PyObject * tupleitem(register PyTupleObject *a, register Py_ssize_t i) { - if (i < 0 || i >= Py_Size(a)) { + if (i < 0 || i >= Py_SIZE(a)) { PyErr_SetString(PyExc_IndexError, "tuple index out of range"); return NULL; } @@ -322,11 +322,11 @@ tupleslice(register PyTupleObject *a, register Py_ssize_t ilow, Py_ssize_t len; if (ilow < 0) ilow = 0; - if (ihigh > Py_Size(a)) - ihigh = Py_Size(a); + if (ihigh > Py_SIZE(a)) + ihigh = Py_SIZE(a); if (ihigh < ilow) ihigh = ilow; - if (ilow == 0 && ihigh == Py_Size(a) && PyTuple_CheckExact(a)) { + if (ilow == 0 && ihigh == Py_SIZE(a) && PyTuple_CheckExact(a)) { Py_INCREF(a); return (PyObject *)a; } @@ -364,11 +364,11 @@ tupleconcat(register PyTupleObject *a, register PyObject *bb) if (!PyTuple_Check(bb)) { PyErr_Format(PyExc_TypeError, "can only concatenate tuple (not \"%.200s\") to tuple", - Py_Type(bb)->tp_name); + Py_TYPE(bb)->tp_name); return NULL; } #define b ((PyTupleObject *)bb) - size = Py_Size(a) + Py_Size(b); + size = Py_SIZE(a) + Py_SIZE(b); if (size < 0) return PyErr_NoMemory(); np = (PyTupleObject *) PyTuple_New(size); @@ -377,14 +377,14 @@ tupleconcat(register PyTupleObject *a, register PyObject *bb) } src = a->ob_item; dest = np->ob_item; - for (i = 0; i < Py_Size(a); i++) { + for (i = 0; i < Py_SIZE(a); i++) { PyObject *v = src[i]; Py_INCREF(v); dest[i] = v; } src = b->ob_item; - dest = np->ob_item + Py_Size(a); - for (i = 0; i < Py_Size(b); i++) { + dest = np->ob_item + Py_SIZE(a); + for (i = 0; i < Py_SIZE(b); i++) { PyObject *v = src[i]; Py_INCREF(v); dest[i] = v; @@ -402,18 +402,18 @@ tuplerepeat(PyTupleObject *a, Py_ssize_t n) PyObject **p, **items; if (n < 0) n = 0; - if (Py_Size(a) == 0 || n == 1) { + if (Py_SIZE(a) == 0 || n == 1) { if (PyTuple_CheckExact(a)) { /* Since tuples are immutable, we can return a shared copy in this case */ Py_INCREF(a); return (PyObject *)a; } - if (Py_Size(a) == 0) + if (Py_SIZE(a) == 0) return PyTuple_New(0); } - size = Py_Size(a) * n; - if (size/Py_Size(a) != n) + size = Py_SIZE(a) * n; + if (size/Py_SIZE(a) != n) return PyErr_NoMemory(); np = (PyTupleObject *) PyTuple_New(size); if (np == NULL) @@ -421,7 +421,7 @@ tuplerepeat(PyTupleObject *a, Py_ssize_t n) p = np->ob_item; items = a->ob_item; for (i = 0; i < n; i++) { - for (j = 0; j < Py_Size(a); j++) { + for (j = 0; j < Py_SIZE(a); j++) { *p = items[j]; Py_INCREF(*p); p++; @@ -435,7 +435,7 @@ tupletraverse(PyTupleObject *o, visitproc visit, void *arg) { Py_ssize_t i; - for (i = Py_Size(o); --i >= 0; ) + for (i = Py_SIZE(o); --i >= 0; ) Py_VISIT(o->ob_item[i]); return 0; } @@ -455,8 +455,8 @@ tuplerichcompare(PyObject *v, PyObject *w, int op) vt = (PyTupleObject *)v; wt = (PyTupleObject *)w; - vlen = Py_Size(vt); - wlen = Py_Size(wt); + vlen = Py_SIZE(vt); + wlen = Py_SIZE(wt); /* Note: the corresponding code for lists has an "early out" test * here when op is EQ or NE and the lengths differ. That pays there, @@ -624,7 +624,7 @@ tuplesubscript(PyTupleObject* self, PyObject* item) else { PyErr_Format(PyExc_TypeError, "tuple indices must be integers, not %.200s", - Py_Type(item)->tp_name); + Py_TYPE(item)->tp_name); return NULL; } } @@ -632,7 +632,7 @@ tuplesubscript(PyTupleObject* self, PyObject* item) static PyObject * tuple_getnewargs(PyTupleObject *v) { - return Py_BuildValue("(N)", tupleslice(v, 0, Py_Size(v))); + return Py_BuildValue("(N)", tupleslice(v, 0, Py_SIZE(v))); } @@ -708,14 +708,14 @@ _PyTuple_Resize(PyObject **pv, Py_ssize_t newsize) Py_ssize_t oldsize; v = (PyTupleObject *) *pv; - if (v == NULL || Py_Type(v) != &PyTuple_Type || - (Py_Size(v) != 0 && Py_Refcnt(v) != 1)) { + if (v == NULL || Py_TYPE(v) != &PyTuple_Type || + (Py_SIZE(v) != 0 && Py_REFCNT(v) != 1)) { *pv = 0; Py_XDECREF(v); PyErr_BadInternalCall(); return -1; } - oldsize = Py_Size(v); + oldsize = Py_SIZE(v); if (oldsize == newsize) return 0; |