mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-21 05:29:02 +00:00
* dict copy speedup refer to bpo-31179 or python/cpython@boa7a037b8fde * __build_class__() uses METH_FASTCALL refer python/cpython@69de71b255 refer python/cpython@773dc6dd06 a single test related to __prepare__ fails. * type_prepare uses METH_FASTCALL refer python/cpython@d526cfe546 refer python/cpython@80ab22fa2c the prepare-related test still fails. It's just related to the error message format though. * separate into ParseStack and ParseStackAndKeywords refer python/cpython@6518a93cb1 refer python/cpython@3e1fad6913 refer python/cpython@c0083fc47d * Add _PyArg_NoStackKeywords refer python/cpython@29d39cc8f5 * _PyStack_UnpackDict now returns int refer python/cpython@998c20962c * METH_FASTCALL changes to .inc files done via python's Argument Clinic tool, refer python/cpython@259f0e4437 * Added _PyArg_UnpackStack refer python/cpython@fe54dda08 * Argument Clinic FASTCALL again refer python/cpython@0c4a828ca * Argument Clinic for ordered dictionary object refer python/cpython@b05cbac052 * speed up getargs refer python/cpython@1741441649 * FASTCALL for sorted, next, and getattr refer python/cpython@5a60ecaa7a refer python/cpython@fda6d0acf0 refer python/cpython@84b388bb80 * Optimize methoddescr_call refer python/cpython@2a1b676d1f refer python/cpython@c52572319c refer python/cpython@35ecebe165 refer python/cpython@8128d5a491 * cleanup _PyMethodDef_RawFastCallDict refer python/cpython@0a2e46835d refer python/cpython@98ccba8344 refer python/cpython@c89ef828cf refer python/cpython@250e4b0063 * print now uses METH_FASTCALL refer python/cpython@c3858bd7c6 refer python/cpython@bd584f169f refer python/cpython@06d34393c2 * _struct module now uses Argument Clinic refer python/cpython@3f2d10132d * make deque methods faster refer python/cpython@dd407d5006 * recursive calls in PyObject_Call refer python/cpython@7399a05965 only partially ported, because RawFastCallKeywords hasn't been ported * add macros refer python/cpython@68a001dd59 * all tests pass in MODE=dbg * convert some internal functions to FASTCALL __import__ might need to be changed later, if it is possible to backport the METH_FASTCALL | METH_KEYWORDS flag distinction later. * speed up unpickling refer python/cpython@bee09aecc2 * added _PyMethodDef_RawFastCallKeywords refer python/cpython@7399a05965 * PyCFunction_Call performance refer python/cpython@12c5838dae * avoid PyMethodObject in slots main change in python/cpython@516b98161a test_exceptions changed in python/cpython@331bbe6aaa type_settattro changed in python/cpython@193f7e094f _PyObject_CallFunctionVa changed in python/cpython@fe4ff83049 * fix refcount error found in MODE=dbg all tests now pass in MODE=dbg
309 lines
8 KiB
C++
309 lines
8 KiB
C++
/* clang-format off */
|
|
/*[clinic input]
|
|
preserve
|
|
[clinic start generated code]*/
|
|
|
|
PyDoc_STRVAR(_io_StringIO_getvalue__doc__,
|
|
"getvalue($self, /)\n"
|
|
"--\n"
|
|
"\n"
|
|
"Retrieve the entire contents of the object.");
|
|
|
|
#define _IO_STRINGIO_GETVALUE_METHODDEF \
|
|
{"getvalue", (PyCFunction)_io_StringIO_getvalue, METH_NOARGS, _io_StringIO_getvalue__doc__},
|
|
|
|
static PyObject *
|
|
_io_StringIO_getvalue_impl(stringio *self);
|
|
|
|
static PyObject *
|
|
_io_StringIO_getvalue(stringio *self, PyObject *Py_UNUSED(ignored))
|
|
{
|
|
return _io_StringIO_getvalue_impl(self);
|
|
}
|
|
|
|
PyDoc_STRVAR(_io_StringIO_tell__doc__,
|
|
"tell($self, /)\n"
|
|
"--\n"
|
|
"\n"
|
|
"Tell the current file position.");
|
|
|
|
#define _IO_STRINGIO_TELL_METHODDEF \
|
|
{"tell", (PyCFunction)_io_StringIO_tell, METH_NOARGS, _io_StringIO_tell__doc__},
|
|
|
|
static PyObject *
|
|
_io_StringIO_tell_impl(stringio *self);
|
|
|
|
static PyObject *
|
|
_io_StringIO_tell(stringio *self, PyObject *Py_UNUSED(ignored))
|
|
{
|
|
return _io_StringIO_tell_impl(self);
|
|
}
|
|
|
|
PyDoc_STRVAR(_io_StringIO_read__doc__,
|
|
"read($self, size=None, /)\n"
|
|
"--\n"
|
|
"\n"
|
|
"Read at most size characters, returned as a string.\n"
|
|
"\n"
|
|
"If the argument is negative or omitted, read until EOF\n"
|
|
"is reached. Return an empty string at EOF.");
|
|
|
|
#define _IO_STRINGIO_READ_METHODDEF \
|
|
{"read", (PyCFunction)_io_StringIO_read, METH_FASTCALL, _io_StringIO_read__doc__},
|
|
|
|
static PyObject *
|
|
_io_StringIO_read_impl(stringio *self, PyObject *arg);
|
|
|
|
static PyObject *
|
|
_io_StringIO_read(stringio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
|
{
|
|
PyObject *return_value = NULL;
|
|
PyObject *arg = Py_None;
|
|
|
|
if (!_PyArg_UnpackStack(args, nargs, "read",
|
|
0, 1,
|
|
&arg)) {
|
|
goto exit;
|
|
}
|
|
|
|
if (!_PyArg_NoStackKeywords("read", kwnames)) {
|
|
goto exit;
|
|
}
|
|
return_value = _io_StringIO_read_impl(self, arg);
|
|
|
|
exit:
|
|
return return_value;
|
|
}
|
|
|
|
PyDoc_STRVAR(_io_StringIO_readline__doc__,
|
|
"readline($self, size=None, /)\n"
|
|
"--\n"
|
|
"\n"
|
|
"Read until newline or EOF.\n"
|
|
"\n"
|
|
"Returns an empty string if EOF is hit immediately.");
|
|
|
|
#define _IO_STRINGIO_READLINE_METHODDEF \
|
|
{"readline", (PyCFunction)_io_StringIO_readline, METH_FASTCALL, _io_StringIO_readline__doc__},
|
|
|
|
static PyObject *
|
|
_io_StringIO_readline_impl(stringio *self, PyObject *arg);
|
|
|
|
static PyObject *
|
|
_io_StringIO_readline(stringio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
|
{
|
|
PyObject *return_value = NULL;
|
|
PyObject *arg = Py_None;
|
|
|
|
if (!_PyArg_UnpackStack(args, nargs, "readline",
|
|
0, 1,
|
|
&arg)) {
|
|
goto exit;
|
|
}
|
|
|
|
if (!_PyArg_NoStackKeywords("readline", kwnames)) {
|
|
goto exit;
|
|
}
|
|
return_value = _io_StringIO_readline_impl(self, arg);
|
|
|
|
exit:
|
|
return return_value;
|
|
}
|
|
|
|
PyDoc_STRVAR(_io_StringIO_truncate__doc__,
|
|
"truncate($self, pos=None, /)\n"
|
|
"--\n"
|
|
"\n"
|
|
"Truncate size to pos.\n"
|
|
"\n"
|
|
"The pos argument defaults to the current file position, as\n"
|
|
"returned by tell(). The current file position is unchanged.\n"
|
|
"Returns the new absolute position.");
|
|
|
|
#define _IO_STRINGIO_TRUNCATE_METHODDEF \
|
|
{"truncate", (PyCFunction)_io_StringIO_truncate, METH_FASTCALL, _io_StringIO_truncate__doc__},
|
|
|
|
static PyObject *
|
|
_io_StringIO_truncate_impl(stringio *self, PyObject *arg);
|
|
|
|
static PyObject *
|
|
_io_StringIO_truncate(stringio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
|
{
|
|
PyObject *return_value = NULL;
|
|
PyObject *arg = Py_None;
|
|
|
|
if (!_PyArg_UnpackStack(args, nargs, "truncate",
|
|
0, 1,
|
|
&arg)) {
|
|
goto exit;
|
|
}
|
|
|
|
if (!_PyArg_NoStackKeywords("truncate", kwnames)) {
|
|
goto exit;
|
|
}
|
|
return_value = _io_StringIO_truncate_impl(self, arg);
|
|
|
|
exit:
|
|
return return_value;
|
|
}
|
|
|
|
PyDoc_STRVAR(_io_StringIO_seek__doc__,
|
|
"seek($self, pos, whence=0, /)\n"
|
|
"--\n"
|
|
"\n"
|
|
"Change stream position.\n"
|
|
"\n"
|
|
"Seek to character offset pos relative to position indicated by whence:\n"
|
|
" 0 Start of stream (the default). pos should be >= 0;\n"
|
|
" 1 Current position - pos must be 0;\n"
|
|
" 2 End of stream - pos must be 0.\n"
|
|
"Returns the new absolute position.");
|
|
|
|
#define _IO_STRINGIO_SEEK_METHODDEF \
|
|
{"seek", (PyCFunction)_io_StringIO_seek, METH_FASTCALL, _io_StringIO_seek__doc__},
|
|
|
|
static PyObject *
|
|
_io_StringIO_seek_impl(stringio *self, Py_ssize_t pos, int whence);
|
|
|
|
static PyObject *
|
|
_io_StringIO_seek(stringio *self, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
|
|
{
|
|
PyObject *return_value = NULL;
|
|
Py_ssize_t pos;
|
|
int whence = 0;
|
|
|
|
if (!_PyArg_ParseStack(args, nargs, "n|i:seek",
|
|
&pos, &whence)) {
|
|
goto exit;
|
|
}
|
|
|
|
if (!_PyArg_NoStackKeywords("seek", kwnames)) {
|
|
goto exit;
|
|
}
|
|
return_value = _io_StringIO_seek_impl(self, pos, whence);
|
|
|
|
exit:
|
|
return return_value;
|
|
}
|
|
|
|
PyDoc_STRVAR(_io_StringIO_write__doc__,
|
|
"write($self, s, /)\n"
|
|
"--\n"
|
|
"\n"
|
|
"Write string to file.\n"
|
|
"\n"
|
|
"Returns the number of characters written, which is always equal to\n"
|
|
"the length of the string.");
|
|
|
|
#define _IO_STRINGIO_WRITE_METHODDEF \
|
|
{"write", (PyCFunction)_io_StringIO_write, METH_O, _io_StringIO_write__doc__},
|
|
|
|
PyDoc_STRVAR(_io_StringIO_close__doc__,
|
|
"close($self, /)\n"
|
|
"--\n"
|
|
"\n"
|
|
"Close the IO object.\n"
|
|
"\n"
|
|
"Attempting any further operation after the object is closed\n"
|
|
"will raise a ValueError.\n"
|
|
"\n"
|
|
"This method has no effect if the file is already closed.");
|
|
|
|
#define _IO_STRINGIO_CLOSE_METHODDEF \
|
|
{"close", (PyCFunction)_io_StringIO_close, METH_NOARGS, _io_StringIO_close__doc__},
|
|
|
|
static PyObject *
|
|
_io_StringIO_close_impl(stringio *self);
|
|
|
|
static PyObject *
|
|
_io_StringIO_close(stringio *self, PyObject *Py_UNUSED(ignored))
|
|
{
|
|
return _io_StringIO_close_impl(self);
|
|
}
|
|
|
|
PyDoc_STRVAR(_io_StringIO___init____doc__,
|
|
"StringIO(initial_value=\'\', newline=\'\\n\')\n"
|
|
"--\n"
|
|
"\n"
|
|
"Text I/O implementation using an in-memory buffer.\n"
|
|
"\n"
|
|
"The initial_value argument sets the value of object. The newline\n"
|
|
"argument is like the one of TextIOWrapper\'s constructor.");
|
|
|
|
static int
|
|
_io_StringIO___init___impl(stringio *self, PyObject *value,
|
|
PyObject *newline_obj);
|
|
|
|
static int
|
|
_io_StringIO___init__(PyObject *self, PyObject *args, PyObject *kwargs)
|
|
{
|
|
int return_value = -1;
|
|
static const char * const _keywords[] = {"initial_value", "newline", NULL};
|
|
static _PyArg_Parser _parser = {"|OO:StringIO", _keywords, 0};
|
|
PyObject *value = NULL;
|
|
PyObject *newline_obj = NULL;
|
|
|
|
if (!_PyArg_ParseTupleAndKeywordsFast(args, kwargs, &_parser,
|
|
&value, &newline_obj)) {
|
|
goto exit;
|
|
}
|
|
return_value = _io_StringIO___init___impl((stringio *)self, value, newline_obj);
|
|
|
|
exit:
|
|
return return_value;
|
|
}
|
|
|
|
PyDoc_STRVAR(_io_StringIO_readable__doc__,
|
|
"readable($self, /)\n"
|
|
"--\n"
|
|
"\n"
|
|
"Returns True if the IO object can be read.");
|
|
|
|
#define _IO_STRINGIO_READABLE_METHODDEF \
|
|
{"readable", (PyCFunction)_io_StringIO_readable, METH_NOARGS, _io_StringIO_readable__doc__},
|
|
|
|
static PyObject *
|
|
_io_StringIO_readable_impl(stringio *self);
|
|
|
|
static PyObject *
|
|
_io_StringIO_readable(stringio *self, PyObject *Py_UNUSED(ignored))
|
|
{
|
|
return _io_StringIO_readable_impl(self);
|
|
}
|
|
|
|
PyDoc_STRVAR(_io_StringIO_writable__doc__,
|
|
"writable($self, /)\n"
|
|
"--\n"
|
|
"\n"
|
|
"Returns True if the IO object can be written.");
|
|
|
|
#define _IO_STRINGIO_WRITABLE_METHODDEF \
|
|
{"writable", (PyCFunction)_io_StringIO_writable, METH_NOARGS, _io_StringIO_writable__doc__},
|
|
|
|
static PyObject *
|
|
_io_StringIO_writable_impl(stringio *self);
|
|
|
|
static PyObject *
|
|
_io_StringIO_writable(stringio *self, PyObject *Py_UNUSED(ignored))
|
|
{
|
|
return _io_StringIO_writable_impl(self);
|
|
}
|
|
|
|
PyDoc_STRVAR(_io_StringIO_seekable__doc__,
|
|
"seekable($self, /)\n"
|
|
"--\n"
|
|
"\n"
|
|
"Returns True if the IO object can be seeked.");
|
|
|
|
#define _IO_STRINGIO_SEEKABLE_METHODDEF \
|
|
{"seekable", (PyCFunction)_io_StringIO_seekable, METH_NOARGS, _io_StringIO_seekable__doc__},
|
|
|
|
static PyObject *
|
|
_io_StringIO_seekable_impl(stringio *self);
|
|
|
|
static PyObject *
|
|
_io_StringIO_seekable(stringio *self, PyObject *Py_UNUSED(ignored))
|
|
{
|
|
return _io_StringIO_seekable_impl(self);
|
|
}
|
|
/*[clinic end generated code: output=ce8018ec29def422 input=a9049054013a1b77]*/
|