Back to index

python3.2  3.2.2
descrobject.h
Go to the documentation of this file.
00001 /* Descriptors */
00002 #ifndef Py_DESCROBJECT_H
00003 #define Py_DESCROBJECT_H
00004 #ifdef __cplusplus
00005 extern "C" {
00006 #endif
00007 
00008 typedef PyObject *(*getter)(PyObject *, void *);
00009 typedef int (*setter)(PyObject *, PyObject *, void *);
00010 
00011 typedef struct PyGetSetDef {
00012     char *name;
00013     getter get;
00014     setter set;
00015     char *doc;
00016     void *closure;
00017 } PyGetSetDef;
00018 
00019 #ifndef Py_LIMITED_API
00020 typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
00021                                  void *wrapped);
00022 
00023 typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
00024                                       void *wrapped, PyObject *kwds);
00025 
00026 struct wrapperbase {
00027     char *name;
00028     int offset;
00029     void *function;
00030     wrapperfunc wrapper;
00031     char *doc;
00032     int flags;
00033     PyObject *name_strobj;
00034 };
00035 
00036 /* Flags for above struct */
00037 #define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */
00038 
00039 /* Various kinds of descriptor objects */
00040 
00041 typedef struct {
00042     PyObject_HEAD
00043     PyTypeObject *d_type;
00044     PyObject *d_name;
00045 } PyDescrObject;
00046 
00047 #define PyDescr_COMMON PyDescrObject d_common
00048 
00049 #define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
00050 #define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
00051 
00052 typedef struct {
00053     PyDescr_COMMON;
00054     PyMethodDef *d_method;
00055 } PyMethodDescrObject;
00056 
00057 typedef struct {
00058     PyDescr_COMMON;
00059     struct PyMemberDef *d_member;
00060 } PyMemberDescrObject;
00061 
00062 typedef struct {
00063     PyDescr_COMMON;
00064     PyGetSetDef *d_getset;
00065 } PyGetSetDescrObject;
00066 
00067 typedef struct {
00068     PyDescr_COMMON;
00069     struct wrapperbase *d_base;
00070     void *d_wrapped; /* This can be any function pointer */
00071 } PyWrapperDescrObject;
00072 #endif /* Py_LIMITED_API */
00073 
00074 PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type;
00075 PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
00076 PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
00077 PyAPI_DATA(PyTypeObject) PyMethodDescr_Type;
00078 PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
00079 PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
00080 
00081 PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
00082 PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
00083 struct PyMemberDef; /* forward declaration for following prototype */
00084 PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
00085                                                struct PyMemberDef *);
00086 PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
00087                                                struct PyGetSetDef *);
00088 #ifndef Py_LIMITED_API
00089 PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
00090                                                 struct wrapperbase *, void *);
00091 #define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)
00092 #endif
00093 
00094 PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
00095 PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
00096 
00097 
00098 PyAPI_DATA(PyTypeObject) PyProperty_Type;
00099 #ifdef __cplusplus
00100 }
00101 #endif
00102 #endif /* !Py_DESCROBJECT_H */
00103