summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/dictobject.c69
-rw-r--r--Objects/frameobject.c111
-rw-r--r--Objects/funcobject.c62
-rw-r--r--Objects/mappingobject.c69
-rw-r--r--Objects/methodobject.c10
-rw-r--r--Objects/moduleobject.c10
-rw-r--r--Objects/object.c12
-rw-r--r--Objects/tupleobject.c39
-rw-r--r--Objects/typeobject.c4
9 files changed, 258 insertions, 128 deletions
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index fb7456d..e40ac8d 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -38,16 +38,18 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Table of primes suitable as keys, in ascending order.
The first line are the largest primes less than some powers of two,
the second line is the largest prime less than 6000,
-and the third line is a selection from Knuth, Vol. 3, Sec. 6.1, Table 1.
-The final value is a sentinel and should cause the memory allocation
-of that many entries to fail (if none of the earlier values cause such
-failure already).
+the third line is a selection from Knuth, Vol. 3, Sec. 6.1, Table 1,
+and the next three lines were suggested by Steve Kirsch.
+The final value is a sentinel.
*/
-static unsigned int primes[] = {
+static long primes[] = {
3, 7, 13, 31, 61, 127, 251, 509, 1021, 2017, 4093,
5987,
9551, 15683, 19609, 31397,
- 0xffffffff /* All bits set -- truncation OK */
+ 65521L, 131071L, 262139L, 524287L, 1048573L, 2097143L,
+ 4194301L, 8388593L, 16777213L, 33554393L, 67108859L,
+ 134217689L, 268435399L, 536870909L, 1073741789L,
+ 0
};
/* Object used as dummy key to fill deleted entries */
@@ -207,8 +209,18 @@ mappingresize(mp)
register int i;
newsize = mp->ma_size;
for (i = 0; ; i++) {
+ if (primes[i] <= 0) {
+ /* Ran out of primes */
+ err_nomem();
+ return -1;
+ }
if (primes[i] > mp->ma_used*2) {
newsize = primes[i];
+ if (newsize != primes[i]) {
+ /* Integer truncation */
+ err_nomem();
+ return -1;
+ }
break;
}
}
@@ -406,15 +418,6 @@ mapping_print(mp, fp, flags)
return 0;
}
-static void
-js(pv, w)
- object **pv;
- object *w;
-{
- joinstring(pv, w);
- XDECREF(w);
-}
-
static object *
mapping_repr(mp)
mappingobject *mp;
@@ -428,16 +431,16 @@ mapping_repr(mp)
sepa = newstringobject(", ");
colon = newstringobject(": ");
any = 0;
- for (i = 0, ep = mp->ma_table; i < mp->ma_size; i++, ep++) {
+ for (i = 0, ep = mp->ma_table; i < mp->ma_size && v; i++, ep++) {
if (ep->me_value != NULL) {
if (any++)
joinstring(&v, sepa);
- js(&v, reprobject(ep->me_key));
+ joinstring_decref(&v, reprobject(ep->me_key));
joinstring(&v, colon);
- js(&v, reprobject(ep->me_value));
+ joinstring_decref(&v, reprobject(ep->me_value));
}
}
- js(&v, newstringobject("}"));
+ joinstring_decref(&v, newstringobject("}"));
XDECREF(sepa);
XDECREF(colon);
return v;
@@ -483,9 +486,9 @@ mapping_ass_sub(mp, v, w)
}
static mapping_methods mapping_as_mapping = {
- mapping_length, /*mp_length*/
- mapping_subscript, /*mp_subscript*/
- mapping_ass_sub, /*mp_ass_subscript*/
+ (inquiry)mapping_length, /*mp_length*/
+ (binaryfunc)mapping_subscript, /*mp_subscript*/
+ (objobjargproc)mapping_ass_sub, /*mp_ass_subscript*/
};
static object *
@@ -607,7 +610,7 @@ getmappingitems(mp)
err_badcall();
return NULL;
}
- return mapping_values((mappingobject *)mp, (object *)NULL);
+ return mapping_items((mappingobject *)mp, (object *)NULL);
}
static int
@@ -702,10 +705,10 @@ mapping_has_key(mp, args)
}
static struct methodlist mapp_methods[] = {
- {"has_key", mapping_has_key},
- {"items", mapping_items},
- {"keys", mapping_keys},
- {"values", mapping_values},
+ {"has_key", (method)mapping_has_key},
+ {"items", (method)mapping_items},
+ {"keys", (method)mapping_keys},
+ {"values", (method)mapping_values},
{NULL, NULL} /* sentinel */
};
@@ -723,12 +726,12 @@ typeobject Mappingtype = {
"dictionary",
sizeof(mappingobject),
0,
- mapping_dealloc, /*tp_dealloc*/
- mapping_print, /*tp_print*/
- mapping_getattr, /*tp_getattr*/
+ (destructor)mapping_dealloc, /*tp_dealloc*/
+ (printfunc)mapping_print, /*tp_print*/
+ (getattrfunc)mapping_getattr, /*tp_getattr*/
0, /*tp_setattr*/
- mapping_compare, /*tp_compare*/
- mapping_repr, /*tp_repr*/
+ (cmpfunc)mapping_compare, /*tp_compare*/
+ (reprfunc)mapping_repr, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
&mapping_as_mapping, /*tp_as_mapping*/
diff --git a/Objects/frameobject.c b/Objects/frameobject.c
index 0b5e75c..a22193f 100644
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -34,15 +34,16 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define OFF(x) offsetof(frameobject, x)
static struct memberlist frame_memberlist[] = {
- {"f_back", T_OBJECT, OFF(f_back)},
- {"f_code", T_OBJECT, OFF(f_code)},
- {"f_globals", T_OBJECT, OFF(f_globals)},
- {"f_locals", T_OBJECT, OFF(f_locals)},
- {"f_owner", T_OBJECT, OFF(f_owner)},
-/* {"f_fastlocals",T_OBJECT, OFF(f_fastlocals)}, /* XXX Unsafe */
- {"f_localmap", T_OBJECT, OFF(f_localmap)},
- {"f_lasti", T_INT, OFF(f_lasti)},
- {"f_lineno", T_INT, OFF(f_lineno)},
+ {"f_back", T_OBJECT, OFF(f_back), RO},
+ {"f_code", T_OBJECT, OFF(f_code), RO},
+ {"f_globals", T_OBJECT, OFF(f_globals), RO},
+ {"f_locals", T_OBJECT, OFF(f_locals), RO},
+ {"f_owner", T_OBJECT, OFF(f_owner), RO},
+/* {"f_fastlocals",T_OBJECT, OFF(f_fastlocals),RO}, /* XXX Unsafe */
+ {"f_localmap", T_OBJECT, OFF(f_localmap),RO},
+ {"f_lasti", T_INT, OFF(f_lasti), RO},
+ {"f_lineno", T_INT, OFF(f_lineno), RO},
+ {"f_trace", T_OBJECT, OFF(f_trace)},
{NULL} /* Sentinel */
};
@@ -51,9 +52,20 @@ frame_getattr(f, name)
frameobject *f;
char *name;
{
+ if (strcmp(name, "f_locals") == 0)
+ fast_2_locals(f);
return getmember((char *)f, frame_memberlist, name);
}
+static int
+frame_setattr(f, name, value)
+ frameobject *f;
+ char *name;
+ object *value;
+{
+ return setmember((char *)f, frame_memberlist, name, value);
+}
+
/* Stack frames are allocated and deallocated at a considerable rate.
In an attempt to improve the speed of function calls, we maintain a
separate free list of stack frames (just like integers are
@@ -88,6 +100,7 @@ frame_dealloc(f)
XDECREF(f->f_owner);
XDECREF(f->f_fastlocals);
XDECREF(f->f_localmap);
+ XDECREF(f->f_trace);
f->f_back = free_list;
free_list = f;
}
@@ -98,10 +111,10 @@ typeobject Frametype = {
"frame",
sizeof(frameobject),
0,
- frame_dealloc, /*tp_dealloc*/
+ (destructor)frame_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- frame_getattr, /*tp_getattr*/
- 0, /*tp_setattr*/
+ (getattrfunc)frame_getattr, /*tp_getattr*/
+ (setattrfunc)frame_setattr, /*tp_setattr*/
0, /*tp_compare*/
0, /*tp_repr*/
0, /*tp_as_number*/
@@ -167,6 +180,7 @@ newframeobject(back, code, globals, locals, owner, nvalues, nblocks)
f->f_iblock = 0;
f->f_lasti = 0;
f->f_lineno = -1;
+ f->f_trace = NULL;
if (f->f_valuestack == NULL || f->f_blockstack == NULL) {
err_nomem();
DECREF(f);
@@ -225,3 +239,74 @@ pop_block(f)
b = &f->f_blockstack[--f->f_iblock];
return b;
}
+
+/* Convert between "fast" version of locals and dictionary version */
+
+void
+fast_2_locals(f)
+ frameobject *f;
+{
+ /* Merge f->f_fastlocals into f->f_locals */
+ object *locals, *fast, *map;
+ object *error_type, *error_value;
+ int j;
+ if (f == NULL)
+ return;
+ locals = f->f_locals;
+ fast = f->f_fastlocals;
+ map = f->f_localmap;
+ if (locals == NULL || fast == NULL || map == NULL)
+ return;
+ if (!is_dictobject(locals) || !is_listobject(fast) ||
+ !is_tupleobject(map))
+ return;
+ err_get(&error_type, &error_value);
+ for (j = gettuplesize(map); --j >= 0; ) {
+ object *key = gettupleitem(map, j);
+ object *value = getlistitem(fast, j);
+ if (value == NULL) {
+ err_clear();
+ if (dict2remove(locals, key) != 0)
+ err_clear();
+ }
+ else {
+ if (dict2insert(locals, key, value) != 0)
+ err_clear();
+ }
+ }
+ err_setval(error_type, error_value);
+}
+
+void
+locals_2_fast(f, clear)
+ frameobject *f;
+ int clear;
+{
+ /* Merge f->f_locals into f->f_fastlocals */
+ object *locals, *fast, *map;
+ object *error_type, *error_value;
+ int j;
+ if (f == NULL)
+ return;
+ locals = f->f_locals;
+ fast = f->f_fastlocals;
+ map = f->f_localmap;
+ if (locals == NULL || fast == NULL || map == NULL)
+ return;
+ if (!is_dictobject(locals) || !is_listobject(fast) ||
+ !is_tupleobject(map))
+ return;
+ err_get(&error_type, &error_value);
+ for (j = gettuplesize(map); --j >= 0; ) {
+ object *key = gettupleitem(map, j);
+ object *value = dict2lookup(locals, key);
+ if (value == NULL)
+ err_clear();
+ else
+ INCREF(value);
+ if (value != NULL || clear)
+ if (setlistitem(fast, j, value) != 0)
+ err_clear();
+ }
+ err_setval(error_type, error_value);
+}
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index cc4900a..d7549e0 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -41,6 +41,8 @@ newfuncobject(code, globals)
op->func_globals = globals;
op->func_name = ((codeobject*)(op->func_code))->co_name;
INCREF(op->func_name);
+ op->func_argcount = -1; /* Unknown */
+ op->func_argdefs = NULL; /* No default arguments */
}
return (object *)op;
}
@@ -67,6 +69,44 @@ getfuncglobals(op)
return ((funcobject *) op) -> func_globals;
}
+object *
+getfuncargstuff(op, argcount_return)
+ object *op;
+ int *argcount_return;
+{
+ if (!is_funcobject(op)) {
+ err_badcall();
+ return NULL;
+ }
+ *argcount_return = ((funcobject *) op) -> func_argcount;
+ return ((funcobject *) op) -> func_argdefs;
+}
+
+int
+setfuncargstuff(op, argcount, argdefs)
+ object *op;
+ int argcount;
+ object *argdefs;
+{
+ if (!is_funcobject(op) ||
+ argdefs != NULL && !is_tupleobject(argdefs)) {
+ err_badcall();
+ return -1;
+ }
+ if (argdefs == None)
+ argdefs = NULL;
+ else if (is_tupleobject(argdefs))
+ XINCREF(argdefs);
+ else {
+ err_setstr(SystemError, "non-tuple default args");
+ return -1;
+ }
+ ((funcobject *) op) -> func_argcount = argcount;
+ XDECREF(((funcobject *) op) -> func_argdefs);
+ ((funcobject *) op) -> func_argdefs = argdefs;
+ return 0;
+}
+
/* Methods */
#define OFF(x) offsetof(funcobject, x)
@@ -75,6 +115,8 @@ static struct memberlist func_memberlist[] = {
{"func_code", T_OBJECT, OFF(func_code), READONLY},
{"func_globals",T_OBJECT, OFF(func_globals), READONLY},
{"func_name", T_OBJECT, OFF(func_name), READONLY},
+ {"func_argcount",T_INT, OFF(func_argcount), READONLY},
+ {"func_argdefs",T_OBJECT, OFF(func_argdefs), READONLY},
{NULL} /* Sentinel */
};
@@ -92,6 +134,7 @@ func_dealloc(op)
{
DECREF(op->func_code);
DECREF(op->func_globals);
+ XDECREF(op->func_argdefs);
DEL(op);
}
@@ -113,8 +156,15 @@ static int
func_compare(f, g)
funcobject *f, *g;
{
+ int c;
if (f->func_globals != g->func_globals)
return (f->func_globals < g->func_globals) ? -1 : 1;
+ c = f->func_argcount < g->func_argcount;
+ if (c != 0)
+ return c < 0 ? -1 : 1;
+ c = cmpobject(f->func_argdefs, g->func_argdefs);
+ if (c != 0)
+ return c;
return cmpobject(f->func_code, g->func_code);
}
@@ -136,14 +186,14 @@ typeobject Functype = {
"function",
sizeof(funcobject),
0,
- func_dealloc, /*tp_dealloc*/
+ (destructor)func_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- func_getattr, /*tp_getattr*/
+ (getattrfunc)func_getattr, /*tp_getattr*/
0, /*tp_setattr*/
- func_compare, /*tp_compare*/
- func_repr, /*tp_repr*/
+ (cmpfunc)func_compare, /*tp_compare*/
+ (reprfunc)func_repr, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
- func_hash, /*tp_hash*/
+ (hashfunc)func_hash, /*tp_hash*/
};
diff --git a/Objects/mappingobject.c b/Objects/mappingobject.c
index fb7456d..e40ac8d 100644
--- a/Objects/mappingobject.c
+++ b/Objects/mappingobject.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -38,16 +38,18 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Table of primes suitable as keys, in ascending order.
The first line are the largest primes less than some powers of two,
the second line is the largest prime less than 6000,
-and the third line is a selection from Knuth, Vol. 3, Sec. 6.1, Table 1.
-The final value is a sentinel and should cause the memory allocation
-of that many entries to fail (if none of the earlier values cause such
-failure already).
+the third line is a selection from Knuth, Vol. 3, Sec. 6.1, Table 1,
+and the next three lines were suggested by Steve Kirsch.
+The final value is a sentinel.
*/
-static unsigned int primes[] = {
+static long primes[] = {
3, 7, 13, 31, 61, 127, 251, 509, 1021, 2017, 4093,
5987,
9551, 15683, 19609, 31397,
- 0xffffffff /* All bits set -- truncation OK */
+ 65521L, 131071L, 262139L, 524287L, 1048573L, 2097143L,
+ 4194301L, 8388593L, 16777213L, 33554393L, 67108859L,
+ 134217689L, 268435399L, 536870909L, 1073741789L,
+ 0
};
/* Object used as dummy key to fill deleted entries */
@@ -207,8 +209,18 @@ mappingresize(mp)
register int i;
newsize = mp->ma_size;
for (i = 0; ; i++) {
+ if (primes[i] <= 0) {
+ /* Ran out of primes */
+ err_nomem();
+ return -1;
+ }
if (primes[i] > mp->ma_used*2) {
newsize = primes[i];
+ if (newsize != primes[i]) {
+ /* Integer truncation */
+ err_nomem();
+ return -1;
+ }
break;
}
}
@@ -406,15 +418,6 @@ mapping_print(mp, fp, flags)
return 0;
}
-static void
-js(pv, w)
- object **pv;
- object *w;
-{
- joinstring(pv, w);
- XDECREF(w);
-}
-
static object *
mapping_repr(mp)
mappingobject *mp;
@@ -428,16 +431,16 @@ mapping_repr(mp)
sepa = newstringobject(", ");
colon = newstringobject(": ");
any = 0;
- for (i = 0, ep = mp->ma_table; i < mp->ma_size; i++, ep++) {
+ for (i = 0, ep = mp->ma_table; i < mp->ma_size && v; i++, ep++) {
if (ep->me_value != NULL) {
if (any++)
joinstring(&v, sepa);
- js(&v, reprobject(ep->me_key));
+ joinstring_decref(&v, reprobject(ep->me_key));
joinstring(&v, colon);
- js(&v, reprobject(ep->me_value));
+ joinstring_decref(&v, reprobject(ep->me_value));
}
}
- js(&v, newstringobject("}"));
+ joinstring_decref(&v, newstringobject("}"));
XDECREF(sepa);
XDECREF(colon);
return v;
@@ -483,9 +486,9 @@ mapping_ass_sub(mp, v, w)
}
static mapping_methods mapping_as_mapping = {
- mapping_length, /*mp_length*/
- mapping_subscript, /*mp_subscript*/
- mapping_ass_sub, /*mp_ass_subscript*/
+ (inquiry)mapping_length, /*mp_length*/
+ (binaryfunc)mapping_subscript, /*mp_subscript*/
+ (objobjargproc)mapping_ass_sub, /*mp_ass_subscript*/
};
static object *
@@ -607,7 +610,7 @@ getmappingitems(mp)
err_badcall();
return NULL;
}
- return mapping_values((mappingobject *)mp, (object *)NULL);
+ return mapping_items((mappingobject *)mp, (object *)NULL);
}
static int
@@ -702,10 +705,10 @@ mapping_has_key(mp, args)
}
static struct methodlist mapp_methods[] = {
- {"has_key", mapping_has_key},
- {"items", mapping_items},
- {"keys", mapping_keys},
- {"values", mapping_values},
+ {"has_key", (method)mapping_has_key},
+ {"items", (method)mapping_items},
+ {"keys", (method)mapping_keys},
+ {"values", (method)mapping_values},
{NULL, NULL} /* sentinel */
};
@@ -723,12 +726,12 @@ typeobject Mappingtype = {
"dictionary",
sizeof(mappingobject),
0,
- mapping_dealloc, /*tp_dealloc*/
- mapping_print, /*tp_print*/
- mapping_getattr, /*tp_getattr*/
+ (destructor)mapping_dealloc, /*tp_dealloc*/
+ (printfunc)mapping_print, /*tp_print*/
+ (getattrfunc)mapping_getattr, /*tp_getattr*/
0, /*tp_setattr*/
- mapping_compare, /*tp_compare*/
- mapping_repr, /*tp_repr*/
+ (cmpfunc)mapping_compare, /*tp_compare*/
+ (reprfunc)mapping_repr, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
&mapping_as_mapping, /*tp_as_mapping*/
diff --git a/Objects/methodobject.c b/Objects/methodobject.c
index 0a56161..f7363bd 100644
--- a/Objects/methodobject.c
+++ b/Objects/methodobject.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -149,16 +149,16 @@ typeobject Methodtype = {
"builtin_function_or_method",
sizeof(methodobject),
0,
- meth_dealloc, /*tp_dealloc*/
+ (destructor)meth_dealloc, /*tp_dealloc*/
0, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- meth_compare, /*tp_compare*/
- meth_repr, /*tp_repr*/
+ (cmpfunc)meth_compare, /*tp_compare*/
+ (reprfunc)meth_repr, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
- meth_hash, /*tp_hash*/
+ (hashfunc)meth_hash, /*tp_hash*/
};
static object *listmethods PROTO((struct methodlist *)); /* Forward */
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 9a687b4..b98d843 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -162,10 +162,10 @@ typeobject Moduletype = {
"module", /*tp_name*/
sizeof(moduleobject), /*tp_size*/
0, /*tp_itemsize*/
- module_dealloc, /*tp_dealloc*/
+ (destructor)module_dealloc, /*tp_dealloc*/
0, /*tp_print*/
- module_getattr, /*tp_getattr*/
- module_setattr, /*tp_setattr*/
+ (getattrfunc)module_getattr, /*tp_getattr*/
+ (setattrfunc)module_setattr, /*tp_setattr*/
0, /*tp_compare*/
- module_repr, /*tp_repr*/
+ (reprfunc)module_repr, /*tp_repr*/
};
diff --git a/Objects/object.c b/Objects/object.c
index 7a7383e..072b50b 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -107,10 +107,8 @@ printobject(op, fp, flags)
int flags;
{
int ret = 0;
- if (intrcheck()) {
- err_set(KeyboardInterrupt);
+ if (sigcheck())
return -1;
- }
if (op == NULL) {
fprintf(fp, "<nil>");
}
@@ -159,10 +157,8 @@ object *
reprobject(v)
object *v;
{
- if (intrcheck()) {
- err_set(KeyboardInterrupt);
+ if (sigcheck())
return NULL;
- }
if (v == NULL)
return newstringobject("<NULL>");
else if (v->ob_type->tp_repr == NULL) {
@@ -349,7 +345,7 @@ static typeobject Notype = {
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
- none_repr, /*tp_repr*/
+ (reprfunc)none_repr, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
0, /*tp_as_mapping*/
diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c
index 6f122ea..59660f9 100644
--- a/Objects/tupleobject.c
+++ b/Objects/tupleobject.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -180,26 +180,19 @@ static object *
tuplerepr(v)
tupleobject *v;
{
- object *s, *t, *comma;
+ object *s, *comma;
int i;
s = newstringobject("(");
comma = newstringobject(", ");
for (i = 0; i < v->ob_size && s != NULL; i++) {
if (i > 0)
joinstring(&s, comma);
- t = reprobject(v->ob_item[i]);
- joinstring(&s, t);
- XDECREF(t);
+ joinstring_decref(&s, reprobject(v->ob_item[i]));
}
DECREF(comma);
- if (v->ob_size == 1) {
- t = newstringobject(",");
- joinstring(&s, t);
- DECREF(t);
- }
- t = newstringobject(")");
- joinstring(&s, t);
- DECREF(t);
+ if (v->ob_size == 1)
+ joinstring_decref(&s, newstringobject(","));
+ joinstring_decref(&s, newstringobject(")"));
return s;
}
@@ -365,11 +358,11 @@ tuplerepeat(a, n)
}
static sequence_methods tuple_as_sequence = {
- tuplelength, /*sq_length*/
- tupleconcat, /*sq_concat*/
- tuplerepeat, /*sq_repeat*/
- tupleitem, /*sq_item*/
- tupleslice, /*sq_slice*/
+ (inquiry)tuplelength, /*sq_length*/
+ (binaryfunc)tupleconcat, /*sq_concat*/
+ (intargfunc)tuplerepeat, /*sq_repeat*/
+ (intargfunc)tupleitem, /*sq_item*/
+ (intintargfunc)tupleslice, /*sq_slice*/
0, /*sq_ass_item*/
0, /*sq_ass_slice*/
};
@@ -380,16 +373,16 @@ typeobject Tupletype = {
"tuple",
sizeof(tupleobject) - sizeof(object *),
sizeof(object *),
- tupledealloc, /*tp_dealloc*/
- tupleprint, /*tp_print*/
+ (destructor)tupledealloc, /*tp_dealloc*/
+ (printfunc)tupleprint, /*tp_print*/
0, /*tp_getattr*/
0, /*tp_setattr*/
- tuplecompare, /*tp_compare*/
- tuplerepr, /*tp_repr*/
+ (cmpfunc)tuplecompare, /*tp_compare*/
+ (reprfunc)tuplerepr, /*tp_repr*/
0, /*tp_as_number*/
&tuple_as_sequence, /*tp_as_sequence*/
0, /*tp_as_mapping*/
- tuplehash, /*tp_hash*/
+ (hashfunc)tuplehash, /*tp_hash*/
};
/* The following function breaks the notion that tuples are immutable:
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 7176008..40bdc88 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -1,5 +1,5 @@
/***********************************************************
-Copyright 1991, 1992, 1993 by Stichting Mathematisch Centrum,
+Copyright 1991, 1992, 1993, 1994 by Stichting Mathematisch Centrum,
Amsterdam, The Netherlands.
All Rights Reserved
@@ -48,5 +48,5 @@ typeobject Typetype = {
0, /*tp_getattr*/
0, /*tp_setattr*/
0, /*tp_compare*/
- type_repr, /*tp_repr*/
+ (reprfunc)type_repr, /*tp_repr*/
};