• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_STRVAR(array_array___copy____doc__,
6 "__copy__($self, /)\n"
7 "--\n"
8 "\n"
9 "Return a copy of the array.");
10 
11 #define ARRAY_ARRAY___COPY___METHODDEF    \
12     {"__copy__", (PyCFunction)array_array___copy__, METH_NOARGS, array_array___copy____doc__},
13 
14 static PyObject *
15 array_array___copy___impl(arrayobject *self);
16 
17 static PyObject *
array_array___copy__(arrayobject * self,PyObject * Py_UNUSED (ignored))18 array_array___copy__(arrayobject *self, PyObject *Py_UNUSED(ignored))
19 {
20     return array_array___copy___impl(self);
21 }
22 
23 PyDoc_STRVAR(array_array___deepcopy____doc__,
24 "__deepcopy__($self, unused, /)\n"
25 "--\n"
26 "\n"
27 "Return a copy of the array.");
28 
29 #define ARRAY_ARRAY___DEEPCOPY___METHODDEF    \
30     {"__deepcopy__", (PyCFunction)array_array___deepcopy__, METH_O, array_array___deepcopy____doc__},
31 
32 PyDoc_STRVAR(array_array_count__doc__,
33 "count($self, v, /)\n"
34 "--\n"
35 "\n"
36 "Return number of occurrences of v in the array.");
37 
38 #define ARRAY_ARRAY_COUNT_METHODDEF    \
39     {"count", (PyCFunction)array_array_count, METH_O, array_array_count__doc__},
40 
41 PyDoc_STRVAR(array_array_index__doc__,
42 "index($self, v, /)\n"
43 "--\n"
44 "\n"
45 "Return index of first occurrence of v in the array.");
46 
47 #define ARRAY_ARRAY_INDEX_METHODDEF    \
48     {"index", (PyCFunction)array_array_index, METH_O, array_array_index__doc__},
49 
50 PyDoc_STRVAR(array_array_remove__doc__,
51 "remove($self, v, /)\n"
52 "--\n"
53 "\n"
54 "Remove the first occurrence of v in the array.");
55 
56 #define ARRAY_ARRAY_REMOVE_METHODDEF    \
57     {"remove", (PyCFunction)array_array_remove, METH_O, array_array_remove__doc__},
58 
59 PyDoc_STRVAR(array_array_pop__doc__,
60 "pop($self, i=-1, /)\n"
61 "--\n"
62 "\n"
63 "Return the i-th element and delete it from the array.\n"
64 "\n"
65 "i defaults to -1.");
66 
67 #define ARRAY_ARRAY_POP_METHODDEF    \
68     {"pop", (PyCFunction)(void(*)(void))array_array_pop, METH_FASTCALL, array_array_pop__doc__},
69 
70 static PyObject *
71 array_array_pop_impl(arrayobject *self, Py_ssize_t i);
72 
73 static PyObject *
array_array_pop(arrayobject * self,PyObject * const * args,Py_ssize_t nargs)74 array_array_pop(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
75 {
76     PyObject *return_value = NULL;
77     Py_ssize_t i = -1;
78 
79     if (!_PyArg_CheckPositional("pop", nargs, 0, 1)) {
80         goto exit;
81     }
82     if (nargs < 1) {
83         goto skip_optional;
84     }
85     if (PyFloat_Check(args[0])) {
86         PyErr_SetString(PyExc_TypeError,
87                         "integer argument expected, got float" );
88         goto exit;
89     }
90     {
91         Py_ssize_t ival = -1;
92         PyObject *iobj = PyNumber_Index(args[0]);
93         if (iobj != NULL) {
94             ival = PyLong_AsSsize_t(iobj);
95             Py_DECREF(iobj);
96         }
97         if (ival == -1 && PyErr_Occurred()) {
98             goto exit;
99         }
100         i = ival;
101     }
102 skip_optional:
103     return_value = array_array_pop_impl(self, i);
104 
105 exit:
106     return return_value;
107 }
108 
109 PyDoc_STRVAR(array_array_extend__doc__,
110 "extend($self, bb, /)\n"
111 "--\n"
112 "\n"
113 "Append items to the end of the array.");
114 
115 #define ARRAY_ARRAY_EXTEND_METHODDEF    \
116     {"extend", (PyCFunction)array_array_extend, METH_O, array_array_extend__doc__},
117 
118 PyDoc_STRVAR(array_array_insert__doc__,
119 "insert($self, i, v, /)\n"
120 "--\n"
121 "\n"
122 "Insert a new item v into the array before position i.");
123 
124 #define ARRAY_ARRAY_INSERT_METHODDEF    \
125     {"insert", (PyCFunction)(void(*)(void))array_array_insert, METH_FASTCALL, array_array_insert__doc__},
126 
127 static PyObject *
128 array_array_insert_impl(arrayobject *self, Py_ssize_t i, PyObject *v);
129 
130 static PyObject *
array_array_insert(arrayobject * self,PyObject * const * args,Py_ssize_t nargs)131 array_array_insert(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
132 {
133     PyObject *return_value = NULL;
134     Py_ssize_t i;
135     PyObject *v;
136 
137     if (!_PyArg_CheckPositional("insert", nargs, 2, 2)) {
138         goto exit;
139     }
140     if (PyFloat_Check(args[0])) {
141         PyErr_SetString(PyExc_TypeError,
142                         "integer argument expected, got float" );
143         goto exit;
144     }
145     {
146         Py_ssize_t ival = -1;
147         PyObject *iobj = PyNumber_Index(args[0]);
148         if (iobj != NULL) {
149             ival = PyLong_AsSsize_t(iobj);
150             Py_DECREF(iobj);
151         }
152         if (ival == -1 && PyErr_Occurred()) {
153             goto exit;
154         }
155         i = ival;
156     }
157     v = args[1];
158     return_value = array_array_insert_impl(self, i, v);
159 
160 exit:
161     return return_value;
162 }
163 
164 PyDoc_STRVAR(array_array_buffer_info__doc__,
165 "buffer_info($self, /)\n"
166 "--\n"
167 "\n"
168 "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"
169 "\n"
170 "The length should be multiplied by the itemsize attribute to calculate\n"
171 "the buffer length in bytes.");
172 
173 #define ARRAY_ARRAY_BUFFER_INFO_METHODDEF    \
174     {"buffer_info", (PyCFunction)array_array_buffer_info, METH_NOARGS, array_array_buffer_info__doc__},
175 
176 static PyObject *
177 array_array_buffer_info_impl(arrayobject *self);
178 
179 static PyObject *
array_array_buffer_info(arrayobject * self,PyObject * Py_UNUSED (ignored))180 array_array_buffer_info(arrayobject *self, PyObject *Py_UNUSED(ignored))
181 {
182     return array_array_buffer_info_impl(self);
183 }
184 
185 PyDoc_STRVAR(array_array_append__doc__,
186 "append($self, v, /)\n"
187 "--\n"
188 "\n"
189 "Append new value v to the end of the array.");
190 
191 #define ARRAY_ARRAY_APPEND_METHODDEF    \
192     {"append", (PyCFunction)array_array_append, METH_O, array_array_append__doc__},
193 
194 PyDoc_STRVAR(array_array_byteswap__doc__,
195 "byteswap($self, /)\n"
196 "--\n"
197 "\n"
198 "Byteswap all items of the array.\n"
199 "\n"
200 "If the items in the array are not 1, 2, 4, or 8 bytes in size, RuntimeError is\n"
201 "raised.");
202 
203 #define ARRAY_ARRAY_BYTESWAP_METHODDEF    \
204     {"byteswap", (PyCFunction)array_array_byteswap, METH_NOARGS, array_array_byteswap__doc__},
205 
206 static PyObject *
207 array_array_byteswap_impl(arrayobject *self);
208 
209 static PyObject *
array_array_byteswap(arrayobject * self,PyObject * Py_UNUSED (ignored))210 array_array_byteswap(arrayobject *self, PyObject *Py_UNUSED(ignored))
211 {
212     return array_array_byteswap_impl(self);
213 }
214 
215 PyDoc_STRVAR(array_array_reverse__doc__,
216 "reverse($self, /)\n"
217 "--\n"
218 "\n"
219 "Reverse the order of the items in the array.");
220 
221 #define ARRAY_ARRAY_REVERSE_METHODDEF    \
222     {"reverse", (PyCFunction)array_array_reverse, METH_NOARGS, array_array_reverse__doc__},
223 
224 static PyObject *
225 array_array_reverse_impl(arrayobject *self);
226 
227 static PyObject *
array_array_reverse(arrayobject * self,PyObject * Py_UNUSED (ignored))228 array_array_reverse(arrayobject *self, PyObject *Py_UNUSED(ignored))
229 {
230     return array_array_reverse_impl(self);
231 }
232 
233 PyDoc_STRVAR(array_array_fromfile__doc__,
234 "fromfile($self, f, n, /)\n"
235 "--\n"
236 "\n"
237 "Read n objects from the file object f and append them to the end of the array.");
238 
239 #define ARRAY_ARRAY_FROMFILE_METHODDEF    \
240     {"fromfile", (PyCFunction)(void(*)(void))array_array_fromfile, METH_FASTCALL, array_array_fromfile__doc__},
241 
242 static PyObject *
243 array_array_fromfile_impl(arrayobject *self, PyObject *f, Py_ssize_t n);
244 
245 static PyObject *
array_array_fromfile(arrayobject * self,PyObject * const * args,Py_ssize_t nargs)246 array_array_fromfile(arrayobject *self, PyObject *const *args, Py_ssize_t nargs)
247 {
248     PyObject *return_value = NULL;
249     PyObject *f;
250     Py_ssize_t n;
251 
252     if (!_PyArg_CheckPositional("fromfile", nargs, 2, 2)) {
253         goto exit;
254     }
255     f = args[0];
256     if (PyFloat_Check(args[1])) {
257         PyErr_SetString(PyExc_TypeError,
258                         "integer argument expected, got float" );
259         goto exit;
260     }
261     {
262         Py_ssize_t ival = -1;
263         PyObject *iobj = PyNumber_Index(args[1]);
264         if (iobj != NULL) {
265             ival = PyLong_AsSsize_t(iobj);
266             Py_DECREF(iobj);
267         }
268         if (ival == -1 && PyErr_Occurred()) {
269             goto exit;
270         }
271         n = ival;
272     }
273     return_value = array_array_fromfile_impl(self, f, n);
274 
275 exit:
276     return return_value;
277 }
278 
279 PyDoc_STRVAR(array_array_tofile__doc__,
280 "tofile($self, f, /)\n"
281 "--\n"
282 "\n"
283 "Write all items (as machine values) to the file object f.");
284 
285 #define ARRAY_ARRAY_TOFILE_METHODDEF    \
286     {"tofile", (PyCFunction)array_array_tofile, METH_O, array_array_tofile__doc__},
287 
288 PyDoc_STRVAR(array_array_fromlist__doc__,
289 "fromlist($self, list, /)\n"
290 "--\n"
291 "\n"
292 "Append items to array from list.");
293 
294 #define ARRAY_ARRAY_FROMLIST_METHODDEF    \
295     {"fromlist", (PyCFunction)array_array_fromlist, METH_O, array_array_fromlist__doc__},
296 
297 PyDoc_STRVAR(array_array_tolist__doc__,
298 "tolist($self, /)\n"
299 "--\n"
300 "\n"
301 "Convert array to an ordinary list with the same items.");
302 
303 #define ARRAY_ARRAY_TOLIST_METHODDEF    \
304     {"tolist", (PyCFunction)array_array_tolist, METH_NOARGS, array_array_tolist__doc__},
305 
306 static PyObject *
307 array_array_tolist_impl(arrayobject *self);
308 
309 static PyObject *
array_array_tolist(arrayobject * self,PyObject * Py_UNUSED (ignored))310 array_array_tolist(arrayobject *self, PyObject *Py_UNUSED(ignored))
311 {
312     return array_array_tolist_impl(self);
313 }
314 
315 PyDoc_STRVAR(array_array_frombytes__doc__,
316 "frombytes($self, buffer, /)\n"
317 "--\n"
318 "\n"
319 "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).");
320 
321 #define ARRAY_ARRAY_FROMBYTES_METHODDEF    \
322     {"frombytes", (PyCFunction)array_array_frombytes, METH_O, array_array_frombytes__doc__},
323 
324 static PyObject *
325 array_array_frombytes_impl(arrayobject *self, Py_buffer *buffer);
326 
327 static PyObject *
array_array_frombytes(arrayobject * self,PyObject * arg)328 array_array_frombytes(arrayobject *self, PyObject *arg)
329 {
330     PyObject *return_value = NULL;
331     Py_buffer buffer = {NULL, NULL};
332 
333     if (PyObject_GetBuffer(arg, &buffer, PyBUF_SIMPLE) != 0) {
334         goto exit;
335     }
336     if (!PyBuffer_IsContiguous(&buffer, 'C')) {
337         _PyArg_BadArgument("frombytes", "argument", "contiguous buffer", arg);
338         goto exit;
339     }
340     return_value = array_array_frombytes_impl(self, &buffer);
341 
342 exit:
343     /* Cleanup for buffer */
344     if (buffer.obj) {
345        PyBuffer_Release(&buffer);
346     }
347 
348     return return_value;
349 }
350 
351 PyDoc_STRVAR(array_array_tobytes__doc__,
352 "tobytes($self, /)\n"
353 "--\n"
354 "\n"
355 "Convert the array to an array of machine values and return the bytes representation.");
356 
357 #define ARRAY_ARRAY_TOBYTES_METHODDEF    \
358     {"tobytes", (PyCFunction)array_array_tobytes, METH_NOARGS, array_array_tobytes__doc__},
359 
360 static PyObject *
361 array_array_tobytes_impl(arrayobject *self);
362 
363 static PyObject *
array_array_tobytes(arrayobject * self,PyObject * Py_UNUSED (ignored))364 array_array_tobytes(arrayobject *self, PyObject *Py_UNUSED(ignored))
365 {
366     return array_array_tobytes_impl(self);
367 }
368 
369 PyDoc_STRVAR(array_array_fromunicode__doc__,
370 "fromunicode($self, ustr, /)\n"
371 "--\n"
372 "\n"
373 "Extends this array with data from the unicode string ustr.\n"
374 "\n"
375 "The array must be a unicode type array; otherwise a ValueError is raised.\n"
376 "Use array.frombytes(ustr.encode(...)) to append Unicode data to an array of\n"
377 "some other type.");
378 
379 #define ARRAY_ARRAY_FROMUNICODE_METHODDEF    \
380     {"fromunicode", (PyCFunction)array_array_fromunicode, METH_O, array_array_fromunicode__doc__},
381 
382 static PyObject *
383 array_array_fromunicode_impl(arrayobject *self, PyObject *ustr);
384 
385 static PyObject *
array_array_fromunicode(arrayobject * self,PyObject * arg)386 array_array_fromunicode(arrayobject *self, PyObject *arg)
387 {
388     PyObject *return_value = NULL;
389     PyObject *ustr;
390 
391     if (!PyUnicode_Check(arg)) {
392         _PyArg_BadArgument("fromunicode", "argument", "str", arg);
393         goto exit;
394     }
395     if (PyUnicode_READY(arg) == -1) {
396         goto exit;
397     }
398     ustr = arg;
399     return_value = array_array_fromunicode_impl(self, ustr);
400 
401 exit:
402     return return_value;
403 }
404 
405 PyDoc_STRVAR(array_array_tounicode__doc__,
406 "tounicode($self, /)\n"
407 "--\n"
408 "\n"
409 "Extends this array with data from the unicode string ustr.\n"
410 "\n"
411 "Convert the array to a unicode string.  The array must be a unicode type array;\n"
412 "otherwise a ValueError is raised.  Use array.tobytes().decode() to obtain a\n"
413 "unicode string from an array of some other type.");
414 
415 #define ARRAY_ARRAY_TOUNICODE_METHODDEF    \
416     {"tounicode", (PyCFunction)array_array_tounicode, METH_NOARGS, array_array_tounicode__doc__},
417 
418 static PyObject *
419 array_array_tounicode_impl(arrayobject *self);
420 
421 static PyObject *
array_array_tounicode(arrayobject * self,PyObject * Py_UNUSED (ignored))422 array_array_tounicode(arrayobject *self, PyObject *Py_UNUSED(ignored))
423 {
424     return array_array_tounicode_impl(self);
425 }
426 
427 PyDoc_STRVAR(array_array___sizeof____doc__,
428 "__sizeof__($self, /)\n"
429 "--\n"
430 "\n"
431 "Size of the array in memory, in bytes.");
432 
433 #define ARRAY_ARRAY___SIZEOF___METHODDEF    \
434     {"__sizeof__", (PyCFunction)array_array___sizeof__, METH_NOARGS, array_array___sizeof____doc__},
435 
436 static PyObject *
437 array_array___sizeof___impl(arrayobject *self);
438 
439 static PyObject *
array_array___sizeof__(arrayobject * self,PyObject * Py_UNUSED (ignored))440 array_array___sizeof__(arrayobject *self, PyObject *Py_UNUSED(ignored))
441 {
442     return array_array___sizeof___impl(self);
443 }
444 
445 PyDoc_STRVAR(array__array_reconstructor__doc__,
446 "_array_reconstructor($module, arraytype, typecode, mformat_code, items,\n"
447 "                     /)\n"
448 "--\n"
449 "\n"
450 "Internal. Used for pickling support.");
451 
452 #define ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF    \
453     {"_array_reconstructor", (PyCFunction)(void(*)(void))array__array_reconstructor, METH_FASTCALL, array__array_reconstructor__doc__},
454 
455 static PyObject *
456 array__array_reconstructor_impl(PyObject *module, PyTypeObject *arraytype,
457                                 int typecode,
458                                 enum machine_format_code mformat_code,
459                                 PyObject *items);
460 
461 static PyObject *
array__array_reconstructor(PyObject * module,PyObject * const * args,Py_ssize_t nargs)462 array__array_reconstructor(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
463 {
464     PyObject *return_value = NULL;
465     PyTypeObject *arraytype;
466     int typecode;
467     enum machine_format_code mformat_code;
468     PyObject *items;
469 
470     if (!_PyArg_CheckPositional("_array_reconstructor", nargs, 4, 4)) {
471         goto exit;
472     }
473     arraytype = (PyTypeObject *)args[0];
474     if (!PyUnicode_Check(args[1])) {
475         _PyArg_BadArgument("_array_reconstructor", "argument 2", "a unicode character", args[1]);
476         goto exit;
477     }
478     if (PyUnicode_READY(args[1])) {
479         goto exit;
480     }
481     if (PyUnicode_GET_LENGTH(args[1]) != 1) {
482         _PyArg_BadArgument("_array_reconstructor", "argument 2", "a unicode character", args[1]);
483         goto exit;
484     }
485     typecode = PyUnicode_READ_CHAR(args[1], 0);
486     if (PyFloat_Check(args[2])) {
487         PyErr_SetString(PyExc_TypeError,
488                         "integer argument expected, got float" );
489         goto exit;
490     }
491     mformat_code = _PyLong_AsInt(args[2]);
492     if (mformat_code == -1 && PyErr_Occurred()) {
493         goto exit;
494     }
495     items = args[3];
496     return_value = array__array_reconstructor_impl(module, arraytype, typecode, mformat_code, items);
497 
498 exit:
499     return return_value;
500 }
501 
502 PyDoc_STRVAR(array_array___reduce_ex____doc__,
503 "__reduce_ex__($self, value, /)\n"
504 "--\n"
505 "\n"
506 "Return state information for pickling.");
507 
508 #define ARRAY_ARRAY___REDUCE_EX___METHODDEF    \
509     {"__reduce_ex__", (PyCFunction)array_array___reduce_ex__, METH_O, array_array___reduce_ex____doc__},
510 
511 PyDoc_STRVAR(array_arrayiterator___reduce____doc__,
512 "__reduce__($self, /)\n"
513 "--\n"
514 "\n"
515 "Return state information for pickling.");
516 
517 #define ARRAY_ARRAYITERATOR___REDUCE___METHODDEF    \
518     {"__reduce__", (PyCFunction)array_arrayiterator___reduce__, METH_NOARGS, array_arrayiterator___reduce____doc__},
519 
520 static PyObject *
521 array_arrayiterator___reduce___impl(arrayiterobject *self);
522 
523 static PyObject *
array_arrayiterator___reduce__(arrayiterobject * self,PyObject * Py_UNUSED (ignored))524 array_arrayiterator___reduce__(arrayiterobject *self, PyObject *Py_UNUSED(ignored))
525 {
526     return array_arrayiterator___reduce___impl(self);
527 }
528 
529 PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
530 "__setstate__($self, state, /)\n"
531 "--\n"
532 "\n"
533 "Set state information for unpickling.");
534 
535 #define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF    \
536     {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
537 /*[clinic end generated code: output=9f70748dd3bc532f input=a9049054013a1b77]*/
538