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(array_array___copy____doc__,
12 : : "__copy__($self, /)\n"
13 : : "--\n"
14 : : "\n"
15 : : "Return a copy of the array.");
16 : :
17 : : #define ARRAY_ARRAY___COPY___METHODDEF \
18 : : {"__copy__", (PyCFunction)array_array___copy__, METH_NOARGS, array_array___copy____doc__},
19 : :
20 : : static PyObject *
21 : : array_array___copy___impl(arrayobject *self);
22 : :
23 : : static PyObject *
24 : 0 : array_array___copy__(arrayobject *self, PyObject *Py_UNUSED(ignored))
25 : : {
26 : 0 : return array_array___copy___impl(self);
27 : : }
28 : :
29 : : PyDoc_STRVAR(array_array___deepcopy____doc__,
30 : : "__deepcopy__($self, unused, /)\n"
31 : : "--\n"
32 : : "\n"
33 : : "Return a copy of the array.");
34 : :
35 : : #define ARRAY_ARRAY___DEEPCOPY___METHODDEF \
36 : : {"__deepcopy__", (PyCFunction)array_array___deepcopy__, METH_O, array_array___deepcopy____doc__},
37 : :
38 : : PyDoc_STRVAR(array_array_count__doc__,
39 : : "count($self, v, /)\n"
40 : : "--\n"
41 : : "\n"
42 : : "Return number of occurrences of v in the array.");
43 : :
44 : : #define ARRAY_ARRAY_COUNT_METHODDEF \
45 : : {"count", (PyCFunction)array_array_count, METH_O, array_array_count__doc__},
46 : :
47 : : PyDoc_STRVAR(array_array_index__doc__,
48 : : "index($self, v, start=0, stop=sys.maxsize, /)\n"
49 : : "--\n"
50 : : "\n"
51 : : "Return index of first occurrence of v in the array.\n"
52 : : "\n"
53 : : "Raise ValueError if the value is not present.");
54 : :
55 : : #define ARRAY_ARRAY_INDEX_METHODDEF \
56 : : {"index", _PyCFunction_CAST(array_array_index), METH_FASTCALL, array_array_index__doc__},
57 : :
58 : : static PyObject *
59 : : array_array_index_impl(arrayobject *self, PyObject *v, Py_ssize_t start,
60 : : Py_ssize_t stop);
61 : :
62 : : static PyObject *
63 : 0 : array_array_index(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
64 : : {
65 : 0 : PyObject *return_value = NULL;
66 : : PyObject *v;
67 : 0 : Py_ssize_t start = 0;
68 : 0 : Py_ssize_t stop = PY_SSIZE_T_MAX;
69 : :
70 [ # # # # : 0 : if (!_PyArg_CheckPositional("index", nargs, 1, 3)) {
# # ]
71 : 0 : goto exit;
72 : : }
73 : 0 : v = args[0];
74 [ # # ]: 0 : if (nargs < 2) {
75 : 0 : goto skip_optional;
76 : : }
77 [ # # ]: 0 : if (!_PyEval_SliceIndexNotNone(args[1], &start)) {
78 : 0 : goto exit;
79 : : }
80 [ # # ]: 0 : if (nargs < 3) {
81 : 0 : goto skip_optional;
82 : : }
83 [ # # ]: 0 : if (!_PyEval_SliceIndexNotNone(args[2], &stop)) {
84 : 0 : goto exit;
85 : : }
86 : 0 : skip_optional:
87 : 0 : return_value = array_array_index_impl(self, v, start, stop);
88 : :
89 : 0 : exit:
90 : 0 : return return_value;
91 : : }
92 : :
93 : : PyDoc_STRVAR(array_array_remove__doc__,
94 : : "remove($self, v, /)\n"
95 : : "--\n"
96 : : "\n"
97 : : "Remove the first occurrence of v in the array.");
98 : :
99 : : #define ARRAY_ARRAY_REMOVE_METHODDEF \
100 : : {"remove", (PyCFunction)array_array_remove, METH_O, array_array_remove__doc__},
101 : :
102 : : PyDoc_STRVAR(array_array_pop__doc__,
103 : : "pop($self, i=-1, /)\n"
104 : : "--\n"
105 : : "\n"
106 : : "Return the i-th element and delete it from the array.\n"
107 : : "\n"
108 : : "i defaults to -1.");
109 : :
110 : : #define ARRAY_ARRAY_POP_METHODDEF \
111 : : {"pop", _PyCFunction_CAST(array_array_pop), METH_FASTCALL, array_array_pop__doc__},
112 : :
113 : : static PyObject *
114 : : array_array_pop_impl(arrayobject *self, Py_ssize_t i);
115 : :
116 : : static PyObject *
117 : 0 : array_array_pop(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
118 : : {
119 : 0 : PyObject *return_value = NULL;
120 : 0 : Py_ssize_t i = -1;
121 : :
122 [ # # # # : 0 : if (!_PyArg_CheckPositional("pop", nargs, 0, 1)) {
# # ]
123 : 0 : goto exit;
124 : : }
125 [ # # ]: 0 : if (nargs < 1) {
126 : 0 : goto skip_optional;
127 : : }
128 : : {
129 : 0 : Py_ssize_t ival = -1;
130 : 0 : PyObject *iobj = _PyNumber_Index(args[0]);
131 [ # # ]: 0 : if (iobj != NULL) {
132 : 0 : ival = PyLong_AsSsize_t(iobj);
133 : 0 : Py_DECREF(iobj);
134 : : }
135 [ # # # # ]: 0 : if (ival == -1 && PyErr_Occurred()) {
136 : 0 : goto exit;
137 : : }
138 : 0 : i = ival;
139 : : }
140 : 0 : skip_optional:
141 : 0 : return_value = array_array_pop_impl(self, i);
142 : :
143 : 0 : exit:
144 : 0 : return return_value;
145 : : }
146 : :
147 : : PyDoc_STRVAR(array_array_extend__doc__,
148 : : "extend($self, bb, /)\n"
149 : : "--\n"
150 : : "\n"
151 : : "Append items to the end of the array.");
152 : :
153 : : #define ARRAY_ARRAY_EXTEND_METHODDEF \
154 : : {"extend", _PyCFunction_CAST(array_array_extend), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array_extend__doc__},
155 : :
156 : : static PyObject *
157 : : array_array_extend_impl(arrayobject *self, PyTypeObject *cls, PyObject *bb);
158 : :
159 : : static PyObject *
160 : 0 : array_array_extend(arrayobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
161 : : {
162 : 0 : PyObject *return_value = NULL;
163 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
164 : : # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
165 : : #else
166 : : # define KWTUPLE NULL
167 : : #endif
168 : :
169 : : static const char * const _keywords[] = {"", NULL};
170 : : static _PyArg_Parser _parser = {
171 : : .keywords = _keywords,
172 : : .fname = "extend",
173 : : .kwtuple = KWTUPLE,
174 : : };
175 : : #undef KWTUPLE
176 : : PyObject *argsbuf[1];
177 : : PyObject *bb;
178 : :
179 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
# # # # ]
180 [ # # ]: 0 : if (!args) {
181 : 0 : goto exit;
182 : : }
183 : 0 : bb = args[0];
184 : 0 : return_value = array_array_extend_impl(self, cls, bb);
185 : :
186 : 0 : exit:
187 : 0 : return return_value;
188 : : }
189 : :
190 : : PyDoc_STRVAR(array_array_insert__doc__,
191 : : "insert($self, i, v, /)\n"
192 : : "--\n"
193 : : "\n"
194 : : "Insert a new item v into the array before position i.");
195 : :
196 : : #define ARRAY_ARRAY_INSERT_METHODDEF \
197 : : {"insert", _PyCFunction_CAST(array_array_insert), METH_FASTCALL, array_array_insert__doc__},
198 : :
199 : : static PyObject *
200 : : array_array_insert_impl(arrayobject *self, Py_ssize_t i, PyObject *v);
201 : :
202 : : static PyObject *
203 : 0 : array_array_insert(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
204 : : {
205 : 0 : PyObject *return_value = NULL;
206 : : Py_ssize_t i;
207 : : PyObject *v;
208 : :
209 [ # # # # : 0 : if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
# # ]
210 : 0 : goto exit;
211 : : }
212 : : {
213 : 0 : Py_ssize_t ival = -1;
214 : 0 : PyObject *iobj = _PyNumber_Index(args[0]);
215 [ # # ]: 0 : if (iobj != NULL) {
216 : 0 : ival = PyLong_AsSsize_t(iobj);
217 : 0 : Py_DECREF(iobj);
218 : : }
219 [ # # # # ]: 0 : if (ival == -1 && PyErr_Occurred()) {
220 : 0 : goto exit;
221 : : }
222 : 0 : i = ival;
223 : : }
224 : 0 : v = args[1];
225 : 0 : return_value = array_array_insert_impl(self, i, v);
226 : :
227 : 0 : exit:
228 : 0 : return return_value;
229 : : }
230 : :
231 : : PyDoc_STRVAR(array_array_buffer_info__doc__,
232 : : "buffer_info($self, /)\n"
233 : : "--\n"
234 : : "\n"
235 : : "Return a tuple (address, length) giving the current memory address and the length in items of the buffer used to hold array\'s contents.\n"
236 : : "\n"
237 : : "The length should be multiplied by the itemsize attribute to calculate\n"
238 : : "the buffer length in bytes.");
239 : :
240 : : #define ARRAY_ARRAY_BUFFER_INFO_METHODDEF \
241 : : {"buffer_info", (PyCFunction)array_array_buffer_info, METH_NOARGS, array_array_buffer_info__doc__},
242 : :
243 : : static PyObject *
244 : : array_array_buffer_info_impl(arrayobject *self);
245 : :
246 : : static PyObject *
247 : 0 : array_array_buffer_info(arrayobject *self, PyObject *Py_UNUSED(ignored))
248 : : {
249 : 0 : return array_array_buffer_info_impl(self);
250 : : }
251 : :
252 : : PyDoc_STRVAR(array_array_append__doc__,
253 : : "append($self, v, /)\n"
254 : : "--\n"
255 : : "\n"
256 : : "Append new value v to the end of the array.");
257 : :
258 : : #define ARRAY_ARRAY_APPEND_METHODDEF \
259 : : {"append", (PyCFunction)array_array_append, METH_O, array_array_append__doc__},
260 : :
261 : : PyDoc_STRVAR(array_array_byteswap__doc__,
262 : : "byteswap($self, /)\n"
263 : : "--\n"
264 : : "\n"
265 : : "Byteswap all items of the array.\n"
266 : : "\n"
267 : : "If the items in the array are not 1, 2, 4, or 8 bytes in size, RuntimeError is\n"
268 : : "raised.");
269 : :
270 : : #define ARRAY_ARRAY_BYTESWAP_METHODDEF \
271 : : {"byteswap", (PyCFunction)array_array_byteswap, METH_NOARGS, array_array_byteswap__doc__},
272 : :
273 : : static PyObject *
274 : : array_array_byteswap_impl(arrayobject *self);
275 : :
276 : : static PyObject *
277 : 0 : array_array_byteswap(arrayobject *self, PyObject *Py_UNUSED(ignored))
278 : : {
279 : 0 : return array_array_byteswap_impl(self);
280 : : }
281 : :
282 : : PyDoc_STRVAR(array_array_reverse__doc__,
283 : : "reverse($self, /)\n"
284 : : "--\n"
285 : : "\n"
286 : : "Reverse the order of the items in the array.");
287 : :
288 : : #define ARRAY_ARRAY_REVERSE_METHODDEF \
289 : : {"reverse", (PyCFunction)array_array_reverse, METH_NOARGS, array_array_reverse__doc__},
290 : :
291 : : static PyObject *
292 : : array_array_reverse_impl(arrayobject *self);
293 : :
294 : : static PyObject *
295 : 0 : array_array_reverse(arrayobject *self, PyObject *Py_UNUSED(ignored))
296 : : {
297 : 0 : return array_array_reverse_impl(self);
298 : : }
299 : :
300 : : PyDoc_STRVAR(array_array_fromfile__doc__,
301 : : "fromfile($self, f, n, /)\n"
302 : : "--\n"
303 : : "\n"
304 : : "Read n objects from the file object f and append them to the end of the array.");
305 : :
306 : : #define ARRAY_ARRAY_FROMFILE_METHODDEF \
307 : : {"fromfile", _PyCFunction_CAST(array_array_fromfile), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array_fromfile__doc__},
308 : :
309 : : static PyObject *
310 : : array_array_fromfile_impl(arrayobject *self, PyTypeObject *cls, PyObject *f,
311 : : Py_ssize_t n);
312 : :
313 : : static PyObject *
314 : 0 : array_array_fromfile(arrayobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
315 : : {
316 : 0 : PyObject *return_value = NULL;
317 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
318 : : # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
319 : : #else
320 : : # define KWTUPLE NULL
321 : : #endif
322 : :
323 : : static const char * const _keywords[] = {"", "", NULL};
324 : : static _PyArg_Parser _parser = {
325 : : .keywords = _keywords,
326 : : .fname = "fromfile",
327 : : .kwtuple = KWTUPLE,
328 : : };
329 : : #undef KWTUPLE
330 : : PyObject *argsbuf[2];
331 : : PyObject *f;
332 : : Py_ssize_t n;
333 : :
334 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
# # # # ]
335 [ # # ]: 0 : if (!args) {
336 : 0 : goto exit;
337 : : }
338 : 0 : f = args[0];
339 : : {
340 : 0 : Py_ssize_t ival = -1;
341 : 0 : PyObject *iobj = _PyNumber_Index(args[1]);
342 [ # # ]: 0 : if (iobj != NULL) {
343 : 0 : ival = PyLong_AsSsize_t(iobj);
344 : 0 : Py_DECREF(iobj);
345 : : }
346 [ # # # # ]: 0 : if (ival == -1 && PyErr_Occurred()) {
347 : 0 : goto exit;
348 : : }
349 : 0 : n = ival;
350 : : }
351 : 0 : return_value = array_array_fromfile_impl(self, cls, f, n);
352 : :
353 : 0 : exit:
354 : 0 : return return_value;
355 : : }
356 : :
357 : : PyDoc_STRVAR(array_array_tofile__doc__,
358 : : "tofile($self, f, /)\n"
359 : : "--\n"
360 : : "\n"
361 : : "Write all items (as machine values) to the file object f.");
362 : :
363 : : #define ARRAY_ARRAY_TOFILE_METHODDEF \
364 : : {"tofile", _PyCFunction_CAST(array_array_tofile), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array_tofile__doc__},
365 : :
366 : : static PyObject *
367 : : array_array_tofile_impl(arrayobject *self, PyTypeObject *cls, PyObject *f);
368 : :
369 : : static PyObject *
370 : 0 : array_array_tofile(arrayobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
371 : : {
372 : 0 : PyObject *return_value = NULL;
373 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
374 : : # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
375 : : #else
376 : : # define KWTUPLE NULL
377 : : #endif
378 : :
379 : : static const char * const _keywords[] = {"", NULL};
380 : : static _PyArg_Parser _parser = {
381 : : .keywords = _keywords,
382 : : .fname = "tofile",
383 : : .kwtuple = KWTUPLE,
384 : : };
385 : : #undef KWTUPLE
386 : : PyObject *argsbuf[1];
387 : : PyObject *f;
388 : :
389 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
# # # # ]
390 [ # # ]: 0 : if (!args) {
391 : 0 : goto exit;
392 : : }
393 : 0 : f = args[0];
394 : 0 : return_value = array_array_tofile_impl(self, cls, f);
395 : :
396 : 0 : exit:
397 : 0 : return return_value;
398 : : }
399 : :
400 : : PyDoc_STRVAR(array_array_fromlist__doc__,
401 : : "fromlist($self, list, /)\n"
402 : : "--\n"
403 : : "\n"
404 : : "Append items to array from list.");
405 : :
406 : : #define ARRAY_ARRAY_FROMLIST_METHODDEF \
407 : : {"fromlist", (PyCFunction)array_array_fromlist, METH_O, array_array_fromlist__doc__},
408 : :
409 : : PyDoc_STRVAR(array_array_tolist__doc__,
410 : : "tolist($self, /)\n"
411 : : "--\n"
412 : : "\n"
413 : : "Convert array to an ordinary list with the same items.");
414 : :
415 : : #define ARRAY_ARRAY_TOLIST_METHODDEF \
416 : : {"tolist", (PyCFunction)array_array_tolist, METH_NOARGS, array_array_tolist__doc__},
417 : :
418 : : static PyObject *
419 : : array_array_tolist_impl(arrayobject *self);
420 : :
421 : : static PyObject *
422 : 0 : array_array_tolist(arrayobject *self, PyObject *Py_UNUSED(ignored))
423 : : {
424 : 0 : return array_array_tolist_impl(self);
425 : : }
426 : :
427 : : PyDoc_STRVAR(array_array_frombytes__doc__,
428 : : "frombytes($self, buffer, /)\n"
429 : : "--\n"
430 : : "\n"
431 : : "Appends items from the string, interpreting it as an array of machine values, as if it had been read from a file using the fromfile() method.");
432 : :
433 : : #define ARRAY_ARRAY_FROMBYTES_METHODDEF \
434 : : {"frombytes", (PyCFunction)array_array_frombytes, METH_O, array_array_frombytes__doc__},
435 : :
436 : : static PyObject *
437 : : array_array_frombytes_impl(arrayobject *self, Py_buffer *buffer);
438 : :
439 : : static PyObject *
440 : 0 : array_array_frombytes(arrayobject *self, PyObject *arg)
441 : : {
442 : 0 : PyObject *return_value = NULL;
443 : 0 : Py_buffer buffer = {NULL, NULL};
444 : :
445 [ # # ]: 0 : if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
446 : 0 : goto exit;
447 : : }
448 [ # # ]: 0 : if (!PyBuffer_IsContiguous(&buffer, 'C')) {
449 : 0 : _PyArg_BadArgument("frombytes", "argument", "contiguous buffer", arg);
450 : 0 : goto exit;
451 : : }
452 : 0 : return_value = array_array_frombytes_impl(self, &buffer);
453 : :
454 : 0 : exit:
455 : : /* Cleanup for buffer */
456 [ # # ]: 0 : if (buffer.obj) {
457 : 0 : PyBuffer_Release(&buffer);
458 : : }
459 : :
460 : 0 : return return_value;
461 : : }
462 : :
463 : : PyDoc_STRVAR(array_array_tobytes__doc__,
464 : : "tobytes($self, /)\n"
465 : : "--\n"
466 : : "\n"
467 : : "Convert the array to an array of machine values and return the bytes representation.");
468 : :
469 : : #define ARRAY_ARRAY_TOBYTES_METHODDEF \
470 : : {"tobytes", (PyCFunction)array_array_tobytes, METH_NOARGS, array_array_tobytes__doc__},
471 : :
472 : : static PyObject *
473 : : array_array_tobytes_impl(arrayobject *self);
474 : :
475 : : static PyObject *
476 : 0 : array_array_tobytes(arrayobject *self, PyObject *Py_UNUSED(ignored))
477 : : {
478 : 0 : return array_array_tobytes_impl(self);
479 : : }
480 : :
481 : : PyDoc_STRVAR(array_array_fromunicode__doc__,
482 : : "fromunicode($self, ustr, /)\n"
483 : : "--\n"
484 : : "\n"
485 : : "Extends this array with data from the unicode string ustr.\n"
486 : : "\n"
487 : : "The array must be a unicode type array; otherwise a ValueError is raised.\n"
488 : : "Use array.frombytes(ustr.encode(...)) to append Unicode data to an array of\n"
489 : : "some other type.");
490 : :
491 : : #define ARRAY_ARRAY_FROMUNICODE_METHODDEF \
492 : : {"fromunicode", (PyCFunction)array_array_fromunicode, METH_O, array_array_fromunicode__doc__},
493 : :
494 : : static PyObject *
495 : : array_array_fromunicode_impl(arrayobject *self, PyObject *ustr);
496 : :
497 : : static PyObject *
498 : 0 : array_array_fromunicode(arrayobject *self, PyObject *arg)
499 : : {
500 : 0 : PyObject *return_value = NULL;
501 : : PyObject *ustr;
502 : :
503 [ # # ]: 0 : if (!PyUnicode_Check(arg)) {
504 : 0 : _PyArg_BadArgument("fromunicode", "argument", "str", arg);
505 : 0 : goto exit;
506 : : }
507 [ # # ]: 0 : if (PyUnicode_READY(arg) == -1) {
508 : 0 : goto exit;
509 : : }
510 : 0 : ustr = arg;
511 : 0 : return_value = array_array_fromunicode_impl(self, ustr);
512 : :
513 : 0 : exit:
514 : 0 : return return_value;
515 : : }
516 : :
517 : : PyDoc_STRVAR(array_array_tounicode__doc__,
518 : : "tounicode($self, /)\n"
519 : : "--\n"
520 : : "\n"
521 : : "Extends this array with data from the unicode string ustr.\n"
522 : : "\n"
523 : : "Convert the array to a unicode string. The array must be a unicode type array;\n"
524 : : "otherwise a ValueError is raised. Use array.tobytes().decode() to obtain a\n"
525 : : "unicode string from an array of some other type.");
526 : :
527 : : #define ARRAY_ARRAY_TOUNICODE_METHODDEF \
528 : : {"tounicode", (PyCFunction)array_array_tounicode, METH_NOARGS, array_array_tounicode__doc__},
529 : :
530 : : static PyObject *
531 : : array_array_tounicode_impl(arrayobject *self);
532 : :
533 : : static PyObject *
534 : 0 : array_array_tounicode(arrayobject *self, PyObject *Py_UNUSED(ignored))
535 : : {
536 : 0 : return array_array_tounicode_impl(self);
537 : : }
538 : :
539 : : PyDoc_STRVAR(array_array___sizeof____doc__,
540 : : "__sizeof__($self, /)\n"
541 : : "--\n"
542 : : "\n"
543 : : "Size of the array in memory, in bytes.");
544 : :
545 : : #define ARRAY_ARRAY___SIZEOF___METHODDEF \
546 : : {"__sizeof__", (PyCFunction)array_array___sizeof__, METH_NOARGS, array_array___sizeof____doc__},
547 : :
548 : : static PyObject *
549 : : array_array___sizeof___impl(arrayobject *self);
550 : :
551 : : static PyObject *
552 : 0 : array_array___sizeof__(arrayobject *self, PyObject *Py_UNUSED(ignored))
553 : : {
554 : 0 : return array_array___sizeof___impl(self);
555 : : }
556 : :
557 : : PyDoc_STRVAR(array__array_reconstructor__doc__,
558 : : "_array_reconstructor($module, arraytype, typecode, mformat_code, items,\n"
559 : : " /)\n"
560 : : "--\n"
561 : : "\n"
562 : : "Internal. Used for pickling support.");
563 : :
564 : : #define ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF \
565 : : {"_array_reconstructor", _PyCFunction_CAST(array__array_reconstructor), METH_FASTCALL, array__array_reconstructor__doc__},
566 : :
567 : : static PyObject *
568 : : array__array_reconstructor_impl(PyObject *module, PyTypeObject *arraytype,
569 : : int typecode,
570 : : enum machine_format_code mformat_code,
571 : : PyObject *items);
572 : :
573 : : static PyObject *
574 : 0 : array__array_reconstructor(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
575 : : {
576 : 0 : PyObject *return_value = NULL;
577 : : PyTypeObject *arraytype;
578 : : int typecode;
579 : : enum machine_format_code mformat_code;
580 : : PyObject *items;
581 : :
582 [ # # # # : 0 : if (!_PyArg_CheckPositional("_array_reconstructor", nargs, 4, 4)) {
# # ]
583 : 0 : goto exit;
584 : : }
585 : 0 : arraytype = (PyTypeObject *)args[0];
586 [ # # ]: 0 : if (!PyUnicode_Check(args[1])) {
587 : 0 : _PyArg_BadArgument("_array_reconstructor", "argument 2", "a unicode character", args[1]);
588 : 0 : goto exit;
589 : : }
590 [ # # ]: 0 : if (PyUnicode_READY(args[1])) {
591 : 0 : goto exit;
592 : : }
593 [ # # ]: 0 : if (PyUnicode_GET_LENGTH(args[1]) != 1) {
594 : 0 : _PyArg_BadArgument("_array_reconstructor", "argument 2", "a unicode character", args[1]);
595 : 0 : goto exit;
596 : : }
597 : 0 : typecode = PyUnicode_READ_CHAR(args[1], 0);
598 : 0 : mformat_code = _PyLong_AsInt(args[2]);
599 [ # # # # ]: 0 : if (mformat_code == -1 && PyErr_Occurred()) {
600 : 0 : goto exit;
601 : : }
602 : 0 : items = args[3];
603 : 0 : return_value = array__array_reconstructor_impl(module, arraytype, typecode, mformat_code, items);
604 : :
605 : 0 : exit:
606 : 0 : return return_value;
607 : : }
608 : :
609 : : PyDoc_STRVAR(array_array___reduce_ex____doc__,
610 : : "__reduce_ex__($self, value, /)\n"
611 : : "--\n"
612 : : "\n"
613 : : "Return state information for pickling.");
614 : :
615 : : #define ARRAY_ARRAY___REDUCE_EX___METHODDEF \
616 : : {"__reduce_ex__", _PyCFunction_CAST(array_array___reduce_ex__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_array___reduce_ex____doc__},
617 : :
618 : : static PyObject *
619 : : array_array___reduce_ex___impl(arrayobject *self, PyTypeObject *cls,
620 : : PyObject *value);
621 : :
622 : : static PyObject *
623 : 0 : array_array___reduce_ex__(arrayobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
624 : : {
625 : 0 : PyObject *return_value = NULL;
626 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
627 : : # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
628 : : #else
629 : : # define KWTUPLE NULL
630 : : #endif
631 : :
632 : : static const char * const _keywords[] = {"", NULL};
633 : : static _PyArg_Parser _parser = {
634 : : .keywords = _keywords,
635 : : .fname = "__reduce_ex__",
636 : : .kwtuple = KWTUPLE,
637 : : };
638 : : #undef KWTUPLE
639 : : PyObject *argsbuf[1];
640 : : PyObject *value;
641 : :
642 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
# # # # ]
643 [ # # ]: 0 : if (!args) {
644 : 0 : goto exit;
645 : : }
646 : 0 : value = args[0];
647 : 0 : return_value = array_array___reduce_ex___impl(self, cls, value);
648 : :
649 : 0 : exit:
650 : 0 : return return_value;
651 : : }
652 : :
653 : : PyDoc_STRVAR(array_arrayiterator___reduce____doc__,
654 : : "__reduce__($self, /)\n"
655 : : "--\n"
656 : : "\n"
657 : : "Return state information for pickling.");
658 : :
659 : : #define ARRAY_ARRAYITERATOR___REDUCE___METHODDEF \
660 : : {"__reduce__", _PyCFunction_CAST(array_arrayiterator___reduce__), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, array_arrayiterator___reduce____doc__},
661 : :
662 : : static PyObject *
663 : : array_arrayiterator___reduce___impl(arrayiterobject *self, PyTypeObject *cls);
664 : :
665 : : static PyObject *
666 : 0 : array_arrayiterator___reduce__(arrayiterobject *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
667 : : {
668 [ # # ]: 0 : if (nargs) {
669 : 0 : PyErr_SetString(PyExc_TypeError, "__reduce__() takes no arguments");
670 : 0 : return NULL;
671 : : }
672 : 0 : return array_arrayiterator___reduce___impl(self, cls);
673 : : }
674 : :
675 : : PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
676 : : "__setstate__($self, state, /)\n"
677 : : "--\n"
678 : : "\n"
679 : : "Set state information for unpickling.");
680 : :
681 : : #define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
682 : : {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
683 : : /*[clinic end generated code: output=69bc1451f7bda234 input=a9049054013a1b77]*/
|