annotate Include/classobject.h @ 80661:94de77bd0b4b 2.7

Issue #16194: document imp.load_dynamic problems when read several extension modules from the same binary object file.
author Andrew Svetlov <andrew.svetlov@gmail.com>
date Thu, 29 Nov 2012 19:51:28 +0200
parents 7b8ba019cd15
children
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;
60112
7b8ba019cd15 Issue #8268: Old-style classes (not just instances) now support weak
Antoine Pitrou <solipsis@pitrou.net>
parents: 45341
diff changeset
21 PyObject *cl_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
22 } 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
23
1290
7971fecbf28e * Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents: 1289
diff changeset
24 typedef struct {
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
25 PyObject_HEAD
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
26 PyClassObject *in_class; /* The class object */
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
27 PyObject *in_dict; /* A dictionary */
16385
1fb6672b20ef PEP 205, Weak References -- initial checkin.
Fred Drake <fdrake@acm.org>
parents: 16313
diff changeset
28 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
29 } PyInstanceObject;
1290
7971fecbf28e * Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents: 1289
diff changeset
30
8657
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
31 typedef struct {
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
32 PyObject_HEAD
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
33 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
34 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
35 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
36 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
37 } PyMethodObject;
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
38
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 21300
diff changeset
39 PyAPI_DATA(PyTypeObject) PyClass_Type, PyInstance_Type, PyMethod_Type;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
40
2129
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 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
42 #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
43 #define PyMethod_Check(op) ((op)->ob_type == &PyMethod_Type)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
44
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 21300
diff changeset
45 PyAPI_FUNC(PyObject *) PyClass_New(PyObject *, PyObject *, PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 21300
diff changeset
46 PyAPI_FUNC(PyObject *) PyInstance_New(PyObject *, PyObject *,
13444
5709ddba423c ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents: 13256
diff changeset
47 PyObject *);
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 21300
diff changeset
48 PyAPI_FUNC(PyObject *) PyInstance_NewRaw(PyObject *, PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 21300
diff changeset
49 PyAPI_FUNC(PyObject *) PyMethod_New(PyObject *, PyObject *, PyObject *);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
50
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 21300
diff changeset
51 PyAPI_FUNC(PyObject *) PyMethod_Function(PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 21300
diff changeset
52 PyAPI_FUNC(PyObject *) PyMethod_Self(PyObject *);
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 21300
diff changeset
53 PyAPI_FUNC(PyObject *) PyMethod_Class(PyObject *);
19751
3d76dfc34c57 Add PyMethod_Function(), PyMethod_Self(), PyMethod_Class() back.
Guido van Rossum <guido@python.org>
parents: 18933
diff changeset
54
28519
2a3095a415b1 New private API function _PyInstance_Lookup. gc will use this to figure
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
55 /* Look up attribute with name (a string) on instance object pinst, using
2a3095a415b1 New private API function _PyInstance_Lookup. gc will use this to figure
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
56 * only the instance and base class dicts. If a descriptor is found in
2a3095a415b1 New private API function _PyInstance_Lookup. gc will use this to figure
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
57 * a class dict, the descriptor is returned without calling it.
2a3095a415b1 New private API function _PyInstance_Lookup. gc will use this to figure
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
58 * Returns NULL if nothing found, else a borrowed reference to the
2a3095a415b1 New private API function _PyInstance_Lookup. gc will use this to figure
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
59 * value associated with name in the dict in which name was found.
2a3095a415b1 New private API function _PyInstance_Lookup. gc will use this to figure
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
60 * The point of this routine is that it never calls arbitrary Python
2a3095a415b1 New private API function _PyInstance_Lookup. gc will use this to figure
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
61 * code, so is always "safe": all it does is dict lookups. The function
28527
5b5462ae314d Typo repair.
Tim Peters <tim.peters@gmail.com>
parents: 28519
diff changeset
62 * can't fail, never sets an exception, and NULL is not an error (it just
28519
2a3095a415b1 New private API function _PyInstance_Lookup. gc will use this to figure
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
63 * means "not found").
2a3095a415b1 New private API function _PyInstance_Lookup. gc will use this to figure
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
64 */
28527
5b5462ae314d Typo repair.
Tim Peters <tim.peters@gmail.com>
parents: 28519
diff changeset
65 PyAPI_FUNC(PyObject *) _PyInstance_Lookup(PyObject *pinst, PyObject *name);
28519
2a3095a415b1 New private API function _PyInstance_Lookup. gc will use this to figure
Tim Peters <tim.peters@gmail.com>
parents: 24752
diff changeset
66
8657
ac43e2246695 Move the definition of PyMethodObject to classobject.h, so it can define
Guido van Rossum <guido@python.org>
parents: 5195
diff changeset
67 /* 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
68 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
69 #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
70 (((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
71 #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
72 (((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
73 #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
74 (((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
75
24752
c1eb668525e1 Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents: 21300
diff changeset
76 PyAPI_FUNC(int) PyClass_IsSubclass(PyObject *, PyObject *);
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
77
45341
65ae68c7aca3 Implemented Martin's suggestion to clear the free lists during the garbage collection of the highest generation.
Christian Heimes <christian@cheimes.de>
parents: 28527
diff changeset
78 PyAPI_FUNC(int) PyMethod_ClearFreeList(void);
14162
27d7d89c774b The real suport for augmented assignment: new opcodes, new PyNumber and
Thomas Wouters <thomas@python.org>
parents: 13444
diff changeset
79
1329
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
80 #ifdef __cplusplus
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
81 }
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
82 #endif
519c25039c6a * Added support for X11 modules.
Guido van Rossum <guido@python.org>
parents: 1290
diff changeset
83 #endif /* !Py_CLASSOBJECT_H */