diff options
author | Damien George <damien.p.george@gmail.com> | 2014-07-27 22:38:58 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-07-27 22:38:58 +0100 |
commit | adf0f2ae1a3debf8465ece7e065ddba2d4032e8c (patch) | |
tree | 090c7544536b130b47e30f8834d7450272dfb54a /py/obj.h | |
parent | 05c255f039b5c0fbdcb0754748fd5d36135acfd9 (diff) |
py: Change stream protocol API: fns return uint; is_text for text.
Diffstat (limited to 'py/obj.h')
-rw-r--r-- | py/obj.h | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -228,13 +228,14 @@ bool mp_get_buffer(mp_obj_t obj, mp_buffer_info_t *bufinfo, int flags); void mp_get_buffer_raise(mp_obj_t obj, mp_buffer_info_t *bufinfo, int flags); // Stream protocol +#define MP_STREAM_ERROR (-1) typedef struct _mp_stream_p_t { - // On error, functions should return -1 and fill in *errcode (values are - // implementation-dependent, but will be exposed to user, e.g. via exception). - mp_int_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); - mp_int_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); + // On error, functions should return MP_STREAM_ERROR and fill in *errcode (values + // are implementation-dependent, but will be exposed to user, e.g. via exception). + mp_uint_t (*read)(mp_obj_t obj, void *buf, mp_uint_t size, int *errcode); + mp_uint_t (*write)(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode); // add seek() ? - int is_bytes : 1; + int is_text : 1; // default is bytes, set this for text stream } mp_stream_p_t; struct _mp_obj_type_t { |