blob: ced17aaf884aab1d9bdc7a69d0b0f0a0e8741fe7 [file] [log] [blame]
Brett Cannon1eb32c22014-10-10 16:26:45 -04001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_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
14static PyObject *
15array_array___copy___impl(arrayobject *self);
16
17static PyObject *
18array_array___copy__(arrayobject *self, PyObject *Py_UNUSED(ignored))
19{
20 return array_array___copy___impl(self);
21}
22
23PyDoc_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
32PyDoc_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
41PyDoc_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
50PyDoc_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
59PyDoc_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)array_array_pop, METH_VARARGS, array_array_pop__doc__},
69
70static PyObject *
71array_array_pop_impl(arrayobject *self, Py_ssize_t i);
72
73static PyObject *
74array_array_pop(arrayobject *self, PyObject *args)
75{
76 PyObject *return_value = NULL;
77 Py_ssize_t i = -1;
78
Serhiy Storchaka247789c2015-04-24 00:40:51 +030079 if (!PyArg_ParseTuple(args, "|n:pop",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030080 &i)) {
Brett Cannon1eb32c22014-10-10 16:26:45 -040081 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030082 }
Brett Cannon1eb32c22014-10-10 16:26:45 -040083 return_value = array_array_pop_impl(self, i);
84
85exit:
86 return return_value;
87}
88
89PyDoc_STRVAR(array_array_extend__doc__,
90"extend($self, bb, /)\n"
91"--\n"
92"\n"
93"Append items to the end of the array.");
94
95#define ARRAY_ARRAY_EXTEND_METHODDEF \
96 {"extend", (PyCFunction)array_array_extend, METH_O, array_array_extend__doc__},
97
98PyDoc_STRVAR(array_array_insert__doc__,
99"insert($self, i, v, /)\n"
100"--\n"
101"\n"
102"Insert a new item v into the array before position i.");
103
104#define ARRAY_ARRAY_INSERT_METHODDEF \
105 {"insert", (PyCFunction)array_array_insert, METH_VARARGS, array_array_insert__doc__},
106
107static PyObject *
108array_array_insert_impl(arrayobject *self, Py_ssize_t i, PyObject *v);
109
110static PyObject *
111array_array_insert(arrayobject *self, PyObject *args)
112{
113 PyObject *return_value = NULL;
114 Py_ssize_t i;
115 PyObject *v;
116
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300117 if (!PyArg_ParseTuple(args, "nO:insert",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300118 &i, &v)) {
Brett Cannon1eb32c22014-10-10 16:26:45 -0400119 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300120 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400121 return_value = array_array_insert_impl(self, i, v);
122
123exit:
124 return return_value;
125}
126
127PyDoc_STRVAR(array_array_buffer_info__doc__,
128"buffer_info($self, /)\n"
129"--\n"
130"\n"
131"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"
132"\n"
133"The length should be multiplied by the itemsize attribute to calculate\n"
134"the buffer length in bytes.");
135
136#define ARRAY_ARRAY_BUFFER_INFO_METHODDEF \
137 {"buffer_info", (PyCFunction)array_array_buffer_info, METH_NOARGS, array_array_buffer_info__doc__},
138
139static PyObject *
140array_array_buffer_info_impl(arrayobject *self);
141
142static PyObject *
143array_array_buffer_info(arrayobject *self, PyObject *Py_UNUSED(ignored))
144{
145 return array_array_buffer_info_impl(self);
146}
147
148PyDoc_STRVAR(array_array_append__doc__,
149"append($self, v, /)\n"
150"--\n"
151"\n"
152"Append new value v to the end of the array.");
153
154#define ARRAY_ARRAY_APPEND_METHODDEF \
155 {"append", (PyCFunction)array_array_append, METH_O, array_array_append__doc__},
156
157PyDoc_STRVAR(array_array_byteswap__doc__,
158"byteswap($self, /)\n"
159"--\n"
160"\n"
161"Byteswap all items of the array.\n"
162"\n"
163"If the items in the array are not 1, 2, 4, or 8 bytes in size, RuntimeError is\n"
164"raised.");
165
166#define ARRAY_ARRAY_BYTESWAP_METHODDEF \
167 {"byteswap", (PyCFunction)array_array_byteswap, METH_NOARGS, array_array_byteswap__doc__},
168
169static PyObject *
170array_array_byteswap_impl(arrayobject *self);
171
172static PyObject *
173array_array_byteswap(arrayobject *self, PyObject *Py_UNUSED(ignored))
174{
175 return array_array_byteswap_impl(self);
176}
177
178PyDoc_STRVAR(array_array_reverse__doc__,
179"reverse($self, /)\n"
180"--\n"
181"\n"
182"Reverse the order of the items in the array.");
183
184#define ARRAY_ARRAY_REVERSE_METHODDEF \
185 {"reverse", (PyCFunction)array_array_reverse, METH_NOARGS, array_array_reverse__doc__},
186
187static PyObject *
188array_array_reverse_impl(arrayobject *self);
189
190static PyObject *
191array_array_reverse(arrayobject *self, PyObject *Py_UNUSED(ignored))
192{
193 return array_array_reverse_impl(self);
194}
195
196PyDoc_STRVAR(array_array_fromfile__doc__,
197"fromfile($self, f, n, /)\n"
198"--\n"
199"\n"
200"Read n objects from the file object f and append them to the end of the array.");
201
202#define ARRAY_ARRAY_FROMFILE_METHODDEF \
203 {"fromfile", (PyCFunction)array_array_fromfile, METH_VARARGS, array_array_fromfile__doc__},
204
205static PyObject *
206array_array_fromfile_impl(arrayobject *self, PyObject *f, Py_ssize_t n);
207
208static PyObject *
209array_array_fromfile(arrayobject *self, PyObject *args)
210{
211 PyObject *return_value = NULL;
212 PyObject *f;
213 Py_ssize_t n;
214
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300215 if (!PyArg_ParseTuple(args, "On:fromfile",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300216 &f, &n)) {
Brett Cannon1eb32c22014-10-10 16:26:45 -0400217 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300218 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400219 return_value = array_array_fromfile_impl(self, f, n);
220
221exit:
222 return return_value;
223}
224
225PyDoc_STRVAR(array_array_tofile__doc__,
226"tofile($self, f, /)\n"
227"--\n"
228"\n"
229"Write all items (as machine values) to the file object f.");
230
231#define ARRAY_ARRAY_TOFILE_METHODDEF \
232 {"tofile", (PyCFunction)array_array_tofile, METH_O, array_array_tofile__doc__},
233
234PyDoc_STRVAR(array_array_fromlist__doc__,
235"fromlist($self, list, /)\n"
236"--\n"
237"\n"
238"Append items to array from list.");
239
240#define ARRAY_ARRAY_FROMLIST_METHODDEF \
241 {"fromlist", (PyCFunction)array_array_fromlist, METH_O, array_array_fromlist__doc__},
242
243PyDoc_STRVAR(array_array_tolist__doc__,
244"tolist($self, /)\n"
245"--\n"
246"\n"
247"Convert array to an ordinary list with the same items.");
248
249#define ARRAY_ARRAY_TOLIST_METHODDEF \
250 {"tolist", (PyCFunction)array_array_tolist, METH_NOARGS, array_array_tolist__doc__},
251
252static PyObject *
253array_array_tolist_impl(arrayobject *self);
254
255static PyObject *
256array_array_tolist(arrayobject *self, PyObject *Py_UNUSED(ignored))
257{
258 return array_array_tolist_impl(self);
259}
260
261PyDoc_STRVAR(array_array_fromstring__doc__,
262"fromstring($self, buffer, /)\n"
263"--\n"
264"\n"
265"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).\n"
266"\n"
267"This method is deprecated. Use frombytes instead.");
268
269#define ARRAY_ARRAY_FROMSTRING_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300270 {"fromstring", (PyCFunction)array_array_fromstring, METH_O, array_array_fromstring__doc__},
Brett Cannon1eb32c22014-10-10 16:26:45 -0400271
272static PyObject *
273array_array_fromstring_impl(arrayobject *self, Py_buffer *buffer);
274
275static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300276array_array_fromstring(arrayobject *self, PyObject *arg)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400277{
278 PyObject *return_value = NULL;
279 Py_buffer buffer = {NULL, NULL};
280
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300281 if (!PyArg_Parse(arg, "s*:fromstring", &buffer)) {
Brett Cannon1eb32c22014-10-10 16:26:45 -0400282 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300283 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400284 return_value = array_array_fromstring_impl(self, &buffer);
285
286exit:
287 /* Cleanup for buffer */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300288 if (buffer.obj) {
Brett Cannon1eb32c22014-10-10 16:26:45 -0400289 PyBuffer_Release(&buffer);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300290 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400291
292 return return_value;
293}
294
295PyDoc_STRVAR(array_array_frombytes__doc__,
296"frombytes($self, buffer, /)\n"
297"--\n"
298"\n"
299"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).");
300
301#define ARRAY_ARRAY_FROMBYTES_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300302 {"frombytes", (PyCFunction)array_array_frombytes, METH_O, array_array_frombytes__doc__},
Brett Cannon1eb32c22014-10-10 16:26:45 -0400303
304static PyObject *
305array_array_frombytes_impl(arrayobject *self, Py_buffer *buffer);
306
307static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300308array_array_frombytes(arrayobject *self, PyObject *arg)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400309{
310 PyObject *return_value = NULL;
311 Py_buffer buffer = {NULL, NULL};
312
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300313 if (!PyArg_Parse(arg, "y*:frombytes", &buffer)) {
Brett Cannon1eb32c22014-10-10 16:26:45 -0400314 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300315 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400316 return_value = array_array_frombytes_impl(self, &buffer);
317
318exit:
319 /* Cleanup for buffer */
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300320 if (buffer.obj) {
Brett Cannon1eb32c22014-10-10 16:26:45 -0400321 PyBuffer_Release(&buffer);
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300322 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400323
324 return return_value;
325}
326
327PyDoc_STRVAR(array_array_tobytes__doc__,
328"tobytes($self, /)\n"
329"--\n"
330"\n"
331"Convert the array to an array of machine values and return the bytes representation.");
332
333#define ARRAY_ARRAY_TOBYTES_METHODDEF \
334 {"tobytes", (PyCFunction)array_array_tobytes, METH_NOARGS, array_array_tobytes__doc__},
335
336static PyObject *
337array_array_tobytes_impl(arrayobject *self);
338
339static PyObject *
340array_array_tobytes(arrayobject *self, PyObject *Py_UNUSED(ignored))
341{
342 return array_array_tobytes_impl(self);
343}
344
345PyDoc_STRVAR(array_array_tostring__doc__,
346"tostring($self, /)\n"
347"--\n"
348"\n"
349"Convert the array to an array of machine values and return the bytes representation.\n"
350"\n"
351"This method is deprecated. Use tobytes instead.");
352
353#define ARRAY_ARRAY_TOSTRING_METHODDEF \
354 {"tostring", (PyCFunction)array_array_tostring, METH_NOARGS, array_array_tostring__doc__},
355
356static PyObject *
357array_array_tostring_impl(arrayobject *self);
358
359static PyObject *
360array_array_tostring(arrayobject *self, PyObject *Py_UNUSED(ignored))
361{
362 return array_array_tostring_impl(self);
363}
364
365PyDoc_STRVAR(array_array_fromunicode__doc__,
366"fromunicode($self, ustr, /)\n"
367"--\n"
368"\n"
369"Extends this array with data from the unicode string ustr.\n"
370"\n"
371"The array must be a unicode type array; otherwise a ValueError is raised.\n"
372"Use array.frombytes(ustr.encode(...)) to append Unicode data to an array of\n"
373"some other type.");
374
375#define ARRAY_ARRAY_FROMUNICODE_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300376 {"fromunicode", (PyCFunction)array_array_fromunicode, METH_O, array_array_fromunicode__doc__},
Brett Cannon1eb32c22014-10-10 16:26:45 -0400377
378static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400379array_array_fromunicode_impl(arrayobject *self, Py_UNICODE *ustr,
380 Py_ssize_clean_t ustr_length);
Brett Cannon1eb32c22014-10-10 16:26:45 -0400381
382static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300383array_array_fromunicode(arrayobject *self, PyObject *arg)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400384{
385 PyObject *return_value = NULL;
386 Py_UNICODE *ustr;
387 Py_ssize_clean_t ustr_length;
388
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300389 if (!PyArg_Parse(arg, "u#:fromunicode", &ustr, &ustr_length)) {
Brett Cannon1eb32c22014-10-10 16:26:45 -0400390 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300391 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400392 return_value = array_array_fromunicode_impl(self, ustr, ustr_length);
393
394exit:
395 return return_value;
396}
397
398PyDoc_STRVAR(array_array_tounicode__doc__,
399"tounicode($self, /)\n"
400"--\n"
401"\n"
402"Extends this array with data from the unicode string ustr.\n"
403"\n"
404"Convert the array to a unicode string. The array must be a unicode type array;\n"
405"otherwise a ValueError is raised. Use array.tobytes().decode() to obtain a\n"
406"unicode string from an array of some other type.");
407
408#define ARRAY_ARRAY_TOUNICODE_METHODDEF \
409 {"tounicode", (PyCFunction)array_array_tounicode, METH_NOARGS, array_array_tounicode__doc__},
410
411static PyObject *
412array_array_tounicode_impl(arrayobject *self);
413
414static PyObject *
415array_array_tounicode(arrayobject *self, PyObject *Py_UNUSED(ignored))
416{
417 return array_array_tounicode_impl(self);
418}
419
420PyDoc_STRVAR(array_array___sizeof____doc__,
421"__sizeof__($self, /)\n"
422"--\n"
423"\n"
424"Size of the array in memory, in bytes.");
425
426#define ARRAY_ARRAY___SIZEOF___METHODDEF \
427 {"__sizeof__", (PyCFunction)array_array___sizeof__, METH_NOARGS, array_array___sizeof____doc__},
428
429static PyObject *
430array_array___sizeof___impl(arrayobject *self);
431
432static PyObject *
433array_array___sizeof__(arrayobject *self, PyObject *Py_UNUSED(ignored))
434{
435 return array_array___sizeof___impl(self);
436}
437
438PyDoc_STRVAR(array__array_reconstructor__doc__,
439"_array_reconstructor($module, arraytype, typecode, mformat_code, items,\n"
440" /)\n"
441"--\n"
442"\n"
443"Internal. Used for pickling support.");
444
445#define ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF \
446 {"_array_reconstructor", (PyCFunction)array__array_reconstructor, METH_VARARGS, array__array_reconstructor__doc__},
447
448static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400449array__array_reconstructor_impl(PyModuleDef *module, PyTypeObject *arraytype,
450 int typecode,
451 enum machine_format_code mformat_code,
452 PyObject *items);
Brett Cannon1eb32c22014-10-10 16:26:45 -0400453
454static PyObject *
455array__array_reconstructor(PyModuleDef *module, PyObject *args)
456{
457 PyObject *return_value = NULL;
458 PyTypeObject *arraytype;
459 int typecode;
Larry Hastingsdfbeb162014-10-13 10:39:41 +0100460 enum machine_format_code mformat_code;
Brett Cannon1eb32c22014-10-10 16:26:45 -0400461 PyObject *items;
462
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300463 if (!PyArg_ParseTuple(args, "OCiO:_array_reconstructor",
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300464 &arraytype, &typecode, &mformat_code, &items)) {
Brett Cannon1eb32c22014-10-10 16:26:45 -0400465 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300466 }
Brett Cannon1eb32c22014-10-10 16:26:45 -0400467 return_value = array__array_reconstructor_impl(module, arraytype, typecode, mformat_code, items);
468
469exit:
470 return return_value;
471}
472
473PyDoc_STRVAR(array_array___reduce_ex____doc__,
474"__reduce_ex__($self, value, /)\n"
475"--\n"
476"\n"
477"Return state information for pickling.");
478
479#define ARRAY_ARRAY___REDUCE_EX___METHODDEF \
480 {"__reduce_ex__", (PyCFunction)array_array___reduce_ex__, METH_O, array_array___reduce_ex____doc__},
481
482PyDoc_STRVAR(array_arrayiterator___reduce____doc__,
483"__reduce__($self, /)\n"
484"--\n"
485"\n"
486"Return state information for pickling.");
487
488#define ARRAY_ARRAYITERATOR___REDUCE___METHODDEF \
489 {"__reduce__", (PyCFunction)array_arrayiterator___reduce__, METH_NOARGS, array_arrayiterator___reduce____doc__},
490
491static PyObject *
492array_arrayiterator___reduce___impl(arrayiterobject *self);
493
494static PyObject *
495array_arrayiterator___reduce__(arrayiterobject *self, PyObject *Py_UNUSED(ignored))
496{
497 return array_arrayiterator___reduce___impl(self);
498}
499
500PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
501"__setstate__($self, state, /)\n"
502"--\n"
503"\n"
504"Set state information for unpickling.");
505
506#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
507 {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
Serhiy Storchaka5dee6552016-06-09 16:16:06 +0300508/*[clinic end generated code: output=0b99c89275eda265 input=a9049054013a1b77]*/