Merge branch 'master' of github.com:micropython/micropython
This commit is contained in:
commit
53775026e7
@ -139,6 +139,18 @@ 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;
|
||||||
} else {
|
} else {
|
||||||
mp_obj_array_t *o = self_in;
|
mp_obj_array_t *o = self_in;
|
||||||
|
if (MP_OBJ_IS_TYPE(index_in, &mp_type_slice)) {
|
||||||
|
machine_uint_t start, stop;
|
||||||
|
if (!m_seq_get_fast_slice_indexes(o->len, index_in, &start, &stop)) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
mp_obj_array_t *res = array_new(o->typecode, stop - start);
|
||||||
|
int sz = mp_binary_get_size('@', o->typecode, NULL);
|
||||||
|
assert(sz > 0);
|
||||||
|
byte *p = o->items;
|
||||||
|
memcpy(res->items, p + start * sz, (stop - start) * sz);
|
||||||
|
return res;
|
||||||
|
} else {
|
||||||
uint index = mp_get_index(o->base.type, o->len, index_in, false);
|
uint index = mp_get_index(o->base.type, o->len, index_in, false);
|
||||||
if (value == MP_OBJ_SENTINEL) {
|
if (value == MP_OBJ_SENTINEL) {
|
||||||
// load
|
// load
|
||||||
@ -150,6 +162,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
STATIC machine_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, int flags) {
|
STATIC machine_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, int flags) {
|
||||||
mp_obj_array_t *o = o_in;
|
mp_obj_array_t *o = o_in;
|
||||||
|
@ -13,3 +13,7 @@ s = 0
|
|||||||
for i in a:
|
for i in a:
|
||||||
s += i
|
s += i
|
||||||
print(s)
|
print(s)
|
||||||
|
|
||||||
|
print(a[1:])
|
||||||
|
print(a[:-1])
|
||||||
|
print(a[2:3])
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
class Base:
|
class Base:
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.a = 1
|
||||||
|
|
||||||
def meth(self):
|
def meth(self):
|
||||||
print("in Base meth")
|
print("in Base meth", self.a)
|
||||||
|
|
||||||
class Sub(Base):
|
class Sub(Base):
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ STATIC mp_obj_t ffimod_func(uint n_args, const mp_obj_t *args) {
|
|||||||
mp_obj_t iterable = mp_getiter(args[3]);
|
mp_obj_t iterable = mp_getiter(args[3]);
|
||||||
mp_obj_t item;
|
mp_obj_t item;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) {
|
while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
|
||||||
o->params[i++] = get_ffi_type(item);
|
o->params[i++] = get_ffi_type(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,7 +178,7 @@ STATIC mp_obj_t mod_ffi_callback(mp_obj_t rettype_in, mp_obj_t func_in, mp_obj_t
|
|||||||
mp_obj_t iterable = mp_getiter(paramtypes_in);
|
mp_obj_t iterable = mp_getiter(paramtypes_in);
|
||||||
mp_obj_t item;
|
mp_obj_t item;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while ((item = mp_iternext(iterable)) != MP_OBJ_NULL) {
|
while ((item = mp_iternext(iterable)) != MP_OBJ_STOP_ITERATION) {
|
||||||
o->params[i++] = get_ffi_type(item);
|
o->params[i++] = get_ffi_type(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user