Mercurial > cpython-lru_cache-weakref
annotate Include/cobject.h @ 58765:2ba7677bfa95 legacy-trunk
testCopysign was defined twice in test_math; combine the definitions
| author | Mark Dickinson <dickinsm@gmail.com> |
|---|---|
| date | Sat, 06 Feb 2010 23:11:25 +0000 |
| parents | bbffe0914c56 |
| children | 911df82bc25d d11fbc796499 |
| 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 |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
14375
diff
changeset
|
17 PyAPI_DATA(PyTypeObject) PyCObject_Type; |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 |
|
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
|
19 #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
|
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 */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
14375
diff
changeset
|
27 PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtr( |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
14375
diff
changeset
|
28 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 */ |
|
24752
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
14375
diff
changeset
|
36 PyAPI_FUNC(PyObject *) PyCObject_FromVoidPtrAndDesc( |
|
c1eb668525e1
Excise DL_EXPORT from Include.
Mark Hammond <mhammond@skippinet.com.au>
parents:
14375
diff
changeset
|
37 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
|
38 |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 /* 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
|
40 PyAPI_FUNC(void *) PyCObject_AsVoidPtr(PyObject *); |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
41 |
|
6509
f022bbd12338
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
Guido van Rossum <guido@python.org>
parents:
5033
diff
changeset
|
42 /* 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
|
43 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
|
44 |
|
5033
5b7b703dabfa
Added PyCObject_Import.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
45 /* 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
|
46 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
|
47 |
|
30716
07a0a0726649
Make CObjects mutable. Fixes #477441.
Martin v. Löwis <martin@v.loewis.de>
parents:
24752
diff
changeset
|
48 /* 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
|
49 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
|
50 |
|
48889
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
51 |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
52 typedef struct { |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
53 PyObject_HEAD |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
54 void *cobject; |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
55 void *desc; |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
56 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
|
57 } PyCObject; |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
58 |
|
bbffe0914c56
#3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents:
44351
diff
changeset
|
59 |
|
3315
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
60 #ifdef __cplusplus |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 } |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 #endif |
|
44f48aaca8bf
opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 #endif /* !Py_COBJECT_H */ |
