home *** CD-ROM | disk | FTP | other *** search
/ PC World 2001 April / PCWorld_2001-04_cd.bin / Software / TemaCD / webclean / !!!python!!! / BeOpen-Python-2.0.exe / METHODOBJECT.H < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-01  |  1.9 KB  |  66 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.  
  18. extern DL_IMPORT(PyCFunction) PyCFunction_GetFunction(PyObject *);
  19. extern DL_IMPORT(PyObject *) PyCFunction_GetSelf(PyObject *);
  20. extern DL_IMPORT(int) PyCFunction_GetFlags(PyObject *);
  21.  
  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)
  30.  
  31. struct PyMethodDef {
  32.     char    *ml_name;
  33.     PyCFunction  ml_meth;
  34.     int         ml_flags;
  35.     char    *ml_doc;
  36. };
  37. typedef struct PyMethodDef PyMethodDef;
  38.  
  39. extern DL_IMPORT(PyObject *) Py_FindMethod(PyMethodDef[], PyObject *, char *);
  40.  
  41. extern DL_IMPORT(PyObject *) PyCFunction_New(PyMethodDef *, PyObject *);
  42.  
  43. /* Flag passed to newmethodobject */
  44. #define METH_OLDARGS  0x0000
  45. #define METH_VARARGS  0x0001
  46. #define METH_KEYWORDS 0x0002
  47.  
  48. typedef struct PyMethodChain {
  49.     PyMethodDef *methods;        /* Methods of this type */
  50.     struct PyMethodChain *link;    /* NULL or base type */
  51. } PyMethodChain;
  52.  
  53. extern DL_IMPORT(PyObject *) Py_FindMethodInChain(PyMethodChain *, PyObject *,
  54.                                                   char *);
  55.  
  56. typedef struct {
  57.     PyObject_HEAD
  58.     PyMethodDef *m_ml;
  59.     PyObject    *m_self;
  60. } PyCFunctionObject;
  61.  
  62. #ifdef __cplusplus
  63. }
  64. #endif
  65. #endif /* !Py_METHODOBJECT_H */
  66.