blob: 0c7061a1d2c3d26fb1a8400f45b730818b8f524a [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",
Brett Cannon1eb32c22014-10-10 16:26:45 -040080 &i))
81 goto exit;
82 return_value = array_array_pop_impl(self, i);
83
84exit:
85 return return_value;
86}
87
88PyDoc_STRVAR(array_array_extend__doc__,
89"extend($self, bb, /)\n"
90"--\n"
91"\n"
92"Append items to the end of the array.");
93
94#define ARRAY_ARRAY_EXTEND_METHODDEF \
95 {"extend", (PyCFunction)array_array_extend, METH_O, array_array_extend__doc__},
96
97PyDoc_STRVAR(array_array_insert__doc__,
98"insert($self, i, v, /)\n"
99"--\n"
100"\n"
101"Insert a new item v into the array before position i.");
102
103#define ARRAY_ARRAY_INSERT_METHODDEF \
104 {"insert", (PyCFunction)array_array_insert, METH_VARARGS, array_array_insert__doc__},
105
106static PyObject *
107array_array_insert_impl(arrayobject *self, Py_ssize_t i, PyObject *v);
108
109static PyObject *
110array_array_insert(arrayobject *self, PyObject *args)
111{
112 PyObject *return_value = NULL;
113 Py_ssize_t i;
114 PyObject *v;
115
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300116 if (!PyArg_ParseTuple(args, "nO:insert",
Brett Cannon1eb32c22014-10-10 16:26:45 -0400117 &i, &v))
118 goto exit;
119 return_value = array_array_insert_impl(self, i, v);
120
121exit:
122 return return_value;
123}
124
125PyDoc_STRVAR(array_array_buffer_info__doc__,
126"buffer_info($self, /)\n"
127"--\n"
128"\n"
129"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"
130"\n"
131"The length should be multiplied by the itemsize attribute to calculate\n"
132"the buffer length in bytes.");
133
134#define ARRAY_ARRAY_BUFFER_INFO_METHODDEF \
135 {"buffer_info", (PyCFunction)array_array_buffer_info, METH_NOARGS, array_array_buffer_info__doc__},
136
137static PyObject *
138array_array_buffer_info_impl(arrayobject *self);
139
140static PyObject *
141array_array_buffer_info(arrayobject *self, PyObject *Py_UNUSED(ignored))
142{
143 return array_array_buffer_info_impl(self);
144}
145
146PyDoc_STRVAR(array_array_append__doc__,
147"append($self, v, /)\n"
148"--\n"
149"\n"
150"Append new value v to the end of the array.");
151
152#define ARRAY_ARRAY_APPEND_METHODDEF \
153 {"append", (PyCFunction)array_array_append, METH_O, array_array_append__doc__},
154
155PyDoc_STRVAR(array_array_byteswap__doc__,
156"byteswap($self, /)\n"
157"--\n"
158"\n"
159"Byteswap all items of the array.\n"
160"\n"
161"If the items in the array are not 1, 2, 4, or 8 bytes in size, RuntimeError is\n"
162"raised.");
163
164#define ARRAY_ARRAY_BYTESWAP_METHODDEF \
165 {"byteswap", (PyCFunction)array_array_byteswap, METH_NOARGS, array_array_byteswap__doc__},
166
167static PyObject *
168array_array_byteswap_impl(arrayobject *self);
169
170static PyObject *
171array_array_byteswap(arrayobject *self, PyObject *Py_UNUSED(ignored))
172{
173 return array_array_byteswap_impl(self);
174}
175
176PyDoc_STRVAR(array_array_reverse__doc__,
177"reverse($self, /)\n"
178"--\n"
179"\n"
180"Reverse the order of the items in the array.");
181
182#define ARRAY_ARRAY_REVERSE_METHODDEF \
183 {"reverse", (PyCFunction)array_array_reverse, METH_NOARGS, array_array_reverse__doc__},
184
185static PyObject *
186array_array_reverse_impl(arrayobject *self);
187
188static PyObject *
189array_array_reverse(arrayobject *self, PyObject *Py_UNUSED(ignored))
190{
191 return array_array_reverse_impl(self);
192}
193
194PyDoc_STRVAR(array_array_fromfile__doc__,
195"fromfile($self, f, n, /)\n"
196"--\n"
197"\n"
198"Read n objects from the file object f and append them to the end of the array.");
199
200#define ARRAY_ARRAY_FROMFILE_METHODDEF \
201 {"fromfile", (PyCFunction)array_array_fromfile, METH_VARARGS, array_array_fromfile__doc__},
202
203static PyObject *
204array_array_fromfile_impl(arrayobject *self, PyObject *f, Py_ssize_t n);
205
206static PyObject *
207array_array_fromfile(arrayobject *self, PyObject *args)
208{
209 PyObject *return_value = NULL;
210 PyObject *f;
211 Py_ssize_t n;
212
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300213 if (!PyArg_ParseTuple(args, "On:fromfile",
Brett Cannon1eb32c22014-10-10 16:26:45 -0400214 &f, &n))
215 goto exit;
216 return_value = array_array_fromfile_impl(self, f, n);
217
218exit:
219 return return_value;
220}
221
222PyDoc_STRVAR(array_array_tofile__doc__,
223"tofile($self, f, /)\n"
224"--\n"
225"\n"
226"Write all items (as machine values) to the file object f.");
227
228#define ARRAY_ARRAY_TOFILE_METHODDEF \
229 {"tofile", (PyCFunction)array_array_tofile, METH_O, array_array_tofile__doc__},
230
231PyDoc_STRVAR(array_array_fromlist__doc__,
232"fromlist($self, list, /)\n"
233"--\n"
234"\n"
235"Append items to array from list.");
236
237#define ARRAY_ARRAY_FROMLIST_METHODDEF \
238 {"fromlist", (PyCFunction)array_array_fromlist, METH_O, array_array_fromlist__doc__},
239
240PyDoc_STRVAR(array_array_tolist__doc__,
241"tolist($self, /)\n"
242"--\n"
243"\n"
244"Convert array to an ordinary list with the same items.");
245
246#define ARRAY_ARRAY_TOLIST_METHODDEF \
247 {"tolist", (PyCFunction)array_array_tolist, METH_NOARGS, array_array_tolist__doc__},
248
249static PyObject *
250array_array_tolist_impl(arrayobject *self);
251
252static PyObject *
253array_array_tolist(arrayobject *self, PyObject *Py_UNUSED(ignored))
254{
255 return array_array_tolist_impl(self);
256}
257
258PyDoc_STRVAR(array_array_fromstring__doc__,
259"fromstring($self, buffer, /)\n"
260"--\n"
261"\n"
262"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"
263"\n"
264"This method is deprecated. Use frombytes instead.");
265
266#define ARRAY_ARRAY_FROMSTRING_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300267 {"fromstring", (PyCFunction)array_array_fromstring, METH_O, array_array_fromstring__doc__},
Brett Cannon1eb32c22014-10-10 16:26:45 -0400268
269static PyObject *
270array_array_fromstring_impl(arrayobject *self, Py_buffer *buffer);
271
272static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300273array_array_fromstring(arrayobject *self, PyObject *arg)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400274{
275 PyObject *return_value = NULL;
276 Py_buffer buffer = {NULL, NULL};
277
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300278 if (!PyArg_Parse(arg, "s*:fromstring", &buffer))
Brett Cannon1eb32c22014-10-10 16:26:45 -0400279 goto exit;
280 return_value = array_array_fromstring_impl(self, &buffer);
281
282exit:
283 /* Cleanup for buffer */
284 if (buffer.obj)
285 PyBuffer_Release(&buffer);
286
287 return return_value;
288}
289
290PyDoc_STRVAR(array_array_frombytes__doc__,
291"frombytes($self, buffer, /)\n"
292"--\n"
293"\n"
294"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).");
295
296#define ARRAY_ARRAY_FROMBYTES_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300297 {"frombytes", (PyCFunction)array_array_frombytes, METH_O, array_array_frombytes__doc__},
Brett Cannon1eb32c22014-10-10 16:26:45 -0400298
299static PyObject *
300array_array_frombytes_impl(arrayobject *self, Py_buffer *buffer);
301
302static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300303array_array_frombytes(arrayobject *self, PyObject *arg)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400304{
305 PyObject *return_value = NULL;
306 Py_buffer buffer = {NULL, NULL};
307
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300308 if (!PyArg_Parse(arg, "y*:frombytes", &buffer))
Brett Cannon1eb32c22014-10-10 16:26:45 -0400309 goto exit;
310 return_value = array_array_frombytes_impl(self, &buffer);
311
312exit:
313 /* Cleanup for buffer */
314 if (buffer.obj)
315 PyBuffer_Release(&buffer);
316
317 return return_value;
318}
319
320PyDoc_STRVAR(array_array_tobytes__doc__,
321"tobytes($self, /)\n"
322"--\n"
323"\n"
324"Convert the array to an array of machine values and return the bytes representation.");
325
326#define ARRAY_ARRAY_TOBYTES_METHODDEF \
327 {"tobytes", (PyCFunction)array_array_tobytes, METH_NOARGS, array_array_tobytes__doc__},
328
329static PyObject *
330array_array_tobytes_impl(arrayobject *self);
331
332static PyObject *
333array_array_tobytes(arrayobject *self, PyObject *Py_UNUSED(ignored))
334{
335 return array_array_tobytes_impl(self);
336}
337
338PyDoc_STRVAR(array_array_tostring__doc__,
339"tostring($self, /)\n"
340"--\n"
341"\n"
342"Convert the array to an array of machine values and return the bytes representation.\n"
343"\n"
344"This method is deprecated. Use tobytes instead.");
345
346#define ARRAY_ARRAY_TOSTRING_METHODDEF \
347 {"tostring", (PyCFunction)array_array_tostring, METH_NOARGS, array_array_tostring__doc__},
348
349static PyObject *
350array_array_tostring_impl(arrayobject *self);
351
352static PyObject *
353array_array_tostring(arrayobject *self, PyObject *Py_UNUSED(ignored))
354{
355 return array_array_tostring_impl(self);
356}
357
358PyDoc_STRVAR(array_array_fromunicode__doc__,
359"fromunicode($self, ustr, /)\n"
360"--\n"
361"\n"
362"Extends this array with data from the unicode string ustr.\n"
363"\n"
364"The array must be a unicode type array; otherwise a ValueError is raised.\n"
365"Use array.frombytes(ustr.encode(...)) to append Unicode data to an array of\n"
366"some other type.");
367
368#define ARRAY_ARRAY_FROMUNICODE_METHODDEF \
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300369 {"fromunicode", (PyCFunction)array_array_fromunicode, METH_O, array_array_fromunicode__doc__},
Brett Cannon1eb32c22014-10-10 16:26:45 -0400370
371static PyObject *
Larry Hastings89964c42015-04-14 18:07:59 -0400372array_array_fromunicode_impl(arrayobject *self, Py_UNICODE *ustr,
373 Py_ssize_clean_t ustr_length);
Brett Cannon1eb32c22014-10-10 16:26:45 -0400374
375static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300376array_array_fromunicode(arrayobject *self, PyObject *arg)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400377{
378 PyObject *return_value = NULL;
379 Py_UNICODE *ustr;
380 Py_ssize_clean_t ustr_length;
381
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300382 if (!PyArg_Parse(arg, "u#:fromunicode", &ustr, &ustr_length))
Brett Cannon1eb32c22014-10-10 16:26:45 -0400383 goto exit;
384 return_value = array_array_fromunicode_impl(self, ustr, ustr_length);
385
386exit:
387 return return_value;
388}
389
390PyDoc_STRVAR(array_array_tounicode__doc__,
391"tounicode($self, /)\n"
392"--\n"
393"\n"
394"Extends this array with data from the unicode string ustr.\n"
395"\n"
396"Convert the array to a unicode string. The array must be a unicode type array;\n"
397"otherwise a ValueError is raised. Use array.tobytes().decode() to obtain a\n"
398"unicode string from an array of some other type.");
399
400#define ARRAY_ARRAY_TOUNICODE_METHODDEF \
401 {"tounicode", (PyCFunction)array_array_tounicode, METH_NOARGS, array_array_tounicode__doc__},
402
403static PyObject *
404array_array_tounicode_impl(arrayobject *self);
405
406static PyObject *
407array_array_tounicode(arrayobject *self, PyObject *Py_UNUSED(ignored))
408{
409 return array_array_tounicode_impl(self);
410}
411
412PyDoc_STRVAR(array_array___sizeof____doc__,
413"__sizeof__($self, /)\n"
414"--\n"
415"\n"
416"Size of the array in memory, in bytes.");
417
418#define ARRAY_ARRAY___SIZEOF___METHODDEF \
419 {"__sizeof__", (PyCFunction)array_array___sizeof__, METH_NOARGS, array_array___sizeof____doc__},
420
421static PyObject *
422array_array___sizeof___impl(arrayobject *self);
423
424static PyObject *
425array_array___sizeof__(arrayobject *self, PyObject *Py_UNUSED(ignored))
426{
427 return array_array___sizeof___impl(self);
428}
429
430PyDoc_STRVAR(array__array_reconstructor__doc__,
431"_array_reconstructor($module, arraytype, typecode, mformat_code, items,\n"
432" /)\n"
433"--\n"
434"\n"
435"Internal. Used for pickling support.");
436
437#define ARRAY__ARRAY_RECONSTRUCTOR_METHODDEF \
438 {"_array_reconstructor", (PyCFunction)array__array_reconstructor, METH_VARARGS, array__array_reconstructor__doc__},
439
440static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300441array__array_reconstructor_impl(PyObject *module, PyTypeObject *arraytype,
Larry Hastings89964c42015-04-14 18:07:59 -0400442 int typecode,
443 enum machine_format_code mformat_code,
444 PyObject *items);
Brett Cannon1eb32c22014-10-10 16:26:45 -0400445
446static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300447array__array_reconstructor(PyObject *module, PyObject *args)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400448{
449 PyObject *return_value = NULL;
450 PyTypeObject *arraytype;
451 int typecode;
Larry Hastingsdfbeb162014-10-13 10:39:41 +0100452 enum machine_format_code mformat_code;
Brett Cannon1eb32c22014-10-10 16:26:45 -0400453 PyObject *items;
454
Serhiy Storchaka247789c2015-04-24 00:40:51 +0300455 if (!PyArg_ParseTuple(args, "OCiO:_array_reconstructor",
Brett Cannon1eb32c22014-10-10 16:26:45 -0400456 &arraytype, &typecode, &mformat_code, &items))
457 goto exit;
458 return_value = array__array_reconstructor_impl(module, arraytype, typecode, mformat_code, items);
459
460exit:
461 return return_value;
462}
463
464PyDoc_STRVAR(array_array___reduce_ex____doc__,
465"__reduce_ex__($self, value, /)\n"
466"--\n"
467"\n"
468"Return state information for pickling.");
469
470#define ARRAY_ARRAY___REDUCE_EX___METHODDEF \
471 {"__reduce_ex__", (PyCFunction)array_array___reduce_ex__, METH_O, array_array___reduce_ex____doc__},
472
473PyDoc_STRVAR(array_arrayiterator___reduce____doc__,
474"__reduce__($self, /)\n"
475"--\n"
476"\n"
477"Return state information for pickling.");
478
479#define ARRAY_ARRAYITERATOR___REDUCE___METHODDEF \
480 {"__reduce__", (PyCFunction)array_arrayiterator___reduce__, METH_NOARGS, array_arrayiterator___reduce____doc__},
481
482static PyObject *
483array_arrayiterator___reduce___impl(arrayiterobject *self);
484
485static PyObject *
486array_arrayiterator___reduce__(arrayiterobject *self, PyObject *Py_UNUSED(ignored))
487{
488 return array_arrayiterator___reduce___impl(self);
489}
490
491PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
492"__setstate__($self, state, /)\n"
493"--\n"
494"\n"
495"Set state information for unpickling.");
496
497#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
498 {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +0300499/*[clinic end generated code: output=305df3f5796039e4 input=a9049054013a1b77]*/