Title: [commits] (vajda) [11181] - added support for RefDict, a dict of RefList (ref collections)
Revision
11181
Author
vajda
Date
2006-07-17 10:08:37 -0700 (Mon, 17 Jul 2006)

Log Message

- added support for RefDict, a dict of RefList (ref collections)
- refactored watchers to use RefDict
- refactored transient watchers to resemble persistent watchers
- added support for ad-hoc attributes (free item values)
- changed getValue() to raise error is no value and no default provided
- version 0.6-31

Modified Paths

Diff

Modified: trunk/internal/chandlerdb/Makefile (11180 => 11181)

--- trunk/internal/chandlerdb/Makefile	2006-07-17 16:55:14 UTC (rev 11180)
+++ trunk/internal/chandlerdb/Makefile	2006-07-17 17:08:37 UTC (rev 11181)
@@ -1,5 +1,5 @@
 
-RELVER=0.6-$(BRANCH_REV_PREFIX)30
+RELVER=0.6-$(BRANCH_REV_PREFIX)31
 CHANDLERDB=$(INTERNAL)/chandlerdb
 DB_VER=4.4
 SRC=""

Modified: trunk/internal/chandlerdb/chandlerdb/item/c.c (11180 => 11181)

--- trunk/internal/chandlerdb/chandlerdb/item/c.c	2006-07-17 16:55:14 UTC (rev 11180)
+++ trunk/internal/chandlerdb/chandlerdb/item/c.c	2006-07-17 17:08:37 UTC (rev 11181)
@@ -32,7 +32,6 @@
 PyObject *Default = NULL;
 
 CView_invokeMonitors_fn CView_invokeMonitors;
-CView_invokeWatchers_fn CView_invokeWatchers;
 PyUUID_Check_fn PyUUID_Check;
 PyCFunction _countAccess;
 
@@ -143,6 +142,5 @@
 
     m = PyImport_ImportModule("chandlerdb.persistence.c");
     LOAD_FN(m, CView_invokeMonitors);
-    LOAD_FN(m, CView_invokeWatchers);
     Py_DECREF(m);
 }    

Modified: trunk/internal/chandlerdb/chandlerdb/item/c.h (11180 => 11181)

--- trunk/internal/chandlerdb/chandlerdb/item/c.h	2006-07-17 16:55:14 UTC (rev 11180)
+++ trunk/internal/chandlerdb/chandlerdb/item/c.h	2006-07-17 17:08:37 UTC (rev 11181)
@@ -46,7 +46,6 @@
 extern PyObject *Default;
 
 extern CView_invokeMonitors_fn CView_invokeMonitors;
-extern CView_invokeWatchers_fn CView_invokeWatchers;
 extern PyUUID_Check_fn PyUUID_Check;
 extern PyCFunction _countAccess;
 

Modified: trunk/internal/chandlerdb/chandlerdb/item/item.c (11180 => 11181)

--- trunk/internal/chandlerdb/chandlerdb/item/item.c	2006-07-17 16:55:14 UTC (rev 11180)
+++ trunk/internal/chandlerdb/chandlerdb/item/item.c	2006-07-17 17:08:37 UTC (rev 11181)
@@ -96,7 +96,7 @@
 static PyObject *_logItem_NAME;
 static PyObject *_clearDirties_NAME;
 static PyObject *_flags_NAME;
-static PyObject *watchers_NAME, *watcherDispatch_NAME;
+static PyObject *watchers_NAME;
 static PyObject *filterItem_NAME;
 static PyObject *_setParent_NAME;
 static PyObject *_setItem_NAME;
@@ -1061,6 +1061,43 @@
     Py_RETURN_FALSE;
 }
 
+static int invokeWatchers(PyObject *dispatch, PyObject *name,
+                          PyObject *op, PyObject *change,
+                          PyObject *item, PyObject *other)
+{
+    PyObject *watchers = PyObject_GetItem(dispatch, name);
+
+    if (watchers)
+    {
+        PyObject *iter = PyObject_GetIter(watchers);
+        Py_DECREF(watchers);
+
+        if (iter)
+        {
+            PyObject *watcher;
+
+            while ((watcher = PyIter_Next(iter))) {
+                PyObject *args = PyTuple_Pack(5, op, change, item, name, other);
+                PyObject *obj = PyObject_Call(watcher, args, NULL);
+
+                Py_DECREF(args);
+                Py_DECREF(watcher);
+                if (!obj)
+                    break;
+                Py_DECREF(obj);
+            }
+            Py_DECREF(iter);
+
+            if (PyErr_Occurred())
+                return -1;
+        }
+
+        return 0;
+    }
+
+    return -1;
+}
+
 static PyObject *t_item__collectionChanged(t_item *self, PyObject *args)
 {
     PyObject *op, *change, *name, *other, *dispatch;
@@ -1072,98 +1109,53 @@
     if (!PyArg_ParseTuple(args, "OOOO", &op, &change, &name, &other))
         return NULL;
 
-    dispatch = PyDict_GetItem(self->values->dict, watcherDispatch_NAME);
-    if (dispatch)
-    {
-        PyObject *watchers = PyDict_GetItem(dispatch, name);
-
-        if (watchers &&
-            CView_invokeWatchers(view, watchers, op, change,
-                                 (PyObject *) self, name, other) < 0)
+    dispatch = PyDict_GetItem(self->references->dict, watchers_NAME);
+    if (dispatch && PySequence_Contains(dispatch, name))
+        if (invokeWatchers(dispatch, name, op, change,
+                           (PyObject *) self, other) < 0)
             return NULL;
-    }
 
-    if (view->watcherDispatch)
+    if (view->watchers)
     {
-        PyObject *dispatch = PyDict_GetItem(view->watcherDispatch, self->uuid);
+        dispatch = PyDict_GetItem(view->watchers, self->uuid);
 
-        if (dispatch)
-        {
-            PyObject *watchers = PyDict_GetItem(dispatch, name);
-
-            if (watchers &&
-                CView_invokeWatchers(view, watchers, op, change,
-                                     (PyObject *) self, name, other) < 0)
+        if (dispatch && PySequence_Contains(dispatch, name))
+            if (invokeWatchers(dispatch, name, op, change,
+                               (PyObject *) self, other) < 0)
                 return NULL;
-        }
     }
 
     Py_RETURN_NONE;
 }
 
-static int __t_item__itemChanged(t_item *self, PyObject *dispatch,
-                                 PyObject *op, PyObject *names)
+static int invokeItemWatchers(PyObject *dispatch, PyObject *uItem,
+                              PyObject *op, PyObject *names)
 {
-    /* name part of item watch is None */
-    PyObject *watchers = PyDict_GetItem(dispatch, Py_None); 
+    PyObject *watchers = PyObject_GetItem(dispatch, uItem);
 
     if (watchers)
     {
-        PyObject *dict, *key, *value;
-        int pos = 0;
+        PyObject *iter = PyObject_GetIter(watchers);
+        Py_DECREF(watchers);
 
-        if (!PyAnySet_Check(watchers))
+        if (iter)
         {
-            PyErr_SetObject(PyExc_TypeError, watchers);
-            return -1;
-        }
+            PyObject *watcher;
 
-        /* a set's dict is organized as { value: True } */
-        dict = ((PySetObject *) watchers)->data;
+            while ((watcher = PyIter_Next(iter))) {
+                PyObject *args = PyTuple_Pack(3, op, uItem, names);
+                PyObject *obj = PyObject_Call(watcher, args, NULL);
 
-        while (PyDict_Next(dict, &pos, &key, &value)) {
-            PyObject *watcher = PyTuple_GetItem(key, 0);
-            PyObject *watch = PyTuple_GetItem(key, 1);
-
-            if (!watcher || !watch)
-                return -1;
-
-            if (!PyObject_Compare(watch, item_NAME))
-            {
-                PyObject *methName, *result;
-
-                if (PyObject_TypeCheck(watcher, SingleRef))
-                    watcher = PyObject_GetItem(((t_item *) self->root)->parent,
-                                               ((t_sr *) watcher)->uuid);
-                else if (PyUUID_Check(watcher))
-                    watcher = PyObject_GetItem(((t_item *) self->root)->parent,
-                                               watcher);
-                else
-                {
-                    PyErr_SetObject(PyExc_TypeError, watcher);
-                    return -1;
-                }
-
-                if (!watcher)
-                {
-                    /* kludge until watchers use bi-refs */
-                    if (PyErr_Occurred() == PyExc_KeyError)
-                    {
-                        PyErr_Clear();
-                        continue;
-                    }
-                    return -1;
-                }
-
-                methName = PyTuple_GetItem(key, 2);
-                result = PyObject_CallMethodObjArgs(watcher, methName, 
-                                                    op, self->uuid, names,
-                                                    NULL);
+                Py_DECREF(args);
                 Py_DECREF(watcher);
-                if (!result)
-                    return -1;
-                Py_DECREF(result);
+                if (!obj)
+                    break;
+                Py_DECREF(obj);
             }
+            Py_DECREF(iter);
+
+            if (PyErr_Occurred())
+                return -1;
         }
     }
 
@@ -1177,25 +1169,23 @@
 
     if (self->status & P_WATCHED)
     {
-        PyObject *dispatch =
-            PyDict_GetItem(self->values->dict, watcherDispatch_NAME);
+        PyObject *dispatch = PyDict_GetItem(self->references->dict,
+                                            watchers_NAME);
 
-        if (dispatch && __t_item__itemChanged(self, dispatch, op, names) < 0)
-            return -1;
+        if (dispatch && PySequence_Contains(dispatch, self->uuid))
+            return invokeItemWatchers(dispatch, self->uuid, op, names);
     }
 
     if (self->status & T_WATCHED)
     {
         t_view *view = (t_view *) ((t_item *) self->root)->parent;
 
-        if (view->watcherDispatch)
+        if (view->watchers)
         {
-            PyObject *dispatch =
-                PyDict_GetItem(view->watcherDispatch, self->uuid);
+            PyObject *dispatch = PyDict_GetItem(view->watchers, self->uuid);
 
-            if (dispatch &&
-                __t_item__itemChanged(self, dispatch, op, names) < 0)
-                return -1;
+            if (dispatch && PySequence_Contains(dispatch, self->uuid))
+                return invokeItemWatchers(dispatch, self->uuid, op, names);
         }
     }
 
@@ -1516,7 +1506,6 @@
             _clearDirties_NAME = PyString_FromString("_clearDirties");
             _flags_NAME = PyString_FromString("_flags");
             watchers_NAME = PyString_FromString("watchers");
-            watcherDispatch_NAME = PyString_FromString("watcherDispatch");
             filterItem_NAME = PyString_FromString("filterItem");
             _setParent_NAME = PyString_FromString("_setParent");
             _setItem_NAME = PyString_FromString("_setItem");

Modified: trunk/internal/chandlerdb/chandlerdb/persistence/container.c (11180 => 11181)

--- trunk/internal/chandlerdb/chandlerdb/persistence/container.c	2006-07-17 16:55:14 UTC (rev 11180)
+++ trunk/internal/chandlerdb/chandlerdb/persistence/container.c	2006-07-17 17:08:37 UTC (rev 11181)
@@ -915,12 +915,13 @@
                           Py_RETURN_NONE;
                       else
                       {
-                          PyObject *tuple = PyTuple_New(3);
+                          PyObject *tuple = PyTuple_New(4);
                           int pos = 0;
 
                           PyTuple_SET_ITEM(tuple, 0, _readValue(buffer, &pos));
                           PyTuple_SET_ITEM(tuple, 1, _readValue(buffer, &pos));
                           PyTuple_SET_ITEM(tuple, 2, _readValue(buffer, &pos));
+                          PyTuple_SET_ITEM(tuple, 3, _readValue(buffer, &pos));
 
                           if (buffer != data.buffer)
                               free(buffer);
@@ -960,14 +961,14 @@
 
 static PyObject *t_ref_container_saveRef(t_ref_container *self, PyObject *args)
 {
-    PyObject *txn, *previous, *next, *alias;
+    PyObject *txn, *previous, *next, *alias, *otherKey;
     char *uCol, *uRef;
     int uColLen, uRefLen;
     unsigned long long version;
 
-    if (!PyArg_ParseTuple(args, "Os#Ks#OOO", &txn, &uCol, &uColLen,
+    if (!PyArg_ParseTuple(args, "Os#Ks#OOOO", &txn, &uCol, &uColLen,
                           &version, &uRef, &uRefLen, 
-                          &previous, &next, &alias))
+                          &previous, &next, &alias, &otherKey))
         return NULL;
 
     if (txn != Py_None && !PyObject_TypeCheck(txn, CDBTxn))
@@ -991,7 +992,7 @@
     {
         DB_TXN *db_txn = txn == Py_None ? NULL : ((t_txn *) txn)->txn;
         DB *db = (((t_container *) self)->db)->db;
-        valueType prevType, nextType, aliasType;
+        valueType prevType, nextType, aliasType, otherKeyType;
         char keyBuffer[40], *dataBuffer, stackBuffer[128];
         DBT key, data;
         int len, err;
@@ -1008,6 +1009,7 @@
         len += _size_valueType(previous, &prevType);
         len += _size_valueType(next, &nextType);
         len += _size_valueType(alias, &aliasType);
+        len += _size_valueType(otherKey, &otherKeyType);
 
         if (len > sizeof(stackBuffer))
         {
@@ -1025,6 +1027,7 @@
         len += _writeValue(dataBuffer + len, previous, prevType);
         len += _writeValue(dataBuffer + len, next, nextType);
         len += _writeValue(dataBuffer + len, alias, aliasType);
+        len += _writeValue(dataBuffer + len, otherKey, otherKeyType);
         memset(&data, 0, sizeof(data));
         data.data = ""
         data.size = len;

Modified: trunk/internal/chandlerdb/chandlerdb/persistence/view.c (11180 => 11181)

--- trunk/internal/chandlerdb/chandlerdb/persistence/view.c	2006-07-17 16:55:14 UTC (rev 11180)
+++ trunk/internal/chandlerdb/chandlerdb/persistence/view.c	2006-07-17 17:08:37 UTC (rev 11181)
@@ -64,7 +64,6 @@
 static PyObject *t_view_getSingleton(t_view *self, PyObject *key);
 static PyObject *t_view_setSingleton(t_view *self, PyObject *args);
 static PyObject *t_view_invokeMonitors(t_view *self, PyObject *args);
-static PyObject *t_view_invokeWatchers(t_view *self, PyObject *args);
 static PyObject *t_view_debugOn(t_view *self, PyObject *arg);
 
 static int t_view_dict_length(t_view *self);
@@ -96,7 +95,7 @@
     { "_registry", T_OBJECT, offsetof(t_view, registry), 0, "" },
     { "_deletedRegistry", T_OBJECT, offsetof(t_view, deletedRegistry), 0, "" },
     { "_monitors", T_OBJECT, offsetof(t_view, monitors), 0, "" },
-    { "_watcherDispatch", T_OBJECT, offsetof(t_view, watcherDispatch), 0, "" },
+    { "_watchers", T_OBJECT, offsetof(t_view, watchers), 0, "" },
     { "_debugOn", T_OBJECT, offsetof(t_view, debugOn), 0, "" },
     { "_deferredDeletes", T_OBJECT, offsetof(t_view, deferredDeletes), 0, "" },
     { NULL, 0, 0, 0, NULL }
@@ -128,7 +127,6 @@
     { "getSingleton", (PyCFunction) t_view_getSingleton, METH_O, NULL },
     { "setSingleton", (PyCFunction) t_view_setSingleton, METH_VARARGS, "" },
     { "invokeMonitors", (PyCFunction) t_view_invokeMonitors, METH_VARARGS, "" },
-    { "invokeWatchers", (PyCFunction) t_view_invokeWatchers, METH_VARARGS, "" },
     { "debugOn", (PyCFunction) t_view_debugOn, METH_O, "" },
     { NULL, NULL, 0, NULL }
 };
@@ -220,9 +218,9 @@
     Py_VISIT(self->registry);
     Py_VISIT(self->deletedRegistry);
     Py_VISIT(self->uuid);
-    Py_VISIT(self->monitors);
     Py_VISIT(self->singletons);
-    Py_VISIT(self->watcherDispatch);
+    Py_VISIT(self->monitors);
+    Py_VISIT(self->watchers);
     Py_VISIT(self->debugOn);
     Py_VISIT(self->deferredDeletes);
 
@@ -237,9 +235,9 @@
     Py_CLEAR(self->registry);
     Py_CLEAR(self->deletedRegistry);
     Py_CLEAR(self->uuid);
-    Py_CLEAR(self->monitors);
     Py_CLEAR(self->singletons);
-    Py_CLEAR(self->watcherDispatch);
+    Py_CLEAR(self->monitors);
+    Py_CLEAR(self->watchers);
     Py_CLEAR(self->debugOn);
     Py_CLEAR(self->deferredDeletes);
 
@@ -275,9 +273,9 @@
     self->registry = NULL;
     self->deletedRegistry = NULL;
     Py_INCREF(uuid); self->uuid = uuid;
-    self->monitors = NULL;
     self->singletons = PyDict_New();
-    self->watcherDispatch = NULL;
+    self->monitors = NULL;
+    self->watchers = NULL;
     self->debugOn = NULL;
     self->deferredDeletes = PyList_New(0);
 
@@ -939,142 +937,6 @@
     Py_RETURN_NONE;
 }
 
-static int _t_view_invokeWatchers(t_view *self, PyObject *watchers,
-                                  PyObject *op, PyObject *change,
-                                  PyObject *owner, PyObject *name,
-                                  PyObject *other)
-{
-    PyObject *dict, *key, *value;
-    int pos = 0;
-
-    if (!PyAnySet_Check(watchers))
-    {
-        PyErr_SetObject(PyExc_TypeError, watchers);
-        return -1;
-    }
-
-    /* a set's dict is organized as { value: True } */
-    dict = ((PySetObject *) watchers)->data;
-
-    while (PyDict_Next(dict, &pos, &key, &value)) {
-        PyObject *watcher = PyTuple_GetItem(key, 0);
-        PyObject *watch = PyTuple_GetItem(key, 1);
-
-        if (!watcher || !watch)
-            return -1;
-
-        if (PyObject_TypeCheck(watcher, SingleRef))
-            watcher = t_view_dict_get(self, ((t_sr *) watcher)->uuid);
-        else if (PyUUID_Check(watcher))
-            watcher = t_view_dict_get(self, watcher);
-        else
-        {
-            PyErr_SetObject(PyExc_TypeError, watcher);
-            return -1;
-        }
-
-        if (!watcher)
-        {
-            if (PyErr_Occurred() == PyExc_KeyError)
-            {
-                PyErr_Clear();
-                continue;
-            }
-            return -1;
-        }
-
-        if (!PyObject_Compare(watch, set_NAME))
-        {
-            PyObject *attrName = PyTuple_GetItem(key, 2);
-            PyObject *set = PyObject_GetAttr(watcher, attrName);
-            PyObject *result;
-
-            if (!set)
-            {
-                Py_DECREF(watcher);
-                return -1;
-            }
-
-            result = PyObject_CallMethodObjArgs(set, sourceChanged_NAME,
-                                                op, change, owner, name,
-                                                Py_False, other, NULL);
-            Py_DECREF(watcher);
-            Py_DECREF(set);
-
-            if (!result)
-                return -1;
-            Py_DECREF(result);
-        }
-        else if (!PyObject_Compare(watch, kind_NAME))
-        {
-            PyObject *methName = PyTuple_GetItem(key, 2);
-            PyObject *result, *kind;
-
-            if (PyUUID_Check(owner))
-            {
-                PyObject *extent = t_view_dict_get(self, owner);
-
-                if (!extent)
-                {
-                    Py_DECREF(watcher);
-                    return -1;
-                }
-
-                kind = PyObject_GetAttr(extent, kind_NAME);
-                Py_DECREF(extent);
-            }
-            else
-                kind = PyObject_GetAttr(owner, kind_NAME);
-
-            if (!kind)
-            {
-                Py_DECREF(watcher);
-                return -1;
-            }
-
-            result = PyObject_CallMethodObjArgs(watcher, methName,
-                                                op, kind, other, NULL);
-            Py_DECREF(kind);
-            Py_DECREF(watcher);
-
-            if (!result)
-                return -1;
-            Py_DECREF(result);
-        }
-        else if (!PyObject_Compare(watch, collection_NAME))
-        {
-            PyObject *methName = PyTuple_GetItem(key, 2);
-            PyObject *result =
-                PyObject_CallMethodObjArgs(watcher, methName,
-                                           op, owner, name, other, NULL);
-
-            Py_DECREF(watcher);
-            if (!result)
-                return -1;
-            Py_DECREF(result);
-        }
-        else
-            Py_DECREF(watcher);
-    }
-
-    return 0;
-}
-
-static PyObject *t_view_invokeWatchers(t_view *self, PyObject *args)
-{
-    PyObject *watchers, *op, *change, *owner, *name, *other;
-
-    if (!PyArg_ParseTuple(args, "OOOOOO", &watchers, &op, &change,
-                          &owner, &name, &other))
-        return NULL;
-
-    if (_t_view_invokeWatchers(self, watchers, op, change,
-                               owner, name, other) < 0)
-        return NULL;
-
-    Py_RETURN_NONE;
-}
-
 static int _debugOn(PyObject *obj, PyFrameObject *frame,
                     int what, PyObject *arg)
 {
@@ -1166,8 +1028,6 @@
 
             cobj = PyCObject_FromVoidPtr(t_view_invokeMonitors, NULL);
             PyModule_AddObject(m, "CView_invokeMonitors", cobj);
-            cobj = PyCObject_FromVoidPtr(_t_view_invokeWatchers, NULL);
-            PyModule_AddObject(m, "CView_invokeWatchers", cobj);
         }
     }
 }

Modified: trunk/internal/chandlerdb/chandlerdb/persistence/view.h (11180 => 11181)

--- trunk/internal/chandlerdb/chandlerdb/persistence/view.h	2006-07-17 16:55:14 UTC (rev 11180)
+++ trunk/internal/chandlerdb/chandlerdb/persistence/view.h	2006-07-17 17:08:37 UTC (rev 11181)
@@ -27,9 +27,9 @@
     PyObject *registry;
     PyObject *deletedRegistry;
     PyObject *uuid;
+    PyObject *singletons;
     PyObject *monitors;
-    PyObject *singletons;
-    PyObject *watcherDispatch;
+    PyObject *watchers;
     PyObject *debugOn;
     PyObject *deferredDeletes;
 } t_view;

Modified: trunk/internal/chandlerdb/chandlerdb/schema/descriptor.c (11180 => 11181)

--- trunk/internal/chandlerdb/chandlerdb/schema/descriptor.c	2006-07-17 16:55:14 UTC (rev 11180)
+++ trunk/internal/chandlerdb/chandlerdb/schema/descriptor.c	2006-07-17 17:08:37 UTC (rev 11181)
@@ -318,7 +318,7 @@
                     }
                 }
 
-                value = PyObject_CallMethodObjArgs(obj, setAttributeValue_NAME, self->name, value, attrDict ? (PyObject *) attrDict : Py_None, flags & REF ? attr->otherName : Py_None, Py_True, Py_False, NULL);
+                value = PyObject_CallMethodObjArgs(obj, setAttributeValue_NAME, self->name, value, attrDict ? (PyObject *) attrDict : Py_None, flags & REF ? attr->otherName : Py_None, Py_True, NULL);
 
                 if (!value)
                     return -1;

Modified: trunk/internal/chandlerdb/chandlerdb/util/linkedmap.c (11180 => 11181)

--- trunk/internal/chandlerdb/chandlerdb/util/linkedmap.c	2006-07-17 16:55:14 UTC (rev 11180)
+++ trunk/internal/chandlerdb/chandlerdb/util/linkedmap.c	2006-07-17 17:08:37 UTC (rev 11181)
@@ -64,6 +64,7 @@
 
 static PyMemberDef t_link_members[] = {
     { "_value", T_OBJECT, offsetof(t_link, value), 0, "" },
+    { "_otherKey", T_OBJECT, offsetof(t_link, otherKey), 0, "" },
     { NULL, 0, 0, 0, NULL }
 };
 
@@ -151,6 +152,7 @@
     Py_VISIT(self->nextKey);
     Py_VISIT(self->value);
     Py_VISIT(self->alias);
+    Py_VISIT(self->otherKey);
 
     return 0;
 }
@@ -162,6 +164,7 @@
     Py_CLEAR(self->nextKey);
     Py_CLEAR(self->value);
     Py_CLEAR(self->alias);
+    Py_CLEAR(self->otherKey);
 
     return 0;
 }
@@ -177,6 +180,7 @@
         self->nextKey = NULL;
         self->value = NULL;
         self->alias = NULL;
+        self->otherKey = NULL;
     }
 
     return (PyObject *) self;
@@ -185,7 +189,7 @@
 static int _t_link_init(t_link *self,
                         PyObject *owner, PyObject *value,
                         PyObject *previousKey, PyObject *nextKey,
-                        PyObject *alias)
+                        PyObject *alias, PyObject *otherKey)
 {
     Py_INCREF(owner); Py_XDECREF(self->owner);
     self->owner = owner;
@@ -202,19 +206,24 @@
     Py_INCREF(alias); Py_XDECREF(self->alias);
     self->alias = alias;
 
+    Py_INCREF(otherKey); Py_XDECREF(self->otherKey);
+    self->otherKey = otherKey;
+
     return 0;
 }
 
 static int t_link_init(t_link *self, PyObject *args, PyObject *kwds)
 {
     PyObject *owner, *value;
-    PyObject *previousKey = Py_None, *nextKey = Py_None, *alias = Py_None;
+    PyObject *previousKey = Py_None, *nextKey = Py_None;
+    PyObject *alias = Py_None, *otherKey = Py_None;
 
-    if (!PyArg_ParseTuple(args, "OO|OOO", &owner, &value,
-                          &previousKey, &nextKey, &alias))
+    if (!PyArg_ParseTuple(args, "OO|OOOO", &owner, &value,
+                          &previousKey, &nextKey, &alias, &otherKey))
         return -1;
     else
-        return _t_link_init(self, owner, value, previousKey, nextKey, alias);
+        return _t_link_init(self, owner, value, previousKey, nextKey,
+                            alias, otherKey);
 }
 
 static PyObject *t_link_repr(t_link *self)
@@ -254,6 +263,10 @@
         Py_INCREF(obj); Py_XDECREF(self->alias);
         self->alias = obj;
 
+        obj = ((t_link *) arg)->otherKey;
+        Py_INCREF(obj); Py_XDECREF(self->otherKey);
+        self->otherKey = obj;
+
         Py_RETURN_NONE;
     }
 }
@@ -561,7 +574,7 @@
         PyObject *link = t_link_new(&LinkType, NULL, NULL);
 
         _t_link_init((t_link *) link, (PyObject *) self, Py_None,
-                     Py_None, Py_None, Py_None);
+                     Py_None, Py_None, Py_None, Py_None);
 
         Py_XDECREF(self->head);
         self->head = link;

Modified: trunk/internal/chandlerdb/chandlerdb/util/linkedmap.h (11180 => 11181)

--- trunk/internal/chandlerdb/chandlerdb/util/linkedmap.h	2006-07-17 16:55:14 UTC (rev 11180)
+++ trunk/internal/chandlerdb/chandlerdb/util/linkedmap.h	2006-07-17 17:08:37 UTC (rev 11181)
@@ -22,6 +22,7 @@
     PyObject *nextKey;
     PyObject *value;
     PyObject *alias;
+    PyObject *otherKey;
 } t_link;
 
 




_______________________________________________
Commits mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/commits

Reply via email to