unix: Update to use new buffer protocol interface with typecode.
This commit is contained in:
parent
57a4b4f178
commit
738bdeb73a
|
@ -268,9 +268,9 @@ mp_obj_t ffifunc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *
|
||||||
values[i] = (ffi_arg)s;
|
values[i] = (ffi_arg)s;
|
||||||
} else if (((mp_obj_base_t*)a)->type->buffer_p.get_buffer != NULL) {
|
} else if (((mp_obj_base_t*)a)->type->buffer_p.get_buffer != NULL) {
|
||||||
mp_obj_base_t *o = (mp_obj_base_t*)a;
|
mp_obj_base_t *o = (mp_obj_base_t*)a;
|
||||||
buffer_info_t bufinfo;
|
mp_buffer_info_t bufinfo;
|
||||||
o->type->buffer_p.get_buffer(o, &bufinfo, BUFFER_READ); // TODO: BUFFER_READ?
|
int ret = o->type->buffer_p.get_buffer(o, &bufinfo, MP_BUFFER_READ); // TODO: MP_BUFFER_READ?
|
||||||
if (bufinfo.buf == NULL) {
|
if (ret != 0 || bufinfo.buf == NULL) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
values[i] = (ffi_arg)bufinfo.buf;
|
values[i] = (ffi_arg)bufinfo.buf;
|
||||||
|
|
|
@ -80,7 +80,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(socket_fileno_obj, socket_fileno);
|
||||||
|
|
||||||
STATIC mp_obj_t socket_connect(mp_obj_t self_in, mp_obj_t addr_in) {
|
STATIC mp_obj_t socket_connect(mp_obj_t self_in, mp_obj_t addr_in) {
|
||||||
mp_obj_socket_t *self = self_in;
|
mp_obj_socket_t *self = self_in;
|
||||||
buffer_info_t bufinfo;
|
mp_buffer_info_t bufinfo;
|
||||||
mp_get_buffer_raise(addr_in, &bufinfo);
|
mp_get_buffer_raise(addr_in, &bufinfo);
|
||||||
int r = connect(self->fd, (const struct sockaddr *)bufinfo.buf, bufinfo.len);
|
int r = connect(self->fd, (const struct sockaddr *)bufinfo.buf, bufinfo.len);
|
||||||
RAISE_ERRNO(r, errno);
|
RAISE_ERRNO(r, errno);
|
||||||
|
@ -90,7 +90,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(socket_connect_obj, socket_connect);
|
||||||
|
|
||||||
STATIC mp_obj_t socket_bind(mp_obj_t self_in, mp_obj_t addr_in) {
|
STATIC mp_obj_t socket_bind(mp_obj_t self_in, mp_obj_t addr_in) {
|
||||||
mp_obj_socket_t *self = self_in;
|
mp_obj_socket_t *self = self_in;
|
||||||
buffer_info_t bufinfo;
|
mp_buffer_info_t bufinfo;
|
||||||
mp_get_buffer_raise(addr_in, &bufinfo);
|
mp_get_buffer_raise(addr_in, &bufinfo);
|
||||||
int r = bind(self->fd, (const struct sockaddr *)bufinfo.buf, bufinfo.len);
|
int r = bind(self->fd, (const struct sockaddr *)bufinfo.buf, bufinfo.len);
|
||||||
RAISE_ERRNO(r, errno);
|
RAISE_ERRNO(r, errno);
|
||||||
|
@ -168,7 +168,7 @@ STATIC mp_obj_t socket_setsockopt(uint n_args, const mp_obj_t *args) {
|
||||||
optval = &val;
|
optval = &val;
|
||||||
optlen = sizeof(val);
|
optlen = sizeof(val);
|
||||||
} else {
|
} else {
|
||||||
buffer_info_t bufinfo;
|
mp_buffer_info_t bufinfo;
|
||||||
mp_get_buffer_raise(args[3], &bufinfo);
|
mp_get_buffer_raise(args[3], &bufinfo);
|
||||||
optval = bufinfo.buf;
|
optval = bufinfo.buf;
|
||||||
optlen = bufinfo.len;
|
optlen = bufinfo.len;
|
||||||
|
|
Loading…
Reference in New Issue