Chris@87
|
1
|
Chris@87
|
2 /* Class object interface */
|
Chris@87
|
3
|
Chris@87
|
4 /* Revealing some structures (not for general use) */
|
Chris@87
|
5
|
Chris@87
|
6 #ifndef Py_CLASSOBJECT_H
|
Chris@87
|
7 #define Py_CLASSOBJECT_H
|
Chris@87
|
8 #ifdef __cplusplus
|
Chris@87
|
9 extern "C" {
|
Chris@87
|
10 #endif
|
Chris@87
|
11
|
Chris@87
|
12 typedef struct {
|
Chris@87
|
13 PyObject_HEAD
|
Chris@87
|
14 PyObject *cl_bases; /* A tuple of class objects */
|
Chris@87
|
15 PyObject *cl_dict; /* A dictionary */
|
Chris@87
|
16 PyObject *cl_name; /* A string */
|
Chris@87
|
17 /* The following three are functions or NULL */
|
Chris@87
|
18 PyObject *cl_getattr;
|
Chris@87
|
19 PyObject *cl_setattr;
|
Chris@87
|
20 PyObject *cl_delattr;
|
Chris@87
|
21 PyObject *cl_weakreflist; /* List of weak references */
|
Chris@87
|
22 } PyClassObject;
|
Chris@87
|
23
|
Chris@87
|
24 typedef struct {
|
Chris@87
|
25 PyObject_HEAD
|
Chris@87
|
26 PyClassObject *in_class; /* The class object */
|
Chris@87
|
27 PyObject *in_dict; /* A dictionary */
|
Chris@87
|
28 PyObject *in_weakreflist; /* List of weak references */
|
Chris@87
|
29 } PyInstanceObject;
|
Chris@87
|
30
|
Chris@87
|
31 typedef struct {
|
Chris@87
|
32 PyObject_HEAD
|
Chris@87
|
33 PyObject *im_func; /* The callable object implementing the method */
|
Chris@87
|
34 PyObject *im_self; /* The instance it is bound to, or NULL */
|
Chris@87
|
35 PyObject *im_class; /* The class that asked for the method */
|
Chris@87
|
36 PyObject *im_weakreflist; /* List of weak references */
|
Chris@87
|
37 } PyMethodObject;
|
Chris@87
|
38
|
Chris@87
|
39 PyAPI_DATA(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type;
|
Chris@87
|
40
|
Chris@87
|
41 #define PyClass_Check(op) ((op)->ob_type == &PyClass_Type)
|
Chris@87
|
42 #define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type)
|
Chris@87
|
43 #define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
|
Chris@87
|
44
|
Chris@87
|
45 PyAPI_FUNC(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *);
|
Chris@87
|
46 PyAPI_FUNC(PyObject *) PyInstance_New(PyObject *, PyObject *,
|
Chris@87
|
47 PyObject *);
|
Chris@87
|
48 PyAPI_FUNC(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *);
|
Chris@87
|
49 PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *);
|
Chris@87
|
50
|
Chris@87
|
51 PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);
|
Chris@87
|
52 PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
|
Chris@87
|
53 PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *);
|
Chris@87
|
54
|
Chris@87
|
55 /* Look up attribute with name (a string) on instance object pinst, using
|
Chris@87
|
56 * only the instance and base class dicts. If a descriptor is found in
|
Chris@87
|
57 * a class dict, the descriptor is returned without calling it.
|
Chris@87
|
58 * Returns NULL if nothing found, else a borrowed reference to the
|
Chris@87
|
59 * value associated with name in the dict in which name was found.
|
Chris@87
|
60 * The point of this routine is that it never calls arbitrary Python
|
Chris@87
|
61 * code, so is always "safe": all it does is dict lookups. The function
|
Chris@87
|
62 * can't fail, never sets an exception, and NULL is not an error (it just
|
Chris@87
|
63 * means "not found").
|
Chris@87
|
64 */
|
Chris@87
|
65 PyAPI_FUNC(PyObject *) _PyInstance_Lookup(PyObject *pinst, PyObject *name);
|
Chris@87
|
66
|
Chris@87
|
67 /* Macros for direct access to these values. Type checks are *not*
|
Chris@87
|
68 done, so use with care. */
|
Chris@87
|
69 #define PyMethod_GET_FUNCTION(meth) \
|
Chris@87
|
70 (((PyMethodObject *)meth) -> im_func)
|
Chris@87
|
71 #define PyMethod_GET_SELF(meth) \
|
Chris@87
|
72 (((PyMethodObject *)meth) -> im_self)
|
Chris@87
|
73 #define PyMethod_GET_CLASS(meth) \
|
Chris@87
|
74 (((PyMethodObject *)meth) -> im_class)
|
Chris@87
|
75
|
Chris@87
|
76 PyAPI_FUNC(int) PyClass_IsSubclass(PyObject *, PyObject *);
|
Chris@87
|
77
|
Chris@87
|
78 PyAPI_FUNC(int) PyMethod_ClearFreeList(void);
|
Chris@87
|
79
|
Chris@87
|
80 #ifdef __cplusplus
|
Chris@87
|
81 }
|
Chris@87
|
82 #endif
|
Chris@87
|
83 #endif /* !Py_CLASSOBJECT_H */
|