Browse Source

nrf: Change types to size_t for all uses of mp_obj_str_get_data.

pull/4788/head
Damien George 6 years ago
parent
commit
7e21cf723a
  1. 6
      ports/nrf/boards/microbit/modules/microbitdisplay.c
  2. 6
      ports/nrf/boards/microbit/modules/microbitimage.c
  3. 2
      ports/nrf/modules/music/modmusic.c
  4. 8
      ports/nrf/modules/uos/microbitfs.c

6
ports/nrf/boards/microbit/modules/microbitdisplay.c

@ -90,7 +90,7 @@ mp_obj_t microbit_display_show_func(mp_uint_t n_args, const mp_obj_t *pos_args,
if (mp_obj_is_str(image)) {
// arg is a string object
mp_uint_t len;
size_t len;
const char *str = mp_obj_str_get_data(image, &len);
if (len == 0) {
// There are no chars; do nothing.
@ -297,7 +297,7 @@ static void draw_object(mp_obj_t obj) {
} else if (mp_obj_get_type(obj) == &microbit_image_type) {
microbit_display_show(display, (microbit_image_obj_t *)obj);
} else if (mp_obj_is_str(obj)) {
mp_uint_t len;
size_t len;
const char *str = mp_obj_str_get_data(obj, &len);
if (len == 1) {
microbit_display_show(display, microbit_image_for_char(str[0]));
@ -415,7 +415,7 @@ mp_obj_t microbit_display_scroll_func(mp_uint_t n_args, const mp_obj_t *pos_args
microbit_display_obj_t *self = (microbit_display_obj_t*)pos_args[0];
mp_arg_val_t args[MP_ARRAY_SIZE(scroll_allowed_args)];
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(scroll_allowed_args), scroll_allowed_args, args);
mp_uint_t len;
size_t len;
const char* str = mp_obj_str_get_data(args[0].u_obj, &len);
mp_obj_t iterable = scrolling_string_image_iterable(str, len, args[0].u_obj, args[3].u_bool /*monospace?*/, args[4].u_bool /*loop*/);
microbit_display_animate(self, iterable, args[1].u_int /*delay*/, false/*clear*/, args[2].u_bool/*wait?*/);

6
ports/nrf/boards/microbit/modules/microbitimage.c

@ -216,7 +216,7 @@ STATIC mp_obj_t microbit_image_make_new(const mp_obj_type_t *type_in, mp_uint_t
case 1: {
if (mp_obj_is_str(args[0])) {
// arg is a string object
mp_uint_t len;
size_t len;
const char *str = mp_obj_str_get_data(args[0], &len);
// make image from string
if (len == 1) {
@ -880,7 +880,7 @@ static mp_obj_t string_image_facade_subscr(mp_obj_t self_in, mp_obj_t index_in,
if (value == MP_OBJ_SENTINEL) {
// Fill in image
string_image_facade_t *self = (string_image_facade_t *)self_in;
mp_uint_t len;
size_t len;
const char *text = mp_obj_str_get_data(self->string, &len);
mp_uint_t index = mp_get_index(self->base.type, len, index_in, false);
microbit_image_set_from_char(self->image, text[index]);
@ -935,7 +935,7 @@ mp_obj_t microbit_string_facade(mp_obj_t string) {
static mp_obj_t microbit_facade_iter_next(mp_obj_t iter_in) {
facade_iterator_t *iter = (facade_iterator_t *)iter_in;
mp_uint_t len;
size_t len;
const char *text = mp_obj_str_get_data(iter->string, &len);
if (iter->index >= len) {
return MP_OBJ_STOP_ITERATION;

2
ports/nrf/modules/music/modmusic.c

@ -126,7 +126,7 @@ void microbit_music_tick(void) {
music_data->async_state = ASYNC_MUSIC_STATE_NEXT_NOTE;
} else {
// a note
mp_uint_t note_len;
size_t note_len;
const char *note_str = mp_obj_str_get_data(note, &note_len);
uint32_t delay_on = start_note(note_str, note_len, music_data->async_pin);
music_data->async_wait_ticks = ticks + delay_on;

8
ports/nrf/modules/uos/microbitfs.c

@ -377,7 +377,7 @@ STATIC file_descriptor_obj *microbit_file_descriptor_new(uint8_t start_chunk, bo
}
STATIC mp_obj_t microbit_remove(mp_obj_t filename) {
mp_uint_t name_len;
size_t name_len;
const char *name = mp_obj_str_get_data(filename, &name_len);
mp_uint_t index = microbit_find_file(name, name_len);
if (index == 255) {
@ -487,7 +487,7 @@ STATIC mp_obj_t microbit_file_list(void) {
}
STATIC mp_obj_t microbit_file_size(mp_obj_t filename) {
mp_uint_t name_len;
size_t name_len;
const char *name = mp_obj_str_get_data(filename, &name_len);
uint8_t chunk = microbit_find_file(name, name_len);
if (chunk == 255) {
@ -659,7 +659,7 @@ mp_obj_t uos_mbfs_open(size_t n_args, const mp_obj_t *args) {
int read = -1;
int text = -1;
if (n_args == 2) {
mp_uint_t len;
size_t len;
const char *mode = mp_obj_str_get_data(args[1], &len);
for (mp_uint_t i = 0; i < len; i++) {
if (mode[i] == 'r' || mode[i] == 'w') {
@ -677,7 +677,7 @@ mp_obj_t uos_mbfs_open(size_t n_args, const mp_obj_t *args) {
}
}
}
mp_uint_t name_len;
size_t name_len;
const char *filename = mp_obj_str_get_data(args[0], &name_len);
file_descriptor_obj *res = microbit_file_open(filename, name_len, read == 0, text == 0);
if (res == NULL) {

Loading…
Cancel
Save