annotate Include/classobject.h @ 25838:8540887bcec6 2.2

Backport of 2.183: Fix memory leak in add_subclass() found by NealN with valgrind.
author Guido van Rossum <guido@python.org>
date Fri, 18 Oct 2002 13:42:21 +0000
parents f5532cc1514b
children 5fa8344d6e6f c1eb668525e1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
1
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
2 /* Class object interface */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
3
1290
7971fecbf28e * Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents: 1289
diff changeset
4 /* Revealing some structures (not for general use) */
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
5
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
6 #ifndef Py_CLASSOBJECT_H
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
7 #define Py_CLASSOBJECT_H
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
8 #ifdef __cplusplus
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
9 extern "C" {
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
10 #endif
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
11
1289
4d292c7857d4 Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
12 typedef struct {
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
13 PyObject_HEAD
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
14 PyObject *cl_bases; /* A tuple of class objects */
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
15 PyObject *cl_dict; /* A dictionary */
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
16 PyObject *cl_name; /* A string */
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
17 /* The following three are functions or NULL */
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
18 PyObject *cl_getattr;
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
19 PyObject *cl_setattr;
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
20 PyObject *cl_delattr;
2129
05360cd616ae The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents: 2074
diff changeset
21 } PyClassObject;
1289
4d292c7857d4 Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents: 1288
diff changeset
22
1290
7971fecbf28e * Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents: 1289
diff changeset
23 typedef struct {
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
24 PyObject_HEAD
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
25 PyClassObject *in_class; /* The class object */
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
26 PyObject *in_dict; /* A dictionary */
16385
1fb6672b20ef PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents: 16313
diff changeset
27 PyObject *in_weakreflist; /* List of weak references */
2129
05360cd616ae The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents: 2074
diff changeset
28 } PyInstanceObject;
1290
7971fecbf28e * Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents: 1289
diff changeset
29
8657
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
30 typedef struct {
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
31 PyObject_HEAD
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
32 PyObject *im_func; /* The callable object implementing the method */
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
33 PyObject *im_self; /* The instance it is bound to, or NULL */
21300
f5532cc1514b PyMethodObject(): Update the comment about im_class based upon a
Guido van Rossum <guido@python.org>
parents: 19751
diff changeset
34 PyObject *im_class; /* The class that asked for the method */
17169
d807488dfc7a Add the necessary field for weak reference support to the function and
Fred Drake <fdrake@acm.org>
parents: 16385
diff changeset
35 PyObject *im_weakreflist; /* List of weak references */
8657
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
36 } PyMethodObject;
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
37
2436
fa98dda07877 make the type a parameter of the DL_IMPORT macro, for Borland C
Guido van Rossum <guido@python.org>
parents: 2197
diff changeset
38 extern DL_IMPORT(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
39
2129
05360cd616ae The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents: 2074
diff changeset
40 #define PyClass_Check(op) ((op)->ob_type == &PyClass_Type)
05360cd616ae The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents: 2074
diff changeset
41 #define PyInstance_Check(op) ((op)->ob_type == &PyInstance_Type)
05360cd616ae The great renaming, phase two: all header files have been updated to
Guido van Rossum <guido@python.org>
parents: 2074
diff changeset
42 #define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
43
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
44 extern DL_IMPORT(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *);
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
45 extern DL_IMPORT(PyObject *) PyInstance_New(PyObject *, PyObject *,
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
46 PyObject *);
16313
662adf03e4fa Added prototype for PyInstance_NewRaw().
Fred Drake <fdrake@acm.org>
parents: 15715
diff changeset
47 extern DL_IMPORT(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *);
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
48 extern DL_IMPORT(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
49
19751
3d76dfc34c57 Add PyMethod_Function(), PyMethod_Self(), PyMethod_Class() back.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
50 extern DL_IMPORT(PyObject *) PyMethod_Function(PyObject *);
3d76dfc34c57 Add PyMethod_Function(), PyMethod_Self(), PyMethod_Class() back.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
51 extern DL_IMPORT(PyObject *) PyMethod_Self(PyObject *);
3d76dfc34c57 Add PyMethod_Function(), PyMethod_Self(), PyMethod_Class() back.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
52 extern DL_IMPORT(PyObject *) PyMethod_Class(PyObject *);
3d76dfc34c57 Add PyMethod_Function(), PyMethod_Self(), PyMethod_Class() back.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
53
8657
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
54 /* Macros for direct access to these values. Type checks are *not*
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
55 done, so use with care. */
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
56 #define PyMethod_GET_FUNCTION(meth) \
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
57 (((PyMethodObject *)meth) -> im_func)
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
58 #define PyMethod_GET_SELF(meth) \
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
59 (((PyMethodObject *)meth) -> im_self)
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
60 #define PyMethod_GET_CLASS(meth) \
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
61 (((PyMethodObject *)meth) -> im_class)
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
62
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
63 extern DL_IMPORT(int) PyClass_IsSubclass(PyObject *, PyObject *);
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
64
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13444
diff changeset
65
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
66 #ifdef __cplusplus
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
67 }
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
68 #endif
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
69 #endif /* !Py_CLASSOBJECT_H */