Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
7f11c794
Commit
7f11c794
authored
Jan 29, 2014
by
Paul Sokolovsky
Browse files
mp_obj_new_bytearray_by_ref(): Allow to create array by reference.
This is special feature for FFI.
parent
1801421f
Changes
2
Hide whitespace changes
Inline
Side-by-side
py/obj.h
View file @
7f11c794
...
...
@@ -349,6 +349,7 @@ extern const mp_obj_type_t zip_type;
// array
extern
const
mp_obj_type_t
array_type
;
uint
mp_obj_array_len
(
mp_obj_t
self_in
);
mp_obj_t
mp_obj_new_bytearray_by_ref
(
uint
n
,
void
*
items
);
// functions
typedef
struct
_mp_obj_fun_native_t
{
// need this so we can define const objects (to go in ROM)
...
...
py/objarray.c
View file @
7f11c794
...
...
@@ -271,6 +271,17 @@ mp_obj_t mp_obj_new_bytearray(uint n, void *items) {
return
o
;
}
// Create bytearray which references specified memory area
mp_obj_t
mp_obj_new_bytearray_by_ref
(
uint
n
,
void
*
items
)
{
mp_obj_array_t
*
o
=
m_new_obj
(
mp_obj_array_t
);
o
->
base
.
type
=
&
array_type
;
o
->
typecode
=
BYTEARRAY_TYPECODE
;
o
->
free
=
0
;
o
->
len
=
n
;
o
->
items
=
items
;
return
o
;
}
/******************************************************************************/
/* array iterator */
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment