[Zope3-checkins] CVS: Zope3/src/zope/proxy/context - decorator.h:1.3 decorator.c:1.4

Steve Alexander steve@cat-box.net
Thu, 8 May 2003 11:16:34 -0400


Update of /cvs-repository/Zope3/src/zope/proxy/context
In directory cvs.zope.org:/tmp/cvs-serv22379/src/zope/proxy/context

Modified Files:
	decorator.h decorator.c 
Log Message:
Removed providedby support from decorators.
This can be provided (n.p.i.) in the mixin class, so there's no need
to complicate the decorator code.


=== Zope3/src/zope/proxy/context/decorator.h 1.2 => 1.3 ===
--- Zope3/src/zope/proxy/context/decorator.h:1.2	Thu May  8 10:51:01 2003
+++ Zope3/src/zope/proxy/context/decorator.h	Thu May  8 11:16:34 2003
@@ -18,18 +18,15 @@
     PyObject *mixin;
     PyObject *names;
     PyObject *names_dict;
-    PyObject *providedby;
 } DecoratorObject;
 
 typedef struct {
     int (*check)(PyObject *obj);
     PyObject *(*create)(PyObject *object, PyObject *context,
-        PyObject *mixin_factory, PyObject *names, PyObject *providedby);
+        PyObject *mixin_factory, PyObject *names);
     PyObject *(*getmixin)(PyObject *wrapper);
     PyObject *(*getmixinfactory)(PyObject *wrapper);
     PyObject *(*getnames)(PyObject *wrapper);
-    PyObject *(*getprovidedby)(PyObject *wrapper);
-    int (*setprovidedby)(PyObject *wrapper, PyObject *providedby);
 } DecoratorInterface;
 
 
@@ -62,19 +59,15 @@
 
 #define Decorator_Check(obj)                                              \
         (_decorator_api->check((obj)))
-#define Decorator_New(object, context, mixin_factory, names, providedby)  \
+#define Decorator_New(object, context, mixin_factory, names)  \
         (_decorator_api->create((object), (context), (mixin_factory),     \
-                                (names), (providedby)))
+                                (names)))
 #define Decorator_GetMixin(wrapper)                                       \
         (_decorator_api->getmixin((wrapper)))
 #define Decorator_GetMixinFactory(wrapper)                                \
         (_decorator_api->getmixinfactory((wrapper)))
 #define Decorator_GetNames(wrapper)                                       \
         (_decorator_api->getnames((wrapper)))
-#define Decorator_GetProvides(wrapper)                                    \
-        (_decorator_api->getprovidedby((wrapper)))
-#define Decorator_SetProvides(wrapper, providedby)                        \
-        (_decorator_api->setprovidedby((wrapper), (providedby)))
 
 #endif
 


=== Zope3/src/zope/proxy/context/decorator.c 1.3 => 1.4 ===
--- Zope3/src/zope/proxy/context/decorator.c:1.3	Thu May  8 10:51:01 2003
+++ Zope3/src/zope/proxy/context/decorator.c	Thu May  8 11:16:34 2003
@@ -23,9 +23,6 @@
 #define Decorator_GetNamesDict(wrapper) \
     (((DecoratorObject *)wrapper)->names_dict)
 
-#define Decorator_GetProvidedby(wrapper) \
-    (((DecoratorObject *)wrapper)->providedby)
-
 static PyTypeObject DecoratorType;
 
 static PyObject *empty_tuple = NULL;
@@ -84,10 +81,9 @@
     PyObject *object;
     PyObject *mixin_factory;
     PyObject *names;
-    PyObject *providedby;
 
-    if (PyArg_UnpackTuple(args, "__new__", 1, 5, &object, &context,
-            &mixin_factory, &names, &providedby)) {
+    if (PyArg_UnpackTuple(args, "__new__", 1, 4, &object, &context,
+            &mixin_factory, &names)) {
         PyObject *wrapperargs = create_wrapper_args(args, object, context);
         if (wrapperargs == NULL)
             goto finally;
@@ -107,11 +103,10 @@
     PyObject *object;
     PyObject *mixin_factory = NULL;
     PyObject *names = NULL;
-    PyObject *providedby = NULL;
     PyObject *fast_names = NULL;
 
-    if (PyArg_UnpackTuple(args, "__init__", 1, 5, &object, &context,
-            &mixin_factory, &names, &providedby)) {
+    if (PyArg_UnpackTuple(args, "__init__", 1, 4, &object, &context,
+            &mixin_factory, &names)) {
         PyObject *temp;
         int size;
         DecoratorObject *decorator = (DecoratorObject *)self;
@@ -130,12 +125,6 @@
             decorator->mixin_factory = mixin_factory;
             Py_XDECREF(temp);
         }
-        if (decorator->providedby != providedby) {
-            temp = decorator->providedby;
-            Py_XINCREF(providedby);
-            decorator->providedby = providedby;
-            Py_XDECREF(temp);
-        }
         /* Take the given names and force them to be in a tuple.
          * If the tuple is empty, names_dict should be NULL.
          * Otherwise, names_dict should have the names as keys.
@@ -199,8 +188,6 @@
         err = visit(Decorator_GetNames(self), arg);
     if (!err && Decorator_GetNamesDict(self) != NULL)
         err = visit(Decorator_GetNamesDict(self), arg);
-    if (!err && Decorator_GetProvidedby(self) != NULL)
-        err = visit(Decorator_GetProvidedby(self), arg);
 
     return err;
 }
@@ -229,10 +216,6 @@
         decorator->names_dict = NULL;
         Py_DECREF(temp);
     }
-    if ((temp = decorator->providedby) != NULL) {
-        decorator->providedby = NULL;
-        Py_DECREF(temp);
-    }
     return 0;
 }
 
@@ -727,7 +710,7 @@
 
 static PyObject *
 create_decorator(PyObject *object, PyObject *context, PyObject *mixin_factory,
-                 PyObject *names, PyObject *providedby)
+                 PyObject *names)
 {
     PyObject *result = NULL;
     PyObject *args;
@@ -749,10 +732,6 @@
     Py_INCREF(names);
     PyTuple_SET_ITEM(args, 3, names);
 
-    if (!providedby) providedby = Py_None;
-    Py_INCREF(providedby);
-    PyTuple_SET_ITEM(args, 4, providedby);
-
     result = PyObject_CallObject((PyObject *)&DecoratorType, args);
     Py_DECREF(args);
     return result;
@@ -766,15 +745,14 @@
 
 static PyObject *
 api_create(PyObject *object, PyObject *context, PyObject *mixin_factory,
-           PyObject *names, PyObject *providedby)
+           PyObject *names)
 {
     if (object == NULL) {
         PyErr_SetString(PyExc_ValueError,
                         "cannot create decorator around NULL");
         return NULL;
     }
-    return create_decorator(object, context, mixin_factory, names,
-                            providedby);
+    return create_decorator(object, context, mixin_factory, names);
 }
 
 static PyObject *
@@ -836,40 +814,6 @@
         return NULL;
 }
 
-static PyObject *
-api_getprovidedby(PyObject *wrapper)
-{
-    /* Returns a borrowed reference. */
-    if (wrapper == NULL)
-        return missing_decorator("getprovidedby");
-    if (check_decorator(wrapper, "getprovidedby"))
-        return Decorator_GetProvidedby(wrapper);
-    else
-        return NULL;
-}
-
-static int
-api_setprovidedby(PyObject *wrapper, PyObject *object)
-{
-    DecoratorObject *wrap;
-    PyObject *oldprovidedby;
-
-    if (wrapper == NULL) {
-        (void) missing_decorator("setprovidedby");
-        return 0;
-    }
-    if (!check_decorator(wrapper, "setprovidedby"))
-        return 0;
-    wrap = (DecoratorObject *) wrapper;
-    oldprovidedby = Decorator_GetProvidedby(wrap);
-    if (object == Py_None)
-        object = NULL;
-    Py_XINCREF(object);
-    wrap->providedby = object;
-    Py_XDECREF(oldprovidedby);
-    return 1;
-}
-
 static DecoratorInterface
 decorator_capi = {
     api_check,
@@ -877,8 +821,6 @@
     api_getmixin,
     api_getmixinfactory,
     api_getnames,
-    api_getprovidedby,
-    api_setprovidedby
 };
 
 static char
@@ -985,49 +927,6 @@
     return PyDictProxy_New(Decorator_GetNamesDict(obj));
 }
 
-static char
-getprovidedby__doc__[] =
-"getprovidedby(decorator) --> object\n"
-"\n"
-"Return the providedby for the decorator. XXX continue from interface.";
-
-static PyObject *
-decorator_getprovidedby(PyObject *unused, PyObject *obj)
-{
-    PyObject *result = NULL;
-
-    if (!check_decorator(obj, "getprovidedby"))
-        return NULL;
-    result = Decorator_GetProvidedby(obj);
-    if (result == NULL)
-        result = Py_None;
-    Py_INCREF(result);
-    return result;
-}
-
-static char
-setprovidedby__doc__[] =
-"setprovidedby(decorator, providedby)\n"
-"\n"
-"Replace the providedby on the decorator with the given one.\n"
-"A None value indicates no providedby.";
-
-static PyObject *
-decorator_setprovidedby(PyObject *unused, PyObject *args)
-{
-    PyObject *wrapper;
-    PyObject *object;
-    PyObject *result = NULL;
-
-    if (PyArg_UnpackTuple(args, "setprovidedby", 2, 2, &wrapper, &object)) {
-        if (api_setprovidedby(wrapper, object)) {
-            result = Py_None;
-            Py_INCREF(result);
-        }
-    }
-    return result;
-}
-
 static PyMethodDef
 module_functions[] = {
     {"getmixin",          decorator_getmixin,          METH_O,
@@ -1040,10 +939,6 @@
      getnames__doc__},
     {"getnamesdict",      decorator_getnamesdict,      METH_O,
      getnamesdict__doc__},
-    {"getprovidedby",     decorator_getprovidedby,     METH_O,
-     getprovidedby__doc__},
-    {"setprovidedby",     decorator_setprovidedby,     METH_VARARGS,
-     setprovidedby__doc__},
     {NULL, NULL, 0, NULL}
 };