Mercurial > cpython-lru_cache-weakref
annotate Include/cobject.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 | 57f4c99082df |
| children |
| rev | line source |
|---|---|
|
60157
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
1 /* |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
2 CObjects are marked Pending Deprecation as of Python 2.7. |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
3 The full schedule for 2.x is as follows: |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
4 - CObjects are marked Pending Deprecation in Python 2.7. |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
5 - CObjects will be marked Deprecated in Python 2.8 |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
6 (if there is one). |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
7 - CObjects will be removed in Python 2.9 (if there is one). |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
8 |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
9 Additionally, for the Python 3.x series: |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
10 - CObjects were marked Deprecated in Python 3.1. |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
11 - CObjects will be removed in Python 3.2. |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
12 |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
13 You should switch all use of CObjects to capsules. Capsules |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
14 have a safer and more consistent API. For more information, |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
15 see Include/pycapsule.h, or read the "Capsules" topic in |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
16 the "Python/C API Reference Manual". |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
17 |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
18 Python 2.7 no longer uses CObjects itself; all objects which |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
19 were formerly CObjects are now capsules. Note that this change |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
20 does not by itself break binary compatibility with extensions |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
21 built for previous versions of Python--PyCObject_AsVoidPtr() |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
22 has been changed to also understand capsules. |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
23 |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
24 */ |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
25 |
|
57f4c99082df
Capsule-related changes:
Larry Hastings <larry@hastings.org>
parents:
59998
diff
changeset
|
26 /* original file header comment follows: */ |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 /* C objects to be exported from one extension module to another. |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 C objects are used for communication between extension modules. |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 They provide a way for an extension module to export a C interface |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 to other extension modules, so that extension modules can use the |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 Python import mechanism to link to one another. |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 */ |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
37 #ifndef Py_COBJECT_H |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
38 #define Py_COBJECT_H |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
39 #ifdef __cplusplus |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
40 extern "C" { |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
41 #endif |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
42 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
14375
diff
changeset
|
43 PyAPI_DATA(PyTypeObject) PyCObject_Type; |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 |
|
44351
86a2679dca46
#1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents:
42334
diff
changeset
|
45 #define PyCObject_Check(op) (Py_TYPE(op) == &PyCObject_Type) |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 /* Create a PyCObject from a pointer to a C object and an optional |
|
13620
5b727ab37092
Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents:
13444
diff
changeset
|
48 destructor function. If the second argument is non-null, then it |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
49 will be called with the first argument if and when the PyCObject is |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 destroyed. |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
14375
diff
changeset
|
53 PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr( |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
14375
diff
changeset
|
54 void *cobj, void (*destruct)(void*)); |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 |
|
6509
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
56 |
|
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
57 /* Create a PyCObject from a pointer to a C object, a description object, |
|
13620
5b727ab37092
Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents:
13444
diff
changeset
|
58 and an optional destructor function. If the third argument is non-null, |
|
6509
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
59 then it will be called with the first and second arguments if and when |
|
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
60 the PyCObject is destroyed. |
|
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
61 */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
14375
diff
changeset
|
62 PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc( |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
14375
diff
changeset
|
63 void *cobj, void *desc, void (*destruct)(void*,void*)); |
|
6509
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
64 |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
65 /* Retrieve a pointer to a C object from a PyCObject. */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
14375
diff
changeset
|
66 PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject *); |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
67 |
|
6509
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
68 /* Retrieve a pointer to a description object from a PyCObject. */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
14375
diff
changeset
|
69 PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *); |
|
6509
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
70 |
|
5033
5b7b703dabfa
Added PyCObject_Import.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
71 /* Import a pointer to a C object from a module using a PyCObject. */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
14375
diff
changeset
|
72 PyAPI_FUNC(void *) PyCObject_Import(char *module_name, char *cobject_name); |
|
5033
5b7b703dabfa
Added PyCObject_Import.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
73 |
|
30716
07a0a0726649
Make CObjects mutable. Fixes #477441.
Martin v. Löwis <martin@v.loewis.de>
parents:
24752
diff
changeset
|
74 /* Modify a C object. Fails (==0) if object has a destructor. */ |
|
07a0a0726649
Make CObjects mutable. Fixes #477441.
Martin v. Löwis <martin@v.loewis.de>
parents:
24752
diff
changeset
|
75 PyAPI_FUNC(int) PyCObject_SetVoidPtr(PyObject *self, void *cobj); |
|
07a0a0726649
Make CObjects mutable. Fixes #477441.
Martin v. Löwis <martin@v.loewis.de>
parents:
24752
diff
changeset
|
76 |
|
48889
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
77 |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
78 typedef struct { |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
79 PyObject_HEAD |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
80 void *cobject; |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
81 void *desc; |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
82 void (*destructor)(void *); |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
83 } PyCObject; |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
84 |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
85 |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
86 #ifdef __cplusplus |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
87 } |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 #endif |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 #endif /* !Py_COBJECT_H */ |
