summaryrefslogtreecommitdiffstatshomepage
path: root/py/obj.h
diff options
context:
space:
mode:
Diffstat (limited to 'py/obj.h')
-rw-r--r--py/obj.h11
1 files changed, 6 insertions, 5 deletions
diff --git a/py/obj.h b/py/obj.h
index d0284e6d21..4745b76443 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -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 {