source: python/trunk/Include/cStringIO.h

Last change on this file was 391, checked in by dmik, 11 years ago

python: Merge vendor 2.7.6 to trunk.

  • Property svn:eol-style set to native
File size: 2.0 KB
RevLine 
[2]1#ifndef Py_CSTRINGIO_H
2#define Py_CSTRINGIO_H
3#ifdef __cplusplus
4extern "C" {
5#endif
6/*
7
8 This header provides access to cStringIO objects from C.
9 Functions are provided for calling cStringIO objects and
[391]10 macros are provided for testing whether you have cStringIO
[2]11 objects.
12
13 Before calling any of the functions or macros, you must initialize
14 the routines with:
15
16 PycString_IMPORT
17
18 This would typically be done in your init function.
19
20*/
[391]21
22#define PycStringIO_CAPSULE_NAME "cStringIO.cStringIO_CAPI"
23
[2]24#define PycString_IMPORT \
[391]25 PycStringIO = ((struct PycStringIO_CAPI*)PyCapsule_Import(\
26 PycStringIO_CAPSULE_NAME, 0))
[2]27
28/* Basic functions to manipulate cStringIO objects from C */
29
30static struct PycStringIO_CAPI {
[391]31
[2]32 /* Read a string from an input object. If the last argument
33 is -1, the remainder will be read.
34 */
35 int(*cread)(PyObject *, char **, Py_ssize_t);
36
37 /* Read a line from an input object. Returns the length of the read
38 line as an int and a pointer inside the object buffer as char** (so
39 the caller doesn't have to provide its own buffer as destination).
40 */
41 int(*creadline)(PyObject *, char **);
42
43 /* Write a string to an output object*/
44 int(*cwrite)(PyObject *, const char *, Py_ssize_t);
45
46 /* Get the output object as a Python string (returns new reference). */
47 PyObject *(*cgetvalue)(PyObject *);
48
49 /* Create a new output object */
50 PyObject *(*NewOutput)(int);
51
52 /* Create an input object from a Python string
53 (copies the Python string reference).
54 */
55 PyObject *(*NewInput)(PyObject *);
56
57 /* The Python types for cStringIO input and output objects.
58 Note that you can do input on an output object.
59 */
60 PyTypeObject *InputType, *OutputType;
61
62} *PycStringIO;
63
64/* These can be used to test if you have one */
65#define PycStringIO_InputCheck(O) \
66 (Py_TYPE(O)==PycStringIO->InputType)
67#define PycStringIO_OutputCheck(O) \
68 (Py_TYPE(O)==PycStringIO->OutputType)
69
70#ifdef __cplusplus
71}
72#endif
73#endif /* !Py_CSTRINGIO_H */
Note: See TracBrowser for help on using the repository browser.