blob: 5e664213ef40a6cdbd5153d318e353e0106f9c50 [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
79 if (!PyArg_ParseTuple(args,
80 "|n:pop",
81 &i))
82 goto exit;
83 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
117 if (!PyArg_ParseTuple(args,
118 "nO:insert",
119 &i, &v))
120 goto exit;
121 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
215 if (!PyArg_ParseTuple(args,
216 "On:fromfile",
217 &f, &n))
218 goto exit;
219 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 Storchaka92e8af62015-04-04 00:12:11 +0300281 if (!PyArg_Parse(arg,
Brett Cannon1eb32c22014-10-10 16:26:45 -0400282 "s*:fromstring",
283 &buffer))
284 goto exit;
285 return_value = array_array_fromstring_impl(self, &buffer);
286
287exit:
288 /* Cleanup for buffer */
289 if (buffer.obj)
290 PyBuffer_Release(&buffer);
291
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 Storchaka92e8af62015-04-04 00:12:11 +0300313 if (!PyArg_Parse(arg,
Brett Cannon1eb32c22014-10-10 16:26:45 -0400314 "y*:frombytes",
315 &buffer))
316 goto exit;
317 return_value = array_array_frombytes_impl(self, &buffer);
318
319exit:
320 /* Cleanup for buffer */
321 if (buffer.obj)
322 PyBuffer_Release(&buffer);
323
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 *
379array_array_fromunicode_impl(arrayobject *self, Py_UNICODE *ustr, Py_ssize_clean_t ustr_length);
380
381static PyObject *
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300382array_array_fromunicode(arrayobject *self, PyObject *arg)
Brett Cannon1eb32c22014-10-10 16:26:45 -0400383{
384 PyObject *return_value = NULL;
385 Py_UNICODE *ustr;
386 Py_ssize_clean_t ustr_length;
387
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300388 if (!PyArg_Parse(arg,
Brett Cannon1eb32c22014-10-10 16:26:45 -0400389 "u#:fromunicode",
390 &ustr, &ustr_length))
391 goto exit;
392 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 Hastingsdfbeb162014-10-13 10:39:41 +0100449array__array_reconstructor_impl(PyModuleDef *module, PyTypeObject *arraytype, int typecode, enum machine_format_code mformat_code, PyObject *items);
Brett Cannon1eb32c22014-10-10 16:26:45 -0400450
451static PyObject *
452array__array_reconstructor(PyModuleDef *module, PyObject *args)
453{
454 PyObject *return_value = NULL;
455 PyTypeObject *arraytype;
456 int typecode;
Larry Hastingsdfbeb162014-10-13 10:39:41 +0100457 enum machine_format_code mformat_code;
Brett Cannon1eb32c22014-10-10 16:26:45 -0400458 PyObject *items;
459
460 if (!PyArg_ParseTuple(args,
461 "OCiO:_array_reconstructor",
462 &arraytype, &typecode, &mformat_code, &items))
463 goto exit;
464 return_value = array__array_reconstructor_impl(module, arraytype, typecode, mformat_code, items);
465
466exit:
467 return return_value;
468}
469
470PyDoc_STRVAR(array_array___reduce_ex____doc__,
471"__reduce_ex__($self, value, /)\n"
472"--\n"
473"\n"
474"Return state information for pickling.");
475
476#define ARRAY_ARRAY___REDUCE_EX___METHODDEF \
477 {"__reduce_ex__", (PyCFunction)array_array___reduce_ex__, METH_O, array_array___reduce_ex____doc__},
478
479PyDoc_STRVAR(array_arrayiterator___reduce____doc__,
480"__reduce__($self, /)\n"
481"--\n"
482"\n"
483"Return state information for pickling.");
484
485#define ARRAY_ARRAYITERATOR___REDUCE___METHODDEF \
486 {"__reduce__", (PyCFunction)array_arrayiterator___reduce__, METH_NOARGS, array_arrayiterator___reduce____doc__},
487
488static PyObject *
489array_arrayiterator___reduce___impl(arrayiterobject *self);
490
491static PyObject *
492array_arrayiterator___reduce__(arrayiterobject *self, PyObject *Py_UNUSED(ignored))
493{
494 return array_arrayiterator___reduce___impl(self);
495}
496
497PyDoc_STRVAR(array_arrayiterator___setstate____doc__,
498"__setstate__($self, state, /)\n"
499"--\n"
500"\n"
501"Set state information for unpickling.");
502
503#define ARRAY_ARRAYITERATOR___SETSTATE___METHODDEF \
504 {"__setstate__", (PyCFunction)array_arrayiterator___setstate__, METH_O, array_arrayiterator___setstate____doc__},
Serhiy Storchaka92e8af62015-04-04 00:12:11 +0300505/*[clinic end generated code: output=a8fbe83c2026fa83 input=a9049054013a1b77]*/