blob: a8e32a3376c5b384c1c3f776ca470f17daef7613 [file] [log] [blame]
Serhiy Storchakaf24131f2015-04-16 11:19:43 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(_io_StringIO_getvalue__doc__,
6"getvalue($self, /)\n"
7"--\n"
8"\n"
9"Retrieve the entire contents of the object.");
10
11#define _IO_STRINGIO_GETVALUE_METHODDEF \
12 {"getvalue", (PyCFunction)_io_StringIO_getvalue, METH_NOARGS, _io_StringIO_getvalue__doc__},
13
14static PyObject *
15_io_StringIO_getvalue_impl(stringio *self);
16
17static PyObject *
18_io_StringIO_getvalue(stringio *self, PyObject *Py_UNUSED(ignored))
19{
20 return _io_StringIO_getvalue_impl(self);
21}
22
23PyDoc_STRVAR(_io_StringIO_tell__doc__,
24"tell($self, /)\n"
25"--\n"
26"\n"
27"Tell the current file position.");
28
29#define _IO_STRINGIO_TELL_METHODDEF \
30 {"tell", (PyCFunction)_io_StringIO_tell, METH_NOARGS, _io_StringIO_tell__doc__},
31
32static PyObject *
33_io_StringIO_tell_impl(stringio *self);
34
35static PyObject *
36_io_StringIO_tell(stringio *self, PyObject *Py_UNUSED(ignored))
37{
38 return _io_StringIO_tell_impl(self);
39}
40
41PyDoc_STRVAR(_io_StringIO_read__doc__,
42"read($self, size=None, /)\n"
43"--\n"
44"\n"
45"Read at most size characters, returned as a string.\n"
46"\n"
47"If the argument is negative or omitted, read until EOF\n"
48"is reached. Return an empty string at EOF.");
49
50#define _IO_STRINGIO_READ_METHODDEF \
51 {"read", (PyCFunction)_io_StringIO_read, METH_VARARGS, _io_StringIO_read__doc__},
52
53static PyObject *
54_io_StringIO_read_impl(stringio *self, PyObject *arg);
55
56static PyObject *
57_io_StringIO_read(stringio *self, PyObject *args)
58{
59 PyObject *return_value = NULL;
60 PyObject *arg = Py_None;
61
62 if (!PyArg_UnpackTuple(args, "read",
63 0, 1,
64 &arg))
65 goto exit;
66 return_value = _io_StringIO_read_impl(self, arg);
67
68exit:
69 return return_value;
70}
71
72PyDoc_STRVAR(_io_StringIO_readline__doc__,
73"readline($self, size=None, /)\n"
74"--\n"
75"\n"
76"Read until newline or EOF.\n"
77"\n"
78"Returns an empty string if EOF is hit immediately.");
79
80#define _IO_STRINGIO_READLINE_METHODDEF \
81 {"readline", (PyCFunction)_io_StringIO_readline, METH_VARARGS, _io_StringIO_readline__doc__},
82
83static PyObject *
84_io_StringIO_readline_impl(stringio *self, PyObject *arg);
85
86static PyObject *
87_io_StringIO_readline(stringio *self, PyObject *args)
88{
89 PyObject *return_value = NULL;
90 PyObject *arg = Py_None;
91
92 if (!PyArg_UnpackTuple(args, "readline",
93 0, 1,
94 &arg))
95 goto exit;
96 return_value = _io_StringIO_readline_impl(self, arg);
97
98exit:
99 return return_value;
100}
101
102PyDoc_STRVAR(_io_StringIO_truncate__doc__,
103"truncate($self, pos=None, /)\n"
104"--\n"
105"\n"
106"Truncate size to pos.\n"
107"\n"
108"The pos argument defaults to the current file position, as\n"
109"returned by tell(). The current file position is unchanged.\n"
110"Returns the new absolute position.");
111
112#define _IO_STRINGIO_TRUNCATE_METHODDEF \
113 {"truncate", (PyCFunction)_io_StringIO_truncate, METH_VARARGS, _io_StringIO_truncate__doc__},
114
115static PyObject *
116_io_StringIO_truncate_impl(stringio *self, PyObject *arg);
117
118static PyObject *
119_io_StringIO_truncate(stringio *self, PyObject *args)
120{
121 PyObject *return_value = NULL;
122 PyObject *arg = Py_None;
123
124 if (!PyArg_UnpackTuple(args, "truncate",
125 0, 1,
126 &arg))
127 goto exit;
128 return_value = _io_StringIO_truncate_impl(self, arg);
129
130exit:
131 return return_value;
132}
133
134PyDoc_STRVAR(_io_StringIO_seek__doc__,
135"seek($self, pos, whence=0, /)\n"
136"--\n"
137"\n"
138"Change stream position.\n"
139"\n"
140"Seek to character offset pos relative to position indicated by whence:\n"
141" 0 Start of stream (the default). pos should be >= 0;\n"
142" 1 Current position - pos must be 0;\n"
143" 2 End of stream - pos must be 0.\n"
144"Returns the new absolute position.");
145
146#define _IO_STRINGIO_SEEK_METHODDEF \
147 {"seek", (PyCFunction)_io_StringIO_seek, METH_VARARGS, _io_StringIO_seek__doc__},
148
149static PyObject *
150_io_StringIO_seek_impl(stringio *self, Py_ssize_t pos, int whence);
151
152static PyObject *
153_io_StringIO_seek(stringio *self, PyObject *args)
154{
155 PyObject *return_value = NULL;
156 Py_ssize_t pos;
157 int whence = 0;
158
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300159 if (!PyArg_ParseTuple(args, "n|i:seek",
Serhiy Storchakaf24131f2015-04-16 11:19:43 +0300160 &pos, &whence))
161 goto exit;
162 return_value = _io_StringIO_seek_impl(self, pos, whence);
163
164exit:
165 return return_value;
166}
167
168PyDoc_STRVAR(_io_StringIO_write__doc__,
169"write($self, s, /)\n"
170"--\n"
171"\n"
172"Write string to file.\n"
173"\n"
174"Returns the number of characters written, which is always equal to\n"
175"the length of the string.");
176
177#define _IO_STRINGIO_WRITE_METHODDEF \
178 {"write", (PyCFunction)_io_StringIO_write, METH_O, _io_StringIO_write__doc__},
179
180PyDoc_STRVAR(_io_StringIO_close__doc__,
181"close($self, /)\n"
182"--\n"
183"\n"
184"Close the IO object.\n"
185"\n"
186"Attempting any further operation after the object is closed\n"
187"will raise a ValueError.\n"
188"\n"
189"This method has no effect if the file is already closed.");
190
191#define _IO_STRINGIO_CLOSE_METHODDEF \
192 {"close", (PyCFunction)_io_StringIO_close, METH_NOARGS, _io_StringIO_close__doc__},
193
194static PyObject *
195_io_StringIO_close_impl(stringio *self);
196
197static PyObject *
198_io_StringIO_close(stringio *self, PyObject *Py_UNUSED(ignored))
199{
200 return _io_StringIO_close_impl(self);
201}
202
203PyDoc_STRVAR(_io_StringIO___init____doc__,
204"StringIO(initial_value=\'\', newline=\'\\n\')\n"
205"--\n"
206"\n"
207"Text I/O implementation using an in-memory buffer.\n"
208"\n"
209"The initial_value argument sets the value of object. The newline\n"
210"argument is like the one of TextIOWrapper\'s constructor.");
211
212static int
213_io_StringIO___init___impl(stringio *self, PyObject *value,
214 PyObject *newline_obj);
215
216static int
217_io_StringIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
218{
219 int return_value = -1;
220 static char *_keywords[] = {"initial_value", "newline", NULL};
221 PyObject *value = NULL;
222 PyObject *newline_obj = NULL;
223
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300224 if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:StringIO", _keywords,
Serhiy Storchakaf24131f2015-04-16 11:19:43 +0300225 &value, &newline_obj))
226 goto exit;
227 return_value = _io_StringIO___init___impl((stringio *)self, value, newline_obj);
228
229exit:
230 return return_value;
231}
232
233PyDoc_STRVAR(_io_StringIO_readable__doc__,
234"readable($self, /)\n"
235"--\n"
236"\n"
237"Returns True if the IO object can be read.");
238
239#define _IO_STRINGIO_READABLE_METHODDEF \
240 {"readable", (PyCFunction)_io_StringIO_readable, METH_NOARGS, _io_StringIO_readable__doc__},
241
242static PyObject *
243_io_StringIO_readable_impl(stringio *self);
244
245static PyObject *
246_io_StringIO_readable(stringio *self, PyObject *Py_UNUSED(ignored))
247{
248 return _io_StringIO_readable_impl(self);
249}
250
251PyDoc_STRVAR(_io_StringIO_writable__doc__,
252"writable($self, /)\n"
253"--\n"
254"\n"
255"Returns True if the IO object can be written.");
256
257#define _IO_STRINGIO_WRITABLE_METHODDEF \
258 {"writable", (PyCFunction)_io_StringIO_writable, METH_NOARGS, _io_StringIO_writable__doc__},
259
260static PyObject *
261_io_StringIO_writable_impl(stringio *self);
262
263static PyObject *
264_io_StringIO_writable(stringio *self, PyObject *Py_UNUSED(ignored))
265{
266 return _io_StringIO_writable_impl(self);
267}
268
269PyDoc_STRVAR(_io_StringIO_seekable__doc__,
270"seekable($self, /)\n"
271"--\n"
272"\n"
273"Returns True if the IO object can be seeked.");
274
275#define _IO_STRINGIO_SEEKABLE_METHODDEF \
276 {"seekable", (PyCFunction)_io_StringIO_seekable, METH_NOARGS, _io_StringIO_seekable__doc__},
277
278static PyObject *
279_io_StringIO_seekable_impl(stringio *self);
280
281static PyObject *
282_io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
283{
284 return _io_StringIO_seekable_impl(self);
285}
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300286/*[clinic end generated code: output=f061cf3a20cd14ed input=a9049054013a1b77]*/