Branch data Line data Source code
1 : : /*[clinic input]
2 : : preserve
3 : : [clinic start generated code]*/
4 : :
5 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 : : # include "pycore_gc.h" // PyGC_Head
7 : : # include "pycore_runtime.h" // _Py_ID()
8 : : #endif
9 : :
10 : :
11 : : PyDoc_STRVAR(_multibytecodec_MultibyteCodec_encode__doc__,
12 : : "encode($self, /, input, errors=None)\n"
13 : : "--\n"
14 : : "\n"
15 : : "Return an encoded string version of `input\'.\n"
16 : : "\n"
17 : : "\'errors\' may be given to set a different error handling scheme. Default is\n"
18 : : "\'strict\' meaning that encoding errors raise a UnicodeEncodeError. Other possible\n"
19 : : "values are \'ignore\', \'replace\' and \'xmlcharrefreplace\' as well as any other name\n"
20 : : "registered with codecs.register_error that can handle UnicodeEncodeErrors.");
21 : :
22 : : #define _MULTIBYTECODEC_MULTIBYTECODEC_ENCODE_METHODDEF \
23 : : {"encode", _PyCFunction_CAST(_multibytecodec_MultibyteCodec_encode), METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_encode__doc__},
24 : :
25 : : static PyObject *
26 : : _multibytecodec_MultibyteCodec_encode_impl(MultibyteCodecObject *self,
27 : : PyObject *input,
28 : : const char *errors);
29 : :
30 : : static PyObject *
31 : 0 : _multibytecodec_MultibyteCodec_encode(MultibyteCodecObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
32 : : {
33 : 0 : PyObject *return_value = NULL;
34 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
35 : :
36 : : #define NUM_KEYWORDS 2
37 : : static struct {
38 : : PyGC_Head _this_is_not_used;
39 : : PyObject_VAR_HEAD
40 : : PyObject *ob_item[NUM_KEYWORDS];
41 : : } _kwtuple = {
42 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
43 : : .ob_item = { &_Py_ID(input), &_Py_ID(errors), },
44 : : };
45 : : #undef NUM_KEYWORDS
46 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
47 : :
48 : : #else // !Py_BUILD_CORE
49 : : # define KWTUPLE NULL
50 : : #endif // !Py_BUILD_CORE
51 : :
52 : : static const char * const _keywords[] = {"input", "errors", NULL};
53 : : static _PyArg_Parser _parser = {
54 : : .keywords = _keywords,
55 : : .fname = "encode",
56 : : .kwtuple = KWTUPLE,
57 : : };
58 : : #undef KWTUPLE
59 : : PyObject *argsbuf[2];
60 [ # # ]: 0 : Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
61 : : PyObject *input;
62 : 0 : const char *errors = NULL;
63 : :
64 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
# # # # ]
65 [ # # ]: 0 : if (!args) {
66 : 0 : goto exit;
67 : : }
68 : 0 : input = args[0];
69 [ # # ]: 0 : if (!noptargs) {
70 : 0 : goto skip_optional_pos;
71 : : }
72 [ # # ]: 0 : if (args[1] == Py_None) {
73 : 0 : errors = NULL;
74 : : }
75 [ # # ]: 0 : else if (PyUnicode_Check(args[1])) {
76 : : Py_ssize_t errors_length;
77 : 0 : errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
78 [ # # ]: 0 : if (errors == NULL) {
79 : 0 : goto exit;
80 : : }
81 [ # # ]: 0 : if (strlen(errors) != (size_t)errors_length) {
82 : 0 : PyErr_SetString(PyExc_ValueError, "embedded null character");
83 : 0 : goto exit;
84 : : }
85 : : }
86 : : else {
87 : 0 : _PyArg_BadArgument("encode", "argument 'errors'", "str or None", args[1]);
88 : 0 : goto exit;
89 : : }
90 : 0 : skip_optional_pos:
91 : 0 : return_value = _multibytecodec_MultibyteCodec_encode_impl(self, input, errors);
92 : :
93 : 0 : exit:
94 : 0 : return return_value;
95 : : }
96 : :
97 : : PyDoc_STRVAR(_multibytecodec_MultibyteCodec_decode__doc__,
98 : : "decode($self, /, input, errors=None)\n"
99 : : "--\n"
100 : : "\n"
101 : : "Decodes \'input\'.\n"
102 : : "\n"
103 : : "\'errors\' may be given to set a different error handling scheme. Default is\n"
104 : : "\'strict\' meaning that encoding errors raise a UnicodeDecodeError. Other possible\n"
105 : : "values are \'ignore\' and \'replace\' as well as any other name registered with\n"
106 : : "codecs.register_error that is able to handle UnicodeDecodeErrors.\"");
107 : :
108 : : #define _MULTIBYTECODEC_MULTIBYTECODEC_DECODE_METHODDEF \
109 : : {"decode", _PyCFunction_CAST(_multibytecodec_MultibyteCodec_decode), METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_decode__doc__},
110 : :
111 : : static PyObject *
112 : : _multibytecodec_MultibyteCodec_decode_impl(MultibyteCodecObject *self,
113 : : Py_buffer *input,
114 : : const char *errors);
115 : :
116 : : static PyObject *
117 : 0 : _multibytecodec_MultibyteCodec_decode(MultibyteCodecObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
118 : : {
119 : 0 : PyObject *return_value = NULL;
120 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
121 : :
122 : : #define NUM_KEYWORDS 2
123 : : static struct {
124 : : PyGC_Head _this_is_not_used;
125 : : PyObject_VAR_HEAD
126 : : PyObject *ob_item[NUM_KEYWORDS];
127 : : } _kwtuple = {
128 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
129 : : .ob_item = { &_Py_ID(input), &_Py_ID(errors), },
130 : : };
131 : : #undef NUM_KEYWORDS
132 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
133 : :
134 : : #else // !Py_BUILD_CORE
135 : : # define KWTUPLE NULL
136 : : #endif // !Py_BUILD_CORE
137 : :
138 : : static const char * const _keywords[] = {"input", "errors", NULL};
139 : : static _PyArg_Parser _parser = {
140 : : .keywords = _keywords,
141 : : .fname = "decode",
142 : : .kwtuple = KWTUPLE,
143 : : };
144 : : #undef KWTUPLE
145 : : PyObject *argsbuf[2];
146 [ # # ]: 0 : Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
147 : 0 : Py_buffer input = {NULL, NULL};
148 : 0 : const char *errors = NULL;
149 : :
150 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
# # # # ]
151 [ # # ]: 0 : if (!args) {
152 : 0 : goto exit;
153 : : }
154 [ # # ]: 0 : if (PyObject_GetBuffer(args[0], &input, PyBUF_SIMPLE) != 0) {
155 : 0 : goto exit;
156 : : }
157 [ # # ]: 0 : if (!PyBuffer_IsContiguous(&input, 'C')) {
158 : 0 : _PyArg_BadArgument("decode", "argument 'input'", "contiguous buffer", args[0]);
159 : 0 : goto exit;
160 : : }
161 [ # # ]: 0 : if (!noptargs) {
162 : 0 : goto skip_optional_pos;
163 : : }
164 [ # # ]: 0 : if (args[1] == Py_None) {
165 : 0 : errors = NULL;
166 : : }
167 [ # # ]: 0 : else if (PyUnicode_Check(args[1])) {
168 : : Py_ssize_t errors_length;
169 : 0 : errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
170 [ # # ]: 0 : if (errors == NULL) {
171 : 0 : goto exit;
172 : : }
173 [ # # ]: 0 : if (strlen(errors) != (size_t)errors_length) {
174 : 0 : PyErr_SetString(PyExc_ValueError, "embedded null character");
175 : 0 : goto exit;
176 : : }
177 : : }
178 : : else {
179 : 0 : _PyArg_BadArgument("decode", "argument 'errors'", "str or None", args[1]);
180 : 0 : goto exit;
181 : : }
182 : 0 : skip_optional_pos:
183 : 0 : return_value = _multibytecodec_MultibyteCodec_decode_impl(self, &input, errors);
184 : :
185 : 0 : exit:
186 : : /* Cleanup for input */
187 [ # # ]: 0 : if (input.obj) {
188 : 0 : PyBuffer_Release(&input);
189 : : }
190 : :
191 : 0 : return return_value;
192 : : }
193 : :
194 : : PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_encode__doc__,
195 : : "encode($self, /, input, final=False)\n"
196 : : "--\n"
197 : : "\n");
198 : :
199 : : #define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_ENCODE_METHODDEF \
200 : : {"encode", _PyCFunction_CAST(_multibytecodec_MultibyteIncrementalEncoder_encode), METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalEncoder_encode__doc__},
201 : :
202 : : static PyObject *
203 : : _multibytecodec_MultibyteIncrementalEncoder_encode_impl(MultibyteIncrementalEncoderObject *self,
204 : : PyObject *input,
205 : : int final);
206 : :
207 : : static PyObject *
208 : 0 : _multibytecodec_MultibyteIncrementalEncoder_encode(MultibyteIncrementalEncoderObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
209 : : {
210 : 0 : PyObject *return_value = NULL;
211 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
212 : :
213 : : #define NUM_KEYWORDS 2
214 : : static struct {
215 : : PyGC_Head _this_is_not_used;
216 : : PyObject_VAR_HEAD
217 : : PyObject *ob_item[NUM_KEYWORDS];
218 : : } _kwtuple = {
219 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
220 : : .ob_item = { &_Py_ID(input), &_Py_ID(final), },
221 : : };
222 : : #undef NUM_KEYWORDS
223 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
224 : :
225 : : #else // !Py_BUILD_CORE
226 : : # define KWTUPLE NULL
227 : : #endif // !Py_BUILD_CORE
228 : :
229 : : static const char * const _keywords[] = {"input", "final", NULL};
230 : : static _PyArg_Parser _parser = {
231 : : .keywords = _keywords,
232 : : .fname = "encode",
233 : : .kwtuple = KWTUPLE,
234 : : };
235 : : #undef KWTUPLE
236 : : PyObject *argsbuf[2];
237 [ # # ]: 0 : Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
238 : : PyObject *input;
239 : 0 : int final = 0;
240 : :
241 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
# # # # ]
242 [ # # ]: 0 : if (!args) {
243 : 0 : goto exit;
244 : : }
245 : 0 : input = args[0];
246 [ # # ]: 0 : if (!noptargs) {
247 : 0 : goto skip_optional_pos;
248 : : }
249 : 0 : final = PyObject_IsTrue(args[1]);
250 [ # # ]: 0 : if (final < 0) {
251 : 0 : goto exit;
252 : : }
253 : 0 : skip_optional_pos:
254 : 0 : return_value = _multibytecodec_MultibyteIncrementalEncoder_encode_impl(self, input, final);
255 : :
256 : 0 : exit:
257 : 0 : return return_value;
258 : : }
259 : :
260 : : PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_getstate__doc__,
261 : : "getstate($self, /)\n"
262 : : "--\n"
263 : : "\n");
264 : :
265 : : #define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_GETSTATE_METHODDEF \
266 : : {"getstate", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_getstate, METH_NOARGS, _multibytecodec_MultibyteIncrementalEncoder_getstate__doc__},
267 : :
268 : : static PyObject *
269 : : _multibytecodec_MultibyteIncrementalEncoder_getstate_impl(MultibyteIncrementalEncoderObject *self);
270 : :
271 : : static PyObject *
272 : 0 : _multibytecodec_MultibyteIncrementalEncoder_getstate(MultibyteIncrementalEncoderObject *self, PyObject *Py_UNUSED(ignored))
273 : : {
274 : 0 : return _multibytecodec_MultibyteIncrementalEncoder_getstate_impl(self);
275 : : }
276 : :
277 : : PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_setstate__doc__,
278 : : "setstate($self, state, /)\n"
279 : : "--\n"
280 : : "\n");
281 : :
282 : : #define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_SETSTATE_METHODDEF \
283 : : {"setstate", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_setstate, METH_O, _multibytecodec_MultibyteIncrementalEncoder_setstate__doc__},
284 : :
285 : : static PyObject *
286 : : _multibytecodec_MultibyteIncrementalEncoder_setstate_impl(MultibyteIncrementalEncoderObject *self,
287 : : PyLongObject *statelong);
288 : :
289 : : static PyObject *
290 : 0 : _multibytecodec_MultibyteIncrementalEncoder_setstate(MultibyteIncrementalEncoderObject *self, PyObject *arg)
291 : : {
292 : 0 : PyObject *return_value = NULL;
293 : : PyLongObject *statelong;
294 : :
295 [ # # ]: 0 : if (!PyLong_Check(arg)) {
296 : 0 : _PyArg_BadArgument("setstate", "argument", "int", arg);
297 : 0 : goto exit;
298 : : }
299 : 0 : statelong = (PyLongObject *)arg;
300 : 0 : return_value = _multibytecodec_MultibyteIncrementalEncoder_setstate_impl(self, statelong);
301 : :
302 : 0 : exit:
303 : 0 : return return_value;
304 : : }
305 : :
306 : : PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_reset__doc__,
307 : : "reset($self, /)\n"
308 : : "--\n"
309 : : "\n");
310 : :
311 : : #define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_RESET_METHODDEF \
312 : : {"reset", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_reset, METH_NOARGS, _multibytecodec_MultibyteIncrementalEncoder_reset__doc__},
313 : :
314 : : static PyObject *
315 : : _multibytecodec_MultibyteIncrementalEncoder_reset_impl(MultibyteIncrementalEncoderObject *self);
316 : :
317 : : static PyObject *
318 : 0 : _multibytecodec_MultibyteIncrementalEncoder_reset(MultibyteIncrementalEncoderObject *self, PyObject *Py_UNUSED(ignored))
319 : : {
320 : 0 : return _multibytecodec_MultibyteIncrementalEncoder_reset_impl(self);
321 : : }
322 : :
323 : : PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_decode__doc__,
324 : : "decode($self, /, input, final=False)\n"
325 : : "--\n"
326 : : "\n");
327 : :
328 : : #define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_DECODE_METHODDEF \
329 : : {"decode", _PyCFunction_CAST(_multibytecodec_MultibyteIncrementalDecoder_decode), METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalDecoder_decode__doc__},
330 : :
331 : : static PyObject *
332 : : _multibytecodec_MultibyteIncrementalDecoder_decode_impl(MultibyteIncrementalDecoderObject *self,
333 : : Py_buffer *input,
334 : : int final);
335 : :
336 : : static PyObject *
337 : 0 : _multibytecodec_MultibyteIncrementalDecoder_decode(MultibyteIncrementalDecoderObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
338 : : {
339 : 0 : PyObject *return_value = NULL;
340 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
341 : :
342 : : #define NUM_KEYWORDS 2
343 : : static struct {
344 : : PyGC_Head _this_is_not_used;
345 : : PyObject_VAR_HEAD
346 : : PyObject *ob_item[NUM_KEYWORDS];
347 : : } _kwtuple = {
348 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
349 : : .ob_item = { &_Py_ID(input), &_Py_ID(final), },
350 : : };
351 : : #undef NUM_KEYWORDS
352 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
353 : :
354 : : #else // !Py_BUILD_CORE
355 : : # define KWTUPLE NULL
356 : : #endif // !Py_BUILD_CORE
357 : :
358 : : static const char * const _keywords[] = {"input", "final", NULL};
359 : : static _PyArg_Parser _parser = {
360 : : .keywords = _keywords,
361 : : .fname = "decode",
362 : : .kwtuple = KWTUPLE,
363 : : };
364 : : #undef KWTUPLE
365 : : PyObject *argsbuf[2];
366 [ # # ]: 0 : Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
367 : 0 : Py_buffer input = {NULL, NULL};
368 : 0 : int final = 0;
369 : :
370 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
# # # # ]
371 [ # # ]: 0 : if (!args) {
372 : 0 : goto exit;
373 : : }
374 [ # # ]: 0 : if (PyObject_GetBuffer(args[0], &input, PyBUF_SIMPLE) != 0) {
375 : 0 : goto exit;
376 : : }
377 [ # # ]: 0 : if (!PyBuffer_IsContiguous(&input, 'C')) {
378 : 0 : _PyArg_BadArgument("decode", "argument 'input'", "contiguous buffer", args[0]);
379 : 0 : goto exit;
380 : : }
381 [ # # ]: 0 : if (!noptargs) {
382 : 0 : goto skip_optional_pos;
383 : : }
384 : 0 : final = PyObject_IsTrue(args[1]);
385 [ # # ]: 0 : if (final < 0) {
386 : 0 : goto exit;
387 : : }
388 : 0 : skip_optional_pos:
389 : 0 : return_value = _multibytecodec_MultibyteIncrementalDecoder_decode_impl(self, &input, final);
390 : :
391 : 0 : exit:
392 : : /* Cleanup for input */
393 [ # # ]: 0 : if (input.obj) {
394 : 0 : PyBuffer_Release(&input);
395 : : }
396 : :
397 : 0 : return return_value;
398 : : }
399 : :
400 : : PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_getstate__doc__,
401 : : "getstate($self, /)\n"
402 : : "--\n"
403 : : "\n");
404 : :
405 : : #define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_GETSTATE_METHODDEF \
406 : : {"getstate", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_getstate, METH_NOARGS, _multibytecodec_MultibyteIncrementalDecoder_getstate__doc__},
407 : :
408 : : static PyObject *
409 : : _multibytecodec_MultibyteIncrementalDecoder_getstate_impl(MultibyteIncrementalDecoderObject *self);
410 : :
411 : : static PyObject *
412 : 0 : _multibytecodec_MultibyteIncrementalDecoder_getstate(MultibyteIncrementalDecoderObject *self, PyObject *Py_UNUSED(ignored))
413 : : {
414 : 0 : return _multibytecodec_MultibyteIncrementalDecoder_getstate_impl(self);
415 : : }
416 : :
417 : : PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_setstate__doc__,
418 : : "setstate($self, state, /)\n"
419 : : "--\n"
420 : : "\n");
421 : :
422 : : #define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_SETSTATE_METHODDEF \
423 : : {"setstate", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_setstate, METH_O, _multibytecodec_MultibyteIncrementalDecoder_setstate__doc__},
424 : :
425 : : static PyObject *
426 : : _multibytecodec_MultibyteIncrementalDecoder_setstate_impl(MultibyteIncrementalDecoderObject *self,
427 : : PyObject *state);
428 : :
429 : : static PyObject *
430 : 0 : _multibytecodec_MultibyteIncrementalDecoder_setstate(MultibyteIncrementalDecoderObject *self, PyObject *arg)
431 : : {
432 : 0 : PyObject *return_value = NULL;
433 : : PyObject *state;
434 : :
435 [ # # ]: 0 : if (!PyTuple_Check(arg)) {
436 : 0 : _PyArg_BadArgument("setstate", "argument", "tuple", arg);
437 : 0 : goto exit;
438 : : }
439 : 0 : state = arg;
440 : 0 : return_value = _multibytecodec_MultibyteIncrementalDecoder_setstate_impl(self, state);
441 : :
442 : 0 : exit:
443 : 0 : return return_value;
444 : : }
445 : :
446 : : PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_reset__doc__,
447 : : "reset($self, /)\n"
448 : : "--\n"
449 : : "\n");
450 : :
451 : : #define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_RESET_METHODDEF \
452 : : {"reset", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_reset, METH_NOARGS, _multibytecodec_MultibyteIncrementalDecoder_reset__doc__},
453 : :
454 : : static PyObject *
455 : : _multibytecodec_MultibyteIncrementalDecoder_reset_impl(MultibyteIncrementalDecoderObject *self);
456 : :
457 : : static PyObject *
458 : 0 : _multibytecodec_MultibyteIncrementalDecoder_reset(MultibyteIncrementalDecoderObject *self, PyObject *Py_UNUSED(ignored))
459 : : {
460 : 0 : return _multibytecodec_MultibyteIncrementalDecoder_reset_impl(self);
461 : : }
462 : :
463 : : PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_read__doc__,
464 : : "read($self, sizeobj=None, /)\n"
465 : : "--\n"
466 : : "\n");
467 : :
468 : : #define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READ_METHODDEF \
469 : : {"read", _PyCFunction_CAST(_multibytecodec_MultibyteStreamReader_read), METH_FASTCALL, _multibytecodec_MultibyteStreamReader_read__doc__},
470 : :
471 : : static PyObject *
472 : : _multibytecodec_MultibyteStreamReader_read_impl(MultibyteStreamReaderObject *self,
473 : : PyObject *sizeobj);
474 : :
475 : : static PyObject *
476 : 0 : _multibytecodec_MultibyteStreamReader_read(MultibyteStreamReaderObject *self, PyObject *const *args, Py_ssize_t nargs)
477 : : {
478 : 0 : PyObject *return_value = NULL;
479 : 0 : PyObject *sizeobj = Py_None;
480 : :
481 [ # # # # : 0 : if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
# # ]
482 : 0 : goto exit;
483 : : }
484 [ # # ]: 0 : if (nargs < 1) {
485 : 0 : goto skip_optional;
486 : : }
487 : 0 : sizeobj = args[0];
488 : 0 : skip_optional:
489 : 0 : return_value = _multibytecodec_MultibyteStreamReader_read_impl(self, sizeobj);
490 : :
491 : 0 : exit:
492 : 0 : return return_value;
493 : : }
494 : :
495 : : PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_readline__doc__,
496 : : "readline($self, sizeobj=None, /)\n"
497 : : "--\n"
498 : : "\n");
499 : :
500 : : #define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READLINE_METHODDEF \
501 : : {"readline", _PyCFunction_CAST(_multibytecodec_MultibyteStreamReader_readline), METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readline__doc__},
502 : :
503 : : static PyObject *
504 : : _multibytecodec_MultibyteStreamReader_readline_impl(MultibyteStreamReaderObject *self,
505 : : PyObject *sizeobj);
506 : :
507 : : static PyObject *
508 : 0 : _multibytecodec_MultibyteStreamReader_readline(MultibyteStreamReaderObject *self, PyObject *const *args, Py_ssize_t nargs)
509 : : {
510 : 0 : PyObject *return_value = NULL;
511 : 0 : PyObject *sizeobj = Py_None;
512 : :
513 [ # # # # : 0 : if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
# # ]
514 : 0 : goto exit;
515 : : }
516 [ # # ]: 0 : if (nargs < 1) {
517 : 0 : goto skip_optional;
518 : : }
519 : 0 : sizeobj = args[0];
520 : 0 : skip_optional:
521 : 0 : return_value = _multibytecodec_MultibyteStreamReader_readline_impl(self, sizeobj);
522 : :
523 : 0 : exit:
524 : 0 : return return_value;
525 : : }
526 : :
527 : : PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_readlines__doc__,
528 : : "readlines($self, sizehintobj=None, /)\n"
529 : : "--\n"
530 : : "\n");
531 : :
532 : : #define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READLINES_METHODDEF \
533 : : {"readlines", _PyCFunction_CAST(_multibytecodec_MultibyteStreamReader_readlines), METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readlines__doc__},
534 : :
535 : : static PyObject *
536 : : _multibytecodec_MultibyteStreamReader_readlines_impl(MultibyteStreamReaderObject *self,
537 : : PyObject *sizehintobj);
538 : :
539 : : static PyObject *
540 : 0 : _multibytecodec_MultibyteStreamReader_readlines(MultibyteStreamReaderObject *self, PyObject *const *args, Py_ssize_t nargs)
541 : : {
542 : 0 : PyObject *return_value = NULL;
543 : 0 : PyObject *sizehintobj = Py_None;
544 : :
545 [ # # # # : 0 : if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) {
# # ]
546 : 0 : goto exit;
547 : : }
548 [ # # ]: 0 : if (nargs < 1) {
549 : 0 : goto skip_optional;
550 : : }
551 : 0 : sizehintobj = args[0];
552 : 0 : skip_optional:
553 : 0 : return_value = _multibytecodec_MultibyteStreamReader_readlines_impl(self, sizehintobj);
554 : :
555 : 0 : exit:
556 : 0 : return return_value;
557 : : }
558 : :
559 : : PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_reset__doc__,
560 : : "reset($self, /)\n"
561 : : "--\n"
562 : : "\n");
563 : :
564 : : #define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_RESET_METHODDEF \
565 : : {"reset", (PyCFunction)_multibytecodec_MultibyteStreamReader_reset, METH_NOARGS, _multibytecodec_MultibyteStreamReader_reset__doc__},
566 : :
567 : : static PyObject *
568 : : _multibytecodec_MultibyteStreamReader_reset_impl(MultibyteStreamReaderObject *self);
569 : :
570 : : static PyObject *
571 : 0 : _multibytecodec_MultibyteStreamReader_reset(MultibyteStreamReaderObject *self, PyObject *Py_UNUSED(ignored))
572 : : {
573 : 0 : return _multibytecodec_MultibyteStreamReader_reset_impl(self);
574 : : }
575 : :
576 : : PyDoc_STRVAR(_multibytecodec_MultibyteStreamWriter_write__doc__,
577 : : "write($self, strobj, /)\n"
578 : : "--\n"
579 : : "\n");
580 : :
581 : : #define _MULTIBYTECODEC_MULTIBYTESTREAMWRITER_WRITE_METHODDEF \
582 : : {"write", _PyCFunction_CAST(_multibytecodec_MultibyteStreamWriter_write), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteStreamWriter_write__doc__},
583 : :
584 : : static PyObject *
585 : : _multibytecodec_MultibyteStreamWriter_write_impl(MultibyteStreamWriterObject *self,
586 : : PyTypeObject *cls,
587 : : PyObject *strobj);
588 : :
589 : : static PyObject *
590 : 0 : _multibytecodec_MultibyteStreamWriter_write(MultibyteStreamWriterObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
591 : : {
592 : 0 : PyObject *return_value = NULL;
593 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
594 : : # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
595 : : #else
596 : : # define KWTUPLE NULL
597 : : #endif
598 : :
599 : : static const char * const _keywords[] = {"", NULL};
600 : : static _PyArg_Parser _parser = {
601 : : .keywords = _keywords,
602 : : .fname = "write",
603 : : .kwtuple = KWTUPLE,
604 : : };
605 : : #undef KWTUPLE
606 : : PyObject *argsbuf[1];
607 : : PyObject *strobj;
608 : :
609 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
# # # # ]
610 [ # # ]: 0 : if (!args) {
611 : 0 : goto exit;
612 : : }
613 : 0 : strobj = args[0];
614 : 0 : return_value = _multibytecodec_MultibyteStreamWriter_write_impl(self, cls, strobj);
615 : :
616 : 0 : exit:
617 : 0 : return return_value;
618 : : }
619 : :
620 : : PyDoc_STRVAR(_multibytecodec_MultibyteStreamWriter_writelines__doc__,
621 : : "writelines($self, lines, /)\n"
622 : : "--\n"
623 : : "\n");
624 : :
625 : : #define _MULTIBYTECODEC_MULTIBYTESTREAMWRITER_WRITELINES_METHODDEF \
626 : : {"writelines", _PyCFunction_CAST(_multibytecodec_MultibyteStreamWriter_writelines), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteStreamWriter_writelines__doc__},
627 : :
628 : : static PyObject *
629 : : _multibytecodec_MultibyteStreamWriter_writelines_impl(MultibyteStreamWriterObject *self,
630 : : PyTypeObject *cls,
631 : : PyObject *lines);
632 : :
633 : : static PyObject *
634 : 0 : _multibytecodec_MultibyteStreamWriter_writelines(MultibyteStreamWriterObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
635 : : {
636 : 0 : PyObject *return_value = NULL;
637 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
638 : : # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
639 : : #else
640 : : # define KWTUPLE NULL
641 : : #endif
642 : :
643 : : static const char * const _keywords[] = {"", NULL};
644 : : static _PyArg_Parser _parser = {
645 : : .keywords = _keywords,
646 : : .fname = "writelines",
647 : : .kwtuple = KWTUPLE,
648 : : };
649 : : #undef KWTUPLE
650 : : PyObject *argsbuf[1];
651 : : PyObject *lines;
652 : :
653 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
# # # # ]
654 [ # # ]: 0 : if (!args) {
655 : 0 : goto exit;
656 : : }
657 : 0 : lines = args[0];
658 : 0 : return_value = _multibytecodec_MultibyteStreamWriter_writelines_impl(self, cls, lines);
659 : :
660 : 0 : exit:
661 : 0 : return return_value;
662 : : }
663 : :
664 : : PyDoc_STRVAR(_multibytecodec_MultibyteStreamWriter_reset__doc__,
665 : : "reset($self, /)\n"
666 : : "--\n"
667 : : "\n");
668 : :
669 : : #define _MULTIBYTECODEC_MULTIBYTESTREAMWRITER_RESET_METHODDEF \
670 : : {"reset", _PyCFunction_CAST(_multibytecodec_MultibyteStreamWriter_reset), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteStreamWriter_reset__doc__},
671 : :
672 : : static PyObject *
673 : : _multibytecodec_MultibyteStreamWriter_reset_impl(MultibyteStreamWriterObject *self,
674 : : PyTypeObject *cls);
675 : :
676 : : static PyObject *
677 : 0 : _multibytecodec_MultibyteStreamWriter_reset(MultibyteStreamWriterObject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
678 : : {
679 [ # # ]: 0 : if (nargs) {
680 : 0 : PyErr_SetString(PyExc_TypeError, "reset() takes no arguments");
681 : 0 : return NULL;
682 : : }
683 : 0 : return _multibytecodec_MultibyteStreamWriter_reset_impl(self, cls);
684 : : }
685 : :
686 : : PyDoc_STRVAR(_multibytecodec___create_codec__doc__,
687 : : "__create_codec($module, arg, /)\n"
688 : : "--\n"
689 : : "\n");
690 : :
691 : : #define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
692 : : {"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__},
693 : : /*[clinic end generated code: output=5f0e8dacddb0ac76 input=a9049054013a1b77]*/
|