Commit 377ef239 authored by Tim Peters's avatar Tim Peters

BTreeItem.child: Changed decl from PyObject* to new Sized*. All else

follows from that.
parent b8825d5b
...@@ -121,7 +121,7 @@ static void PyVar_AssignB(Bucket **v, Bucket *e) { Py_XDECREF(*v); *v=e;} ...@@ -121,7 +121,7 @@ static void PyVar_AssignB(Bucket **v, Bucket *e) { Py_XDECREF(*v); *v=e;}
typedef struct BTreeItem_s { typedef struct BTreeItem_s {
KEY_TYPE key; KEY_TYPE key;
PyObject *child; Sized *child; /* points to another BTree, or to a Bucket of some sort */
} BTreeItem; } BTreeItem;
typedef struct BTree_s { typedef struct BTree_s {
...@@ -323,7 +323,7 @@ static char BTree_module_documentation[] = ...@@ -323,7 +323,7 @@ static char BTree_module_documentation[] =
"\n" "\n"
MASTER_ID MASTER_ID
BTREEITEMSTEMPLATE_C BTREEITEMSTEMPLATE_C
"$Id: BTreeModuleTemplate.c,v 1.25 2002/05/31 17:30:30 tim_one Exp $\n" "$Id: BTreeModuleTemplate.c,v 1.26 2002/05/31 17:56:59 tim_one Exp $\n"
BTREETEMPLATE_C BTREETEMPLATE_C
BUCKETTEMPLATE_C BUCKETTEMPLATE_C
KEYMACROS_H KEYMACROS_H
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
****************************************************************************/ ****************************************************************************/
#define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.31 2002/05/31 17:22:40 tim_one Exp $\n" #define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.32 2002/05/31 17:56:59 tim_one Exp $\n"
/* /*
** _BTree_get ** _BTree_get
...@@ -144,16 +144,16 @@ BTree_clone(BTree *self) ...@@ -144,16 +144,16 @@ BTree_clone(BTree *self)
Py_XINCREF(n1->firstbucket); Py_XINCREF(n1->firstbucket);
/* Initialize our data to hold split data */ /* Initialize our data to hold split data */
self->data=d; self->data = d;
self->len=2; self->len = 2;
self->size=2; self->size = 2;
self->data->child=OBJECT(n1); self->data->child = SIZED(n1);
COPY_KEY(self->data[1].key, n2->data->key); COPY_KEY(self->data[1].key, n2->data->key);
/* We take the unused reference from n2, so there's no reason to INCREF! */ /* We take the unused reference from n2, so there's no reason to INCREF! */
/* INCREF_KEY(self->data[1].key); */ /* INCREF_KEY(self->data[1].key); */
self->data[1].child=OBJECT(n2); self->data[1].child = SIZED(n2);
return 0; return 0;
...@@ -179,7 +179,7 @@ static int ...@@ -179,7 +179,7 @@ static int
BTree_grow(BTree *self, int index, int noval) BTree_grow(BTree *self, int index, int noval)
{ {
int i; int i;
PyObject *v, *e=0; Sized *v, *e=0;
BTreeItem *d; BTreeItem *d;
if (self->len == self->size) if (self->len == self->size)
...@@ -203,9 +203,10 @@ BTree_grow(BTree *self, int index, int noval) ...@@ -203,9 +203,10 @@ BTree_grow(BTree *self, int index, int noval)
d=self->data+index; d=self->data+index;
if (self->len) if (self->len)
{ {
v=d->child; v = d->child;
/* Create a new object of the same type as the target value */ /* Create a new object of the same type as the target value */
UNLESS (e=PyObject_CallObject(OBJECT(v->ob_type), NULL)) return -1; e = SIZED(PyObject_CallObject(OBJECT(v->ob_type), NULL));
UNLESS (e) return -1;
PER_USE_OR_RETURN(BUCKET(v), -1); PER_USE_OR_RETURN(BUCKET(v), -1);
...@@ -257,13 +258,13 @@ BTree_grow(BTree *self, int index, int noval) ...@@ -257,13 +258,13 @@ BTree_grow(BTree *self, int index, int noval)
{ {
if (noval) if (noval)
{ {
UNLESS (d->child=PyObject_CallObject(OBJECT(&SetType), NULL)) d->child = SIZED(PyObject_CallObject(OBJECT(&SetType), NULL));
return -1; UNLESS (d->child) return -1;
} }
else else
{ {
UNLESS (d->child=PyObject_CallObject(OBJECT(&BucketType), NULL)) d->child = SIZED(PyObject_CallObject(OBJECT(&BucketType), NULL));
return -1; UNLESS (d->child) return -1;
} }
self->len=1; self->len=1;
Py_INCREF(d->child); Py_INCREF(d->child);
...@@ -284,7 +285,7 @@ BTree_lastBucket(BTree *self) ...@@ -284,7 +285,7 @@ BTree_lastBucket(BTree *self)
return NULL; return NULL;
} }
o=self->data[self->len - 1].child; o = OBJECT(self->data[self->len - 1].child);
Py_INCREF(o); Py_INCREF(o);
UNLESS (SameType_Check(self, o)) return BUCKET(o); UNLESS (SameType_Check(self, o)) return BUCKET(o);
...@@ -638,7 +639,7 @@ BTree_getstate(BTree *self, PyObject *args) ...@@ -638,7 +639,7 @@ BTree_getstate(BTree *self, PyObject *args)
PyTuple_SET_ITEM(r,l,o); PyTuple_SET_ITEM(r,l,o);
l++; l++;
} }
o=self->data[i].child; o = OBJECT(self->data[i].child);
Py_INCREF(o); Py_INCREF(o);
PyTuple_SET_ITEM(r,l,o); PyTuple_SET_ITEM(r,l,o);
l++; l++;
...@@ -698,23 +699,23 @@ _BTree_setstate(BTree *self, PyObject *state, int noval) ...@@ -698,23 +699,23 @@ _BTree_setstate(BTree *self, PyObject *state, int noval)
UNLESS (copied) return -1; UNLESS (copied) return -1;
INCREF_KEY(d->key); INCREF_KEY(d->key);
} }
d->child=PyTuple_GET_ITEM(items,l); d->child = SIZED(PyTuple_GET_ITEM(items,l));
if (PyTuple_Check(d->child)) if (PyTuple_Check(d->child))
{ {
if (noval) if (noval)
{ {
UNLESS (d->child=PyObject_CallObject(OBJECT(&SetType), d->child = SIZED(PyObject_CallObject(OBJECT(&SetType),
NULL)) NULL));
return -1; UNLESS (d->child) return -1;
if (_set_setstate(BUCKET(d->child), if (_set_setstate(BUCKET(d->child),
PyTuple_GET_ITEM(items,l)) PyTuple_GET_ITEM(items,l))
< 0) return -1; < 0) return -1;
} }
else else
{ {
UNLESS (d->child=PyObject_CallObject(OBJECT(&BucketType), d->child = SIZED(PyObject_CallObject(OBJECT(&BucketType),
NULL)) NULL));
return -1; UNLESS (d->child) return -1;
if (_bucket_setstate(BUCKET(d->child), if (_bucket_setstate(BUCKET(d->child),
PyTuple_GET_ITEM(items,l)) PyTuple_GET_ITEM(items,l))
< 0) return -1; < 0) return -1;
...@@ -729,7 +730,8 @@ _BTree_setstate(BTree *self, PyObject *state, int noval) ...@@ -729,7 +730,8 @@ _BTree_setstate(BTree *self, PyObject *state, int noval)
if (len) if (len)
{ {
if (! firstbucket) firstbucket=self->data->child; if (! firstbucket)
firstbucket = OBJECT(self->data->child);
UNLESS (ExtensionClassSubclassInstance_Check( UNLESS (ExtensionClassSubclassInstance_Check(
firstbucket, firstbucket,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment