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
134c10e7
Commit
134c10e7
authored
11 years ago
by
Damien George
Browse files
Options
Downloads
Plain Diff
Merge branch 'master' of github.com:micropython/micropython
parents
47e1b85d
f898a95c
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
py/objarray.c
+7
-0
7 additions, 0 deletions
py/objarray.c
py/objstr.c
+1
-0
1 addition, 0 deletions
py/objstr.c
tests/basics/bytearray1.py
+1
-0
1 addition, 0 deletions
tests/basics/bytearray1.py
unix/modffi.c
+13
-2
13 additions, 2 deletions
unix/modffi.c
with
22 additions
and
2 deletions
py/objarray.c
+
7
−
0
View file @
134c10e7
...
@@ -91,6 +91,13 @@ STATIC mp_obj_t array_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
...
@@ -91,6 +91,13 @@ STATIC mp_obj_t array_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
// This is top-level factory function, not virtual method
// This is top-level factory function, not virtual method
// TODO: "bytearray" really should be type, not function
// TODO: "bytearray" really should be type, not function
STATIC
mp_obj_t
mp_builtin_bytearray
(
mp_obj_t
arg
)
{
STATIC
mp_obj_t
mp_builtin_bytearray
(
mp_obj_t
arg
)
{
if
(
MP_OBJ_IS_SMALL_INT
(
arg
))
{
uint
len
=
MP_OBJ_SMALL_INT_VALUE
(
arg
);
mp_obj_array_t
*
o
=
array_new
(
BYTEARRAY_TYPECODE
,
len
);
memset
(
o
->
items
,
0
,
len
);
return
o
;
}
return
array_construct
(
BYTEARRAY_TYPECODE
,
arg
);
return
array_construct
(
BYTEARRAY_TYPECODE
,
arg
);
}
}
MP_DEFINE_CONST_FUN_OBJ_1
(
mp_builtin_bytearray_obj
,
mp_builtin_bytearray
);
MP_DEFINE_CONST_FUN_OBJ_1
(
mp_builtin_bytearray_obj
,
mp_builtin_bytearray
);
...
...
This diff is collapsed.
Click to expand it.
py/objstr.c
+
1
−
0
View file @
134c10e7
...
@@ -1352,6 +1352,7 @@ const mp_obj_type_t mp_type_bytes = {
...
@@ -1352,6 +1352,7 @@ const mp_obj_type_t mp_type_bytes = {
.
make_new
=
bytes_make_new
,
.
make_new
=
bytes_make_new
,
.
binary_op
=
str_binary_op
,
.
binary_op
=
str_binary_op
,
.
getiter
=
mp_obj_new_bytes_iterator
,
.
getiter
=
mp_obj_new_bytes_iterator
,
.
buffer_p
=
{
.
get_buffer
=
str_get_buffer
},
.
locals_dict
=
(
mp_obj_t
)
&
str_locals_dict
,
.
locals_dict
=
(
mp_obj_t
)
&
str_locals_dict
,
};
};
...
...
This diff is collapsed.
Click to expand it.
tests/basics/bytearray1.py
+
1
−
0
View file @
134c10e7
print
(
bytearray
(
4
))
a
=
bytearray
([
1
,
2
,
200
])
a
=
bytearray
([
1
,
2
,
200
])
print
(
a
[
0
],
a
[
2
])
print
(
a
[
0
],
a
[
2
])
print
(
a
[
-
1
])
print
(
a
[
-
1
])
...
...
This diff is collapsed.
Click to expand it.
unix/modffi.c
+
13
−
2
View file @
134c10e7
...
@@ -253,14 +253,22 @@ mp_obj_t ffifunc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *
...
@@ -253,14 +253,22 @@ mp_obj_t ffifunc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *
values
[
i
]
=
0
;
values
[
i
]
=
0
;
}
else
if
(
MP_OBJ_IS_INT
(
a
))
{
}
else
if
(
MP_OBJ_IS_INT
(
a
))
{
values
[
i
]
=
mp_obj_int_get
(
a
);
values
[
i
]
=
mp_obj_int_get
(
a
);
}
else
if
(
MP_OBJ_IS_STR
(
a
)
||
MP_OBJ_IS_TYPE
(
a
,
&
mp_type_bytes
)
)
{
}
else
if
(
MP_OBJ_IS_STR
(
a
))
{
const
char
*
s
=
mp_obj_str_get_str
(
a
);
const
char
*
s
=
mp_obj_str_get_str
(
a
);
values
[
i
]
=
(
ffi_arg
)
s
;
values
[
i
]
=
(
ffi_arg
)
s
;
}
else
if
(((
mp_obj_base_t
*
)
a
)
->
type
->
buffer_p
.
get_buffer
!=
NULL
)
{
mp_obj_base_t
*
o
=
(
mp_obj_base_t
*
)
a
;
buffer_info_t
bufinfo
;
o
->
type
->
buffer_p
.
get_buffer
(
o
,
&
bufinfo
,
BUFFER_READ
);
// TODO: BUFFER_READ?
if
(
bufinfo
.
buf
==
NULL
)
{
goto
error
;
}
values
[
i
]
=
(
ffi_arg
)
bufinfo
.
buf
;
}
else
if
(
MP_OBJ_IS_TYPE
(
a
,
&
fficallback_type
))
{
}
else
if
(
MP_OBJ_IS_TYPE
(
a
,
&
fficallback_type
))
{
mp_obj_fficallback_t
*
p
=
a
;
mp_obj_fficallback_t
*
p
=
a
;
values
[
i
]
=
(
ffi_arg
)
p
->
func
;
values
[
i
]
=
(
ffi_arg
)
p
->
func
;
}
else
{
}
else
{
assert
(
0
)
;
goto
error
;
}
}
valueptrs
[
i
]
=
&
values
[
i
];
valueptrs
[
i
]
=
&
values
[
i
];
}
}
...
@@ -268,6 +276,9 @@ mp_obj_t ffifunc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *
...
@@ -268,6 +276,9 @@ mp_obj_t ffifunc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *
ffi_arg
retval
;
ffi_arg
retval
;
ffi_call
(
&
self
->
cif
,
self
->
func
,
&
retval
,
valueptrs
);
ffi_call
(
&
self
->
cif
,
self
->
func
,
&
retval
,
valueptrs
);
return
return_ffi_value
(
retval
,
self
->
rettype
);
return
return_ffi_value
(
retval
,
self
->
rettype
);
error:
nlr_raise
(
mp_obj_new_exception_msg
(
&
mp_type_TypeError
,
"Don't know how to pass object to native function"
));
}
}
STATIC
const
mp_obj_type_t
ffifunc_type
=
{
STATIC
const
mp_obj_type_t
ffifunc_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