Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
12154b17
Commit
12154b17
authored
Mar 19, 2016
by
Damien George
Browse files
extmod/uctypes: Use mp_binary_get_val helper when extracting value.
It handles more cases than mp_binary_get_int.
parent
8d4d6731
Changes
1
Hide whitespace changes
Inline
Side-by-side
extmod/moductypes.c
View file @
12154b17
...
...
@@ -282,12 +282,9 @@ STATIC mp_obj_t uctypes_struct_sizeof(mp_obj_t obj_in) {
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
uctypes_struct_sizeof_obj
,
uctypes_struct_sizeof
);
STATIC
inline
mp_obj_t
get_unaligned
(
uint
val_type
,
void
*
p
,
int
big_endian
)
{
mp_int_t
val
=
mp_binary_get_int
(
GET_SCALAR_SIZE
(
val_type
),
val_type
&
1
,
big_endian
,
p
);
if
(
val_type
==
UINT32
)
{
return
mp_obj_new_int_from_uint
(
val
);
}
else
{
return
mp_obj_new_int
(
val
);
}
char
struct_type
=
big_endian
?
'>'
:
'<'
;
static
const
char
type2char
[
8
]
=
"BbHhIiQq"
;
return
mp_binary_get_val
(
struct_type
,
type2char
[
val_type
],
(
byte
**
)
&
p
);
}
STATIC
inline
void
set_unaligned
(
uint
val_type
,
byte
*
p
,
int
big_endian
,
mp_obj_t
val
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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