37 #if MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_BUILTINS_MEMORYVIEW 54 #if MICROPY_PY_BUILTINS_MEMORYVIEW 55 #define TYPECODE_MASK (0x7f) 57 #define TYPECODE_MASK (~(size_t)0) 68 #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY 79 for (
size_t i = 0; i < o->
len; i++) {
92 #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY 96 #if MICROPY_PY_BUILTINS_BYTEARRAY && MICROPY_PY_ARRAY 98 #elif MICROPY_PY_BUILTINS_BYTEARRAY 111 #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY 125 size_t len = bufinfo.
len / sz;
170 return array_construct(*typecode,
args[1]);
175 #if MICROPY_PY_BUILTINS_BYTEARRAY 196 #if MICROPY_PY_BUILTINS_MEMORYVIEW 201 self->typecode = typecode;
225 self->typecode |= 0x80;
254 size_t rhs_len = rhs_bufinfo.
len / sz;
263 #if MICROPY_PY_BUILTINS_MEMORYVIEW 268 array_extend(lhs_in, rhs_in);
283 return mp_obj_new_bool(
310 #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY 317 if (self->free == 0) {
321 self->items =
m_renew(
byte, self->items, item_sz * self->len, item_sz * (self->len + self->free));
322 mp_seq_clear(self->items, self->len + 1, self->len + self->free, item_sz);
345 size_t len = arg_bufinfo.
len / sz;
349 if (self->free < len) {
350 self->items =
m_renew(
byte, self->items, (self->len + self->free) * sz, (self->len + len) * sz);
375 #if MICROPY_PY_BUILTINS_SLICE 378 if (!mp_seq_get_fast_slice_indexes(o->
len, index_in, &slice)) {
382 #if MICROPY_PY_ARRAY_SLICE_ASSIGN 394 src_len = src_slice->
len;
395 src_items = src_slice->
items;
396 #if MICROPY_PY_BUILTINS_MEMORYVIEW 398 src_items = (
uint8_t*)src_items + (src_slice->
free * item_sz);
407 src_len = bufinfo.
len;
408 src_items = bufinfo.
buf;
416 #if MICROPY_PY_BUILTINS_MEMORYVIEW 425 dest_items += o->
free * item_sz;
429 if (len_adj > o->
free) {
433 dest_items = o->
items;
436 slice.
start, slice.
stop, src_items, src_len, len_adj, item_sz);
439 slice.
start, slice.
stop, src_items, src_len, item_sz);
457 #if MICROPY_PY_BUILTINS_MEMORYVIEW 472 #if MICROPY_PY_BUILTINS_MEMORYVIEW 497 bufinfo->
len = o->
len * sz;
499 #if MICROPY_PY_BUILTINS_MEMORYVIEW 513 #if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY 525 .
name = MP_QSTR_array,
526 .print = array_print,
527 .make_new = array_make_new,
528 .getiter = array_iterator_new,
529 .unary_op = array_unary_op,
530 .binary_op = array_binary_op,
531 .subscr = array_subscr,
532 .buffer_p = { .get_buffer = array_get_buffer },
537 #if MICROPY_PY_BUILTINS_BYTEARRAY 540 .
name = MP_QSTR_bytearray,
541 .print = array_print,
542 .make_new = bytearray_make_new,
543 .getiter = array_iterator_new,
544 .unary_op = array_unary_op,
545 .binary_op = array_binary_op,
546 .subscr = array_subscr,
547 .buffer_p = { .get_buffer = array_get_buffer },
552 #if MICROPY_PY_BUILTINS_MEMORYVIEW 555 .
name = MP_QSTR_memoryview,
556 .make_new = memoryview_make_new,
557 .getiter = array_iterator_new,
558 .unary_op = array_unary_op,
559 .binary_op = array_binary_op,
560 .subscr = array_subscr,
561 .buffer_p = { .get_buffer = array_get_buffer },
571 #if MICROPY_PY_BUILTINS_BYTEARRAY 593 typedef struct _mp_obj_array_it_t {
602 if (self->cur < self->array->len) {
603 return mp_binary_get_val_array(self->array->typecode & TYPECODE_MASK, self->array->items, self->offset + self->cur++);
611 .
name = MP_QSTR_iterator,
613 .iternext = array_it_iternext,
619 mp_obj_array_it_t *o = (mp_obj_array_it_t*)iter_buf;
620 o->
base.type = &array_it_type;
624 #if MICROPY_PY_BUILTINS_MEMORYVIEW 626 o->offset = array->
free;
632 #endif // MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_BUILTINS_MEMORYVIEW
#define mp_seq_clear(start, len, alloc_len, item_sz)
void * memset(void *b, int c, size_t len)
const mp_obj_type_t mp_type_bytearray
#define MP_DEFINE_CONST_DICT(dict_name, table_name)
NORETURN void mp_raise_NotImplementedError(const char *msg)
mp_obj_t mp_obj_new_memoryview(byte typecode, size_t nitems, void *items)
const mp_obj_type_t mp_type_memoryview
#define MP_OBJ_IS_TYPE(o, t)
#define MICROPY_PY_BUILTINS_BYTEARRAY
bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags)
bool mp_seq_cmp_bytes(mp_uint_t op, const byte *data1, size_t len1, const byte *data2, size_t len2)
int mp_print_str(const mp_print_t *print, const char *str)
#define MP_OBJ_FROM_PTR(p)
size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign)
void mp_arg_check_num(size_t n_args, size_t n_kw, size_t n_args_min, size_t n_args_max, bool takes_kw)
#define BYTEARRAY_TYPECODE
void mp_str_print_quoted(const mp_print_t *print, const byte *str_data, size_t str_len, bool is_bytes)
const mp_obj_type_t mp_type_bytes
mp_obj_t mp_obj_new_bytearray(size_t n, void *items)
mp_int_t mp_obj_get_int(mp_const_obj_t arg)
const mp_obj_type_t mp_type_array
#define MP_OBJ_SMALL_INT_VALUE(o)
#define mp_obj_is_float(o)
size_t mp_get_index(const mp_obj_type_t *type, size_t len, mp_obj_t index, bool is_slice)
mp_obj_t mp_obj_len_maybe(mp_obj_t o_in)
#define MP_OBJ_NEW_SMALL_INT(small_int)
void mp_binary_set_val_array(char typecode, void *p, mp_uint_t index, mp_obj_t val_in)
void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind)
mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index)
const byte * find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction)
#define mp_seq_replace_slice_no_grow(dest, dest_len, beg, end, slice, slice_len, item_sz)
mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items)
const mp_obj_type_t mp_type_type
#define m_renew(type, ptr, old_num, new_num)
#define MP_DEFINE_CONST_FUN_OBJ_2(obj_name, fun_name)
NORETURN void mp_raise_ValueError(const char *msg)
mp_obj_t mp_identity_getiter(mp_obj_t self, mp_obj_iter_buf_t *iter_buf)
void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, mp_uint_t flags)
#define mp_seq_copy(dest, src, len, item_t)
const char * mp_obj_str_get_str(mp_obj_t self_in)
const mp_obj_type_t mp_type_slice
#define mp_seq_replace_slice_grow_inplace(dest, dest_len, beg, end, slice, slice_len, len_adj, item_sz)
mp_obj_t mp_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf)
#define MP_OBJ_STOP_ITERATION
mp_obj_t mp_iternext(mp_obj_t o_in)
int mp_printf(const mp_print_t *print, const char *fmt,...)
void * memcpy(void *dst, const void *src, size_t n)
#define mp_seq_cat(dest, src1, len1, src2, len2, item_t)