home *** CD-ROM | disk | FTP | other *** search
/ Freelog 33 / Freelog033.iso / Progr / Python-2.2.1.exe / METHODOBJECT.H < prev    next >
Encoding:
C/C++ Source or Header  |  2001-08-12  |  2.1 KB  |  71 lines

  1.  
  2. /* Method object interface */
  3.  
  4. #ifndef Py_METHODOBJECT_H
  5. #define Py_METHODOBJECT_H
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9.  
  10. extern DL_IMPORT(PyTypeObject) PyCFunction_Type;
  11.  
  12. #define PyCFunction_Check(op) ((op)->ob_type == &PyCFunction_Type)
  13.  
  14. typedef PyObject *(*PyCFunction)(PyObject *, PyObject *);
  15. typedef PyObject *(*PyCFunctionWithKeywords)(PyObject *, PyObject *,
  16.                          PyObject *);
  17. typedef PyObject *(*PyNoArgsFunction)(PyObject *);
  18.  
  19. extern DL_IMPORT(PyCFunction) PyCFunction_GetFunction(PyObject *);
  20. extern DL_IMPORT(PyObject *) PyCFunction_GetSelf(PyObject *);
  21. extern DL_IMPORT(int) PyCFunction_GetFlags(PyObject *);
  22.  
  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. extern DL_IMPORT(PyObject *) PyCFunction_Call(PyObject *, PyObject *, PyObject *);
  32.  
  33. struct PyMethodDef {
  34.     char    *ml_name;
  35.     PyCFunction  ml_meth;
  36.     int         ml_flags;
  37.     char    *ml_doc;
  38. };
  39. typedef struct PyMethodDef PyMethodDef;
  40.  
  41. extern DL_IMPORT(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, char *);
  42.  
  43. extern DL_IMPORT(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *);
  44.  
  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 any other flag. */
  50. #define METH_NOARGS   0x0004
  51. #define METH_O        0x0008
  52.  
  53. typedef struct PyMethodChain {
  54.     PyMethodDef *methods;        /* Methods of this type */
  55.     struct PyMethodChain *link;    /* NULL or base type */
  56. } PyMethodChain;
  57.  
  58. extern DL_IMPORT(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *,
  59.                                                   char *);
  60.  
  61. typedef struct {
  62.     PyObject_HEAD
  63.     PyMethodDef *m_ml;
  64.     PyObject    *m_self;
  65. } PyCFunctionObject;
  66.  
  67. #ifdef __cplusplus
  68. }
  69. #endif
  70. #endif /* !Py_METHODOBJECT_H */
  71.