annotate Include/cobject.h @ 28646:193b8aec00ce legacy-trunk

Changes from Jonathan Riehl to allow his pgen extension (PEP 269) to work. This includes some more code that used to be part of pgen in the main parser; I'm okay with that. I'll see if the Windows build needs work next.
author Guido van Rossum <guido@python.org>
date Thu, 17 Apr 2003 14:55:42 +0000
parents c1eb668525e1
children 07a0a0726649
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
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 */
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
3315
44f48aaca8bf opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff changeset
48 #ifdef __cplusplus
44f48aaca8bf opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff changeset
49 }
44f48aaca8bf opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff changeset
50 #endif
44f48aaca8bf opaque C object a la Jim Fulton
Guido van Rossum <guido@python.org>
parents:
diff changeset
51 #endif /* !Py_COBJECT_H */