Debian Codegraph @

Modules/cjkcodecs/clinic/multibytecodec.c.h

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