annotate Include/cobject.h @ 51749:1408feec0084 3.0

Merged revisions 69798 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ................ r69798 | benjamin.peterson | 2009-02-19 22:02:38 -0600 (Thu, 19 Feb 2009) | 13 lines Merged revisions 69769,69776 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r69769 | georg.brandl | 2009-02-19 02:30:06 -0600 (Thu, 19 Feb 2009) | 1 line #5310, #3558: fix operator precedence table. ........ r69776 | georg.brandl | 2009-02-19 10:34:51 -0600 (Thu, 19 Feb 2009) | 2 lines #5317: update IronPython URL. ........ ................
author Benjamin Peterson <benjamin@python.org>
date Fri, 20 Feb 2009 04:05:32 +0000
parents 27e142d99a71
children 911df82bc25d d11fbc796499
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
48888
27e142d99a71 #3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents: 44351
diff changeset
51
27e142d99a71 #3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents: 44351
diff changeset
52 typedef struct {
27e142d99a71 #3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents: 44351
diff changeset
53 PyObject_HEAD
27e142d99a71 #3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents: 44351
diff changeset
54 void *cobject;
27e142d99a71 #3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents: 44351
diff changeset
55 void *desc;
27e142d99a71 #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 *);
27e142d99a71 #3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents: 44351
diff changeset
57 } PyCObject;
27e142d99a71 #3668: When PyArg_ParseTuple correctly parses a s* format, but raises an
Antoine Pitrou <solipsis@pitrou.net>
parents: 44351
diff changeset
58
27e142d99a71 #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 */