mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 12:40:15 +01:00
all: Simplify buffer protocol to just a "get buffer" callback.
The buffer protocol type only has a single member, and this existing layout creates problems for the upcoming split/slot-index mp_obj_type_t layout optimisations. If we need to make the buffer protocol more sophisticated in the future either we can rely on the mp_obj_type_t optimisations to just add additional slots to mp_obj_type_t or re-visit the buffer protocol then. This change is a no-op in terms of generated code. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
committed by
Damien George
parent
ca51d63c37
commit
fb2a57800a
@@ -55,7 +55,6 @@ const mp_obj_type_t microbit_repeat_iterator_type = {
|
||||
.subscr = NULL,
|
||||
.getiter = mp_identity_getiter,
|
||||
.iternext = microbit_repeat_iter_next,
|
||||
.buffer_p = {NULL},
|
||||
MP_OBJ_NULL
|
||||
};
|
||||
|
||||
|
||||
@@ -554,7 +554,6 @@ const mp_obj_type_t microbit_display_type = {
|
||||
.subscr = NULL,
|
||||
.getiter = NULL,
|
||||
.iternext = NULL,
|
||||
.buffer_p = {NULL},
|
||||
.locals_dict = (mp_obj_dict_t*)µbit_display_locals_dict,
|
||||
};
|
||||
|
||||
|
||||
@@ -690,7 +690,6 @@ const mp_obj_type_t microbit_image_type = {
|
||||
.subscr = NULL,
|
||||
.getiter = NULL,
|
||||
.iternext = NULL,
|
||||
.buffer_p = {NULL},
|
||||
.locals_dict = (mp_obj_dict_t*)µbit_image_locals_dict,
|
||||
};
|
||||
|
||||
|
||||
@@ -505,10 +505,10 @@ STATIC mp_obj_t ffifunc_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const
|
||||
} else if (mp_obj_is_str(a)) {
|
||||
const char *s = mp_obj_str_get_str(a);
|
||||
values[i].ffi = (ffi_arg)(intptr_t)s;
|
||||
} else if (((mp_obj_base_t *)MP_OBJ_TO_PTR(a))->type->buffer_p.get_buffer != NULL) {
|
||||
} else if (((mp_obj_base_t *)MP_OBJ_TO_PTR(a))->type->buffer != NULL) {
|
||||
mp_obj_base_t *o = (mp_obj_base_t *)MP_OBJ_TO_PTR(a);
|
||||
mp_buffer_info_t bufinfo;
|
||||
int ret = o->type->buffer_p.get_buffer(MP_OBJ_FROM_PTR(o), &bufinfo, MP_BUFFER_READ); // TODO: MP_BUFFER_READ?
|
||||
int ret = o->type->buffer(MP_OBJ_FROM_PTR(o), &bufinfo, MP_BUFFER_READ); // TODO: MP_BUFFER_READ?
|
||||
if (ret != 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user