annotate Include/cStringIO.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 d11fbc796499
children 3983ca1a9897
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25554
36124157b317 SF # 607253, header file problems by Ralf W. Grosse-Kunstleve
Neal Norwitz <nnorwitz@gmail.com>
parents: 24580
diff changeset
1 #ifndef Py_CSTRINGIO_H
36124157b317 SF # 607253, header file problems by Ralf W. Grosse-Kunstleve
Neal Norwitz <nnorwitz@gmail.com>
parents: 24580
diff changeset
2 #define Py_CSTRINGIO_H
22688
c0596f84a8fb Patch #536908: Add missing #include guards/extern "C".
Martin v. Löwis <martin@v.loewis.de>
parents: 18064
diff changeset
3 #ifdef __cplusplus
c0596f84a8fb Patch #536908: Add missing #include guards/extern "C".
Martin v. Löwis <martin@v.loewis.de>
parents: 18064
diff changeset
4 extern "C" {
c0596f84a8fb Patch #536908: Add missing #include guards/extern "C".
Martin v. Löwis <martin@v.loewis.de>
parents: 18064
diff changeset
5 #endif
4598
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
6 /*
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
7
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
8 This header provides access to cStringIO objects from C.
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 Functions are provided for calling cStringIO objects and
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
10 macros are provided for testing whether you have cStringIO
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 objects.
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
12
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
13 Before calling any of the functions or macros, you must initialize
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
14 the routines with:
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
15
9944
396a38ea9b84 There's a macro PycString_IMPORT which the documentation listed as
Guido van Rossum <guido@python.org>
parents: 9605
diff changeset
16 PycString_IMPORT
4598
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 This would typically be done in your init function.
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
19
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 */
59998
d11fbc796499 Backported PyCapsule from 3.1, and converted most uses of
Larry Hastings <larry@hastings.org>
parents: 44351
diff changeset
21
d11fbc796499 Backported PyCapsule from 3.1, and converted most uses of
Larry Hastings <larry@hastings.org>
parents: 44351
diff changeset
22 #define PycStringIO_CAPSULE_NAME "cStringIO.cStringIO_CAPI"
d11fbc796499 Backported PyCapsule from 3.1, and converted most uses of
Larry Hastings <larry@hastings.org>
parents: 44351
diff changeset
23
24580
ca20be24381f Remove function definition from cStringIO.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 22805
diff changeset
24 #define PycString_IMPORT \
59998
d11fbc796499 Backported PyCapsule from 3.1, and converted most uses of
Larry Hastings <larry@hastings.org>
parents: 44351
diff changeset
25 PycStringIO = ((struct PycStringIO_CAPI*)PyCapsule_Import(\
d11fbc796499 Backported PyCapsule from 3.1, and converted most uses of
Larry Hastings <larry@hastings.org>
parents: 44351
diff changeset
26 PycStringIO_CAPSULE_NAME, 0))
4598
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
27
13620
5b727ab37092 Spelling fixes supplied by Rob W. W. Hooft. All these are fixes in either
Thomas Wouters <thomas@python.org>
parents: 13447
diff changeset
28 /* Basic functions to manipulate cStringIO objects from C */
4598
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
29
5279
16372a4c4c14 Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents: 4902
diff changeset
30 static struct PycStringIO_CAPI {
16372a4c4c14 Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents: 4902
diff changeset
31
27291
7039375226a7 SF bug #670229: doc improvement for cStringIO.h
Raymond Hettinger <python@rcn.com>
parents: 25554
diff changeset
32 /* Read a string from an input object. If the last argument
7039375226a7 SF bug #670229: doc improvement for cStringIO.h
Raymond Hettinger <python@rcn.com>
parents: 25554
diff changeset
33 is -1, the remainder will be read.
7039375226a7 SF bug #670229: doc improvement for cStringIO.h
Raymond Hettinger <python@rcn.com>
parents: 25554
diff changeset
34 */
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35999
diff changeset
35 int(*cread)(PyObject *, char **, Py_ssize_t);
4598
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
36
27291
7039375226a7 SF bug #670229: doc improvement for cStringIO.h
Raymond Hettinger <python@rcn.com>
parents: 25554
diff changeset
37 /* Read a line from an input object. Returns the length of the read
7039375226a7 SF bug #670229: doc improvement for cStringIO.h
Raymond Hettinger <python@rcn.com>
parents: 25554
diff changeset
38 line as an int and a pointer inside the object buffer as char** (so
7039375226a7 SF bug #670229: doc improvement for cStringIO.h
Raymond Hettinger <python@rcn.com>
parents: 25554
diff changeset
39 the caller doesn't have to provide its own buffer as destination).
7039375226a7 SF bug #670229: doc improvement for cStringIO.h
Raymond Hettinger <python@rcn.com>
parents: 25554
diff changeset
40 */
13447
a89f7f268de4 Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents: 9944
diff changeset
41 int(*creadline)(PyObject *, char **);
4598
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
42
27291
7039375226a7 SF bug #670229: doc improvement for cStringIO.h
Raymond Hettinger <python@rcn.com>
parents: 25554
diff changeset
43 /* Write a string to an output object*/
36501
7fdc639bc5b4 Merge ssize_t branch.
Martin v. Löwis <martin@v.loewis.de>
parents: 35999
diff changeset
44 int(*cwrite)(PyObject *, const char *, Py_ssize_t);
4598
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
45
27291
7039375226a7 SF bug #670229: doc improvement for cStringIO.h
Raymond Hettinger <python@rcn.com>
parents: 25554
diff changeset
46 /* Get the output object as a Python string (returns new reference). */
13447
a89f7f268de4 Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents: 9944
diff changeset
47 PyObject *(*cgetvalue)(PyObject *);
4598
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
48
5279
16372a4c4c14 Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents: 4902
diff changeset
49 /* Create a new output object */
13447
a89f7f268de4 Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents: 9944
diff changeset
50 PyObject *(*NewOutput)(int);
4598
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
51
27291
7039375226a7 SF bug #670229: doc improvement for cStringIO.h
Raymond Hettinger <python@rcn.com>
parents: 25554
diff changeset
52 /* Create an input object from a Python string
7039375226a7 SF bug #670229: doc improvement for cStringIO.h
Raymond Hettinger <python@rcn.com>
parents: 25554
diff changeset
53 (copies the Python string reference).
7039375226a7 SF bug #670229: doc improvement for cStringIO.h
Raymond Hettinger <python@rcn.com>
parents: 25554
diff changeset
54 */
13447
a89f7f268de4 Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents: 9944
diff changeset
55 PyObject *(*NewInput)(PyObject *);
4598
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
56
5279
16372a4c4c14 Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents: 4902
diff changeset
57 /* The Python types for cStringIO input and output objects.
16372a4c4c14 Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents: 4902
diff changeset
58 Note that you can do input on an output object.
16372a4c4c14 Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents: 4902
diff changeset
59 */
16372a4c4c14 Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents: 4902
diff changeset
60 PyTypeObject *InputType, *OutputType;
16372a4c4c14 Changed the way the C API was exported. Jim Fulton.
Guido van Rossum <guido@python.org>
parents: 4902
diff changeset
61
24580
ca20be24381f Remove function definition from cStringIO.h.
Jeremy Hylton <jeremy@alum.mit.edu>
parents: 22805
diff changeset
62 } *PycStringIO;
4598
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
63
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
64 /* These can be used to test if you have one */
4902
d46e478b5767 Jim's latest version
Guido van Rossum <guido@python.org>
parents: 4598
diff changeset
65 #define PycStringIO_InputCheck(O) \
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
66 (Py_TYPE(O)==PycStringIO->InputType)
4902
d46e478b5767 Jim's latest version
Guido van Rossum <guido@python.org>
parents: 4598
diff changeset
67 #define PycStringIO_OutputCheck(O) \
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
68 (Py_TYPE(O)==PycStringIO->OutputType)
4598
8fdb0539cfb1 Jim F's brainchild
Guido van Rossum <guido@python.org>
parents:
diff changeset
69
22688
c0596f84a8fb Patch #536908: Add missing #include guards/extern "C".
Martin v. Löwis <martin@v.loewis.de>
parents: 18064
diff changeset
70 #ifdef __cplusplus
c0596f84a8fb Patch #536908: Add missing #include guards/extern "C".
Martin v. Löwis <martin@v.loewis.de>
parents: 18064
diff changeset
71 }
c0596f84a8fb Patch #536908: Add missing #include guards/extern "C".
Martin v. Löwis <martin@v.loewis.de>
parents: 18064
diff changeset
72 #endif
25554
36124157b317 SF # 607253, header file problems by Ralf W. Grosse-Kunstleve
Neal Norwitz <nnorwitz@gmail.com>
parents: 24580
diff changeset
73 #endif /* !Py_CSTRINGIO_H */