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 / CLASSOBJECT.H < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-01  |  2.5 KB  |  75 lines

  1.  
  2. /* Class object interface */
  3.  
  4. /* Revealing some structures (not for general use) */
  5.  
  6. #ifndef Py_CLASSOBJECT_H
  7. #define Py_CLASSOBJECT_H
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11.  
  12. typedef struct {
  13.     PyObject_HEAD
  14.     PyObject    *cl_bases;    /* A tuple of class objects */
  15.     PyObject    *cl_dict;    /* A dictionary */
  16.     PyObject    *cl_name;    /* A string */
  17.     /* The following three are functions or NULL */
  18.     PyObject    *cl_getattr;
  19.     PyObject    *cl_setattr;
  20.     PyObject    *cl_delattr;
  21. } PyClassObject;
  22.  
  23. typedef struct {
  24.     PyObject_HEAD
  25.     PyClassObject *in_class;    /* The class object */
  26.     PyObject      *in_dict;    /* A dictionary */
  27. } PyInstanceObject;
  28.  
  29. typedef struct {
  30.     PyObject_HEAD
  31.     PyObject *im_func;   /* The callable object implementing the method */
  32.     PyObject *im_self;   /* The instance it is bound to, or NULL */
  33.     PyObject *im_class;  /* The class that defined the method */
  34. } PyMethodObject;
  35.  
  36. extern DL_IMPORT(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type;
  37.  
  38. #define PyClass_Check(op) ((op)->ob_type == &PyClass_Type)
  39. #define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type)
  40. #define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
  41.  
  42. extern DL_IMPORT(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *);
  43. extern DL_IMPORT(PyObject *) PyInstance_New(PyObject *, PyObject *,
  44.                                             PyObject *);
  45. extern DL_IMPORT(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *);
  46.  
  47. extern DL_IMPORT(PyObject *) PyMethod_Function(PyObject *);
  48. extern DL_IMPORT(PyObject *) PyMethod_Self(PyObject *);
  49. extern DL_IMPORT(PyObject *) PyMethod_Class(PyObject *);
  50.  
  51. /* Macros for direct access to these values. Type checks are *not*
  52.    done, so use with care. */
  53. #define PyMethod_GET_FUNCTION(meth) \
  54.         (((PyMethodObject *)meth) -> im_func)
  55. #define PyMethod_GET_SELF(meth) \
  56.     (((PyMethodObject *)meth) -> im_self)
  57. #define PyMethod_GET_CLASS(meth) \
  58.     (((PyMethodObject *)meth) -> im_class)
  59.  
  60. extern DL_IMPORT(int) PyClass_IsSubclass(PyObject *, PyObject *);
  61.  
  62. extern DL_IMPORT(PyObject *) PyInstance_DoBinOp(PyObject *, PyObject *,
  63.                                                 char *, char *,
  64.                                                 PyObject * (*)(PyObject *,
  65.                                                                PyObject *));
  66.  
  67. extern DL_IMPORT(int)
  68. PyInstance_HalfBinOp(PyObject *, PyObject *, char *, PyObject **,
  69.             PyObject * (*)(PyObject *, PyObject *), int);
  70.  
  71. #ifdef __cplusplus
  72. }
  73. #endif
  74. #endif /* !Py_CLASSOBJECT_H */
  75.