py-cvs-2001_07_13 (Rev 1.3) merge
[python/dscho.git] / Include / methodobject.h
bloba205011e696726c7f9c75bbcc9135b3ad7d1066b
2 /* Method object interface */
4 #ifndef Py_METHODOBJECT_H
5 #define Py_METHODOBJECT_H
6 #ifdef __cplusplus
7 extern "C" {
8 #endif
10 extern DL_IMPORT(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 *);
18 extern DL_IMPORT(PyCFunction) PyCFunction_GetFunction(PyObject *);
19 extern DL_IMPORT(PyObject *) PyCFunction_GetSelf(PyObject *);
20 extern DL_IMPORT(int) PyCFunction_GetFlags(PyObject *);
22 /* Macros for direct access to these values. Type checks are *not*
23 done, so use with care. */
24 #define PyCFunction_GET_FUNCTION(func) \
25 (((PyCFunctionObject *)func) -> m_ml -> ml_meth)
26 #define PyCFunction_GET_SELF(func) \
27 (((PyCFunctionObject *)func) -> m_self)
28 #define PyCFunction_GET_FLAGS(func) \
29 (((PyCFunctionObject *)func) -> m_ml -> ml_flags)
31 struct PyMethodDef {
32 char *ml_name;
33 PyCFunction ml_meth;
34 int ml_flags;
35 char *ml_doc;
37 typedef struct PyMethodDef PyMethodDef;
39 extern DL_IMPORT(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, char *);
41 extern DL_IMPORT(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *);
43 /* Flag passed to newmethodobject */
44 #define METH_OLDARGS 0x0000
45 #define METH_VARARGS 0x0001
46 #define METH_KEYWORDS 0x0002
48 typedef struct PyMethodChain {
49 PyMethodDef *methods; /* Methods of this type */
50 struct PyMethodChain *link; /* NULL or base type */
51 } PyMethodChain;
53 extern DL_IMPORT(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *,
54 char *);
56 typedef struct {
57 PyObject_HEAD
58 PyMethodDef *m_ml;
59 PyObject *m_self;
60 } PyCFunctionObject;
62 #ifdef __cplusplus
64 #endif
65 #endif /* !Py_METHODOBJECT_H */