/necco/python/Include/methodobject.h
C Header | 58 lines | 39 code | 13 blank | 6 comment | 1 complexity | c62f35c5df888fca11067e75ea7eb3f0 MD5 | raw file
1
2/* Method object interface */
3
4#ifndef Py_METHODOBJECT_H
5#define Py_METHODOBJECT_H
6
7PyAPI_DATA(PyTypeObject) PyCFunction_Type;
8
9#define PyCFunction_Check(op) ((op)->ob_type == &PyCFunction_Type)
10
11typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
12typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
13 PyObject *);
14typedef PyObject *(*PyNoArgsFunction)(PyObject *);
15
16#define PyCFunction_GET_FUNCTION(func) \
17 (((PyCFunctionObject *)func) -> m_ml -> ml_meth)
18#define PyCFunction_GET_SELF(func) \
19 (((PyCFunctionObject *)func) -> m_self)
20#define PyCFunction_GET_FLAGS(func) \
21 (((PyCFunctionObject *)func) -> m_ml -> ml_flags)
22PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
23
24struct PyMethodDef {
25 char *ml_name;
26 PyCFunction ml_meth;
27 int ml_flags;
28 char *ml_doc;
29};
30
31typedef struct PyMethodDef PyMethodDef;
32
33#define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL)
34PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *,
35 PyObject *);
36
37/* Flag passed to newmethodobject */
38#define METH_OLDARGS 0x0000
39#define METH_VARARGS 0x0001
40#define METH_KEYWORDS 0x0002
41/* METH_NOARGS and METH_O must not be combined with the flags above. */
42#define METH_NOARGS 0x0004
43#define METH_O 0x0008
44
45/* METH_CLASS and METH_STATIC are a little different; these control
46 the construction of methods for a class. These cannot be used for
47 functions in modules. */
48#define METH_CLASS 0x0010
49#define METH_STATIC 0x0020
50
51typedef struct {
52 PyObject_HEAD
53 PyMethodDef *m_ml;
54 PyObject *m_self;
55 PyObject *m_module;
56} PyCFunctionObject;
57
58#endif /* !Py_METHODOBJECT_H */