blob: 25857fc6d6f029d91e32f5b4a2c5eee3697362cd [file] [log] [blame]
Brett Cannonf2de1fc2014-08-22 11:45:03 -04001/*[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 \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +030017 {"encode", (PyCFunction)_multibytecodec_MultibyteCodec_encode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_encode__doc__},
Brett Cannonf2de1fc2014-08-22 11:45:03 -040018
19static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -040020_multibytecodec_MultibyteCodec_encode_impl(MultibyteCodecObject *self,
21 PyObject *input,
22 const char *errors);
Brett Cannonf2de1fc2014-08-22 11:45:03 -040023
24static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +020025_multibytecodec_MultibyteCodec_encode(MultibyteCodecObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Brett Cannonf2de1fc2014-08-22 11:45:03 -040026{
27 PyObject *return_value = NULL;
Serhiy Storchaka9171a8b2016-08-14 10:52:18 +030028 static const char * const _keywords[] = {"input", "errors", NULL};
29 static _PyArg_Parser _parser = {"O|z:encode", _keywords, 0};
Brett Cannonf2de1fc2014-08-22 11:45:03 -040030 PyObject *input;
31 const char *errors = NULL;
32
Victor Stinner3e1fad62017-01-17 01:29:01 +010033 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030034 &input, &errors)) {
Brett Cannonf2de1fc2014-08-22 11:45:03 -040035 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030036 }
Brett Cannonf2de1fc2014-08-22 11:45:03 -040037 return_value = _multibytecodec_MultibyteCodec_encode_impl(self, input, errors);
38
39exit:
40 return return_value;
41}
42
43PyDoc_STRVAR(_multibytecodec_MultibyteCodec_decode__doc__,
44"decode($self, /, input, errors=None)\n"
45"--\n"
46"\n"
47"Decodes \'input\'.\n"
48"\n"
49"\'errors\' may be given to set a different error handling scheme. Default is\n"
50"\'strict\' meaning that encoding errors raise a UnicodeDecodeError. Other possible\n"
51"values are \'ignore\' and \'replace\' as well as any other name registered with\n"
52"codecs.register_error that is able to handle UnicodeDecodeErrors.\"");
53
54#define _MULTIBYTECODEC_MULTIBYTECODEC_DECODE_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +030055 {"decode", (PyCFunction)_multibytecodec_MultibyteCodec_decode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteCodec_decode__doc__},
Brett Cannonf2de1fc2014-08-22 11:45:03 -040056
57static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -040058_multibytecodec_MultibyteCodec_decode_impl(MultibyteCodecObject *self,
59 Py_buffer *input,
60 const char *errors);
Brett Cannonf2de1fc2014-08-22 11:45:03 -040061
62static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +020063_multibytecodec_MultibyteCodec_decode(MultibyteCodecObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Brett Cannonf2de1fc2014-08-22 11:45:03 -040064{
65 PyObject *return_value = NULL;
Serhiy Storchaka9171a8b2016-08-14 10:52:18 +030066 static const char * const _keywords[] = {"input", "errors", NULL};
67 static _PyArg_Parser _parser = {"y*|z:decode", _keywords, 0};
Brett Cannonf2de1fc2014-08-22 11:45:03 -040068 Py_buffer input = {NULL, NULL};
69 const char *errors = NULL;
70
Victor Stinner3e1fad62017-01-17 01:29:01 +010071 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030072 &input, &errors)) {
Brett Cannonf2de1fc2014-08-22 11:45:03 -040073 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030074 }
Brett Cannonf2de1fc2014-08-22 11:45:03 -040075 return_value = _multibytecodec_MultibyteCodec_decode_impl(self, &input, errors);
76
77exit:
78 /* Cleanup for input */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030079 if (input.obj) {
Brett Cannonf2de1fc2014-08-22 11:45:03 -040080 PyBuffer_Release(&input);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030081 }
Brett Cannonf2de1fc2014-08-22 11:45:03 -040082
83 return return_value;
84}
85
86PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_encode__doc__,
Serhiy Storchaka8b2e8b62015-05-30 11:30:39 +030087"encode($self, /, input, final=False)\n"
Zachary Ware8ef887c2015-04-13 18:22:35 -050088"--\n"
89"\n");
Brett Cannonf2de1fc2014-08-22 11:45:03 -040090
91#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_ENCODE_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +030092 {"encode", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_encode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalEncoder_encode__doc__},
Brett Cannonf2de1fc2014-08-22 11:45:03 -040093
94static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -040095_multibytecodec_MultibyteIncrementalEncoder_encode_impl(MultibyteIncrementalEncoderObject *self,
96 PyObject *input,
97 int final);
Brett Cannonf2de1fc2014-08-22 11:45:03 -040098
99static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200100_multibytecodec_MultibyteIncrementalEncoder_encode(MultibyteIncrementalEncoderObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400101{
102 PyObject *return_value = NULL;
Serhiy Storchaka9171a8b2016-08-14 10:52:18 +0300103 static const char * const _keywords[] = {"input", "final", NULL};
104 static _PyArg_Parser _parser = {"O|i:encode", _keywords, 0};
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400105 PyObject *input;
106 int final = 0;
107
Victor Stinner3e1fad62017-01-17 01:29:01 +0100108 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300109 &input, &final)) {
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400110 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300111 }
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400112 return_value = _multibytecodec_MultibyteIncrementalEncoder_encode_impl(self, input, final);
113
114exit:
115 return return_value;
116}
117
118PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalEncoder_reset__doc__,
119"reset($self, /)\n"
Zachary Ware8ef887c2015-04-13 18:22:35 -0500120"--\n"
121"\n");
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400122
123#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALENCODER_RESET_METHODDEF \
124 {"reset", (PyCFunction)_multibytecodec_MultibyteIncrementalEncoder_reset, METH_NOARGS, _multibytecodec_MultibyteIncrementalEncoder_reset__doc__},
125
126static PyObject *
127_multibytecodec_MultibyteIncrementalEncoder_reset_impl(MultibyteIncrementalEncoderObject *self);
128
129static PyObject *
130_multibytecodec_MultibyteIncrementalEncoder_reset(MultibyteIncrementalEncoderObject *self, PyObject *Py_UNUSED(ignored))
131{
132 return _multibytecodec_MultibyteIncrementalEncoder_reset_impl(self);
133}
134
135PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_decode__doc__,
Serhiy Storchaka8b2e8b62015-05-30 11:30:39 +0300136"decode($self, /, input, final=False)\n"
Zachary Ware8ef887c2015-04-13 18:22:35 -0500137"--\n"
138"\n");
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400139
140#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_DECODE_METHODDEF \
Serhiy Storchaka6969eaf2017-07-03 21:20:15 +0300141 {"decode", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_decode, METH_FASTCALL|METH_KEYWORDS, _multibytecodec_MultibyteIncrementalDecoder_decode__doc__},
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400142
143static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400144_multibytecodec_MultibyteIncrementalDecoder_decode_impl(MultibyteIncrementalDecoderObject *self,
145 Py_buffer *input,
146 int final);
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400147
148static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200149_multibytecodec_MultibyteIncrementalDecoder_decode(MultibyteIncrementalDecoderObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400150{
151 PyObject *return_value = NULL;
Serhiy Storchaka9171a8b2016-08-14 10:52:18 +0300152 static const char * const _keywords[] = {"input", "final", NULL};
153 static _PyArg_Parser _parser = {"y*|i:decode", _keywords, 0};
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400154 Py_buffer input = {NULL, NULL};
155 int final = 0;
156
Victor Stinner3e1fad62017-01-17 01:29:01 +0100157 if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300158 &input, &final)) {
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400159 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300160 }
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400161 return_value = _multibytecodec_MultibyteIncrementalDecoder_decode_impl(self, &input, final);
162
163exit:
164 /* Cleanup for input */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300165 if (input.obj) {
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400166 PyBuffer_Release(&input);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300167 }
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400168
169 return return_value;
170}
171
172PyDoc_STRVAR(_multibytecodec_MultibyteIncrementalDecoder_reset__doc__,
173"reset($self, /)\n"
Zachary Ware8ef887c2015-04-13 18:22:35 -0500174"--\n"
175"\n");
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400176
177#define _MULTIBYTECODEC_MULTIBYTEINCREMENTALDECODER_RESET_METHODDEF \
178 {"reset", (PyCFunction)_multibytecodec_MultibyteIncrementalDecoder_reset, METH_NOARGS, _multibytecodec_MultibyteIncrementalDecoder_reset__doc__},
179
180static PyObject *
181_multibytecodec_MultibyteIncrementalDecoder_reset_impl(MultibyteIncrementalDecoderObject *self);
182
183static PyObject *
184_multibytecodec_MultibyteIncrementalDecoder_reset(MultibyteIncrementalDecoderObject *self, PyObject *Py_UNUSED(ignored))
185{
186 return _multibytecodec_MultibyteIncrementalDecoder_reset_impl(self);
187}
188
189PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_read__doc__,
190"read($self, sizeobj=None, /)\n"
Zachary Ware8ef887c2015-04-13 18:22:35 -0500191"--\n"
192"\n");
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400193
194#define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READ_METHODDEF \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100195 {"read", (PyCFunction)_multibytecodec_MultibyteStreamReader_read, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_read__doc__},
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400196
197static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400198_multibytecodec_MultibyteStreamReader_read_impl(MultibyteStreamReaderObject *self,
199 PyObject *sizeobj);
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400200
201static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200202_multibytecodec_MultibyteStreamReader_read(MultibyteStreamReaderObject *self, PyObject *const *args, Py_ssize_t nargs)
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400203{
204 PyObject *return_value = NULL;
205 PyObject *sizeobj = Py_None;
206
Sylvain74453812017-06-10 06:51:48 +0200207 if (!_PyArg_UnpackStack(args, nargs, "read",
208 0, 1,
209 &sizeobj)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100210 goto exit;
211 }
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400212 return_value = _multibytecodec_MultibyteStreamReader_read_impl(self, sizeobj);
213
214exit:
215 return return_value;
216}
217
218PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_readline__doc__,
219"readline($self, sizeobj=None, /)\n"
Zachary Ware8ef887c2015-04-13 18:22:35 -0500220"--\n"
221"\n");
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400222
223#define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READLINE_METHODDEF \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100224 {"readline", (PyCFunction)_multibytecodec_MultibyteStreamReader_readline, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readline__doc__},
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400225
226static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400227_multibytecodec_MultibyteStreamReader_readline_impl(MultibyteStreamReaderObject *self,
228 PyObject *sizeobj);
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400229
230static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200231_multibytecodec_MultibyteStreamReader_readline(MultibyteStreamReaderObject *self, PyObject *const *args, Py_ssize_t nargs)
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400232{
233 PyObject *return_value = NULL;
234 PyObject *sizeobj = Py_None;
235
Sylvain74453812017-06-10 06:51:48 +0200236 if (!_PyArg_UnpackStack(args, nargs, "readline",
237 0, 1,
238 &sizeobj)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100239 goto exit;
240 }
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400241 return_value = _multibytecodec_MultibyteStreamReader_readline_impl(self, sizeobj);
242
243exit:
244 return return_value;
245}
246
247PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_readlines__doc__,
248"readlines($self, sizehintobj=None, /)\n"
Zachary Ware8ef887c2015-04-13 18:22:35 -0500249"--\n"
250"\n");
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400251
252#define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_READLINES_METHODDEF \
Victor Stinner0c4a8282017-01-17 02:21:47 +0100253 {"readlines", (PyCFunction)_multibytecodec_MultibyteStreamReader_readlines, METH_FASTCALL, _multibytecodec_MultibyteStreamReader_readlines__doc__},
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400254
255static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400256_multibytecodec_MultibyteStreamReader_readlines_impl(MultibyteStreamReaderObject *self,
257 PyObject *sizehintobj);
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400258
259static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200260_multibytecodec_MultibyteStreamReader_readlines(MultibyteStreamReaderObject *self, PyObject *const *args, Py_ssize_t nargs)
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400261{
262 PyObject *return_value = NULL;
263 PyObject *sizehintobj = Py_None;
264
Sylvain74453812017-06-10 06:51:48 +0200265 if (!_PyArg_UnpackStack(args, nargs, "readlines",
266 0, 1,
267 &sizehintobj)) {
Victor Stinner0c4a8282017-01-17 02:21:47 +0100268 goto exit;
269 }
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400270 return_value = _multibytecodec_MultibyteStreamReader_readlines_impl(self, sizehintobj);
271
272exit:
273 return return_value;
274}
275
276PyDoc_STRVAR(_multibytecodec_MultibyteStreamReader_reset__doc__,
277"reset($self, /)\n"
Zachary Ware8ef887c2015-04-13 18:22:35 -0500278"--\n"
279"\n");
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400280
281#define _MULTIBYTECODEC_MULTIBYTESTREAMREADER_RESET_METHODDEF \
282 {"reset", (PyCFunction)_multibytecodec_MultibyteStreamReader_reset, METH_NOARGS, _multibytecodec_MultibyteStreamReader_reset__doc__},
283
284static PyObject *
285_multibytecodec_MultibyteStreamReader_reset_impl(MultibyteStreamReaderObject *self);
286
287static PyObject *
288_multibytecodec_MultibyteStreamReader_reset(MultibyteStreamReaderObject *self, PyObject *Py_UNUSED(ignored))
289{
290 return _multibytecodec_MultibyteStreamReader_reset_impl(self);
291}
292
293PyDoc_STRVAR(_multibytecodec_MultibyteStreamWriter_write__doc__,
294"write($self, strobj, /)\n"
Zachary Ware8ef887c2015-04-13 18:22:35 -0500295"--\n"
296"\n");
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400297
298#define _MULTIBYTECODEC_MULTIBYTESTREAMWRITER_WRITE_METHODDEF \
299 {"write", (PyCFunction)_multibytecodec_MultibyteStreamWriter_write, METH_O, _multibytecodec_MultibyteStreamWriter_write__doc__},
300
301PyDoc_STRVAR(_multibytecodec_MultibyteStreamWriter_writelines__doc__,
302"writelines($self, lines, /)\n"
Zachary Ware8ef887c2015-04-13 18:22:35 -0500303"--\n"
304"\n");
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400305
306#define _MULTIBYTECODEC_MULTIBYTESTREAMWRITER_WRITELINES_METHODDEF \
307 {"writelines", (PyCFunction)_multibytecodec_MultibyteStreamWriter_writelines, METH_O, _multibytecodec_MultibyteStreamWriter_writelines__doc__},
308
309PyDoc_STRVAR(_multibytecodec_MultibyteStreamWriter_reset__doc__,
310"reset($self, /)\n"
Zachary Ware8ef887c2015-04-13 18:22:35 -0500311"--\n"
312"\n");
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400313
314#define _MULTIBYTECODEC_MULTIBYTESTREAMWRITER_RESET_METHODDEF \
315 {"reset", (PyCFunction)_multibytecodec_MultibyteStreamWriter_reset, METH_NOARGS, _multibytecodec_MultibyteStreamWriter_reset__doc__},
316
317static PyObject *
318_multibytecodec_MultibyteStreamWriter_reset_impl(MultibyteStreamWriterObject *self);
319
320static PyObject *
321_multibytecodec_MultibyteStreamWriter_reset(MultibyteStreamWriterObject *self, PyObject *Py_UNUSED(ignored))
322{
323 return _multibytecodec_MultibyteStreamWriter_reset_impl(self);
324}
325
326PyDoc_STRVAR(_multibytecodec___create_codec__doc__,
327"__create_codec($module, arg, /)\n"
Zachary Ware8ef887c2015-04-13 18:22:35 -0500328"--\n"
329"\n");
Brett Cannonf2de1fc2014-08-22 11:45:03 -0400330
331#define _MULTIBYTECODEC___CREATE_CODEC_METHODDEF \
332 {"__create_codec", (PyCFunction)_multibytecodec___create_codec, METH_O, _multibytecodec___create_codec__doc__},
Serhiy Storchakaa5552f02017-12-15 13:11:11 +0200333/*[clinic end generated code: output=680f59f4cfe63c25 input=a9049054013a1b77]*/