Update for release.
[python/dscho.git] / Include / methodobject.h
blob993bdae28930373685be1b4a0c9ea3e81d6237c3
2 /* Method object interface */
4 #ifndef Py_METHODOBJECT_H
5 #define Py_METHODOBJECT_H
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
10 PyAPI_DATA(PyTypeObject) PyCFunction_Type;
12 #define PyCFunction_Check(op) ((op)->ob_type == &PyCFunction_Type)
14 typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
15 typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
16 PyObject *);
17 typedef PyObject *(*PyNoArgsFunction)(PyObject *);
19 PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *);
20 PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *);
21 PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *);
23 /* Macros for direct access to these values. Type checks are *not*
24 done, so use with care. */
25 #define PyCFunction_GET_FUNCTION(func) \
26 (((PyCFunctionObject *)func) -> m_ml -> ml_meth)
27 #define PyCFunction_GET_SELF(func) \
28 (((PyCFunctionObject *)func) -> m_self)
29 #define PyCFunction_GET_FLAGS(func) \
30 (((PyCFunctionObject *)func) -> m_ml -> ml_flags)
31 PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
33 struct PyMethodDef {
34 char *ml_name;
35 PyCFunction ml_meth;
36 int ml_flags;
37 char *ml_doc;
39 typedef struct PyMethodDef PyMethodDef;
41 PyAPI_FUNC(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, char *);
43 PyAPI_FUNC(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *);
45 /* Flag passed to newmethodobject */
46 #define METH_OLDARGS 0x0000
47 #define METH_VARARGS 0x0001
48 #define METH_KEYWORDS 0x0002
49 /* METH_NOARGS and METH_O must not be combined with the flags above. */
50 #define METH_NOARGS 0x0004
51 #define METH_O 0x0008
53 /* METH_CLASS and METH_STATIC are a little different; these control
54 the construction of methods for a class. These cannot be used for
55 functions in modules. */
56 #define METH_CLASS 0x0010
57 #define METH_STATIC 0x0020
59 typedef struct PyMethodChain {
60 PyMethodDef *methods; /* Methods of this type */
61 struct PyMethodChain *link; /* NULL or base type */
62 } PyMethodChain;
64 PyAPI_FUNC(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *,
65 char *);
67 typedef struct {
68 PyObject_HEAD
69 PyMethodDef *m_ml;
70 PyObject *m_self;
71 } PyCFunctionObject;
73 #ifdef __cplusplus
75 #endif
76 #endif /* !Py_METHODOBJECT_H */