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
945a01c4
Commit
945a01c4
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py: Fix bug in type_store_attr, trying to store to ROM.
parent
bdcbf0fc
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/map.h
+5
-0
5 additions, 0 deletions
py/map.h
py/objtype.c
+9
-5
9 additions, 5 deletions
py/objtype.c
with
14 additions
and
5 deletions
py/map.h
+
5
−
0
View file @
945a01c4
...
...
@@ -3,6 +3,11 @@ typedef struct _mp_map_elem_t {
mp_obj_t
value
;
}
mp_map_elem_t
;
// TODO maybe have a truncated mp_map_t for fixed tables, since alloc=used
// put alloc last in the structure, so the truncated version does not need it
// this would save 1 ROM word for all ROM objects that have a locals_dict
// would also need a trucated dict structure
typedef
struct
_mp_map_t
{
machine_uint_t
all_keys_are_qstrs
:
1
;
machine_uint_t
table_is_fixed_array
:
1
;
...
...
This diff is collapsed.
Click to expand it.
py/objtype.c
+
9
−
5
View file @
945a01c4
...
...
@@ -325,14 +325,18 @@ STATIC bool type_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
if
(
self
->
locals_dict
!=
NULL
)
{
assert
(
MP_OBJ_IS_TYPE
(
self
->
locals_dict
,
&
dict_type
));
// Micro Python restriction, for now
mp_map_t
*
locals_map
=
((
void
*
)
self
->
locals_dict
+
sizeof
(
mp_obj_base_t
));
// XXX hack to get map object from dict object
mp_map_lookup
(
locals_map
,
MP_OBJ_NEW_QSTR
(
attr
),
MP_MAP_LOOKUP_ADD_IF_NOT_FOUND
)
->
value
=
value
;
mp_map_t
*
locals_map
=
mp_obj_dict_get_map
(
self
->
locals_dict
);
mp_map_elem_t
*
elem
=
mp_map_lookup
(
locals_map
,
MP_OBJ_NEW_QSTR
(
attr
),
MP_MAP_LOOKUP_ADD_IF_NOT_FOUND
);
// note that locals_map may be in ROM, so add will fail in that case
if
(
elem
!=
NULL
)
{
elem
->
value
=
value
;
return
true
;
}
else
{
return
false
;
}
}
return
false
;
}
const
mp_obj_type_t
mp_type_type
=
{
{
&
mp_type_type
},
.
name
=
MP_QSTR_type
,
...
...
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