diff options
author | Damien George <damien.p.george@gmail.com> | 2014-04-18 22:29:21 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-04-18 22:29:21 +0100 |
commit | 57a4b4f178698435b584892f69db5d5f2ea396dc (patch) | |
tree | b38aac7f18d31f714c2029a0a6e3f93e36447295 /py/obj.h | |
parent | 3fd2d7fad2022e3f26304fbc6ad74e6d8dd66e5f (diff) |
py: Add typecode to buffer protocol.
When querying an object that supports the buffer protocol, that object
must now return a typecode (as per binary.[ch]). This does not have to
be honoured by the caller, but can be useful for determining element
size.
Diffstat (limited to 'py/obj.h')
-rw-r--r-- | py/obj.h | 24 |
1 files changed, 10 insertions, 14 deletions
@@ -189,32 +189,28 @@ typedef struct _mp_method_t { } mp_method_t; // Buffer protocol -typedef struct _buffer_info_t { +typedef struct _mp_buffer_info_t { // if we'd bother to support various versions of structure // (with different number of fields), we can distinguish // them with ver = sizeof(struct). Cons: overkill for *micro*? //int ver; // ? void *buf; - machine_int_t len; - - // Rationale: have array.array and have SIMD operations on them - // Cons: users can pass item size to processing functions themselves, - // though that's not "plug&play" - // int itemsize; + machine_int_t len; // in bytes + int typecode; // as per binary.h // Rationale: to load arbitrary-sized sprites directly to LCD // Cons: a bit adhoc usecase // int stride; -} buffer_info_t; -#define BUFFER_READ (1) -#define BUFFER_WRITE (2) -#define BUFFER_RW (BUFFER_READ | BUFFER_WRITE) +} mp_buffer_info_t; +#define MP_BUFFER_READ (1) +#define MP_BUFFER_WRITE (2) +#define MP_BUFFER_RW (MP_BUFFER_READ | MP_BUFFER_WRITE) typedef struct _mp_buffer_p_t { - machine_int_t (*get_buffer)(mp_obj_t obj, buffer_info_t *bufinfo, int flags); + machine_int_t (*get_buffer)(mp_obj_t obj, mp_buffer_info_t *bufinfo, int flags); } mp_buffer_p_t; -bool mp_get_buffer(mp_obj_t obj, buffer_info_t *bufinfo); -void mp_get_buffer_raise(mp_obj_t obj, buffer_info_t *bufinfo); +bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo); +void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo); // Stream protocol typedef struct _mp_stream_p_t { |