Commit 63970e79 authored by Jeremy Hylton's avatar Jeremy Hylton

Initial cut at BTrees implementation. It compiles, but does not work.

parent 4171baa3
......@@ -12,23 +12,11 @@
****************************************************************************/
#include "Python.h"
#ifdef PERSISTENT
#include "cPersistence.h"
#include "cPersistenceAPI.h"
/***************************************************************
The following are macros that ought to be in cPersistence.h */
#ifndef PER_USE
#define PER_USE(O) \
(((O)->state != cPersistent_GHOST_STATE \
|| (cPersistenceCAPI->setstate((PyObject*)(O)) >= 0)) \
? (((O)->state==cPersistent_UPTODATE_STATE) \
? ((O)->state=cPersistent_STICKY_STATE) : 1) : 0)
#define PER_ACCESSED(O) ((O)->atime=((long)(time(NULL)/3))%65536)
#endif
/***************************************************************/
#else
......@@ -70,7 +58,7 @@ typedef struct BTreeItemStruct {
typedef struct Bucket_s {
#ifdef PERSISTENT
cPersistent_HEAD
PyPersist_HEAD
#else
PyObject_HEAD
#endif
......@@ -88,7 +76,7 @@ static void PyVar_AssignB(Bucket **v, Bucket *e) { Py_XDECREF(*v); *v=e;}
typedef struct {
#ifdef PERSISTENT
cPersistent_HEAD
PyPersist_HEAD
#else
PyObject_HEAD
#endif
......@@ -97,7 +85,7 @@ typedef struct {
BTreeItem *data;
} BTree;
staticforward PyExtensionClass BTreeType;
staticforward PyTypeObject BTreeType;
#define BTREE(O) ((BTree*)(O))
......@@ -270,7 +258,7 @@ static char BTree_module_documentation[] =
"\n"
MASTER_ID
BTREEITEMSTEMPLATE_C
"$Id: BTreeModuleTemplate.c,v 1.18 2002/02/11 23:40:40 gvanrossum Exp $\n"
"$Id: BTreeModuleTemplate.c,v 1.19 2002/02/20 23:59:51 jeremy Exp $\n"
BTREETEMPLATE_C
BUCKETTEMPLATE_C
KEYMACROS_H
......@@ -282,44 +270,37 @@ VALUEMACROS_H
BTREEITEMSTEMPLATE_C
;
int
init_persist_type(PyTypeObject *type)
{
type->ob_type = &PyType_Type;
type->tp_getattro = PyPersist_TYPE->tp_getattro;
type->tp_setattro = PyPersist_TYPE->tp_setattro;
/* XXX for now */
type->tp_traverse = PyPersist_TYPE->tp_traverse;
type->tp_clear = PyPersist_TYPE->tp_clear;
return PyType_Ready(type);
}
void
INITMODULE (void)
{
PyObject *m, *d, *c;
UNLESS (sort_str=PyString_FromString("sort")) return;
UNLESS (reverse_str=PyString_FromString("reverse")) return;
UNLESS (items_str=PyString_FromString("items")) return;
UNLESS (__setstate___str=PyString_FromString("__setstate__")) return;
UNLESS (PyExtensionClassCAPI=PyCObject_Import("ExtensionClass","CAPI"))
sort_str = PyString_InternFromString("sort");
if (!sort_str)
return;
reverse_str = PyString_InternFromString("reverse");
if (!reverse_str)
return;
__setstate___str = PyString_InternFromString("__setstate__");
if (!__setstate___str)
return;
#ifdef PERSISTENT
if ((cPersistenceCAPI=PyCObject_Import("cPersistence","CAPI")))
{
BucketType.methods.link=cPersistenceCAPI->methods;
BucketType.tp_getattro=cPersistenceCAPI->getattro;
BucketType.tp_setattro=cPersistenceCAPI->setattro;
SetType.methods.link=cPersistenceCAPI->methods;
SetType.tp_getattro=cPersistenceCAPI->getattro;
SetType.tp_setattro=cPersistenceCAPI->setattro;
BTreeType.methods.link=cPersistenceCAPI->methods;
BTreeType.tp_getattro=cPersistenceCAPI->getattro;
BTreeType.tp_setattro=cPersistenceCAPI->setattro;
TreeSetType.methods.link=cPersistenceCAPI->methods;
TreeSetType.tp_getattro=cPersistenceCAPI->getattro;
TreeSetType.tp_setattro=cPersistenceCAPI->setattro;
}
else return;
/* Grab the ConflictError class */
m = PyImport_ImportModule("ZODB.POSException");
if (m != NULL) {
c = PyObject_GetAttrString(m, "BTreesConflictError");
if (c != NULL)
......@@ -332,31 +313,40 @@ INITMODULE (void)
ConflictError=PyExc_ValueError;
}
#else
BTreeType.tp_getattro=PyExtensionClassCAPI->getattro;
BucketType.tp_getattro=PyExtensionClassCAPI->getattro;
SetType.tp_getattro=PyExtensionClassCAPI->getattro;
TreeSetType.tp_getattro=PyExtensionClassCAPI->getattro;
#endif
BTreeItemsType.ob_type=&PyType_Type;
#ifdef INTSET_H
UNLESS(d = PyImport_ImportModule("intSet")) return;
UNLESS(intSetType = PyObject_GetAttrString (d, "intSet")) return;
Py_DECREF (d);
#endif
/* Initialize the PyPersist_C_API and the type objects. */
PyPersist_C_API = PyCObject_Import("Persistence.cPersistence", "C_API");
if (PyPersist_C_API == NULL)
return;
BTreeItemsType.ob_type = &PyType_Type;
init_persist_type(&BucketType);
init_persist_type(&BTreeType);
init_persist_type(&SetType);
init_persist_type(&TreeSetType);
/* Create the module and add the functions */
m = Py_InitModule4("_" MOD_NAME_PREFIX "BTree", module_methods,
BTree_module_documentation,
(PyObject*)NULL,PYTHON_API_VERSION);
m = Py_InitModule4("_" MOD_NAME_PREFIX "BTree",
module_methods, BTree_module_documentation,
(PyObject *)NULL, PYTHON_API_VERSION);
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
PyExtensionClass_Export(d,MOD_NAME_PREFIX "Bucket", BucketType);
PyExtensionClass_Export(d,MOD_NAME_PREFIX "BTree", BTreeType);
PyExtensionClass_Export(d,MOD_NAME_PREFIX "Set", SetType);
PyExtensionClass_Export(d,MOD_NAME_PREFIX "TreeSet", TreeSetType);
if (PyDict_SetItemString(d, MOD_NAME_PREFIX "Bucket",
(PyObject *)&BucketType) < 0)
return;
if (PyDict_SetItemString(d, MOD_NAME_PREFIX "BTree",
(PyObject *)&BTreeType) < 0)
return;
if (PyDict_SetItemString(d, MOD_NAME_PREFIX "Set",
(PyObject *)&SetType) < 0)
return;
if (PyDict_SetItemString(d, MOD_NAME_PREFIX "TreeSet",
(PyObject *)&TreeSetType) < 0)
return;
}
......@@ -12,7 +12,7 @@
****************************************************************************/
#define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.21 2002/02/11 23:40:40 gvanrossum Exp $\n"
#define BTREETEMPLATE_C "$Id: BTreeTemplate.c,v 1.22 2002/02/20 23:59:51 jeremy Exp $\n"
/*
** _BTree_get
......@@ -481,7 +481,7 @@ _BTree_set(BTree *self, PyObject *keyarg, PyObject *value,
|| (bchanged /* The bucket changed */
&& self->len == 1 /* We have only one */
&& ! SameType_Check(self, self->data->value) /* It's our child */
&& BUCKET(self->data->value)->oid == NULL /* It's in our record */
&& BUCKET(self->data->value)->po_oid == NULL /* It's in our record */
)
)
if (PER_CHANGED(self) < 0)
......@@ -570,10 +570,10 @@ _BTree_clear(BTree *self)
static PyObject *
BTree__p_deactivate(BTree *self, PyObject *args)
{
if (self->state==cPersistent_UPTODATE_STATE && self->jar)
if (self->po_state == UPTODATE && self->po_dm)
{
if (_BTree_clear(self) < 0) return NULL;
self->state=cPersistent_GHOST_STATE;
self->po_state = GHOST;
}
Py_INCREF(Py_None);
......@@ -619,7 +619,7 @@ BTree_getstate(BTree *self, PyObject *args)
if (self->len == 1
&& self->data->value->ob_type != self->ob_type
#ifdef PERSISTENT
&& BUCKET(self->data->value)->oid == NULL
&& BUCKET(self->data->value)->po_oid == NULL
#endif
)
{
......@@ -731,9 +731,9 @@ _BTree_setstate(BTree *self, PyObject *state, int noval)
{
if (! firstbucket) firstbucket=self->data->value;
UNLESS (ExtensionClassSubclassInstance_Check(
firstbucket,
noval ? &SetType : &BucketType))
/* XXX what is this? */
if (!PyObject_IsInstance(firstbucket, (PyObject *)
(noval ? &SetType : &BucketType)))
{
PyErr_SetString(PyExc_TypeError,
"No firstbucket in non-empty BTree");
......@@ -788,7 +788,7 @@ BTree__p_resolveConflict(BTree *self, PyObject *args)
UNLESS (s[i]==Py_None || PyTuple_Check(s[i]))
return merge_error(-100, -100, -100, -100);
if (ExtensionClassSubclassInstance_Check(self, &BTreeType))
if (PyObject_IsInstance((PyObject *)self, (PyObject *)&BTreeType))
r = _bucket__p_resolveConflict(OBJECT(&BucketType), s);
else
r = _bucket__p_resolveConflict(OBJECT(&SetType), s);
......@@ -1238,11 +1238,7 @@ static void
BTree_dealloc(BTree *self)
{
_BTree_clear(self);
PER_DEL(self);
Py_DECREF(self->ob_type);
PyMem_DEL(self);
PyPersist_TYPE->tp_dealloc((PyObject *)self);
}
static int
......@@ -1301,35 +1297,46 @@ static PyNumberMethods BTree_as_number_for_nonzero = {
0,0,0,0,0,0,0,0,0,0,
(inquiry)BTree_nonzero};
static PyExtensionClass BTreeType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
MOD_NAME_PREFIX "BTree", /*tp_name*/
sizeof(BTree), /*tp_basicsize*/
0, /*tp_itemsize*/
/************* methods ********************/
(destructor) BTree_dealloc,/*tp_dealloc*/
(printfunc)0, /*tp_print*/
(getattrfunc)0, /*obsolete tp_getattr*/
(setattrfunc)0, /*obsolete tp_setattr*/
(cmpfunc)0, /*tp_compare*/
(reprfunc)0, /*tp_repr*/
&BTree_as_number_for_nonzero, /*tp_as_number*/
0, /*tp_as_sequence*/
&BTree_as_mapping, /*tp_as_mapping*/
(hashfunc)0, /*tp_hash*/
(ternaryfunc)0, /*tp_call*/
(reprfunc)0, /*tp_str*/
(getattrofunc)0,
0, /*tp_setattro*/
/* Space for future expansion */
0L,0L,
"Mapping type implemented as sorted list of items",
METHOD_CHAIN(BTree_methods),
EXTENSIONCLASS_BASICNEW_FLAG
#ifdef PERSISTENT
| PERSISTENT_TYPE_FLAG
#endif
| EXTENSIONCLASS_NOINSTDICT_FLAG,
static PyTypeObject BTreeType = {
PyObject_HEAD_INIT(NULL) /* PyPersist_Type */
0, /* ob_size */
"Persistence.BTrees.OOBTree." MOD_NAME_PREFIX "BTree", /* tp_name */
sizeof(BTree), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)BTree_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
&BTree_as_number_for_nonzero, /* tp_as_number */
0, /* tp_as_sequence */
&BTree_as_mapping, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
/* XXX need to define traverse and clear functions */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE, /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
BTree_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
......@@ -12,7 +12,7 @@
****************************************************************************/
#define BUCKETTEMPLATE_C "$Id: BucketTemplate.c,v 1.25 2002/02/11 23:40:40 gvanrossum Exp $\n"
#define BUCKETTEMPLATE_C "$Id: BucketTemplate.c,v 1.26 2002/02/20 23:59:51 jeremy Exp $\n"
/*
** _bucket_get
......@@ -806,10 +806,10 @@ _bucket_clear(Bucket *self)
static PyObject *
bucket__p_deactivate(Bucket *self, PyObject *args)
{
if (self->state==cPersistent_UPTODATE_STATE && self->jar)
if (self->po_state == UPTODATE && self->po_dm)
{
if (_bucket_clear(self) < 0) return NULL;
self->state=cPersistent_GHOST_STATE;
self->po_state = GHOST;
}
Py_INCREF(Py_None);
......@@ -1130,14 +1130,10 @@ static struct PyMethodDef Bucket_methods[] = {
};
static void
Bucket_dealloc(Bucket *self)
bucket_dealloc(Bucket *self)
{
_bucket_clear(self);
PER_DEL(self);
Py_DECREF(self->ob_type);
PyMem_DEL(self);
PyPersist_TYPE->tp_dealloc((PyObject *)self);
}
/* Code to access Bucket objects as mappings */
......@@ -1164,8 +1160,11 @@ bucket_repr(Bucket *self)
static PyObject *format;
PyObject *r, *t;
UNLESS (format) UNLESS (format=PyString_FromString(MOD_NAME_PREFIX "Bucket(%s)"))
return NULL;
if (format == NULL) {
format = PyString_FromString(MOD_NAME_PREFIX "Bucket(%s)");
if (format == NULL)
return NULL;
}
UNLESS (t=PyTuple_New(1)) return NULL;
UNLESS (r=bucket_items(self,NULL)) goto err;
PyTuple_SET_ITEM(t,0,r);
......@@ -1177,40 +1176,50 @@ err:
return NULL;
}
static PyExtensionClass BucketType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
MOD_NAME_PREFIX "Bucket", /*tp_name*/
sizeof(Bucket), /*tp_basicsize*/
0, /*tp_itemsize*/
/*********** methods ***********************/
(destructor) Bucket_dealloc, /*tp_dealloc*/
(printfunc)0, /*tp_print*/
(getattrfunc)0, /*obsolete tp_getattr*/
(setattrfunc)0, /*obsolete tp_setattr*/
(cmpfunc)0, /*tp_compare*/
(reprfunc) bucket_repr, /*tp_repr*/
0, /*tp_as_number*/
0, /*tp_as_sequence*/
&Bucket_as_mapping, /*tp_as_mapping*/
(hashfunc)0, /*tp_hash*/
(ternaryfunc)0, /*tp_call*/
(reprfunc)0, /*tp_str*/
(getattrofunc)0, /*tp_getattro*/
0, /*tp_setattro*/
/* Space for future expansion */
0L,0L,
"Mapping type implemented as sorted list of items",
METHOD_CHAIN(Bucket_methods),
EXTENSIONCLASS_BASICNEW_FLAG
#ifdef PERSISTENT
| PERSISTENT_TYPE_FLAG
#endif
| EXTENSIONCLASS_NOINSTDICT_FLAG,
static PyTypeObject BucketType = {
PyObject_HEAD_INIT(NULL) /* PyPersist_Type */
0, /* ob_size */
MOD_NAME_PREFIX "Bucket", /* tp_name */
sizeof(Bucket), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)bucket_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
(reprfunc)bucket_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
&Bucket_as_mapping, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
/* XXX need to define traverse and clear functions */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE, /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
Bucket_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
static int
nextBucket(SetIteration *i)
{
......
......@@ -17,6 +17,6 @@ from _IIBTree import *
# We don't really want _ names in pickles, so update all of the __module__
# references.
for o in globals().values():
if hasattr(o, '__module__'):
o.__module__=__name__
##for o in globals().values():
## if hasattr(o, '__module__'):
## o.__module__=__name__
......@@ -17,6 +17,6 @@ from _IOBTree import *
# We don't really want _ names in pickles, so update all of the __module__
# references.
for o in globals().values():
if hasattr(o, '__module__'):
o.__module__=__name__
##for o in globals().values():
## if hasattr(o, '__module__'):
## o.__module__=__name__
......@@ -17,6 +17,6 @@ from _OIBTree import *
# We don't really want _ names in pickles, so update all of the __module__
# references.
for o in globals().values():
if hasattr(o, '__module__'):
o.__module__=__name__
##for o in globals().values():
## if hasattr(o, '__module__'):
## o.__module__=__name__
......@@ -17,6 +17,21 @@ from _OOBTree import *
# We don't really want _ names in pickles, so update all of the __module__
# references.
for o in globals().values():
if hasattr(o, '__module__'):
o.__module__=__name__
##for o in globals().values():
## print o
## if hasattr(o, '__module__'):
## o.__module__=__name__
# XXX can't figure out why _reduce() won't call our __getstate__.
import copy_reg
def pickle_OOBTree(t):
return t.__class__, t.__getstate__()
def unpickle_OOBTree(state):
obj = OOBTree.__new__(OOBTree, None)
obj.__setstate__(state)
return obj
copy_reg.pickle(OOBTree, pickle_OOBTree)
......@@ -16,7 +16,7 @@
Set operations
****************************************************************************/
#define SETOPTEMPLATE_C "$Id: SetOpTemplate.c,v 1.10 2002/02/11 23:40:40 gvanrossum Exp $\n"
#define SETOPTEMPLATE_C "$Id: SetOpTemplate.c,v 1.11 2002/02/20 23:59:51 jeremy Exp $\n"
#ifdef INTSET_H
static int
......@@ -67,7 +67,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
{
i->position=0;
if (ExtensionClassSubclassInstance_Check(s, &BucketType))
if (PyObject_IsInstance(s, (PyObject *)&BucketType))
{
i->set = s;
Py_INCREF(s);
......@@ -82,7 +82,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
i->hasValue=1;
}
else if (ExtensionClassSubclassInstance_Check(s, &SetType))
else if (PyObject_IsInstance(s, (PyObject *)&SetType))
{
i->set = s;
Py_INCREF(s);
......@@ -90,7 +90,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
i->next=nextSet;
i->hasValue=0;
}
else if (ExtensionClassSubclassInstance_Check(s, &BTreeType))
else if (PyObject_IsInstance(s, (PyObject *)&BTreeType))
{
i->set=BTree_rangeSearch(BTREE(s), NULL, 'i');
UNLESS(i->set) return -1;
......@@ -104,7 +104,7 @@ initSetIteration(SetIteration *i, PyObject *s, int w, int *merge)
i->next=nextTreeSetItems;
i->hasValue=1;
}
else if (ExtensionClassSubclassInstance_Check(s, &TreeSetType))
else if (PyObject_IsInstance(s, (PyObject *)&TreeSetType))
{
i->set=BTree_rangeSearch(BTREE(s), NULL, 'k');
UNLESS(i->set) return -1;
......
......@@ -12,7 +12,7 @@
****************************************************************************/
#define SETTEMPLATE_C "$Id: SetTemplate.c,v 1.13 2002/02/11 23:40:40 gvanrossum Exp $\n"
#define SETTEMPLATE_C "$Id: SetTemplate.c,v 1.14 2002/02/20 23:59:51 jeremy Exp $\n"
static PyObject *
Set_insert(Bucket *self, PyObject *args)
......@@ -236,37 +236,48 @@ static PySequenceMethods set_as_sequence = {
(intintobjargproc)0, /*sq_ass_slice*/
};
static PyExtensionClass SetType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
MOD_NAME_PREFIX "Set", /*tp_name*/
sizeof(Bucket), /*tp_basicsize*/
0, /*tp_itemsize*/
/*********** methods ***********************/
(destructor) Bucket_dealloc, /*tp_dealloc*/
(printfunc)0, /*tp_print*/
(getattrfunc)0, /*obsolete tp_getattr*/
(setattrfunc)0, /*obsolete tp_setattr*/
(cmpfunc)0, /*tp_compare*/
(reprfunc) set_repr, /*tp_repr*/
0, /*tp_as_number*/
&set_as_sequence, /*tp_as_sequence*/
0, /*tp_as_mapping*/
(hashfunc)0, /*tp_hash*/
(ternaryfunc)0, /*tp_call*/
(reprfunc)0, /*tp_str*/
(getattrofunc)0, /*tp_getattro*/
0, /*tp_setattro*/
/* Space for future expansion */
0L,0L,
"Set implemented as sorted keys",
METHOD_CHAIN(Set_methods),
EXTENSIONCLASS_BASICNEW_FLAG
#ifdef PERSISTENT
| PERSISTENT_TYPE_FLAG
#endif
| EXTENSIONCLASS_NOINSTDICT_FLAG,
static PyTypeObject SetType = {
PyObject_HEAD_INIT(NULL) /* PyPersist_Type */
0, /* ob_size */
MOD_NAME_PREFIX "Set", /* tp_name */
sizeof(Bucket), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)bucket_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
(reprfunc)set_repr, /* tp_repr */
0, /* tp_as_number */
&set_as_sequence, /* tp_as_sequence */
0, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
/* XXX need to define traverse and clear functions */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE, /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
Set_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
static int
......
......@@ -12,7 +12,7 @@
****************************************************************************/
#define TREESETTEMPLATE_C "$Id: TreeSetTemplate.c,v 1.11 2002/02/11 23:40:40 gvanrossum Exp $\n"
#define TREESETTEMPLATE_C "$Id: TreeSetTemplate.c,v 1.12 2002/02/20 23:59:51 jeremy Exp $\n"
static PyObject *
TreeSet_insert(BTree *self, PyObject *args)
......@@ -127,35 +127,46 @@ static PyMappingMethods TreeSet_as_mapping = {
(inquiry)BTree_length, /*mp_length*/
};
static PyExtensionClass TreeSetType = {
PyObject_HEAD_INIT(NULL)
0, /*ob_size*/
MOD_NAME_PREFIX "TreeSet", /*tp_name*/
sizeof(BTree), /*tp_basicsize*/
0, /*tp_itemsize*/
/************* methods ********************/
(destructor) BTree_dealloc, /*tp_dealloc*/
(printfunc)0, /*tp_print*/
(getattrfunc)0, /*obsolete tp_getattr*/
(setattrfunc)0, /*obsolete tp_setattr*/
(cmpfunc)0, /*tp_compare*/
(reprfunc)0, /*tp_repr*/
&BTree_as_number_for_nonzero, /*tp_as_number*/
0, /*tp_as_sequence*/
&TreeSet_as_mapping, /*tp_as_mapping*/
(hashfunc)0, /*tp_hash*/
(ternaryfunc)0, /*tp_call*/
(reprfunc)0, /*tp_str*/
(getattrofunc)0,
0, /*tp_setattro*/
/* Space for future expansion */
0L,0L,
"Set implemented as sorted tree of items",
METHOD_CHAIN(TreeSet_methods),
EXTENSIONCLASS_BASICNEW_FLAG
#ifdef PERSISTENT
| PERSISTENT_TYPE_FLAG
#endif
| EXTENSIONCLASS_NOINSTDICT_FLAG,
static PyTypeObject TreeSetType = {
PyObject_HEAD_INIT(NULL) /* PyPersist_Type */
0, /* ob_size */
MOD_NAME_PREFIX "TreeSet", /* tp_name */
sizeof(BTree), /* tp_basicsize */
0, /* tp_itemsize */
(destructor)BTree_dealloc, /* tp_dealloc */
0, /* tp_print */
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_compare */
0, /* tp_repr */
&BTree_as_number_for_nonzero, /* tp_as_number */
0, /* tp_as_sequence */
&TreeSet_as_mapping, /* tp_as_mapping */
0, /* tp_hash */
0, /* tp_call */
0, /* tp_str */
0, /* tp_getattro */
0, /* tp_setattro */
0, /* tp_as_buffer */
/* XXX need to define traverse and clear functions */
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
Py_TPFLAGS_BASETYPE, /* tp_flags */
0, /* tp_doc */
0, /* tp_traverse */
0, /* tp_clear */
0, /* tp_richcompare */
0, /* tp_weaklistoffset */
0, /* tp_iter */
0, /* tp_iternext */
TreeSet_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
0, /* tp_base */
0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
0, /* tp_init */
0, /* tp_alloc */
PyType_GenericNew, /* tp_new */
};
/* Setup template macros */
#define MASTER_ID "$Id: _IIBTree.c,v 1.3 2001/04/02 16:31:05 jeremy Exp $\n"
#define MASTER_ID "$Id: _IIBTree.c,v 1.4 2002/02/20 23:59:51 jeremy Exp $\n"
#define PERSISTENT
......@@ -11,7 +11,6 @@
#include "intkeymacros.h"
#include "intvaluemacros.h"
#include "cPersistence.h"
#ifndef EXCLUDE_INTSET_SUPPORT
#include "BTree/intSet.h"
#endif
......
#define MASTER_ID "$Id: _IOBTree.c,v 1.3 2001/04/02 16:31:05 jeremy Exp $\n"
#define MASTER_ID "$Id: _IOBTree.c,v 1.4 2002/02/20 23:59:51 jeremy Exp $\n"
#define PERSISTENT
......@@ -10,7 +10,6 @@
#include "intkeymacros.h"
#include "objectvaluemacros.h"
#include "cPersistence.h"
#ifndef EXCLUDE_INTSET_SUPPORT
#include "BTree/intSet.h"
#endif
......
import ZODB
##import ZODB
try: import intSet
except: pass
else: del intSet
##try: import intSet
##except: pass
##else: del intSet
# Register interfaces
try: import Interface
except ImportError: pass # Don't register interfaces if no scarecrow
else:
import Interfaces
del Interfaces
del Interface
### Register interfaces
##try: import Interface
##except ImportError: pass # Don't register interfaces if no scarecrow
##else:
## import Interfaces
## del Interfaces
## del Interface
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