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
GitLab 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
ef9124f5
Commit
ef9124f5
authored
11 years ago
by
Paul Sokolovsky
Browse files
Options
Downloads
Patches
Plain Diff
binary: Rename array accessors for clarity.
parent
2da81fa8
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/binary.c
+2
-2
2 additions, 2 deletions
py/binary.c
py/objarray.c
+6
-6
6 additions, 6 deletions
py/objarray.c
with
8 additions
and
8 deletions
py/binary.c
+
2
−
2
View file @
ef9124f5
...
...
@@ -39,7 +39,7 @@ int mp_binary_get_size(char typecode) {
return
-
1
;
}
mp_obj_t
mp_binary_get_val
(
char
typecode
,
void
*
p
,
int
index
)
{
mp_obj_t
mp_binary_get_val
_array
(
char
typecode
,
void
*
p
,
int
index
)
{
machine_int_t
val
=
0
;
switch
(
typecode
)
{
case
'b'
:
...
...
@@ -121,7 +121,7 @@ mp_obj_t mp_binary_get_val_unaligned(char typecode, byte **ptr) {
}
}
void
mp_binary_set_val
(
char
typecode
,
void
*
p
,
int
index
,
mp_obj_t
val_in
)
{
void
mp_binary_set_val
_array
(
char
typecode
,
void
*
p
,
int
index
,
mp_obj_t
val_in
)
{
machine_int_t
val
=
0
;
if
(
MP_OBJ_IS_INT
(
val_in
))
{
val
=
mp_obj_int_get
(
val_in
);
...
...
This diff is collapsed.
Click to expand it.
py/objarray.c
+
6
−
6
View file @
ef9124f5
...
...
@@ -40,7 +40,7 @@ STATIC void array_print(void (*print)(void *env, const char *fmt, ...), void *en
if
(
i
>
0
)
{
print
(
env
,
", "
);
}
mp_obj_print_helper
(
print
,
env
,
mp_binary_get_val
(
o
->
typecode
,
o
->
items
,
i
),
PRINT_REPR
);
mp_obj_print_helper
(
print
,
env
,
mp_binary_get_val
_array
(
o
->
typecode
,
o
->
items
,
i
),
PRINT_REPR
);
}
print
(
env
,
"]"
);
}
...
...
@@ -67,7 +67,7 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
if
(
len
==
0
)
{
array_append
(
array
,
item
);
}
else
{
mp_binary_set_val
(
typecode
,
array
->
items
,
i
++
,
item
);
mp_binary_set_val
_array
(
typecode
,
array
->
items
,
i
++
,
item
);
}
}
...
...
@@ -118,7 +118,7 @@ STATIC mp_obj_t array_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
case
MP_BINARY_OP_SUBSCR
:
{
uint
index
=
mp_get_index
(
o
->
base
.
type
,
o
->
len
,
rhs
,
false
);
return
mp_binary_get_val
(
o
->
typecode
,
o
->
items
,
index
);
return
mp_binary_get_val
_array
(
o
->
typecode
,
o
->
items
,
index
);
}
default:
...
...
@@ -136,7 +136,7 @@ STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
self
->
free
=
8
;
self
->
items
=
m_realloc
(
self
->
items
,
item_sz
*
self
->
len
,
item_sz
*
(
self
->
len
+
self
->
free
));
}
mp_binary_set_val
(
self
->
typecode
,
self
->
items
,
self
->
len
++
,
arg
);
mp_binary_set_val
_array
(
self
->
typecode
,
self
->
items
,
self
->
len
++
,
arg
);
self
->
free
--
;
return
mp_const_none
;
// return None, as per CPython
}
...
...
@@ -149,7 +149,7 @@ STATIC bool array_store_item(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
}
mp_obj_array_t
*
o
=
self_in
;
uint
index
=
mp_get_index
(
o
->
base
.
type
,
o
->
len
,
index_in
,
false
);
mp_binary_set_val
(
o
->
typecode
,
o
->
items
,
index
,
value
);
mp_binary_set_val
_array
(
o
->
typecode
,
o
->
items
,
index
,
value
);
return
true
;
}
...
...
@@ -235,7 +235,7 @@ typedef struct _mp_obj_array_it_t {
STATIC
mp_obj_t
array_it_iternext
(
mp_obj_t
self_in
)
{
mp_obj_array_it_t
*
self
=
self_in
;
if
(
self
->
cur
<
self
->
array
->
len
)
{
return
mp_binary_get_val
(
self
->
array
->
typecode
,
self
->
array
->
items
,
self
->
cur
++
);
return
mp_binary_get_val
_array
(
self
->
array
->
typecode
,
self
->
array
->
items
,
self
->
cur
++
);
}
else
{
return
MP_OBJ_NULL
;
}
...
...
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