diff options
| author | Damien George | 2014-04-13 12:08:52 +0100 |
|---|---|---|
| committer | Damien George | 2014-04-13 12:08:52 +0100 |
| commit | 8a1cab952f08f46182f6f86caf8edf37e477be33 (patch) | |
| tree | 0d032ab1e5390a3d68414f2305a42a8172ee16bf /py/objfun.c | |
| parent | 4b01de44ba110394cac66f83a44a037fc58ae4e8 (diff) | |
py: Fix mp_get_buffer, and use it in more places.
Must use mp_obj_get_type to get the type of an object. Can't assume
mp_obj_t is castable to mp_obj_base_t.
Diffstat (limited to 'py/objfun.c')
| -rw-r--r-- | py/objfun.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/py/objfun.c b/py/objfun.c index 056789c33..8fadbc611 100644 --- a/py/objfun.c +++ b/py/objfun.c @@ -442,14 +442,15 @@ STATIC machine_uint_t convert_obj_for_inline_asm(mp_obj_t obj) { mp_obj_t *items; mp_obj_list_get(obj, &len, &items); return (machine_uint_t)items; - } else if (type->buffer_p.get_buffer != NULL) { - // supports the buffer protocol, get a pointer to the data - buffer_info_t bufinfo; - type->buffer_p.get_buffer(obj, &bufinfo, BUFFER_READ); - return (machine_uint_t)bufinfo.buf; } else { - // just pass along a pointer to the object - return (machine_uint_t)obj; + buffer_info_t bufinfo; + if (mp_get_buffer(obj, &bufinfo)) { + // supports the buffer protocol, return a pointer to the data + return (machine_uint_t)bufinfo.buf; + } else { + // just pass along a pointer to the object + return (machine_uint_t)obj; + } } } } |
