Lines Matching refs:o

39 STATIC void check_stringio_is_open(const mp_obj_stringio_t *o) {  in check_stringio_is_open()  argument
40 if (o->vstr == NULL) { in check_stringio_is_open()
45 #define check_stringio_is_open(o) argument
56 mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in); in stringio_read() local
57 check_stringio_is_open(o); in stringio_read()
58 if (o->vstr->len <= o->pos) { // read to EOF, or seeked to EOF or beyond in stringio_read()
61 mp_uint_t remaining = o->vstr->len - o->pos; in stringio_read()
65 memcpy(buf, o->vstr->buf + o->pos, size); in stringio_read()
66 o->pos += size; in stringio_read()
70 STATIC void stringio_copy_on_write(mp_obj_stringio_t *o) { in stringio_copy_on_write() argument
71 const void *buf = o->vstr->buf; in stringio_copy_on_write()
72 o->vstr->buf = m_new(char, o->vstr->len); in stringio_copy_on_write()
73 o->vstr->fixed_buf = false; in stringio_copy_on_write()
74 o->ref_obj = MP_OBJ_NULL; in stringio_copy_on_write()
75 memcpy(o->vstr->buf, buf, o->vstr->len); in stringio_copy_on_write()
80 mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in); in stringio_write() local
81 check_stringio_is_open(o); in stringio_write()
83 if (o->vstr->fixed_buf) { in stringio_write()
84 stringio_copy_on_write(o); in stringio_write()
87 mp_uint_t new_pos = o->pos + size; in stringio_write()
93 mp_uint_t org_len = o->vstr->len; in stringio_write()
94 if (new_pos > o->vstr->alloc) { in stringio_write()
96 o->vstr->len = o->vstr->alloc; in stringio_write()
98 vstr_add_len(o->vstr, new_pos - o->vstr->alloc); in stringio_write()
101 if (o->pos > org_len) { in stringio_write()
102 memset(o->vstr->buf + org_len, 0, o->pos - org_len); in stringio_write()
104 memcpy(o->vstr->buf + o->pos, buf, size); in stringio_write()
105 o->pos = new_pos; in stringio_write()
106 if (new_pos > o->vstr->len) { in stringio_write()
107 o->vstr->len = new_pos; in stringio_write()
114 mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in); in stringio_ioctl() local
121 ref = o->pos; in stringio_ioctl()
124 ref = o->vstr->len; in stringio_ioctl()
141 s->offset = o->pos = new_pos; in stringio_ioctl()
148 vstr_free(o->vstr); in stringio_ioctl()
149 o->vstr = NULL; in stringio_ioctl()
151 vstr_clear(o->vstr); in stringio_ioctl()
152 o->vstr->alloc = 0; in stringio_ioctl()
153 o->vstr->len = 0; in stringio_ioctl()
154 o->pos = 0; in stringio_ioctl()
163 #define STREAM_TO_CONTENT_TYPE(o) (((o)->base.type == &mp_type_stringio) ? &mp_type_str : &mp_type_… argument
180 mp_obj_stringio_t *o = m_new_obj(mp_obj_stringio_t); in stringio_new() local
181 o->base.type = type; in stringio_new()
182 o->pos = 0; in stringio_new()
183 o->ref_obj = MP_OBJ_NULL; in stringio_new()
184 return o; in stringio_new()
194 mp_obj_stringio_t *o = stringio_new(type_in); in stringio_make_new() local
203 o->vstr = m_new_obj(vstr_t); in stringio_make_new()
204 vstr_init_fixed_buf(o->vstr, bufinfo.len, bufinfo.buf); in stringio_make_new()
205 o->vstr->len = bufinfo.len; in stringio_make_new()
206 o->ref_obj = args[0]; in stringio_make_new()
207 return MP_OBJ_FROM_PTR(o); in stringio_make_new()
215 o->vstr = vstr_new(sz); in stringio_make_new()
218 stringio_write(MP_OBJ_FROM_PTR(o), bufinfo.buf, bufinfo.len, NULL); in stringio_make_new()
220 o->pos = 0; in stringio_make_new()
222 return MP_OBJ_FROM_PTR(o); in stringio_make_new()