Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
58d9eeb8
Commit
58d9eeb8
authored
Feb 16, 2017
by
Damien George
Browse files
py/objlist: Convert mp_uint_t to size_t where appropriate.
parent
22982394
Changes
3
Hide whitespace changes
Inline
Side-by-side
py/obj.h
View file @
58d9eeb8
...
...
@@ -631,7 +631,7 @@ mp_obj_t mp_obj_new_fun_asm(mp_uint_t n_args, void *fun_data, mp_uint_t type_sig
mp_obj_t
mp_obj_new_gen_wrap
(
mp_obj_t
fun
);
mp_obj_t
mp_obj_new_closure
(
mp_obj_t
fun
,
mp_uint_t
n_closed
,
const
mp_obj_t
*
closed
);
mp_obj_t
mp_obj_new_tuple
(
size_t
n
,
const
mp_obj_t
*
items
);
mp_obj_t
mp_obj_new_list
(
mp_uint
_t
n
,
mp_obj_t
*
items
);
mp_obj_t
mp_obj_new_list
(
size
_t
n
,
mp_obj_t
*
items
);
mp_obj_t
mp_obj_new_dict
(
mp_uint_t
n_args
);
mp_obj_t
mp_obj_new_set
(
mp_uint_t
n_args
,
mp_obj_t
*
items
);
mp_obj_t
mp_obj_new_slice
(
mp_obj_t
start
,
mp_obj_t
stop
,
mp_obj_t
step
);
...
...
@@ -720,11 +720,11 @@ mp_int_t mp_obj_tuple_hash(mp_obj_t self_in);
// list
struct
_mp_obj_list_t
;
void
mp_obj_list_init
(
struct
_mp_obj_list_t
*
o
,
mp_uint
_t
n
);
void
mp_obj_list_init
(
struct
_mp_obj_list_t
*
o
,
size
_t
n
);
mp_obj_t
mp_obj_list_append
(
mp_obj_t
self_in
,
mp_obj_t
arg
);
mp_obj_t
mp_obj_list_remove
(
mp_obj_t
self_in
,
mp_obj_t
value
);
void
mp_obj_list_get
(
mp_obj_t
self_in
,
mp_uint_t
*
len
,
mp_obj_t
**
items
);
void
mp_obj_list_set_len
(
mp_obj_t
self_in
,
mp_uint
_t
len
);
void
mp_obj_list_set_len
(
mp_obj_t
self_in
,
size
_t
len
);
void
mp_obj_list_store
(
mp_obj_t
self_in
,
mp_obj_t
index
,
mp_obj_t
value
);
mp_obj_t
mp_obj_list_sort
(
size_t
n_args
,
const
mp_obj_t
*
args
,
mp_map_t
*
kwargs
);
...
...
py/objlist.c
View file @
58d9eeb8
...
...
@@ -33,8 +33,8 @@
#include
"py/runtime.h"
#include
"py/stackctrl.h"
STATIC
mp_obj_t
mp_obj_new_list_iterator
(
mp_obj_t
list
,
mp_uint
_t
cur
);
STATIC
mp_obj_list_t
*
list_new
(
mp_uint
_t
n
);
STATIC
mp_obj_t
mp_obj_new_list_iterator
(
mp_obj_t
list
,
size
_t
cur
);
STATIC
mp_obj_list_t
*
list_new
(
size
_t
n
);
STATIC
mp_obj_t
list_extend
(
mp_obj_t
self_in
,
mp_obj_t
arg_in
);
STATIC
mp_obj_t
list_pop
(
size_t
n_args
,
const
mp_obj_t
*
args
);
...
...
@@ -50,7 +50,7 @@ STATIC void list_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k
kind
=
PRINT_REPR
;
}
mp_print_str
(
print
,
"["
);
for
(
mp_uint
_t
i
=
0
;
i
<
o
->
len
;
i
++
)
{
for
(
size
_t
i
=
0
;
i
<
o
->
len
;
i
++
)
{
if
(
i
>
0
)
{
mp_print_str
(
print
,
", "
);
}
...
...
@@ -374,7 +374,7 @@ STATIC mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) {
if
(
index
<
0
)
{
index
=
0
;
}
if
((
mp_uint
_t
)
index
>
self
->
len
)
{
if
((
size
_t
)
index
>
self
->
len
)
{
index
=
self
->
len
;
}
...
...
@@ -451,7 +451,7 @@ const mp_obj_type_t mp_type_list = {
.
locals_dict
=
(
mp_obj_dict_t
*
)
&
list_locals_dict
,
};
void
mp_obj_list_init
(
mp_obj_list_t
*
o
,
mp_uint
_t
n
)
{
void
mp_obj_list_init
(
mp_obj_list_t
*
o
,
size
_t
n
)
{
o
->
base
.
type
=
&
mp_type_list
;
o
->
alloc
=
n
<
LIST_MIN_ALLOC
?
LIST_MIN_ALLOC
:
n
;
o
->
len
=
n
;
...
...
@@ -459,16 +459,16 @@ void mp_obj_list_init(mp_obj_list_t *o, mp_uint_t n) {
mp_seq_clear
(
o
->
items
,
n
,
o
->
alloc
,
sizeof
(
*
o
->
items
));
}
STATIC
mp_obj_list_t
*
list_new
(
mp_uint
_t
n
)
{
STATIC
mp_obj_list_t
*
list_new
(
size
_t
n
)
{
mp_obj_list_t
*
o
=
m_new_obj
(
mp_obj_list_t
);
mp_obj_list_init
(
o
,
n
);
return
o
;
}
mp_obj_t
mp_obj_new_list
(
mp_uint
_t
n
,
mp_obj_t
*
items
)
{
mp_obj_t
mp_obj_new_list
(
size
_t
n
,
mp_obj_t
*
items
)
{
mp_obj_list_t
*
o
=
list_new
(
n
);
if
(
items
!=
NULL
)
{
for
(
mp_uint
_t
i
=
0
;
i
<
n
;
i
++
)
{
for
(
size
_t
i
=
0
;
i
<
n
;
i
++
)
{
o
->
items
[
i
]
=
items
[
i
];
}
}
...
...
@@ -481,7 +481,7 @@ void mp_obj_list_get(mp_obj_t self_in, mp_uint_t *len, mp_obj_t **items) {
*
items
=
self
->
items
;
}
void
mp_obj_list_set_len
(
mp_obj_t
self_in
,
mp_uint
_t
len
)
{
void
mp_obj_list_set_len
(
mp_obj_t
self_in
,
size
_t
len
)
{
// trust that the caller knows what it's doing
// TODO realloc if len got much smaller than alloc
mp_obj_list_t
*
self
=
MP_OBJ_TO_PTR
(
self_in
);
...
...
@@ -501,7 +501,7 @@ typedef struct _mp_obj_list_it_t {
mp_obj_base_t
base
;
mp_fun_1_t
iternext
;
mp_obj_t
list
;
mp_uint
_t
cur
;
size
_t
cur
;
}
mp_obj_list_it_t
;
STATIC
mp_obj_t
list_it_iternext
(
mp_obj_t
self_in
)
{
...
...
@@ -516,7 +516,7 @@ STATIC mp_obj_t list_it_iternext(mp_obj_t self_in) {
}
}
mp_obj_t
mp_obj_new_list_iterator
(
mp_obj_t
list
,
mp_uint
_t
cur
)
{
mp_obj_t
mp_obj_new_list_iterator
(
mp_obj_t
list
,
size
_t
cur
)
{
mp_obj_list_it_t
*
o
=
m_new_obj
(
mp_obj_list_it_t
);
o
->
base
.
type
=
&
mp_type_polymorph_iter
;
o
->
iternext
=
list_it_iternext
;
...
...
py/objlist.h
View file @
58d9eeb8
...
...
@@ -30,8 +30,8 @@
typedef
struct
_mp_obj_list_t
{
mp_obj_base_t
base
;
mp_uint
_t
alloc
;
mp_uint
_t
len
;
size
_t
alloc
;
size
_t
len
;
mp_obj_t
*
items
;
}
mp_obj_list_t
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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