Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
M
micropython
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
card10
micropython
Commits
22982394
Commit
22982394
authored
8 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py/objtuple: Convert mp_uint_t to size_t where appropriate.
parent
891dc5c6
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
py/obj.h
+1
-1
1 addition, 1 deletion
py/obj.h
py/objattrtuple.c
+5
-5
5 additions, 5 deletions
py/objattrtuple.c
py/objtuple.c
+9
-9
9 additions, 9 deletions
py/objtuple.c
py/objtuple.h
+3
-3
3 additions, 3 deletions
py/objtuple.h
with
18 additions
and
18 deletions
py/obj.h
+
1
−
1
View file @
22982394
...
...
@@ -630,7 +630,7 @@ mp_obj_t mp_obj_new_fun_viper(mp_uint_t n_args, void *fun_data, mp_uint_t type_s
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
(
mp_uint
_t
n
,
const
mp_obj_t
*
items
);
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_dict
(
mp_uint_t
n_args
);
mp_obj_t
mp_obj_new_set
(
mp_uint_t
n_args
,
mp_obj_t
*
items
);
...
...
This diff is collapsed.
Click to expand it.
py/objattrtuple.c
+
5
−
5
View file @
22982394
...
...
@@ -34,7 +34,7 @@ STATIC
#endif
void
mp_obj_attrtuple_print_helper
(
const
mp_print_t
*
print
,
const
qstr
*
fields
,
mp_obj_tuple_t
*
o
)
{
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
,
", "
);
}
...
...
@@ -59,9 +59,9 @@ STATIC void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
if
(
dest
[
0
]
==
MP_OBJ_NULL
)
{
// load attribute
mp_obj_tuple_t
*
self
=
MP_OBJ_TO_PTR
(
self_in
);
mp_uint
_t
len
=
self
->
len
;
size
_t
len
=
self
->
len
;
const
qstr
*
fields
=
(
const
qstr
*
)
MP_OBJ_TO_PTR
(
self
->
items
[
len
]);
for
(
mp_uint
_t
i
=
0
;
i
<
len
;
i
++
)
{
for
(
size
_t
i
=
0
;
i
<
len
;
i
++
)
{
if
(
fields
[
i
]
==
attr
)
{
dest
[
0
]
=
self
->
items
[
i
];
return
;
...
...
@@ -70,11 +70,11 @@ STATIC void mp_obj_attrtuple_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
}
}
mp_obj_t
mp_obj_new_attrtuple
(
const
qstr
*
fields
,
mp_uint
_t
n
,
const
mp_obj_t
*
items
)
{
mp_obj_t
mp_obj_new_attrtuple
(
const
qstr
*
fields
,
size
_t
n
,
const
mp_obj_t
*
items
)
{
mp_obj_tuple_t
*
o
=
m_new_obj_var
(
mp_obj_tuple_t
,
mp_obj_t
,
n
+
1
);
o
->
base
.
type
=
&
mp_type_attrtuple
;
o
->
len
=
n
;
for
(
mp_uint
_t
i
=
0
;
i
<
n
;
i
++
)
{
for
(
size
_t
i
=
0
;
i
<
n
;
i
++
)
{
o
->
items
[
i
]
=
items
[
i
];
}
o
->
items
[
n
]
=
MP_OBJ_FROM_PTR
(
fields
);
...
...
This diff is collapsed.
Click to expand it.
py/objtuple.c
+
9
−
9
View file @
22982394
...
...
@@ -32,7 +32,7 @@
#include
"py/runtime0.h"
#include
"py/runtime.h"
STATIC
mp_obj_t
mp_obj_new_tuple_iterator
(
mp_obj_tuple_t
*
tuple
,
mp_uint
_t
cur
);
STATIC
mp_obj_t
mp_obj_new_tuple_iterator
(
mp_obj_tuple_t
*
tuple
,
size
_t
cur
);
/******************************************************************************/
/* tuple */
...
...
@@ -45,7 +45,7 @@ void mp_obj_tuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t
mp_print_str
(
print
,
"("
);
kind
=
PRINT_REPR
;
}
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
,
", "
);
}
...
...
@@ -80,8 +80,8 @@ STATIC mp_obj_t mp_obj_tuple_make_new(const mp_obj_type_t *type_in, size_t n_arg
// TODO optimise for cases where we know the length of the iterator
mp_uint
_t
alloc
=
4
;
mp_uint
_t
len
=
0
;
size
_t
alloc
=
4
;
size
_t
len
=
0
;
mp_obj_t
*
items
=
m_new
(
mp_obj_t
,
alloc
);
mp_obj_t
iterable
=
mp_getiter
(
args
[
0
]);
...
...
@@ -127,7 +127,7 @@ mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in) {
case
MP_UNARY_OP_HASH
:
{
// start hash with pointer to empty tuple, to make it fairly unique
mp_int_t
hash
=
(
mp_int_t
)
mp_const_empty_tuple
;
for
(
mp_uint
_t
i
=
0
;
i
<
self
->
len
;
i
++
)
{
for
(
size
_t
i
=
0
;
i
<
self
->
len
;
i
++
)
{
hash
+=
MP_OBJ_SMALL_INT_VALUE
(
mp_unary_op
(
MP_UNARY_OP_HASH
,
self
->
items
[
i
]));
}
return
MP_OBJ_NEW_SMALL_INT
(
hash
);
...
...
@@ -235,7 +235,7 @@ const mp_obj_type_t mp_type_tuple = {
// the zero-length tuple
const
mp_obj_tuple_t
mp_const_empty_tuple_obj
=
{{
&
mp_type_tuple
},
0
};
mp_obj_t
mp_obj_new_tuple
(
mp_uint
_t
n
,
const
mp_obj_t
*
items
)
{
mp_obj_t
mp_obj_new_tuple
(
size
_t
n
,
const
mp_obj_t
*
items
)
{
if
(
n
==
0
)
{
return
mp_const_empty_tuple
;
}
...
...
@@ -243,7 +243,7 @@ mp_obj_t mp_obj_new_tuple(mp_uint_t n, const mp_obj_t *items) {
o
->
base
.
type
=
&
mp_type_tuple
;
o
->
len
=
n
;
if
(
items
)
{
for
(
mp_uint
_t
i
=
0
;
i
<
n
;
i
++
)
{
for
(
size
_t
i
=
0
;
i
<
n
;
i
++
)
{
o
->
items
[
i
]
=
items
[
i
];
}
}
...
...
@@ -270,7 +270,7 @@ typedef struct _mp_obj_tuple_it_t {
mp_obj_base_t
base
;
mp_fun_1_t
iternext
;
mp_obj_tuple_t
*
tuple
;
mp_uint
_t
cur
;
size
_t
cur
;
}
mp_obj_tuple_it_t
;
STATIC
mp_obj_t
tuple_it_iternext
(
mp_obj_t
self_in
)
{
...
...
@@ -284,7 +284,7 @@ STATIC mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
}
}
STATIC
mp_obj_t
mp_obj_new_tuple_iterator
(
mp_obj_tuple_t
*
tuple
,
mp_uint
_t
cur
)
{
STATIC
mp_obj_t
mp_obj_new_tuple_iterator
(
mp_obj_tuple_t
*
tuple
,
size
_t
cur
)
{
mp_obj_tuple_it_t
*
o
=
m_new_obj
(
mp_obj_tuple_it_t
);
o
->
base
.
type
=
&
mp_type_polymorph_iter
;
o
->
iternext
=
tuple_it_iternext
;
...
...
This diff is collapsed.
Click to expand it.
py/objtuple.h
+
3
−
3
View file @
22982394
...
...
@@ -30,13 +30,13 @@
typedef
struct
_mp_obj_tuple_t
{
mp_obj_base_t
base
;
mp_uint
_t
len
;
size
_t
len
;
mp_obj_t
items
[];
}
mp_obj_tuple_t
;
typedef
struct
_mp_rom_obj_tuple_t
{
mp_obj_base_t
base
;
mp_uint
_t
len
;
size
_t
len
;
mp_rom_obj_t
items
[];
}
mp_rom_obj_tuple_t
;
...
...
@@ -59,6 +59,6 @@ extern const mp_obj_type_t mp_type_attrtuple;
void
mp_obj_attrtuple_print_helper
(
const
mp_print_t
*
print
,
const
qstr
*
fields
,
mp_obj_tuple_t
*
o
);
#endif
mp_obj_t
mp_obj_new_attrtuple
(
const
qstr
*
fields
,
mp_uint
_t
n
,
const
mp_obj_t
*
items
);
mp_obj_t
mp_obj_new_attrtuple
(
const
qstr
*
fields
,
size
_t
n
,
const
mp_obj_t
*
items
);
#endif // __MICROPY_INCLUDED_PY_OBJTUPLE_H__
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment