blob: cf5e4ee09063aaa9149261f5a2fc7d41a8e2f684 [file] [log] [blame]
Steve Dower312cef72016-10-03 09:04:58 -07001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5#if defined(MS_WINDOWS)
6
7PyDoc_STRVAR(_testconsole_write_input__doc__,
8"write_input($module, /, file, s)\n"
9"--\n"
10"\n"
11"Writes UTF-16-LE encoded bytes to the console as if typed by a user.");
12
13#define _TESTCONSOLE_WRITE_INPUT_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +020014 {"write_input", (PyCFunction)(void(*)(void))_testconsole_write_input, METH_FASTCALL|METH_KEYWORDS, _testconsole_write_input__doc__},
Steve Dower312cef72016-10-03 09:04:58 -070015
16static PyObject *
17_testconsole_write_input_impl(PyObject *module, PyObject *file,
18 PyBytesObject *s);
19
20static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +020021_testconsole_write_input(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Steve Dower312cef72016-10-03 09:04:58 -070022{
23 PyObject *return_value = NULL;
24 static const char * const _keywords[] = {"file", "s", NULL};
Serhiy Storchaka31913912019-03-14 10:32:22 +020025 static _PyArg_Parser _parser = {NULL, _keywords, "write_input", 0};
26 PyObject *argsbuf[2];
Steve Dower312cef72016-10-03 09:04:58 -070027 PyObject *file;
28 PyBytesObject *s;
29
Serhiy Storchaka31913912019-03-14 10:32:22 +020030 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
31 if (!args) {
Steve Dower312cef72016-10-03 09:04:58 -070032 goto exit;
33 }
Serhiy Storchaka31913912019-03-14 10:32:22 +020034 file = args[0];
35 if (!PyBytes_Check(args[1])) {
Rémi Lapeyre4901fe22019-08-29 16:49:08 +020036 _PyArg_BadArgument("write_input", "argument 's'", "bytes", args[1]);
Serhiy Storchaka31913912019-03-14 10:32:22 +020037 goto exit;
38 }
39 s = (PyBytesObject *)args[1];
Steve Dower312cef72016-10-03 09:04:58 -070040 return_value = _testconsole_write_input_impl(module, file, s);
41
42exit:
43 return return_value;
44}
45
46#endif /* defined(MS_WINDOWS) */
47
48#if defined(MS_WINDOWS)
49
50PyDoc_STRVAR(_testconsole_read_output__doc__,
51"read_output($module, /, file)\n"
52"--\n"
53"\n"
54"Reads a str from the console as written to stdout.");
55
56#define _TESTCONSOLE_READ_OUTPUT_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +020057 {"read_output", (PyCFunction)(void(*)(void))_testconsole_read_output, METH_FASTCALL|METH_KEYWORDS, _testconsole_read_output__doc__},
Steve Dower312cef72016-10-03 09:04:58 -070058
59static PyObject *
60_testconsole_read_output_impl(PyObject *module, PyObject *file);
61
62static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +020063_testconsole_read_output(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Steve Dower312cef72016-10-03 09:04:58 -070064{
65 PyObject *return_value = NULL;
66 static const char * const _keywords[] = {"file", NULL};
Serhiy Storchaka31913912019-03-14 10:32:22 +020067 static _PyArg_Parser _parser = {NULL, _keywords, "read_output", 0};
68 PyObject *argsbuf[1];
Steve Dower312cef72016-10-03 09:04:58 -070069 PyObject *file;
70
Serhiy Storchaka31913912019-03-14 10:32:22 +020071 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
72 if (!args) {
Steve Dower312cef72016-10-03 09:04:58 -070073 goto exit;
74 }
Serhiy Storchaka31913912019-03-14 10:32:22 +020075 file = args[0];
Steve Dower312cef72016-10-03 09:04:58 -070076 return_value = _testconsole_read_output_impl(module, file);
77
78exit:
79 return return_value;
80}
81
82#endif /* defined(MS_WINDOWS) */
83
84#ifndef _TESTCONSOLE_WRITE_INPUT_METHODDEF
85 #define _TESTCONSOLE_WRITE_INPUT_METHODDEF
86#endif /* !defined(_TESTCONSOLE_WRITE_INPUT_METHODDEF) */
87
88#ifndef _TESTCONSOLE_READ_OUTPUT_METHODDEF
89 #define _TESTCONSOLE_READ_OUTPUT_METHODDEF
90#endif /* !defined(_TESTCONSOLE_READ_OUTPUT_METHODDEF) */
Rémi Lapeyre4901fe22019-08-29 16:49:08 +020091/*[clinic end generated code: output=dd8b093a91b62753 input=a9049054013a1b77]*/