multibytecodec.c.h 23 KB

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