Mercurial > cpython-lru_cache-weakref
annotate Include/cobject.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 | 6f6f965c5e2d |
| children | c1eb668525e1 |
| rev | line source |
|---|---|
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 /* 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
|
3 |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 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
|
5 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
|
6 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
|
7 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
|
8 |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 */ |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
10 |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
11 #ifndef Py_COBJECT_H |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
12 #define Py_COBJECT_H |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
13 #ifdef __cplusplus |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
14 extern "C" { |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
15 #endif |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
16 |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 extern DL_IMPORT(PyTypeObject) PyCObject_Type; |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 #define PyCObject_Check(op) ((op)->ob_type == &PyCObject_Type) |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 /* 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
|
22 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
|
23 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
|
24 destroyed. |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 */ |
|
9586
60fdb1db1175
Add DL_IMPORT(returntype) for all officially exported functions.
Guido van Rossum <guido@python.org>
parents:
6509
diff
changeset
|
27 extern DL_IMPORT(PyObject *) |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
28 PyCObject_FromVoidPtr(void *cobj, void (*destruct)(void*)); |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
29 |
|
6509
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
30 |
|
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
31 /* 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
|
32 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
|
33 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
|
34 the PyCObject is destroyed. |
|
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
35 */ |
|
9586
60fdb1db1175
Add DL_IMPORT(returntype) for all officially exported functions.
Guido van Rossum <guido@python.org>
parents:
6509
diff
changeset
|
36 extern DL_IMPORT(PyObject *) |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
37 PyCObject_FromVoidPtrAndDesc(void *cobj, void *desc, |
|
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
38 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
|
39 |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 /* Retrieve a pointer to a C object from a PyCObject. */ |
|
9586
60fdb1db1175
Add DL_IMPORT(returntype) for all officially exported functions.
Guido van Rossum <guido@python.org>
parents:
6509
diff
changeset
|
41 extern DL_IMPORT(void *) |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
42 PyCObject_AsVoidPtr(PyObject *); |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 |
|
6509
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
44 /* Retrieve a pointer to a description object from a PyCObject. */ |
|
9586
60fdb1db1175
Add DL_IMPORT(returntype) for all officially exported functions.
Guido van Rossum <guido@python.org>
parents:
6509
diff
changeset
|
45 extern DL_IMPORT(void *) |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
46 PyCObject_GetDesc(PyObject *); |
|
6509
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
47 |
|
5033
5b7b703dabfa
Added PyCObject_Import.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
48 /* Import a pointer to a C object from a module using a PyCObject. */ |
|
9586
60fdb1db1175
Add DL_IMPORT(returntype) for all officially exported functions.
Guido van Rossum <guido@python.org>
parents:
6509
diff
changeset
|
49 extern DL_IMPORT(void *) |
|
13444
5709ddba423c
ANSI-fication and Py_PROTO extermination.
Fred Drake <fdrake@acm.org>
parents:
13256
diff
changeset
|
50 PyCObject_Import(char *module_name, char *cobject_name); |
|
5033
5b7b703dabfa
Added PyCObject_Import.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
51 |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 #ifdef __cplusplus |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 } |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 #endif |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 #endif /* !Py_COBJECT_H */ |
