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
c00ee200
Commit
c00ee200
authored
6 years ago
by
Damien George
Browse files
Options
Downloads
Patches
Plain Diff
py/objarray: Replace 0x80 with new MP_OBJ_ARRAY_TYPECODE_FLAG_RW macro.
parent
ca2b1d6b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
py/objarray.c
+4
-4
4 additions, 4 deletions
py/objarray.c
py/objarray.h
+3
-0
3 additions, 0 deletions
py/objarray.h
with
7 additions
and
4 deletions
py/objarray.c
+
4
−
4
View file @
c00ee200
...
...
@@ -222,7 +222,7 @@ STATIC mp_obj_t memoryview_make_new(const mp_obj_type_t *type_in, size_t n_args,
// test if the object can be written to
if
(
mp_get_buffer
(
args
[
0
],
&
bufinfo
,
MP_BUFFER_RW
))
{
self
->
typecode
|=
0x80
;
// used to
indicate writable buffer
self
->
typecode
|=
MP_OBJ_ARRAY_TYPECODE_FLAG_RW
;
//
indicate writable buffer
}
return
MP_OBJ_FROM_PTR
(
self
);
...
...
@@ -414,7 +414,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
uint8_t
*
dest_items
=
o
->
items
;
#if MICROPY_PY_BUILTINS_MEMORYVIEW
if
(
o
->
base
.
type
==
&
mp_type_memoryview
)
{
if
((
o
->
typecode
&
0x80
)
==
0
)
{
if
(
!
(
o
->
typecode
&
MP_OBJ_ARRAY_TYPECODE_FLAG_RW
)
)
{
// store to read-only memoryview not allowed
return
MP_OBJ_NULL
;
}
...
...
@@ -471,7 +471,7 @@ STATIC mp_obj_t array_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value
#if MICROPY_PY_BUILTINS_MEMORYVIEW
if
(
o
->
base
.
type
==
&
mp_type_memoryview
)
{
index
+=
o
->
free
;
if
(
value
!=
MP_OBJ_SENTINEL
&&
(
o
->
typecode
&
0x80
)
==
0
)
{
if
(
value
!=
MP_OBJ_SENTINEL
&&
!
(
o
->
typecode
&
MP_OBJ_ARRAY_TYPECODE_FLAG_RW
)
)
{
// store to read-only memoryview
return
MP_OBJ_NULL
;
}
...
...
@@ -497,7 +497,7 @@ STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_ui
bufinfo
->
typecode
=
o
->
typecode
&
TYPECODE_MASK
;
#if MICROPY_PY_BUILTINS_MEMORYVIEW
if
(
o
->
base
.
type
==
&
mp_type_memoryview
)
{
if
((
o
->
typecode
&
0x80
)
==
0
&&
(
flags
&
MP_BUFFER_WRITE
))
{
if
(
!
(
o
->
typecode
&
MP_OBJ_ARRAY_TYPECODE_FLAG_RW
)
&&
(
flags
&
MP_BUFFER_WRITE
))
{
// read-only memoryview
return
1
;
}
...
...
This diff is collapsed.
Click to expand it.
py/objarray.h
+
3
−
0
View file @
c00ee200
...
...
@@ -29,6 +29,9 @@
#include
"py/obj.h"
// Used only for memoryview types, set in "typecode" to indicate a writable memoryview
#define MP_OBJ_ARRAY_TYPECODE_FLAG_RW (0x80)
typedef
struct
_mp_obj_array_t
{
mp_obj_base_t
base
;
size_t
typecode
:
8
;
...
...
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