Chris@87: Chris@87: /* Method object interface */ Chris@87: Chris@87: #ifndef Py_METHODOBJECT_H Chris@87: #define Py_METHODOBJECT_H Chris@87: #ifdef __cplusplus Chris@87: extern "C" { Chris@87: #endif Chris@87: Chris@87: /* This is about the type 'builtin_function_or_method', Chris@87: not Python methods in user-defined classes. See classobject.h Chris@87: for the latter. */ Chris@87: Chris@87: PyAPI_DATA(PyTypeObject) PyCFunction_Type; Chris@87: Chris@87: #define PyCFunction_Check(op) (Py_TYPE(op) == &PyCFunction_Type) Chris@87: Chris@87: typedef PyObject *(*PyCFunction)(PyObject *, PyObject *); Chris@87: typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *, Chris@87: PyObject *); Chris@87: typedef PyObject *(*PyNoArgsFunction)(PyObject *); Chris@87: Chris@87: PyAPI_FUNC(PyCFunction) PyCFunction_GetFunction(PyObject *); Chris@87: PyAPI_FUNC(PyObject *) PyCFunction_GetSelf(PyObject *); Chris@87: PyAPI_FUNC(int) PyCFunction_GetFlags(PyObject *); Chris@87: Chris@87: /* Macros for direct access to these values. Type checks are *not* Chris@87: done, so use with care. */ Chris@87: #define PyCFunction_GET_FUNCTION(func) \ Chris@87: (((PyCFunctionObject *)func) -> m_ml -> ml_meth) Chris@87: #define PyCFunction_GET_SELF(func) \ Chris@87: (((PyCFunctionObject *)func) -> m_self) Chris@87: #define PyCFunction_GET_FLAGS(func) \ Chris@87: (((PyCFunctionObject *)func) -> m_ml -> ml_flags) Chris@87: PyAPI_FUNC(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *); Chris@87: Chris@87: struct PyMethodDef { Chris@87: const char *ml_name; /* The name of the built-in function/method */ Chris@87: PyCFunction ml_meth; /* The C function that implements it */ Chris@87: int ml_flags; /* Combination of METH_xxx flags, which mostly Chris@87: describe the args expected by the C func */ Chris@87: const char *ml_doc; /* The __doc__ attribute, or NULL */ Chris@87: }; Chris@87: typedef struct PyMethodDef PyMethodDef; Chris@87: Chris@87: PyAPI_FUNC(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, const char *); Chris@87: Chris@87: #define PyCFunction_New(ML, SELF) PyCFunction_NewEx((ML), (SELF), NULL) Chris@87: PyAPI_FUNC(PyObject *) PyCFunction_NewEx(PyMethodDef *, PyObject *, Chris@87: PyObject *); Chris@87: Chris@87: /* Flag passed to newmethodobject */ Chris@87: #define METH_OLDARGS 0x0000 Chris@87: #define METH_VARARGS 0x0001 Chris@87: #define METH_KEYWORDS 0x0002 Chris@87: /* METH_NOARGS and METH_O must not be combined with the flags above. */ Chris@87: #define METH_NOARGS 0x0004 Chris@87: #define METH_O 0x0008 Chris@87: Chris@87: /* METH_CLASS and METH_STATIC are a little different; these control Chris@87: the construction of methods for a class. These cannot be used for Chris@87: functions in modules. */ Chris@87: #define METH_CLASS 0x0010 Chris@87: #define METH_STATIC 0x0020 Chris@87: Chris@87: /* METH_COEXIST allows a method to be entered eventhough a slot has Chris@87: already filled the entry. When defined, the flag allows a separate Chris@87: method, "__contains__" for example, to coexist with a defined Chris@87: slot like sq_contains. */ Chris@87: Chris@87: #define METH_COEXIST 0x0040 Chris@87: Chris@87: typedef struct PyMethodChain { Chris@87: PyMethodDef *methods; /* Methods of this type */ Chris@87: struct PyMethodChain *link; /* NULL or base type */ Chris@87: } PyMethodChain; Chris@87: Chris@87: PyAPI_FUNC(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *, Chris@87: const char *); Chris@87: Chris@87: typedef struct { Chris@87: PyObject_HEAD Chris@87: PyMethodDef *m_ml; /* Description of the C function to call */ Chris@87: PyObject *m_self; /* Passed as 'self' arg to the C func, can be NULL */ Chris@87: PyObject *m_module; /* The __module__ attribute, can be anything */ Chris@87: } PyCFunctionObject; Chris@87: Chris@87: PyAPI_FUNC(int) PyCFunction_ClearFreeList(void); Chris@87: Chris@87: #ifdef __cplusplus Chris@87: } Chris@87: #endif Chris@87: #endif /* !Py_METHODOBJECT_H */