py: Fix prefix on few sequence helpers, was incorrectly "mp_".
This commit is contained in:
parent
aa4d19a05c
commit
d915a52eb6
6
py/obj.h
6
py/obj.h
|
@ -564,9 +564,9 @@ const mp_obj_t *mp_obj_property_get(mp_obj_t self_in);
|
||||||
|
|
||||||
// sequence helpers
|
// sequence helpers
|
||||||
void mp_seq_multiply(const void *items, uint item_sz, uint len, uint times, void *dest);
|
void mp_seq_multiply(const void *items, uint item_sz, uint len, uint times, void *dest);
|
||||||
bool m_seq_get_fast_slice_indexes(machine_uint_t len, mp_obj_t slice, machine_uint_t *begin, machine_uint_t *end);
|
bool mp_seq_get_fast_slice_indexes(machine_uint_t len, mp_obj_t slice, machine_uint_t *begin, machine_uint_t *end);
|
||||||
#define m_seq_copy(dest, src, len, item_t) memcpy(dest, src, len * sizeof(item_t))
|
#define mp_seq_copy(dest, src, len, item_t) memcpy(dest, src, len * sizeof(item_t))
|
||||||
#define m_seq_cat(dest, src1, len1, src2, len2, item_t) { memcpy(dest, src1, (len1) * sizeof(item_t)); memcpy(dest + (len1), src2, (len2) * sizeof(item_t)); }
|
#define mp_seq_cat(dest, src1, len1, src2, len2, item_t) { memcpy(dest, src1, (len1) * sizeof(item_t)); memcpy(dest + (len1), src2, (len2) * sizeof(item_t)); }
|
||||||
bool mp_seq_cmp_bytes(int op, const byte *data1, uint len1, const byte *data2, uint len2);
|
bool mp_seq_cmp_bytes(int op, const byte *data1, uint len1, const byte *data2, uint len2);
|
||||||
bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, uint len1, const mp_obj_t *items2, uint len2);
|
bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, uint len1, const mp_obj_t *items2, uint len2);
|
||||||
mp_obj_t mp_seq_index_obj(const mp_obj_t *items, uint len, uint n_args, const mp_obj_t *args);
|
mp_obj_t mp_seq_index_obj(const mp_obj_t *items, uint len, uint n_args, const mp_obj_t *args);
|
||||||
|
|
|
@ -176,7 +176,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
|
||||||
return MP_OBJ_NOT_SUPPORTED;
|
return MP_OBJ_NOT_SUPPORTED;
|
||||||
}
|
}
|
||||||
machine_uint_t start, stop;
|
machine_uint_t start, stop;
|
||||||
if (!m_seq_get_fast_slice_indexes(o->len, index_in, &start, &stop)) {
|
if (!mp_seq_get_fast_slice_indexes(o->len, index_in, &start, &stop)) {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
mp_obj_array_t *res = array_new(o->typecode, stop - start);
|
mp_obj_array_t *res = array_new(o->typecode, stop - start);
|
||||||
|
|
|
@ -119,7 +119,7 @@ STATIC mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
|
||||||
}
|
}
|
||||||
mp_obj_list_t *p = rhs;
|
mp_obj_list_t *p = rhs;
|
||||||
mp_obj_list_t *s = list_new(o->len + p->len);
|
mp_obj_list_t *s = list_new(o->len + p->len);
|
||||||
m_seq_cat(s->items, o->items, o->len, p->items, p->len, mp_obj_t);
|
mp_seq_cat(s->items, o->items, o->len, p->items, p->len, mp_obj_t);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
case MP_BINARY_OP_INPLACE_ADD: {
|
case MP_BINARY_OP_INPLACE_ADD: {
|
||||||
|
@ -162,11 +162,11 @@ STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
|
||||||
#if MICROPY_ENABLE_SLICE
|
#if MICROPY_ENABLE_SLICE
|
||||||
if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
|
if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
|
||||||
machine_uint_t start, stop;
|
machine_uint_t start, stop;
|
||||||
if (!m_seq_get_fast_slice_indexes(self->len, index, &start, &stop)) {
|
if (!mp_seq_get_fast_slice_indexes(self->len, index, &start, &stop)) {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
mp_obj_list_t *res = list_new(stop - start);
|
mp_obj_list_t *res = list_new(stop - start);
|
||||||
m_seq_copy(res->items, self->items + start, res->len, mp_obj_t);
|
mp_seq_copy(res->items, self->items + start, res->len, mp_obj_t);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -333,7 +333,7 @@ STATIC mp_obj_t str_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
|
||||||
#if MICROPY_ENABLE_SLICE
|
#if MICROPY_ENABLE_SLICE
|
||||||
if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
|
if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
|
||||||
machine_uint_t start, stop;
|
machine_uint_t start, stop;
|
||||||
if (!m_seq_get_fast_slice_indexes(self_len, index, &start, &stop)) {
|
if (!mp_seq_get_fast_slice_indexes(self_len, index, &start, &stop)) {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
return mp_obj_new_str(self_data + start, stop - start, false);
|
return mp_obj_new_str(self_data + start, stop - start, false);
|
||||||
|
|
|
@ -127,7 +127,7 @@ mp_obj_t tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
|
||||||
}
|
}
|
||||||
mp_obj_tuple_t *p = rhs;
|
mp_obj_tuple_t *p = rhs;
|
||||||
mp_obj_tuple_t *s = mp_obj_new_tuple(o->len + p->len, NULL);
|
mp_obj_tuple_t *s = mp_obj_new_tuple(o->len + p->len, NULL);
|
||||||
m_seq_cat(s->items, o->items, o->len, p->items, p->len, mp_obj_t);
|
mp_seq_cat(s->items, o->items, o->len, p->items, p->len, mp_obj_t);
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
case MP_BINARY_OP_MULTIPLY: {
|
case MP_BINARY_OP_MULTIPLY: {
|
||||||
|
@ -159,11 +159,11 @@ mp_obj_t tuple_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
|
||||||
#if MICROPY_ENABLE_SLICE
|
#if MICROPY_ENABLE_SLICE
|
||||||
if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
|
if (MP_OBJ_IS_TYPE(index, &mp_type_slice)) {
|
||||||
machine_uint_t start, stop;
|
machine_uint_t start, stop;
|
||||||
if (!m_seq_get_fast_slice_indexes(self->len, index, &start, &stop)) {
|
if (!mp_seq_get_fast_slice_indexes(self->len, index, &start, &stop)) {
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
mp_obj_tuple_t *res = mp_obj_new_tuple(stop - start, NULL);
|
mp_obj_tuple_t *res = mp_obj_new_tuple(stop - start, NULL);
|
||||||
m_seq_copy(res->items, self->items + start, res->len, mp_obj_t);
|
mp_seq_copy(res->items, self->items + start, res->len, mp_obj_t);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -578,7 +578,7 @@ mp_obj_t mp_call_method_n_kw_var(bool have_self, uint n_args_n_kw, const mp_obj_
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy the fixed pos args
|
// copy the fixed pos args
|
||||||
m_seq_copy(args2 + args2_len, args, n_args, mp_obj_t);
|
mp_seq_copy(args2 + args2_len, args, n_args, mp_obj_t);
|
||||||
args2_len += n_args;
|
args2_len += n_args;
|
||||||
|
|
||||||
} else if (MP_OBJ_IS_TYPE(pos_seq, &mp_type_tuple) || MP_OBJ_IS_TYPE(pos_seq, &mp_type_list)) {
|
} else if (MP_OBJ_IS_TYPE(pos_seq, &mp_type_tuple) || MP_OBJ_IS_TYPE(pos_seq, &mp_type_list)) {
|
||||||
|
@ -599,7 +599,7 @@ mp_obj_t mp_call_method_n_kw_var(bool have_self, uint n_args_n_kw, const mp_obj_
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy the fixed and variable position args
|
// copy the fixed and variable position args
|
||||||
m_seq_cat(args2 + args2_len, args, n_args, items, len, mp_obj_t);
|
mp_seq_cat(args2 + args2_len, args, n_args, items, len, mp_obj_t);
|
||||||
args2_len += n_args + len;
|
args2_len += n_args + len;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -615,7 +615,7 @@ mp_obj_t mp_call_method_n_kw_var(bool have_self, uint n_args_n_kw, const mp_obj_
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy the fixed position args
|
// copy the fixed position args
|
||||||
m_seq_copy(args2 + args2_len, args, n_args, mp_obj_t);
|
mp_seq_copy(args2 + args2_len, args, n_args, mp_obj_t);
|
||||||
|
|
||||||
// extract the variable position args from the iterator
|
// extract the variable position args from the iterator
|
||||||
mp_obj_t iterable = mp_getiter(pos_seq);
|
mp_obj_t iterable = mp_getiter(pos_seq);
|
||||||
|
@ -633,7 +633,7 @@ mp_obj_t mp_call_method_n_kw_var(bool have_self, uint n_args_n_kw, const mp_obj_
|
||||||
uint pos_args_len = args2_len;
|
uint pos_args_len = args2_len;
|
||||||
|
|
||||||
// Copy the fixed kw args.
|
// Copy the fixed kw args.
|
||||||
m_seq_copy(args2 + args2_len, args + n_args, 2 * n_kw, mp_obj_t);
|
mp_seq_copy(args2 + args2_len, args + n_args, 2 * n_kw, mp_obj_t);
|
||||||
args2_len += 2 * n_kw;
|
args2_len += 2 * n_kw;
|
||||||
|
|
||||||
// Extract (key,value) pairs from kw_dict dictionary and append to args2.
|
// Extract (key,value) pairs from kw_dict dictionary and append to args2.
|
||||||
|
|
|
@ -50,7 +50,7 @@ void mp_seq_multiply(const void *items, uint item_sz, uint len, uint times, void
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool m_seq_get_fast_slice_indexes(machine_uint_t len, mp_obj_t slice, machine_uint_t *begin, machine_uint_t *end) {
|
bool mp_seq_get_fast_slice_indexes(machine_uint_t len, mp_obj_t slice, machine_uint_t *begin, machine_uint_t *end) {
|
||||||
machine_int_t start, stop, step;
|
machine_int_t start, stop, step;
|
||||||
mp_obj_slice_get(slice, &start, &stop, &step);
|
mp_obj_slice_get(slice, &start, &stop, &step);
|
||||||
if (step != 1) {
|
if (step != 1) {
|
||||||
|
|
Loading…
Reference in New Issue