Back to index

python3.2  3.2.2
Classes | Defines | Functions | Variables
descrobject.c File Reference
#include "Python.h"
#include "structmember.h"

Go to the source code of this file.

Classes

struct  proxyobject
struct  wrapperobject
struct  propertyobject

Defines

#define Wrapper_Check(v)   (Py_TYPE(v) == &wrappertype)
#define TEST_COND(cond)   ((cond) ? Py_True : Py_False)

Functions

static void descr_dealloc (PyDescrObject *descr)
static PyObjectdescr_name (PyDescrObject *descr)
static PyObjectdescr_repr (PyDescrObject *descr, char *format)
static PyObjectmethod_repr (PyMethodDescrObject *descr)
static PyObjectmember_repr (PyMemberDescrObject *descr)
static PyObjectgetset_repr (PyGetSetDescrObject *descr)
static PyObjectwrapperdescr_repr (PyWrapperDescrObject *descr)
static int descr_check (PyDescrObject *descr, PyObject *obj, PyObject **pres)
static PyObjectclassmethod_get (PyMethodDescrObject *descr, PyObject *obj, PyObject *type)
static PyObjectmethod_get (PyMethodDescrObject *descr, PyObject *obj, PyObject *type)
static PyObjectmember_get (PyMemberDescrObject *descr, PyObject *obj, PyObject *type)
static PyObjectgetset_get (PyGetSetDescrObject *descr, PyObject *obj, PyObject *type)
static PyObjectwrapperdescr_get (PyWrapperDescrObject *descr, PyObject *obj, PyObject *type)
static int descr_setcheck (PyDescrObject *descr, PyObject *obj, PyObject *value, int *pres)
static int member_set (PyMemberDescrObject *descr, PyObject *obj, PyObject *value)
static int getset_set (PyGetSetDescrObject *descr, PyObject *obj, PyObject *value)
static PyObjectmethoddescr_call (PyMethodDescrObject *descr, PyObject *args, PyObject *kwds)
static PyObjectclassmethoddescr_call (PyMethodDescrObject *descr, PyObject *args, PyObject *kwds)
static PyObjectwrapperdescr_call (PyWrapperDescrObject *descr, PyObject *args, PyObject *kwds)
static PyObjectmethod_get_doc (PyMethodDescrObject *descr, void *closure)
static PyObjectmember_get_doc (PyMemberDescrObject *descr, void *closure)
static PyObjectgetset_get_doc (PyGetSetDescrObject *descr, void *closure)
static PyObjectwrapperdescr_get_doc (PyWrapperDescrObject *descr, void *closure)
static int descr_traverse (PyObject *self, visitproc visit, void *arg)
static PyDescrObjectdescr_new (PyTypeObject *descrtype, PyTypeObject *type, const char *name)
PyObjectPyDescr_NewMethod (PyTypeObject *type, PyMethodDef *method)
PyObjectPyDescr_NewClassMethod (PyTypeObject *type, PyMethodDef *method)
PyObjectPyDescr_NewMember (PyTypeObject *type, PyMemberDef *member)
PyObjectPyDescr_NewGetSet (PyTypeObject *type, PyGetSetDef *getset)
PyObjectPyDescr_NewWrapper (PyTypeObject *type, struct wrapperbase *base, void *wrapped)
static Py_ssize_t proxy_len (proxyobject *pp)
static PyObjectproxy_getitem (proxyobject *pp, PyObject *key)
static int proxy_contains (proxyobject *pp, PyObject *key)
static PyObjectproxy_get (proxyobject *pp, PyObject *args)
static PyObjectproxy_keys (proxyobject *pp)
static PyObjectproxy_values (proxyobject *pp)
static PyObjectproxy_items (proxyobject *pp)
static PyObjectproxy_copy (proxyobject *pp)
static void proxy_dealloc (proxyobject *pp)
static PyObjectproxy_getiter (proxyobject *pp)
static PyObjectproxy_str (proxyobject *pp)
static PyObjectproxy_repr (proxyobject *pp)
static int proxy_traverse (PyObject *self, visitproc visit, void *arg)
static PyObjectproxy_richcompare (proxyobject *v, PyObject *w, int op)
PyObjectPyDictProxy_New (PyObject *dict)
static void wrapper_dealloc (wrapperobject *wp)
static PyObjectwrapper_richcompare (PyObject *a, PyObject *b, int op)
static Py_hash_t wrapper_hash (wrapperobject *wp)
static PyObjectwrapper_repr (wrapperobject *wp)
static PyObjectwrapper_objclass (wrapperobject *wp)
static PyObjectwrapper_name (wrapperobject *wp)
static PyObjectwrapper_doc (wrapperobject *wp)
static PyObjectwrapper_call (wrapperobject *wp, PyObject *args, PyObject *kwds)
static int wrapper_traverse (PyObject *self, visitproc visit, void *arg)
PyObjectPyWrapper_New (PyObject *d, PyObject *self)
static PyObjectproperty_copy (PyObject *, PyObject *, PyObject *, PyObject *)
 PyDoc_STRVAR (getter_doc,"Descriptor to change the getter on a property.")
static PyObjectproperty_getter (PyObject *self, PyObject *getter)
 PyDoc_STRVAR (setter_doc,"Descriptor to change the setter on a property.")
static PyObjectproperty_setter (PyObject *self, PyObject *setter)
 PyDoc_STRVAR (deleter_doc,"Descriptor to change the deleter on a property.")
static PyObjectproperty_deleter (PyObject *self, PyObject *deleter)
static void property_dealloc (PyObject *self)
static PyObjectproperty_descr_get (PyObject *self, PyObject *obj, PyObject *type)
static int property_descr_set (PyObject *self, PyObject *obj, PyObject *value)
static int property_init (PyObject *self, PyObject *args, PyObject *kwds)
 PyDoc_STRVAR (property_doc,"property(fget=None, fset=None, fdel=None, doc=None) -> property attribute\n""\n""fget is a function to be used for getting an attribute value, and likewise\n""fset is a function for setting, and fdel a function for del'ing, an\n""attribute. Typical use is to define a managed attribute x:\n""class C(object):\n"" def getx(self): return self._x\n"" def setx(self, value): self._x = value\n"" def delx(self): del self._x\n"" x = property(getx, setx, delx, \"I'm the 'x' property.\")\n""\n""Decorators make defining new properties or modifying existing ones easy:\n""class C(object):\n"" @property\n"" def x(self): return self._x\n"" @x.setter\n"" def x(self, value): self._x = value\n"" @x.deleter\n"" def x(self): del self._x\n")
static int property_traverse (PyObject *self, visitproc visit, void *arg)

Variables

static PyMemberDef descr_members []
static PyGetSetDef method_getset []
static PyGetSetDef member_getset []
static PyGetSetDef getset_getset []
static PyGetSetDef wrapperdescr_getset []
PyTypeObject PyMethodDescr_Type
PyTypeObject PyClassMethodDescr_Type
PyTypeObject PyMemberDescr_Type
PyTypeObject PyGetSetDescr_Type
PyTypeObject PyWrapperDescr_Type
static PyMappingMethods proxy_as_mapping
static PySequenceMethods proxy_as_sequence
static PyMethodDef proxy_methods []
PyTypeObject PyDictProxy_Type
static PyTypeObject wrappertype
static PyMemberDef wrapper_members []
static PyGetSetDef wrapper_getsets []
static PyMemberDef property_members []
static PyMethodDef property_methods []
PyTypeObject PyProperty_Type

Class Documentation

struct proxyobject

Definition at line 660 of file descrobject.c.

Collaboration diagram for proxyobject:
Class Members
PyObject_HEAD PyObject * dict
struct wrapperobject

Definition at line 852 of file descrobject.c.

Collaboration diagram for wrapperobject:
Class Members
PyObject_HEAD
PyWrapperDescrObject *
descr
PyObject * self
struct propertyobject

Definition at line 1117 of file descrobject.c.

Collaboration diagram for propertyobject:
Class Members
int getter_doc
PyObject * prop_del
PyObject * prop_doc
PyObject_HEAD PyObject * prop_get
PyObject * prop_set

Define Documentation

#define TEST_COND (   cond)    ((cond) ? Py_True : Py_False)

Definition at line 871 of file descrobject.c.

#define Wrapper_Check (   v)    (Py_TYPE(v) == &wrappertype)

Definition at line 858 of file descrobject.c.


Function Documentation

static PyObject* classmethod_get ( PyMethodDescrObject descr,
PyObject obj,
PyObject type 
) [static]

Definition at line 83 of file descrobject.c.

{
    /* Ensure a valid type.  Class methods ignore obj. */
    if (type == NULL) {
        if (obj != NULL)
            type = (PyObject *)obj->ob_type;
        else {
            /* Wot - no type?! */
            PyErr_Format(PyExc_TypeError,
                         "descriptor '%V' for type '%s' "
                         "needs either an object or a type",
                         descr_name((PyDescrObject *)descr), "?",
                         PyDescr_TYPE(descr)->tp_name);
            return NULL;
        }
    }
    if (!PyType_Check(type)) {
        PyErr_Format(PyExc_TypeError,
                     "descriptor '%V' for type '%s' "
                     "needs a type, not a '%s' as arg 2",
                     descr_name((PyDescrObject *)descr), "?",
                     PyDescr_TYPE(descr)->tp_name,
                     type->ob_type->tp_name);
        return NULL;
    }
    if (!PyType_IsSubtype((PyTypeObject *)type, PyDescr_TYPE(descr))) {
        PyErr_Format(PyExc_TypeError,
                     "descriptor '%V' for type '%s' "
                     "doesn't apply to type '%s'",
                     descr_name((PyDescrObject *)descr), "?",
                     PyDescr_TYPE(descr)->tp_name,
                     ((PyTypeObject *)type)->tp_name);
        return NULL;
    }
    return PyCFunction_New(descr->d_method, type);
}

Here is the call graph for this function:

static PyObject* classmethoddescr_call ( PyMethodDescrObject descr,
PyObject args,
PyObject kwds 
) [static]

Definition at line 256 of file descrobject.c.

{
    PyObject *func, *result;

    func = PyCFunction_New(descr->d_method, (PyObject *)PyDescr_TYPE(descr));
    if (func == NULL)
        return NULL;

    result = PyEval_CallObjectWithKeywords(func, args, kwds);
    Py_DECREF(func);
    return result;
}

Here is the call graph for this function:

static int descr_check ( PyDescrObject descr,
PyObject obj,
PyObject **  pres 
) [static]

Definition at line 62 of file descrobject.c.

{
    if (obj == NULL) {
        Py_INCREF(descr);
        *pres = (PyObject *)descr;
        return 1;
    }
    if (!PyObject_TypeCheck(obj, descr->d_type)) {
        PyErr_Format(PyExc_TypeError,
                     "descriptor '%V' for '%s' objects "
                     "doesn't apply to '%s' object",
                     descr_name((PyDescrObject *)descr), "?",
                     descr->d_type->tp_name,
                     obj->ob_type->tp_name);
        *pres = NULL;
        return 1;
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void descr_dealloc ( PyDescrObject descr) [static]

Definition at line 7 of file descrobject.c.

Here is the call graph for this function:

static PyObject* descr_name ( PyDescrObject descr) [static]

Definition at line 16 of file descrobject.c.

{
    if (descr->d_name != NULL && PyUnicode_Check(descr->d_name))
        return descr->d_name;
    return NULL;
}

Here is the caller graph for this function:

static PyDescrObject* descr_new ( PyTypeObject descrtype,
PyTypeObject type,
const char *  name 
) [static]

Definition at line 575 of file descrobject.c.

{
    PyDescrObject *descr;

    descr = (PyDescrObject *)PyType_GenericAlloc(descrtype, 0);
    if (descr != NULL) {
        Py_XINCREF(type);
        descr->d_type = type;
        descr->d_name = PyUnicode_InternFromString(name);
        if (descr->d_name == NULL) {
            Py_DECREF(descr);
            descr = NULL;
        }
    }
    return descr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* descr_repr ( PyDescrObject descr,
char *  format 
) [static]

Definition at line 24 of file descrobject.c.

{
    PyObject *name = NULL;
    if (descr->d_name != NULL && PyUnicode_Check(descr->d_name))
        name = descr->d_name;

    return PyUnicode_FromFormat(format, name, "?", descr->d_type->tp_name);
}

Here is the caller graph for this function:

static int descr_setcheck ( PyDescrObject descr,
PyObject obj,
PyObject value,
int pres 
) [static]

Definition at line 167 of file descrobject.c.

{
    assert(obj != NULL);
    if (!PyObject_TypeCheck(obj, descr->d_type)) {
        PyErr_Format(PyExc_TypeError,
                     "descriptor '%V' for '%.100s' objects "
                     "doesn't apply to '%.100s' object",
                     descr_name(descr), "?",
                     descr->d_type->tp_name,
                     obj->ob_type->tp_name);
        *pres = -1;
        return 1;
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int descr_traverse ( PyObject self,
visitproc  visit,
void arg 
) [static]

Definition at line 381 of file descrobject.c.

{
    PyDescrObject *descr = (PyDescrObject *)self;
    Py_VISIT(descr->d_type);
    return 0;
}
static PyObject* getset_get ( PyGetSetDescrObject descr,
PyObject obj,
PyObject type 
) [static]

Definition at line 141 of file descrobject.c.

{
    PyObject *res;

    if (descr_check((PyDescrObject *)descr, obj, &res))
        return res;
    if (descr->d_getset->get != NULL)
        return descr->d_getset->get(obj, descr->d_getset->closure);
    PyErr_Format(PyExc_AttributeError,
                 "attribute '%V' of '%.100s' objects is not readable",
                 descr_name((PyDescrObject *)descr), "?",
                 PyDescr_TYPE(descr)->tp_name);
    return NULL;
}

Here is the call graph for this function:

static PyObject* getset_get_doc ( PyGetSetDescrObject descr,
void closure 
) [static]

Definition at line 351 of file descrobject.c.

{
    if (descr->d_getset->doc == NULL) {
        Py_INCREF(Py_None);
        return Py_None;
    }
    return PyUnicode_FromString(descr->d_getset->doc);
}

Here is the call graph for this function:

static PyObject* getset_repr ( PyGetSetDescrObject descr) [static]

Definition at line 48 of file descrobject.c.

{
    return descr_repr((PyDescrObject *)descr,
                      "<attribute '%V' of '%s' objects>");
}

Here is the call graph for this function:

static int getset_set ( PyGetSetDescrObject descr,
PyObject obj,
PyObject value 
) [static]

Definition at line 195 of file descrobject.c.

{
    int res;

    if (descr_setcheck((PyDescrObject *)descr, obj, value, &res))
        return res;
    if (descr->d_getset->set != NULL)
        return descr->d_getset->set(obj, value,
                                    descr->d_getset->closure);
    PyErr_Format(PyExc_AttributeError,
                 "attribute '%V' of '%.100s' objects is not writable",
                 descr_name((PyDescrObject *)descr), "?",
                 PyDescr_TYPE(descr)->tp_name);
    return -1;
}

Here is the call graph for this function:

static PyObject* member_get ( PyMemberDescrObject descr,
PyObject obj,
PyObject type 
) [static]

Definition at line 131 of file descrobject.c.

{
    PyObject *res;

    if (descr_check((PyDescrObject *)descr, obj, &res))
        return res;
    return PyMember_GetOne((char *)obj, descr->d_member);
}

Here is the call graph for this function:

static PyObject* member_get_doc ( PyMemberDescrObject descr,
void closure 
) [static]

Definition at line 336 of file descrobject.c.

{
    if (descr->d_member->doc == NULL) {
        Py_INCREF(Py_None);
        return Py_None;
    }
    return PyUnicode_FromString(descr->d_member->doc);
}

Here is the call graph for this function:

static PyObject* member_repr ( PyMemberDescrObject descr) [static]

Definition at line 41 of file descrobject.c.

{
    return descr_repr((PyDescrObject *)descr,
                      "<member '%V' of '%s' objects>");
}

Here is the call graph for this function:

static int member_set ( PyMemberDescrObject descr,
PyObject obj,
PyObject value 
) [static]

Definition at line 185 of file descrobject.c.

{
    int res;

    if (descr_setcheck((PyDescrObject *)descr, obj, value, &res))
        return res;
    return PyMember_SetOne((char *)obj, descr->d_member, value);
}

Here is the call graph for this function:

static PyObject* method_get ( PyMethodDescrObject descr,
PyObject obj,
PyObject type 
) [static]

Definition at line 121 of file descrobject.c.

{
    PyObject *res;

    if (descr_check((PyDescrObject *)descr, obj, &res))
        return res;
    return PyCFunction_New(descr->d_method, obj);
}

Here is the call graph for this function:

static PyObject* method_get_doc ( PyMethodDescrObject descr,
void closure 
) [static]

Definition at line 315 of file descrobject.c.

{
    if (descr->d_method->ml_doc == NULL) {
        Py_INCREF(Py_None);
        return Py_None;
    }
    return PyUnicode_FromString(descr->d_method->ml_doc);
}

Here is the call graph for this function:

static PyObject* method_repr ( PyMethodDescrObject descr) [static]

Definition at line 34 of file descrobject.c.

{
    return descr_repr((PyDescrObject *)descr,
                      "<method '%V' of '%s' objects>");
}

Here is the call graph for this function:

static PyObject* methoddescr_call ( PyMethodDescrObject descr,
PyObject args,
PyObject kwds 
) [static]

Definition at line 212 of file descrobject.c.

{
    Py_ssize_t argc;
    PyObject *self, *func, *result;

    /* Make sure that the first argument is acceptable as 'self' */
    assert(PyTuple_Check(args));
    argc = PyTuple_GET_SIZE(args);
    if (argc < 1) {
        PyErr_Format(PyExc_TypeError,
                     "descriptor '%V' of '%.100s' "
                     "object needs an argument",
                     descr_name((PyDescrObject *)descr), "?",
                     PyDescr_TYPE(descr)->tp_name);
        return NULL;
    }
    self = PyTuple_GET_ITEM(args, 0);
    if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
                                  (PyObject *)PyDescr_TYPE(descr))) {
        PyErr_Format(PyExc_TypeError,
                     "descriptor '%V' "
                     "requires a '%.100s' object "
                     "but received a '%.100s'",
                     descr_name((PyDescrObject *)descr), "?",
                     PyDescr_TYPE(descr)->tp_name,
                     self->ob_type->tp_name);
        return NULL;
    }

    func = PyCFunction_New(descr->d_method, self);
    if (func == NULL)
        return NULL;
    args = PyTuple_GetSlice(args, 1, argc);
    if (args == NULL) {
        Py_DECREF(func);
        return NULL;
    }
    result = PyEval_CallObjectWithKeywords(func, args, kwds);
    Py_DECREF(args);
    Py_DECREF(func);
    return result;
}

Here is the call graph for this function:

static PyObject * property_copy ( PyObject old,
PyObject get,
PyObject set,
PyObject del 
) [static]

Definition at line 1233 of file descrobject.c.

{
    propertyobject *pold = (propertyobject *)old;
    PyObject *new, *type, *doc;

    type = PyObject_Type(old);
    if (type == NULL)
        return NULL;

    if (get == NULL || get == Py_None) {
        Py_XDECREF(get);
        get = pold->prop_get ? pold->prop_get : Py_None;
    }
    if (set == NULL || set == Py_None) {
        Py_XDECREF(set);
        set = pold->prop_set ? pold->prop_set : Py_None;
    }
    if (del == NULL || del == Py_None) {
        Py_XDECREF(del);
        del = pold->prop_del ? pold->prop_del : Py_None;
    }
    if (pold->getter_doc && get != Py_None) {
        /* make _init use __doc__ from getter */
        doc = Py_None;
    }
    else {
        doc = pold->prop_doc ? pold->prop_doc : Py_None;
    }

    new =  PyObject_CallFunction(type, "OOOO", get, set, del, doc);
    Py_DECREF(type);
    if (new == NULL)
        return NULL;
    return new;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void property_dealloc ( PyObject self) [static]

Definition at line 1177 of file descrobject.c.

{
    propertyobject *gs = (propertyobject *)self;

    _PyObject_GC_UNTRACK(self);
    Py_XDECREF(gs->prop_get);
    Py_XDECREF(gs->prop_set);
    Py_XDECREF(gs->prop_del);
    Py_XDECREF(gs->prop_doc);
    self->ob_type->tp_free(self);
}
static PyObject* property_deleter ( PyObject self,
PyObject deleter 
) [static]

Definition at line 1162 of file descrobject.c.

{
    return property_copy(self, NULL, NULL, deleter);
}

Here is the call graph for this function:

static PyObject* property_descr_get ( PyObject self,
PyObject obj,
PyObject type 
) [static]

Definition at line 1190 of file descrobject.c.

{
    propertyobject *gs = (propertyobject *)self;

    if (obj == NULL || obj == Py_None) {
        Py_INCREF(self);
        return self;
    }
    if (gs->prop_get == NULL) {
        PyErr_SetString(PyExc_AttributeError, "unreadable attribute");
        return NULL;
    }
    return PyObject_CallFunctionObjArgs(gs->prop_get, obj, NULL);
}

Here is the call graph for this function:

static int property_descr_set ( PyObject self,
PyObject obj,
PyObject value 
) [static]

Definition at line 1206 of file descrobject.c.

{
    propertyobject *gs = (propertyobject *)self;
    PyObject *func, *res;

    if (value == NULL)
        func = gs->prop_del;
    else
        func = gs->prop_set;
    if (func == NULL) {
        PyErr_SetString(PyExc_AttributeError,
                        value == NULL ?
                        "can't delete attribute" :
                "can't set attribute");
        return -1;
    }
    if (value == NULL)
        res = PyObject_CallFunctionObjArgs(func, obj, NULL);
    else
        res = PyObject_CallFunctionObjArgs(func, obj, value, NULL);
    if (res == NULL)
        return -1;
    Py_DECREF(res);
    return 0;
}

Here is the call graph for this function:

static PyObject* property_getter ( PyObject self,
PyObject getter 
) [static]

Definition at line 1142 of file descrobject.c.

{
    return property_copy(self, getter, NULL, NULL);
}

Here is the call graph for this function:

static int property_init ( PyObject self,
PyObject args,
PyObject kwds 
) [static]

Definition at line 1270 of file descrobject.c.

{
    PyObject *get = NULL, *set = NULL, *del = NULL, *doc = NULL;
    static char *kwlist[] = {"fget", "fset", "fdel", "doc", 0};
    propertyobject *prop = (propertyobject *)self;

    if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO:property",
                                     kwlist, &get, &set, &del, &doc))
        return -1;

    if (get == Py_None)
        get = NULL;
    if (set == Py_None)
        set = NULL;
    if (del == Py_None)
        del = NULL;

    Py_XINCREF(get);
    Py_XINCREF(set);
    Py_XINCREF(del);
    Py_XINCREF(doc);

    prop->prop_get = get;
    prop->prop_set = set;
    prop->prop_del = del;
    prop->prop_doc = doc;
    prop->getter_doc = 0;

    /* if no docstring given and the getter has one, use that one */
    if ((doc == NULL || doc == Py_None) && get != NULL) {
        PyObject *get_doc = PyObject_GetAttrString(get, "__doc__");
        if (get_doc) {
            if (Py_TYPE(self) == &PyProperty_Type) {
                Py_XDECREF(prop->prop_doc);
                prop->prop_doc = get_doc;
            }
            else {
                /* If this is a property subclass, put __doc__
                in dict of the subclass instance instead,
                otherwise it gets shadowed by __doc__ in the
                class's dict. */
                int err = PyObject_SetAttrString(self, "__doc__", get_doc);
                Py_DECREF(get_doc);
                if (err < 0)
                    return -1;
            }
            prop->getter_doc = 1;
        }
        else if (PyErr_ExceptionMatches(PyExc_Exception)) {
            PyErr_Clear();
        }
        else {
            return -1;
        }
    }

    return 0;
}

Here is the call graph for this function:

static PyObject* property_setter ( PyObject self,
PyObject setter 
) [static]

Definition at line 1152 of file descrobject.c.

{
    return property_copy(self, NULL, setter, NULL);
}

Here is the call graph for this function:

static int property_traverse ( PyObject self,
visitproc  visit,
void arg 
) [static]

Definition at line 1352 of file descrobject.c.

{
    propertyobject *pp = (propertyobject *)self;
    Py_VISIT(pp->prop_get);
    Py_VISIT(pp->prop_set);
    Py_VISIT(pp->prop_del);
    Py_VISIT(pp->prop_doc);
    return 0;
}
static int proxy_contains ( proxyobject pp,
PyObject key 
) [static]

Definition at line 684 of file descrobject.c.

{
    return PyDict_Contains(pp->dict, key);
}

Here is the call graph for this function:

static PyObject* proxy_copy ( proxyobject pp) [static]

Definition at line 731 of file descrobject.c.

{
    return PyObject_CallMethod(pp->dict, "copy", NULL);
}

Here is the call graph for this function:

static void proxy_dealloc ( proxyobject pp) [static]

Definition at line 752 of file descrobject.c.

Here is the call graph for this function:

static PyObject* proxy_get ( proxyobject pp,
PyObject args 
) [static]

Definition at line 703 of file descrobject.c.

{
    PyObject *key, *def = Py_None;

    if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &def))
        return NULL;
    return PyObject_CallMethod(pp->dict, "get", "(OO)", key, def);
}

Here is the call graph for this function:

static PyObject* proxy_getitem ( proxyobject pp,
PyObject key 
) [static]

Definition at line 672 of file descrobject.c.

{
    return PyObject_GetItem(pp->dict, key);
}

Here is the call graph for this function:

static PyObject* proxy_getiter ( proxyobject pp) [static]

Definition at line 760 of file descrobject.c.

{
    return PyObject_GetIter(pp->dict);
}

Here is the call graph for this function:

static PyObject* proxy_items ( proxyobject pp) [static]

Definition at line 725 of file descrobject.c.

{
    return PyObject_CallMethod(pp->dict, "items", NULL);
}

Here is the call graph for this function:

static PyObject* proxy_keys ( proxyobject pp) [static]

Definition at line 713 of file descrobject.c.

{
    return PyObject_CallMethod(pp->dict, "keys", NULL);
}

Here is the call graph for this function:

static Py_ssize_t proxy_len ( proxyobject pp) [static]

Definition at line 666 of file descrobject.c.

{
    return PyObject_Size(pp->dict);
}

Here is the call graph for this function:

static PyObject* proxy_repr ( proxyobject pp) [static]

Definition at line 772 of file descrobject.c.

{
    return PyUnicode_FromFormat("dict_proxy(%R)", pp->dict);
}
static PyObject* proxy_richcompare ( proxyobject v,
PyObject w,
int  op 
) [static]

Definition at line 786 of file descrobject.c.

{
    return PyObject_RichCompare(v->dict, w, op);
}

Here is the call graph for this function:

static PyObject* proxy_str ( proxyobject pp) [static]

Definition at line 766 of file descrobject.c.

{
    return PyObject_Str(pp->dict);
}

Here is the call graph for this function:

static int proxy_traverse ( PyObject self,
visitproc  visit,
void arg 
) [static]

Definition at line 778 of file descrobject.c.

{
    proxyobject *pp = (proxyobject *)self;
    Py_VISIT(pp->dict);
    return 0;
}
static PyObject* proxy_values ( proxyobject pp) [static]

Definition at line 719 of file descrobject.c.

{
    return PyObject_CallMethod(pp->dict, "values", NULL);
}

Here is the call graph for this function:

Definition at line 605 of file descrobject.c.

{
    PyMethodDescrObject *descr;

    descr = (PyMethodDescrObject *)descr_new(&PyClassMethodDescr_Type,
                                             type, method->ml_name);
    if (descr != NULL)
        descr->d_method = method;
    return (PyObject *)descr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PyObject* PyDescr_NewGetSet ( PyTypeObject type,
PyGetSetDef getset 
)

Definition at line 629 of file descrobject.c.

{
    PyGetSetDescrObject *descr;

    descr = (PyGetSetDescrObject *)descr_new(&PyGetSetDescr_Type,
                                             type, getset->name);
    if (descr != NULL)
        descr->d_getset = getset;
    return (PyObject *)descr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PyObject* PyDescr_NewMember ( PyTypeObject type,
PyMemberDef member 
)

Definition at line 617 of file descrobject.c.

{
    PyMemberDescrObject *descr;

    descr = (PyMemberDescrObject *)descr_new(&PyMemberDescr_Type,
                                             type, member->name);
    if (descr != NULL)
        descr->d_member = member;
    return (PyObject *)descr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PyObject* PyDescr_NewMethod ( PyTypeObject type,
PyMethodDef method 
)

Definition at line 593 of file descrobject.c.

{
    PyMethodDescrObject *descr;

    descr = (PyMethodDescrObject *)descr_new(&PyMethodDescr_Type,
                                             type, method->ml_name);
    if (descr != NULL)
        descr->d_method = method;
    return (PyObject *)descr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PyObject* PyDescr_NewWrapper ( PyTypeObject type,
struct wrapperbase base,
void wrapped 
)

Definition at line 641 of file descrobject.c.

{
    PyWrapperDescrObject *descr;

    descr = (PyWrapperDescrObject *)descr_new(&PyWrapperDescr_Type,
                                             type, base->name);
    if (descr != NULL) {
        descr->d_base = base;
        descr->d_wrapped = wrapped;
    }
    return (PyObject *)descr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 830 of file descrobject.c.

{
    proxyobject *pp;

    pp = PyObject_GC_New(proxyobject, &PyDictProxy_Type);
    if (pp != NULL) {
        Py_INCREF(dict);
        pp->dict = dict;
        _PyObject_GC_TRACK(pp);
    }
    return (PyObject *)pp;
}

Here is the caller graph for this function:

PyDoc_STRVAR ( getter_doc  ,
"Descriptor to change the getter on a property."   
)
PyDoc_STRVAR ( setter_doc  ,
"Descriptor to change the setter on a property."   
)
PyDoc_STRVAR ( deleter_doc  ,
"Descriptor to change the deleter on a property."   
)
PyDoc_STRVAR ( property_doc  ,
"property(fget=None, fset=None, fdel=None, doc=None) -> property attribute\n""\n""fget is a function to be used for getting an attribute  value,
and likewise\n""fset is a function for  setting,
and fdel a function for del'  ing 
)
PyObject* PyWrapper_New ( PyObject d,
PyObject self 
)

Definition at line 1063 of file descrobject.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static PyObject* wrapper_call ( wrapperobject wp,
PyObject args,
PyObject kwds 
) [static]

Definition at line 996 of file descrobject.c.

{
    wrapperfunc wrapper = wp->descr->d_base->wrapper;
    PyObject *self = wp->self;

    if (wp->descr->d_base->flags & PyWrapperFlag_KEYWORDS) {
        wrapperfunc_kwds wk = (wrapperfunc_kwds)wrapper;
        return (*wk)(self, args, wp->descr->d_wrapped, kwds);
    }

    if (kwds != NULL && (!PyDict_Check(kwds) || PyDict_Size(kwds) != 0)) {
        PyErr_Format(PyExc_TypeError,
                     "wrapper %s doesn't take keyword arguments",
                     wp->descr->d_base->name);
        return NULL;
    }
    return (*wrapper)(self, args, wp->descr->d_wrapped);
}

Here is the call graph for this function:

static void wrapper_dealloc ( wrapperobject wp) [static]

Definition at line 861 of file descrobject.c.

Here is the call graph for this function:

static PyObject* wrapper_doc ( wrapperobject wp) [static]

Definition at line 975 of file descrobject.c.

{
    const char *s = wp->descr->d_base->doc;

    if (s == NULL) {
        Py_INCREF(Py_None);
        return Py_None;
    }
    else {
        return PyUnicode_FromString(s);
    }
}

Here is the call graph for this function:

static Py_hash_t wrapper_hash ( wrapperobject wp) [static]

Definition at line 928 of file descrobject.c.

{
    Py_hash_t x, y;
    x = _Py_HashPointer(wp->descr);
    if (x == -1)
        return -1;
    y = PyObject_Hash(wp->self);
    if (y == -1)
        return -1;
    x = x ^ y;
    if (x == -1)
        x = -2;
    return x;
}

Here is the call graph for this function:

static PyObject* wrapper_name ( wrapperobject wp) [static]

Definition at line 967 of file descrobject.c.

{
    const char *s = wp->descr->d_base->name;

    return PyUnicode_FromString(s);
}

Here is the call graph for this function:

static PyObject* wrapper_objclass ( wrapperobject wp) [static]

Definition at line 958 of file descrobject.c.

{
    PyObject *c = (PyObject *)PyDescr_TYPE(wp->descr);

    Py_INCREF(c);
    return c;
}
static PyObject* wrapper_repr ( wrapperobject wp) [static]

Definition at line 944 of file descrobject.c.

{
    return PyUnicode_FromFormat("<method-wrapper '%s' of %s object at %p>",
                               wp->descr->d_base->name,
                               wp->self->ob_type->tp_name,
                               wp->self);
}
static PyObject* wrapper_richcompare ( PyObject a,
PyObject b,
int  op 
) [static]

Definition at line 874 of file descrobject.c.

{
    int result;
    PyObject *v;
    PyWrapperDescrObject *a_descr, *b_descr;

    assert(a != NULL && b != NULL);

    /* both arguments should be wrapperobjects */
    if (!Wrapper_Check(a) || !Wrapper_Check(b)) {
        v = Py_NotImplemented;
        Py_INCREF(v);
        return v;
    }

    /* compare by descriptor address; if the descriptors are the same,
       compare by the objects they're bound to */
    a_descr = ((wrapperobject *)a)->descr;
    b_descr = ((wrapperobject *)b)->descr;
    if (a_descr == b_descr) {
        a = ((wrapperobject *)a)->self;
        b = ((wrapperobject *)b)->self;
        return PyObject_RichCompare(a, b, op);
    }

    result = a_descr - b_descr;
    switch (op) {
    case Py_EQ:
        v = TEST_COND(result == 0);
        break;
    case Py_NE:
        v = TEST_COND(result != 0);
        break;
    case Py_LE:
        v = TEST_COND(result <= 0);
        break;
    case Py_GE:
        v = TEST_COND(result >= 0);
        break;
    case Py_LT:
        v = TEST_COND(result < 0);
        break;
    case Py_GT:
        v = TEST_COND(result > 0);
        break;
    default:
        PyErr_BadArgument();
        return NULL;
    }
    Py_INCREF(v);
    return v;
}

Here is the call graph for this function:

static int wrapper_traverse ( PyObject self,
visitproc  visit,
void arg 
) [static]

Definition at line 1016 of file descrobject.c.

{
    wrapperobject *wp = (wrapperobject *)self;
    Py_VISIT(wp->descr);
    Py_VISIT(wp->self);
    return 0;
}
static PyObject* wrapperdescr_call ( PyWrapperDescrObject descr,
PyObject args,
PyObject kwds 
) [static]

Definition at line 271 of file descrobject.c.

{
    Py_ssize_t argc;
    PyObject *self, *func, *result;

    /* Make sure that the first argument is acceptable as 'self' */
    assert(PyTuple_Check(args));
    argc = PyTuple_GET_SIZE(args);
    if (argc < 1) {
        PyErr_Format(PyExc_TypeError,
                     "descriptor '%V' of '%.100s' "
                     "object needs an argument",
                     descr_name((PyDescrObject *)descr), "?",
                     PyDescr_TYPE(descr)->tp_name);
        return NULL;
    }
    self = PyTuple_GET_ITEM(args, 0);
    if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
                                  (PyObject *)PyDescr_TYPE(descr))) {
        PyErr_Format(PyExc_TypeError,
                     "descriptor '%V' "
                     "requires a '%.100s' object "
                     "but received a '%.100s'",
                     descr_name((PyDescrObject *)descr), "?",
                     PyDescr_TYPE(descr)->tp_name,
                     self->ob_type->tp_name);
        return NULL;
    }

    func = PyWrapper_New((PyObject *)descr, self);
    if (func == NULL)
        return NULL;
    args = PyTuple_GetSlice(args, 1, argc);
    if (args == NULL) {
        Py_DECREF(func);
        return NULL;
    }
    result = PyEval_CallObjectWithKeywords(func, args, kwds);
    Py_DECREF(args);
    Py_DECREF(func);
    return result;
}

Here is the call graph for this function:

static PyObject* wrapperdescr_get ( PyWrapperDescrObject descr,
PyObject obj,
PyObject type 
) [static]

Definition at line 157 of file descrobject.c.

{
    PyObject *res;

    if (descr_check((PyDescrObject *)descr, obj, &res))
        return res;
    return PyWrapper_New((PyObject *)descr, obj);
}

Here is the call graph for this function:

static PyObject* wrapperdescr_get_doc ( PyWrapperDescrObject descr,
void closure 
) [static]

Definition at line 366 of file descrobject.c.

{
    if (descr->d_base->doc == NULL) {
        Py_INCREF(Py_None);
        return Py_None;
    }
    return PyUnicode_FromString(descr->d_base->doc);
}

Here is the call graph for this function:

static PyObject* wrapperdescr_repr ( PyWrapperDescrObject descr) [static]

Definition at line 55 of file descrobject.c.

{
    return descr_repr((PyDescrObject *)descr,
                      "<slot wrapper '%V' of '%s' objects>");
}

Here is the call graph for this function:


Variable Documentation

Initial value:
 {
    {"__objclass__", T_OBJECT, offsetof(PyDescrObject, d_type), READONLY},
    {"__name__", T_OBJECT, offsetof(PyDescrObject, d_name), READONLY},
    {0}
}

Definition at line 324 of file descrobject.c.

Initial value:
 {
    {"__doc__", (getter)getset_get_doc},
    {0}
}

Definition at line 360 of file descrobject.c.

Initial value:
 {
    {"__doc__", (getter)member_get_doc},
    {0}
}

Definition at line 345 of file descrobject.c.

Initial value:
 {
    {"__doc__", (getter)method_get_doc},
    {0}
}

Definition at line 330 of file descrobject.c.

Initial value:
 {
    {"fget", T_OBJECT, offsetof(propertyobject, prop_get), READONLY},
    {"fset", T_OBJECT, offsetof(propertyobject, prop_set), READONLY},
    {"fdel", T_OBJECT, offsetof(propertyobject, prop_del), READONLY},
    {"__doc__",  T_OBJECT, offsetof(propertyobject, prop_doc), READONLY},
    {0}
}

Definition at line 1129 of file descrobject.c.

Initial value:
 {
    {"getter", property_getter, METH_O, getter_doc},
    {"setter", property_setter, METH_O, setter_doc},
    {"deleter", property_deleter, METH_O, deleter_doc},
    {0}
}

Definition at line 1168 of file descrobject.c.

Initial value:

Definition at line 677 of file descrobject.c.

Initial value:
 {
    0,                                          
    0,                                          
    0,                                          
    0,                                          
    0,                                          
    0,                                          
    0,                                          
    (objobjproc)proxy_contains,                 
    0,                                          
    0,                                          
}

Definition at line 689 of file descrobject.c.

Initial value:
 {
    {"get",       (PyCFunction)proxy_get,        METH_VARARGS,
     PyDoc_STR("D.get(k[,d]) -> D[k] if k in D, else d."
                                    "  d defaults to None.")},
    {"keys",      (PyCFunction)proxy_keys,       METH_NOARGS,
     PyDoc_STR("D.keys() -> list of D's keys")},
    {"values",    (PyCFunction)proxy_values,     METH_NOARGS,
     PyDoc_STR("D.values() -> list of D's values")},
    {"items",     (PyCFunction)proxy_items,      METH_NOARGS,
     PyDoc_STR("D.items() -> list of D's (key, value) pairs, as 2-tuples")},
    {"copy",      (PyCFunction)proxy_copy,       METH_NOARGS,
     PyDoc_STR("D.copy() -> a shallow copy of D")},
    {0}
}

Definition at line 736 of file descrobject.c.

Definition at line 426 of file descrobject.c.

Definition at line 791 of file descrobject.c.

Definition at line 500 of file descrobject.c.

Definition at line 463 of file descrobject.c.

Definition at line 388 of file descrobject.c.

Definition at line 1362 of file descrobject.c.

Definition at line 537 of file descrobject.c.

Initial value:
 {
    {"__objclass__", (getter)wrapper_objclass},
    {"__name__", (getter)wrapper_name},
    {"__doc__", (getter)wrapper_doc},
    {0}
}

Definition at line 988 of file descrobject.c.

Initial value:
 {
    {"__self__", T_OBJECT, offsetof(wrapperobject, self), READONLY},
    {0}
}

Definition at line 952 of file descrobject.c.

Initial value:
 {
    {"__doc__", (getter)wrapperdescr_get_doc},
    {0}
}

Definition at line 375 of file descrobject.c.

static PyTypeObject wrappertype [static]

Definition at line 850 of file descrobject.c.