Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
c49ddb93
Commit
c49ddb93
authored
Jun 01, 2014
by
Damien George
Browse files
py: Fix configurability of builtin slice.
parent
3ebd4d0c
Changes
5
Hide whitespace changes
Inline
Side-by-side
py/obj.h
View file @
c49ddb93
...
...
@@ -568,7 +568,9 @@ typedef struct {
}
mp_bound_slice_t
;
void
mp_seq_multiply
(
const
void
*
items
,
uint
item_sz
,
uint
len
,
uint
times
,
void
*
dest
);
#if MICROPY_PY_BUILTINS_SLICE
bool
mp_seq_get_fast_slice_indexes
(
machine_uint_t
len
,
mp_obj_t
slice
,
mp_bound_slice_t
*
indexes
);
#endif
#define mp_seq_copy(dest, src, len, item_t) memcpy(dest, src, len * 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
);
...
...
py/objarray.c
View file @
c49ddb93
...
...
@@ -169,7 +169,9 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
return
MP_OBJ_NULL
;
// op not supported
}
else
{
mp_obj_array_t
*
o
=
self_in
;
if
(
MP_OBJ_IS_TYPE
(
index_in
,
&
mp_type_slice
))
{
if
(
0
)
{
#if MICROPY_PY_BUILTINS_SLICE
}
else
if
(
MP_OBJ_IS_TYPE
(
index_in
,
&
mp_type_slice
))
{
if
(
value
!=
MP_OBJ_SENTINEL
)
{
// Only getting a slice is suported so far, not assignment
// TODO: confirmed that both bytearray and array.array support
...
...
@@ -187,6 +189,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
byte
*
p
=
o
->
items
;
memcpy
(
res
->
items
,
p
+
slice
.
start
*
sz
,
(
slice
.
stop
-
slice
.
start
)
*
sz
);
return
res
;
#endif
}
else
{
uint
index
=
mp_get_index
(
o
->
base
.
type
,
o
->
len
,
index_in
,
false
);
if
(
value
==
MP_OBJ_SENTINEL
)
{
...
...
py/runtime.c
View file @
c49ddb93
...
...
@@ -1185,7 +1185,9 @@ void *const mp_fun_table[MP_F_NUMBER_OF] = {
mp_import_name
,
mp_import_from
,
mp_import_all
,
#if MICROPY_PY_BUILTINS_SLICE
mp_obj_new_slice
,
#endif
mp_unpack_sequence
,
mp_unpack_ex
,
};
...
...
py/runtime0.h
View file @
c49ddb93
...
...
@@ -127,7 +127,9 @@ typedef enum {
MP_F_IMPORT_NAME
,
MP_F_IMPORT_FROM
,
MP_F_IMPORT_ALL
,
#if MICROPY_PY_BUILTINS_SLICE
MP_F_NEW_SLICE
,
#endif
MP_F_UNPACK_SEQUENCE
,
MP_F_UNPACK_EX
,
MP_F_NUMBER_OF
,
...
...
py/sequence.c
View file @
c49ddb93
...
...
@@ -51,6 +51,8 @@ void mp_seq_multiply(const void *items, uint item_sz, uint len, uint times, void
}
}
#if MICROPY_PY_BUILTINS_SLICE
bool
mp_seq_get_fast_slice_indexes
(
machine_uint_t
len
,
mp_obj_t
slice
,
mp_bound_slice_t
*
indexes
)
{
mp_obj_t
ostart
,
ostop
,
ostep
;
machine_int_t
start
,
stop
;
...
...
@@ -102,6 +104,8 @@ bool mp_seq_get_fast_slice_indexes(machine_uint_t len, mp_obj_t slice, mp_bound_
return
true
;
}
#endif
mp_obj_t
mp_seq_extract_slice
(
uint
len
,
const
mp_obj_t
*
seq
,
mp_bound_slice_t
*
indexes
)
{
machine_int_t
start
=
indexes
->
start
,
stop
=
indexes
->
stop
;
machine_int_t
step
=
indexes
->
step
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment