1/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(_multibytecodec_MultibyteCodec_encode__doc__,
6"encode($self, /, input, errors=None)\n"
7"--\n"
8"\n"
9"Return an encoded string version of `input\'.\n"
10"\n"
11"\'errors\' may be given to set a different error handling scheme. Default is\n"
12"\'strict\' meaning that encoding errors raise a UnicodeEncodeError. Other possible\n"
13"values are \'ignore\', \'replace\' and \'xmlcharrefreplace\' as well as any other name\n"
14"registered with codecs.register_error that can handle UnicodeEncodeErrors.");
15
16#define _MULTIBYTECODEC_MULTIBYTECODEC_ENCODE_METHODDEF \
17 {"encode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteCodec_encode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_encode__doc__},
18
19static PyObject *
20_multibytecodec_MultibyteCodec_encode_impl(MultibyteCodecObject *self,
21 PyObject *input,
22 const char *errors);
23
24static PyObject *
25_multibytecodec_MultibyteCodec_encode(MultibyteCodecObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
26{
27 PyObject *return_value = NULL;
28 static const char * const _keywords[] = {"input", "errors", NULL};
29 static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0};
30 PyObject *argsbuf[2];
31 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
32 PyObject *input;
33 const char *errors = NULL;
34
35 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
36 if (!args) {
37 goto exit;
38 }
39 input = args[0];
40 if (!noptargs) {
41 goto skip_optional_pos;
42 }
43 if (args[1] == Py_None) {
44 errors = NULL;
45 }
46 else if (PyUnicode_Check(args[1])) {
47 Py_ssize_t errors_length;
48 errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
49 if (errors == NULL) {
50 goto exit;
51 }
52 if (strlen(errors) != (size_t)errors_length) {
53 PyErr_SetString(PyExc_ValueError, "embedded null character");
54 goto exit;
55 }
56 }
57 else {
58 _PyArg_BadArgument("encode", "argument 'errors'", "str or None", args[1]);
59 goto exit;
60 }
61skip_optional_pos:
62 return_value = _multibytecodec_MultibyteCodec_encode_impl(self, input, errors);
63
64exit:
65 return return_value;
66}
67
68PyDoc_STRVAR(_multibytecodec_MultibyteCodec_decode__doc__,
69"decode($self, /, input, errors=None)\n"
70"--\n"
71"\n"
72"Decodes \'input\'.\n"
73"\n"
74"\'errors\' may be given to set a different error handling scheme. Default is\n"
75"\'strict\' meaning that encoding errors raise a UnicodeDecodeError. Other possible\n"
76"values are \'ignore\' and \'replace\' as well as any other name registered with\n"
77"codecs.register_error that is able to handle UnicodeDecodeErrors.\"");
78
79#define _MULTIBYTECODEC_MULTIBYTECODEC_DECODE_METHODDEF \
80 {"decode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteCodec_decode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_decode__doc__},
81
82static PyObject *
83_multibytecodec_MultibyteCodec_decode_impl(MultibyteCodecObject *self,
84 Py_buffer *input,
85 const char *errors);
86
87static PyObject *
88_multibytecodec_MultibyteCodec_decode(MultibyteCodecObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
89{
90 PyObject *return_value = NULL;
91 static const char * const _keywords[] = {"input", "errors", NULL};
92 static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0};
93 PyObject *argsbuf[2];
94 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
95 Py_buffer input = {NULL, NULL};
96 const char *errors = NULL;
97
98 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
99 if (!args) {
100 goto exit;
101 }
102 if (PyObject_GetBuffer(args[0], &input, PyBUF_SIMPLE) != 0) {
103 goto exit;
104 }
105 if (!PyBuffer_IsContiguous(&input, 'C')) {
106 _PyArg_BadArgument("decode", "argument 'input'", "contiguous buffer", args[0]);
107 goto exit;
108 }
109 if (!noptargs) {
110 goto skip_optional_pos;
111 }
112 if (args[1] == Py_None) {
113 errors = NULL;
114 }
115 else if (PyUnicode_Check(args[1])) {
116 Py_ssize_t errors_length;
117 errors = PyUnicode_AsUTF8AndSize(args[1], &errors_length);
118 if (errors == NULL) {
119 goto exit;
120 }
121 if (strlen(errors) != (size_t)errors_length) {
122 PyErr_SetString(PyExc_ValueError, "embedded null character");
123 goto exit;
124 }
125 }
126 else {
127 _PyArg_BadArgument("decode", "argument 'errors'", "str or None", args[1]);
128 goto exit;
129 }
130skip_optional_pos:
131 return_value = _multibytecodec_MultibyteCodec_decode_impl(self, &input, errors);
132
133exit:
134 /* Cleanup for input */
135 if (input.obj) {
136 PyBuffer_Release(&input);
137 }
138
139 return return_value;
140}
141
142PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_encode__doc__,
143"encode($self, /, input, final=False)\n"
144"--\n"
145"\n");
146
147#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_ENCODE_METHODDEF \
148 {"encode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteIncrementalEncoder_encode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalEncoder_encode__doc__},
149
150static PyObject *
151_multibytecodec_MultibyteIncrementalEncoder_encode_impl(MultibyteIncrementalEncoderObject *self,
152 PyObject *input,
153 int final);
154
155static PyObject *
156_multibytecodec_MultibyteIncrementalEncoder_encode(MultibyteIncrementalEncoderObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
157{
158 PyObject *return_value = NULL;
159 static const char * const _keywords[] = {"input", "final", NULL};
160 static _PyArg_Parser _parser = {NULL, _keywords, "encode", 0};
161 PyObject *argsbuf[2];
162 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
163 PyObject *input;
164 int final = 0;
165
166 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
167 if (!args) {
168 goto exit;
169 }
170 input = args[0];
171 if (!noptargs) {
172 goto skip_optional_pos;
173 }
174 final = _PyLong_AsInt(args[1]);
175 if (final == -1 && PyErr_Occurred()) {
176 goto exit;
177 }
178skip_optional_pos:
179 return_value = _multibytecodec_MultibyteIncrementalEncoder_encode_impl(self, input, final);
180
181exit:
182 return return_value;
183}
184
185PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_getstate__doc__,
186"getstate($self, /)\n"
187"--\n"
188"\n");
189
190#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_GETSTATE_METHODDEF \
191 {"getstate", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_getstate, METH_NOARGS, _multibytecodec_MultibyteIncrementalEncoder_getstate__doc__},
192
193static PyObject *
194_multibytecodec_MultibyteIncrementalEncoder_getstate_impl(MultibyteIncrementalEncoderObject *self);
195
196static PyObject *
197_multibytecodec_MultibyteIncrementalEncoder_getstate(MultibyteIncrementalEncoderObject *self, PyObject *Py_UNUSED(ignored))
198{
199 return _multibytecodec_MultibyteIncrementalEncoder_getstate_impl(self);
200}
201
202PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_setstate__doc__,
203"setstate($self, state, /)\n"
204"--\n"
205"\n");
206
207#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_SETSTATE_METHODDEF \
208 {"setstate", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_setstate, METH_O, _multibytecodec_MultibyteIncrementalEncoder_setstate__doc__},
209
210static PyObject *
211_multibytecodec_MultibyteIncrementalEncoder_setstate_impl(MultibyteIncrementalEncoderObject *self,
212 PyLongObject *statelong);
213
214static PyObject *
215_multibytecodec_MultibyteIncrementalEncoder_setstate(MultibyteIncrementalEncoderObject *self, PyObject *arg)
216{
217 PyObject *return_value = NULL;
218 PyLongObject *statelong;
219
220 if (!PyLong_Check(arg)) {
221 _PyArg_BadArgument("setstate", "argument", "int", arg);
222 goto exit;
223 }
224 statelong = (PyLongObject *)arg;
225 return_value = _multibytecodec_MultibyteIncrementalEncoder_setstate_impl(self, statelong);
226
227exit:
228 return return_value;
229}
230
231PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_reset__doc__,
232"reset($self, /)\n"
233"--\n"
234"\n");
235
236#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_RESET_METHODDEF \
237 {"reset", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_reset, METH_NOARGS, _multibytecodec_MultibyteIncrementalEncoder_reset__doc__},
238
239static PyObject *
240_multibytecodec_MultibyteIncrementalEncoder_reset_impl(MultibyteIncrementalEncoderObject *self);
241
242static PyObject *
243_multibytecodec_MultibyteIncrementalEncoder_reset(MultibyteIncrementalEncoderObject *self, PyObject *Py_UNUSED(ignored))
244{
245 return _multibytecodec_MultibyteIncrementalEncoder_reset_impl(self);
246}
247
248PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_decode__doc__,
249"decode($self, /, input, final=False)\n"
250"--\n"
251"\n");
252
253#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_DECODE_METHODDEF \
254 {"decode", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteIncrementalDecoder_decode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalDecoder_decode__doc__},
255
256static PyObject *
257_multibytecodec_MultibyteIncrementalDecoder_decode_impl(MultibyteIncrementalDecoderObject *self,
258 Py_buffer *input,
259 int final);
260
261static PyObject *
262_multibytecodec_MultibyteIncrementalDecoder_decode(MultibyteIncrementalDecoderObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
263{
264 PyObject *return_value = NULL;
265 static const char * const _keywords[] = {"input", "final", NULL};
266 static _PyArg_Parser _parser = {NULL, _keywords, "decode", 0};
267 PyObject *argsbuf[2];
268 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
269 Py_buffer input = {NULL, NULL};
270 int final = 0;
271
272 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 2, 0, argsbuf);
273 if (!args) {
274 goto exit;
275 }
276 if (PyObject_GetBuffer(args[0], &input, PyBUF_SIMPLE) != 0) {
277 goto exit;
278 }
279 if (!PyBuffer_IsContiguous(&input, 'C')) {
280 _PyArg_BadArgument("decode", "argument 'input'", "contiguous buffer", args[0]);
281 goto exit;
282 }
283 if (!noptargs) {
284 goto skip_optional_pos;
285 }
286 final = _PyLong_AsInt(args[1]);
287 if (final == -1 && PyErr_Occurred()) {
288 goto exit;
289 }
290skip_optional_pos:
291 return_value = _multibytecodec_MultibyteIncrementalDecoder_decode_impl(self, &input, final);
292
293exit:
294 /* Cleanup for input */
295 if (input.obj) {
296 PyBuffer_Release(&input);
297 }
298
299 return return_value;
300}
301
302PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_getstate__doc__,
303"getstate($self, /)\n"
304"--\n"
305"\n");
306
307#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_GETSTATE_METHODDEF \
308 {"getstate", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_getstate, METH_NOARGS, _multibytecodec_MultibyteIncrementalDecoder_getstate__doc__},
309
310static PyObject *
311_multibytecodec_MultibyteIncrementalDecoder_getstate_impl(MultibyteIncrementalDecoderObject *self);
312
313static PyObject *
314_multibytecodec_MultibyteIncrementalDecoder_getstate(MultibyteIncrementalDecoderObject *self, PyObject *Py_UNUSED(ignored))
315{
316 return _multibytecodec_MultibyteIncrementalDecoder_getstate_impl(self);
317}
318
319PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_setstate__doc__,
320"setstate($self, state, /)\n"
321"--\n"
322"\n");
323
324#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_SETSTATE_METHODDEF \
325 {"setstate", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_setstate, METH_O, _multibytecodec_MultibyteIncrementalDecoder_setstate__doc__},
326
327static PyObject *
328_multibytecodec_MultibyteIncrementalDecoder_setstate_impl(MultibyteIncrementalDecoderObject *self,
329 PyObject *state);
330
331static PyObject *
332_multibytecodec_MultibyteIncrementalDecoder_setstate(MultibyteIncrementalDecoderObject *self, PyObject *arg)
333{
334 PyObject *return_value = NULL;
335 PyObject *state;
336
337 if (!PyTuple_Check(arg)) {
338 _PyArg_BadArgument("setstate", "argument", "tuple", arg);
339 goto exit;
340 }
341 state = arg;
342 return_value = _multibytecodec_MultibyteIncrementalDecoder_setstate_impl(self, state);
343
344exit:
345 return return_value;
346}
347
348PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_reset__doc__,
349"reset($self, /)\n"
350"--\n"
351"\n");
352
353#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_RESET_METHODDEF \
354 {"reset", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_reset, METH_NOARGS, _multibytecodec_MultibyteIncrementalDecoder_reset__doc__},
355
356static PyObject *
357_multibytecodec_MultibyteIncrementalDecoder_reset_impl(MultibyteIncrementalDecoderObject *self);
358
359static PyObject *
360_multibytecodec_MultibyteIncrementalDecoder_reset(MultibyteIncrementalDecoderObject *self, PyObject *Py_UNUSED(ignored))
361{
362 return _multibytecodec_MultibyteIncrementalDecoder_reset_impl(self);
363}
364
365PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_read__doc__,
366"read($self, sizeobj=None, /)\n"
367"--\n"
368"\n");
369
370#define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READ_METHODDEF \
371 {"read", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamReader_read, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_read__doc__},
372
373static PyObject *
374_multibytecodec_MultibyteStreamReader_read_impl(MultibyteStreamReaderObject *self,
375 PyObject *sizeobj);
376
377static PyObject *
378_multibytecodec_MultibyteStreamReader_read(MultibyteStreamReaderObject *self, PyObject *const *args, Py_ssize_t nargs)
379{
380 PyObject *return_value = NULL;
381 PyObject *sizeobj = Py_None;
382
383 if (!_PyArg_CheckPositional("read", nargs, 0, 1)) {
384 goto exit;
385 }
386 if (nargs < 1) {
387 goto skip_optional;
388 }
389 sizeobj = args[0];
390skip_optional:
391 return_value = _multibytecodec_MultibyteStreamReader_read_impl(self, sizeobj);
392
393exit:
394 return return_value;
395}
396
397PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_readline__doc__,
398"readline($self, sizeobj=None, /)\n"
399"--\n"
400"\n");
401
402#define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READLINE_METHODDEF \
403 {"readline", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamReader_readline, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readline__doc__},
404
405static PyObject *
406_multibytecodec_MultibyteStreamReader_readline_impl(MultibyteStreamReaderObject *self,
407 PyObject *sizeobj);
408
409static PyObject *
410_multibytecodec_MultibyteStreamReader_readline(MultibyteStreamReaderObject *self, PyObject *const *args, Py_ssize_t nargs)
411{
412 PyObject *return_value = NULL;
413 PyObject *sizeobj = Py_None;
414
415 if (!_PyArg_CheckPositional("readline", nargs, 0, 1)) {
416 goto exit;
417 }
418 if (nargs < 1) {
419 goto skip_optional;
420 }
421 sizeobj = args[0];
422skip_optional:
423 return_value = _multibytecodec_MultibyteStreamReader_readline_impl(self, sizeobj);
424
425exit:
426 return return_value;
427}
428
429PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_readlines__doc__,
430"readlines($self, sizehintobj=None, /)\n"
431"--\n"
432"\n");
433
434#define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READLINES_METHODDEF \
435 {"readlines", (PyCFunction)(void(*)(void))_multibytecodec_MultibyteStreamReader_readlines, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readlines__doc__},
436
437static PyObject *
438_multibytecodec_MultibyteStreamReader_readlines_impl(MultibyteStreamReaderObject *self,
439 PyObject *sizehintobj);
440
441static PyObject *
442_multibytecodec_MultibyteStreamReader_readlines(MultibyteStreamReaderObject *self, PyObject *const *args, Py_ssize_t nargs)
443{
444 PyObject *return_value = NULL;
445 PyObject *sizehintobj = Py_None;
446
447 if (!_PyArg_CheckPositional("readlines", nargs, 0, 1)) {
448 goto exit;
449 }
450 if (nargs < 1) {
451 goto skip_optional;
452 }
453 sizehintobj = args[0];
454skip_optional:
455 return_value = _multibytecodec_MultibyteStreamReader_readlines_impl(self, sizehintobj);
456
457exit:
458 return return_value;
459}
460
461PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_reset__doc__,
462"reset($self, /)\n"
463"--\n"
464"\n");
465
466#define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_RESET_METHODDEF \
467 {"reset", (PyCFunction)_multibytecodec_MultibyteStreamReader_reset, METH_NOARGS, _multibytecodec_MultibyteStreamReader_reset__doc__},
468
469static PyObject *
470_multibytecodec_MultibyteStreamReader_reset_impl(MultibyteStreamReaderObject *self);
471
472static PyObject *
473_multibytecodec_MultibyteStreamReader_reset(MultibyteStreamReaderObject *self, PyObject *Py_UNUSED(ignored))
474{
475 return _multibytecodec_MultibyteStreamReader_reset_impl(self);
476}
477
478PyDoc_STRVAR(_multibytecodec_MultibyteStreamWriter_write__doc__,
479"write($self, strobj, /)\n"
480"--\n"
481"\n");
482
483#define _MULTIBYTECODEC_MULTIBYTESTREAMWRITER_WRITE_METHODDEF \
484 {"write", (PyCFunction)_multibytecodec_MultibyteStreamWriter_write, METH_O, _multibytecodec_MultibyteStreamWriter_write__doc__},
485
486PyDoc_STRVAR(_multibytecodec_MultibyteStreamWriter_writelines__doc__,
487"writelines($self, lines, /)\n"
488"--\n"
489"\n");
490
491#define _MULTIBYTECODEC_MULTIBYTESTREAMWRITER_WRITELINES_METHODDEF \
492 {"writelines", (PyCFunction)_multibytecodec_MultibyteStreamWriter_writelines, METH_O, _multibytecodec_MultibyteStreamWriter_writelines__doc__},
493
494PyDoc_STRVAR(_multibytecodec_MultibyteStreamWriter_reset__doc__,
495"reset($self, /)\n"
496"--\n"
497"\n");
498
499#define _MULTIBYTECODEC_MULTIBYTESTREAMWRITER_RESET_METHODDEF \
500 {"reset", (PyCFunction)_multibytecodec_MultibyteStreamWriter_reset, METH_NOARGS, _multibytecodec_MultibyteStreamWriter_reset__doc__},
501
502static PyObject *
503_multibytecodec_MultibyteStreamWriter_reset_impl(MultibyteStreamWriterObject *self);
504
505static PyObject *
506_multibytecodec_MultibyteStreamWriter_reset(MultibyteStreamWriterObject *self, PyObject *Py_UNUSED(ignored))
507{
508 return _multibytecodec_MultibyteStreamWriter_reset_impl(self);
509}
510
511PyDoc_STRVAR(_multibytecodec___create_codec__doc__,
512"__create_codec($module, arg, /)\n"
513"--\n"
514"\n");
515
516#define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
517 {"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__},
518/*[clinic end generated code: output=5c0f74129db07c87 input=a9049054013a1b77]*/
519