home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / py2s152.zip / Include / classobject.h < prev    next >
C/C++ Source or Header  |  1999-06-27  |  4KB  |  100 lines

  1. #ifndef Py_CLASSOBJECT_H
  2. #define Py_CLASSOBJECT_H
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6.  
  7. /***********************************************************
  8. Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
  9. The Netherlands.
  10.  
  11.                         All Rights Reserved
  12.  
  13. Permission to use, copy, modify, and distribute this software and its
  14. documentation for any purpose and without fee is hereby granted,
  15. provided that the above copyright notice appear in all copies and that
  16. both that copyright notice and this permission notice appear in
  17. supporting documentation, and that the names of Stichting Mathematisch
  18. Centrum or CWI or Corporation for National Research Initiatives or
  19. CNRI not be used in advertising or publicity pertaining to
  20. distribution of the software without specific, written prior
  21. permission.
  22.  
  23. While CWI is the initial source for this software, a modified version
  24. is made available by the Corporation for National Research Initiatives
  25. (CNRI) at the Internet address ftp://ftp.python.org.
  26.  
  27. STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
  28. REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
  29. MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
  30. CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  31. DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  32. PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  33. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  34. PERFORMANCE OF THIS SOFTWARE.
  35.  
  36. ******************************************************************/
  37.  
  38. /* Class object interface */
  39.  
  40. /* Revealing some structures (not for general use) */
  41.  
  42. typedef struct {
  43.     PyObject_HEAD
  44.     PyObject    *cl_bases;    /* A tuple of class objects */
  45.     PyObject    *cl_dict;    /* A dictionary */
  46.     PyObject    *cl_name;    /* A string */
  47.     /* The following three are functions or NULL */
  48.     PyObject    *cl_getattr;
  49.     PyObject    *cl_setattr;
  50.     PyObject    *cl_delattr;
  51. } PyClassObject;
  52.  
  53. typedef struct {
  54.     PyObject_HEAD
  55.     PyClassObject    *in_class;    /* The class object */
  56.     PyObject    *in_dict;    /* A dictionary */
  57. } PyInstanceObject;
  58.  
  59. typedef struct {
  60.     PyObject_HEAD
  61.     PyObject *im_func;   /* The callable object implementing the method */
  62.     PyObject *im_self;   /* The instance it is bound to, or NULL */
  63.     PyObject *im_class;  /* The class that defined the method */
  64. } PyMethodObject;
  65.  
  66. extern DL_IMPORT(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type;
  67.  
  68. #define PyClass_Check(op) ((op)->ob_type == &PyClass_Type)
  69. #define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type)
  70. #define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
  71.  
  72. extern DL_IMPORT(PyObject *) PyClass_New Py_PROTO((PyObject *, PyObject *, PyObject *));
  73. extern DL_IMPORT(PyObject *) PyInstance_New Py_PROTO((PyObject *, PyObject *, PyObject *));
  74. extern DL_IMPORT(PyObject *) PyMethod_New Py_PROTO((PyObject *, PyObject *, PyObject *));
  75.  
  76. extern DL_IMPORT(PyObject *) PyMethod_Function Py_PROTO((PyObject *));
  77. extern DL_IMPORT(PyObject *) PyMethod_Self Py_PROTO((PyObject *));
  78. extern DL_IMPORT(PyObject *) PyMethod_Class Py_PROTO((PyObject *));
  79.  
  80. /* Macros for direct access to these values. Type checks are *not*
  81.    done, so use with care. */
  82. #define PyMethod_GET_FUNCTION(meth) \
  83.         (((PyMethodObject *)meth) -> im_func)
  84. #define PyMethod_GET_SELF(meth) \
  85.     (((PyMethodObject *)meth) -> im_self)
  86. #define PyMethod_GET_CLASS(meth) \
  87.     (((PyMethodObject *)meth) -> im_class)
  88.  
  89. extern DL_IMPORT(int) PyClass_IsSubclass Py_PROTO((PyObject *, PyObject *));
  90.  
  91. extern DL_IMPORT(PyObject *) PyInstance_DoBinOp
  92.     Py_PROTO((PyObject *, PyObject *,
  93.           char *, char *,
  94.           PyObject * (*) Py_PROTO((PyObject *, PyObject *)) ));
  95.  
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif /* !Py_CLASSOBJECT_H */
  100.