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 project is archived. Its data is
read-only
.
Show more breadcrumbs
card10
micropython
Commits
26ed0011
Commit
26ed0011
authored
Dec 27, 2015
by
Antonin ENFRUN
Committed by
Paul Sokolovsky
Jan 3, 2016
Browse files
Options
Downloads
Patches
Plain Diff
uctypes: Implement assignment for scalar array
parent
8212d973
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
extmod/moductypes.c
+23
-8
23 additions, 8 deletions
extmod/moductypes.c
with
23 additions
and
8 deletions
extmod/moductypes.c
+
23
−
8
View file @
26ed0011
...
...
@@ -512,8 +512,8 @@ STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_ob
if
(
value
==
MP_OBJ_NULL
)
{
// delete
return
MP_OBJ_NULL
;
// op not supported
}
else
if
(
value
==
MP_OBJ_SENTINEL
)
{
// load
}
else
{
// load
/ store
if
(
!
MP_OBJ_IS_TYPE
(
self
->
desc
,
&
mp_type_tuple
))
{
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_TypeError
,
"struct: cannot index"
));
}
...
...
@@ -533,9 +533,24 @@ STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_ob
}
if
(
t
->
len
==
2
)
{
// array of scalars
if
(
self
->
flags
==
LAYOUT_NATIVE
)
{
if
(
value
==
MP_OBJ_SENTINEL
)
{
return
get_aligned
(
val_type
,
self
->
addr
,
index
);
}
else
{
set_aligned
(
val_type
,
self
->
addr
,
index
,
value
);
return
value
;
// just !MP_OBJ_NULL
}
}
else
{
byte
*
p
=
self
->
addr
+
GET_SCALAR_SIZE
(
val_type
)
*
index
;
if
(
value
==
MP_OBJ_SENTINEL
)
{
return
get_unaligned
(
val_type
,
p
,
self
->
flags
);
}
else
{
set_unaligned
(
val_type
,
p
,
self
->
flags
,
value
);
return
value
;
// just !MP_OBJ_NULL
}
}
}
else
if
(
value
==
MP_OBJ_SENTINEL
)
{
mp_uint_t
dummy
=
0
;
mp_uint_t
size
=
uctypes_struct_size
(
t
->
items
[
2
],
self
->
flags
,
&
dummy
);
mp_obj_uctypes_struct_t
*
o
=
m_new_obj
(
mp_obj_uctypes_struct_t
);
...
...
@@ -544,7 +559,10 @@ STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_ob
o
->
addr
=
self
->
addr
+
size
*
index
;
o
->
flags
=
self
->
flags
;
return
MP_OBJ_FROM_PTR
(
o
);
}
else
{
return
MP_OBJ_NULL
;
// op not supported
}
}
else
if
(
agg_type
==
PTR
)
{
byte
*
p
=
*
(
void
**
)
self
->
addr
;
if
(
MP_OBJ_IS_SMALL_INT
(
t
->
items
[
1
]))
{
...
...
@@ -564,9 +582,6 @@ STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_ob
assert
(
0
);
return
MP_OBJ_NULL
;
}
else
{
// store
return
MP_OBJ_NULL
;
// op not supported
}
}
...
...
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