objstringio: Implement io.BytesIO.

Done in generalized manner, allowing any stream class to be specified as
working with bytes.
This commit is contained in:
Paul Sokolovsky
2014-05-15 07:28:19 +03:00
parent 0c124c3123
commit a47b64ae2d
7 changed files with 46 additions and 11 deletions

View File

@@ -246,6 +246,7 @@ typedef struct _mp_stream_p_t {
machine_int_t (*read)(mp_obj_t obj, void *buf, machine_uint_t size, int *errcode);
machine_int_t (*write)(mp_obj_t obj, const void *buf, machine_uint_t size, int *errcode);
// add seek() ?
int is_bytes : 1;
} mp_stream_p_t;
struct _mp_obj_type_t {
@@ -321,6 +322,7 @@ extern const mp_obj_type_t mp_type_staticmethod;
extern const mp_obj_type_t mp_type_classmethod;
extern const mp_obj_type_t mp_type_property;
extern const mp_obj_type_t mp_type_stringio;
extern const mp_obj_type_t mp_type_bytesio;
// Exceptions
extern const mp_obj_type_t mp_type_BaseException;