Steve Dower | 312cef7 | 2016-10-03 09:04:58 -0700 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | #if defined(MS_WINDOWS) |
| 6 | |
| 7 | PyDoc_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 Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 14 | {"write_input", (PyCFunction)(void(*)(void))_testconsole_write_input, METH_FASTCALL|METH_KEYWORDS, _testconsole_write_input__doc__}, |
Steve Dower | 312cef7 | 2016-10-03 09:04:58 -0700 | [diff] [blame] | 15 | |
| 16 | static PyObject * |
| 17 | _testconsole_write_input_impl(PyObject *module, PyObject *file, |
| 18 | PyBytesObject *s); |
| 19 | |
| 20 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 21 | _testconsole_write_input(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Steve Dower | 312cef7 | 2016-10-03 09:04:58 -0700 | [diff] [blame] | 22 | { |
| 23 | PyObject *return_value = NULL; |
| 24 | static const char * const _keywords[] = {"file", "s", NULL}; |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 25 | static _PyArg_Parser _parser = {NULL, _keywords, "write_input", 0}; |
| 26 | PyObject *argsbuf[2]; |
Steve Dower | 312cef7 | 2016-10-03 09:04:58 -0700 | [diff] [blame] | 27 | PyObject *file; |
| 28 | PyBytesObject *s; |
| 29 | |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 30 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf); |
| 31 | if (!args) { |
Steve Dower | 312cef7 | 2016-10-03 09:04:58 -0700 | [diff] [blame] | 32 | goto exit; |
| 33 | } |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 34 | file = args[0]; |
| 35 | if (!PyBytes_Check(args[1])) { |
Rémi Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame^] | 36 | _PyArg_BadArgument("write_input", "argument 's'", "bytes", args[1]); |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 37 | goto exit; |
| 38 | } |
| 39 | s = (PyBytesObject *)args[1]; |
Steve Dower | 312cef7 | 2016-10-03 09:04:58 -0700 | [diff] [blame] | 40 | return_value = _testconsole_write_input_impl(module, file, s); |
| 41 | |
| 42 | exit: |
| 43 | return return_value; |
| 44 | } |
| 45 | |
| 46 | #endif /* defined(MS_WINDOWS) */ |
| 47 | |
| 48 | #if defined(MS_WINDOWS) |
| 49 | |
| 50 | PyDoc_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 Storchaka | 4a934d4 | 2018-11-27 11:27:36 +0200 | [diff] [blame] | 57 | {"read_output", (PyCFunction)(void(*)(void))_testconsole_read_output, METH_FASTCALL|METH_KEYWORDS, _testconsole_read_output__doc__}, |
Steve Dower | 312cef7 | 2016-10-03 09:04:58 -0700 | [diff] [blame] | 58 | |
| 59 | static PyObject * |
| 60 | _testconsole_read_output_impl(PyObject *module, PyObject *file); |
| 61 | |
| 62 | static PyObject * |
Serhiy Storchaka | a5552f0 | 2017-12-15 13:11:11 +0200 | [diff] [blame] | 63 | _testconsole_read_output(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames) |
Steve Dower | 312cef7 | 2016-10-03 09:04:58 -0700 | [diff] [blame] | 64 | { |
| 65 | PyObject *return_value = NULL; |
| 66 | static const char * const _keywords[] = {"file", NULL}; |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 67 | static _PyArg_Parser _parser = {NULL, _keywords, "read_output", 0}; |
| 68 | PyObject *argsbuf[1]; |
Steve Dower | 312cef7 | 2016-10-03 09:04:58 -0700 | [diff] [blame] | 69 | PyObject *file; |
| 70 | |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 71 | args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf); |
| 72 | if (!args) { |
Steve Dower | 312cef7 | 2016-10-03 09:04:58 -0700 | [diff] [blame] | 73 | goto exit; |
| 74 | } |
Serhiy Storchaka | 3191391 | 2019-03-14 10:32:22 +0200 | [diff] [blame] | 75 | file = args[0]; |
Steve Dower | 312cef7 | 2016-10-03 09:04:58 -0700 | [diff] [blame] | 76 | return_value = _testconsole_read_output_impl(module, file); |
| 77 | |
| 78 | exit: |
| 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 Lapeyre | 4901fe2 | 2019-08-29 16:49:08 +0200 | [diff] [blame^] | 91 | /*[clinic end generated code: output=dd8b093a91b62753 input=a9049054013a1b77]*/ |