source: python/trunk/Include/descrobject.h

Last change on this file was 391, checked in by dmik, 11 years ago

python: Merge vendor 2.7.6 to trunk.

  • Property svn:eol-style set to native
File size: 2.4 KB
RevLine 
[2]1/* Descriptors */
2#ifndef Py_DESCROBJECT_H
3#define Py_DESCROBJECT_H
4#ifdef __cplusplus
5extern "C" {
6#endif
7
8typedef PyObject *(*getter)(PyObject *, void *);
9typedef int (*setter)(PyObject *, PyObject *, void *);
10
11typedef struct PyGetSetDef {
[391]12 char *name;
13 getter get;
14 setter set;
15 char *doc;
16 void *closure;
[2]17} PyGetSetDef;
18
19typedef PyObject *(*wrapperfunc)(PyObject *self, PyObject *args,
[391]20 void *wrapped);
[2]21
22typedef PyObject *(*wrapperfunc_kwds)(PyObject *self, PyObject *args,
[391]23 void *wrapped, PyObject *kwds);
[2]24
25struct wrapperbase {
[391]26 char *name;
27 int offset;
28 void *function;
29 wrapperfunc wrapper;
30 char *doc;
31 int flags;
32 PyObject *name_strobj;
[2]33};
34
35/* Flags for above struct */
36#define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */
37
38/* Various kinds of descriptor objects */
39
40#define PyDescr_COMMON \
[391]41 PyObject_HEAD \
42 PyTypeObject *d_type; \
43 PyObject *d_name
[2]44
45typedef struct {
[391]46 PyDescr_COMMON;
[2]47} PyDescrObject;
48
49typedef struct {
[391]50 PyDescr_COMMON;
51 PyMethodDef *d_method;
[2]52} PyMethodDescrObject;
53
54typedef struct {
[391]55 PyDescr_COMMON;
56 struct PyMemberDef *d_member;
[2]57} PyMemberDescrObject;
58
59typedef struct {
[391]60 PyDescr_COMMON;
61 PyGetSetDef *d_getset;
[2]62} PyGetSetDescrObject;
63
64typedef struct {
[391]65 PyDescr_COMMON;
66 struct wrapperbase *d_base;
67 void *d_wrapped; /* This can be any function pointer */
[2]68} PyWrapperDescrObject;
69
70PyAPI_DATA(PyTypeObject) PyWrapperDescr_Type;
71PyAPI_DATA(PyTypeObject) PyDictProxy_Type;
72PyAPI_DATA(PyTypeObject) PyGetSetDescr_Type;
73PyAPI_DATA(PyTypeObject) PyMemberDescr_Type;
74
75PyAPI_FUNC(PyObject *) PyDescr_NewMethod(PyTypeObject *, PyMethodDef *);
76PyAPI_FUNC(PyObject *) PyDescr_NewClassMethod(PyTypeObject *, PyMethodDef *);
77PyAPI_FUNC(PyObject *) PyDescr_NewMember(PyTypeObject *,
[391]78 struct PyMemberDef *);
[2]79PyAPI_FUNC(PyObject *) PyDescr_NewGetSet(PyTypeObject *,
[391]80 struct PyGetSetDef *);
[2]81PyAPI_FUNC(PyObject *) PyDescr_NewWrapper(PyTypeObject *,
[391]82 struct wrapperbase *, void *);
[2]83#define PyDescr_IsData(d) (Py_TYPE(d)->tp_descr_set != NULL)
84
85PyAPI_FUNC(PyObject *) PyDictProxy_New(PyObject *);
86PyAPI_FUNC(PyObject *) PyWrapper_New(PyObject *, PyObject *);
87
88
89PyAPI_DATA(PyTypeObject) PyProperty_Type;
90#ifdef __cplusplus
91}
92#endif
93#endif /* !Py_DESCROBJECT_H */
94
Note: See TracBrowser for help on using the repository browser.