Chris@87: Chris@87: /* Class object interface */ Chris@87: Chris@87: /* Revealing some structures (not for general use) */ Chris@87: Chris@87: #ifndef Py_CLASSOBJECT_H Chris@87: #define Py_CLASSOBJECT_H Chris@87: #ifdef __cplusplus Chris@87: extern "C" { Chris@87: #endif Chris@87: Chris@87: typedef struct { Chris@87: PyObject_HEAD Chris@87: PyObject *cl_bases; /* A tuple of class objects */ Chris@87: PyObject *cl_dict; /* A dictionary */ Chris@87: PyObject *cl_name; /* A string */ Chris@87: /* The following three are functions or NULL */ Chris@87: PyObject *cl_getattr; Chris@87: PyObject *cl_setattr; Chris@87: PyObject *cl_delattr; Chris@87: PyObject *cl_weakreflist; /* List of weak references */ Chris@87: } PyClassObject; Chris@87: Chris@87: typedef struct { Chris@87: PyObject_HEAD Chris@87: PyClassObject *in_class; /* The class object */ Chris@87: PyObject *in_dict; /* A dictionary */ Chris@87: PyObject *in_weakreflist; /* List of weak references */ Chris@87: } PyInstanceObject; Chris@87: Chris@87: typedef struct { Chris@87: PyObject_HEAD Chris@87: PyObject *im_func; /* The callable object implementing the method */ Chris@87: PyObject *im_self; /* The instance it is bound to, or NULL */ Chris@87: PyObject *im_class; /* The class that asked for the method */ Chris@87: PyObject *im_weakreflist; /* List of weak references */ Chris@87: } PyMethodObject; Chris@87: Chris@87: PyAPI_DATA(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type; Chris@87: Chris@87: #define PyClass_Check(op) ((op)->ob_type == &PyClass_Type) Chris@87: #define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type) Chris@87: #define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type) Chris@87: Chris@87: PyAPI_FUNC(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *); Chris@87: PyAPI_FUNC(PyObject *) PyInstance_New(PyObject *, PyObject *, Chris@87: PyObject *); Chris@87: PyAPI_FUNC(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *); Chris@87: PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *); Chris@87: Chris@87: PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *); Chris@87: PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *); Chris@87: PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *); Chris@87: Chris@87: /* Look up attribute with name (a string) on instance object pinst, using Chris@87: * only the instance and base class dicts. If a descriptor is found in Chris@87: * a class dict, the descriptor is returned without calling it. Chris@87: * Returns NULL if nothing found, else a borrowed reference to the Chris@87: * value associated with name in the dict in which name was found. Chris@87: * The point of this routine is that it never calls arbitrary Python Chris@87: * code, so is always "safe": all it does is dict lookups. The function Chris@87: * can't fail, never sets an exception, and NULL is not an error (it just Chris@87: * means "not found"). Chris@87: */ Chris@87: PyAPI_FUNC(PyObject *) _PyInstance_Lookup(PyObject *pinst, PyObject *name); 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 PyMethod_GET_FUNCTION(meth) \ Chris@87: (((PyMethodObject *)meth) -> im_func) Chris@87: #define PyMethod_GET_SELF(meth) \ Chris@87: (((PyMethodObject *)meth) -> im_self) Chris@87: #define PyMethod_GET_CLASS(meth) \ Chris@87: (((PyMethodObject *)meth) -> im_class) Chris@87: Chris@87: PyAPI_FUNC(int) PyClass_IsSubclass(PyObject *, PyObject *); Chris@87: Chris@87: PyAPI_FUNC(int) PyMethod_ClearFreeList(void); Chris@87: Chris@87: #ifdef __cplusplus Chris@87: } Chris@87: #endif Chris@87: #endif /* !Py_CLASSOBJECT_H */