py: Change all uint to mp_uint_t in obj.h.

Part of code cleanup, working towards resolving issue #50.
This commit is contained in:
Damien George 2014-08-30 14:19:41 +01:00
parent 9c4cbe2ac0
commit d182b98a37
17 changed files with 71 additions and 96 deletions

View File

@ -46,7 +46,7 @@
// args[0] is function from class body // args[0] is function from class body
// args[1] is class name // args[1] is class name
// args[2:] are base objects // args[2:] are base objects
STATIC mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t mp_builtin___build_class__(mp_uint_t n_args, const mp_obj_t *args) {
assert(2 <= n_args); assert(2 <= n_args);
// set the new classes __locals__ object // set the new classes __locals__ object
@ -86,7 +86,6 @@ STATIC mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) {
return new_class; return new_class;
} }
MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin___build_class___obj, 2, mp_builtin___build_class__); MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin___build_class___obj, 2, mp_builtin___build_class__);
STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) { STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
@ -96,7 +95,6 @@ STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
} }
return mp_const_none; return mp_const_none;
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin___repl_print___obj, mp_builtin___repl_print__); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin___repl_print___obj, mp_builtin___repl_print__);
STATIC mp_obj_t mp_builtin_abs(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
@ -127,7 +125,6 @@ STATIC mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
return mp_const_none; return mp_const_none;
} }
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs);
STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
@ -140,7 +137,6 @@ STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
} }
return mp_const_true; return mp_const_true;
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all);
STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
@ -153,14 +149,12 @@ STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
} }
return mp_const_false; return mp_const_false;
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_any_obj, mp_builtin_any); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_any_obj, mp_builtin_any);
STATIC mp_obj_t mp_builtin_bin(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_bin(mp_obj_t o_in) {
mp_obj_t args[] = { MP_OBJ_NEW_QSTR(MP_QSTR__brace_open__colon__hash_b_brace_close_), o_in }; mp_obj_t args[] = { MP_OBJ_NEW_QSTR(MP_QSTR__brace_open__colon__hash_b_brace_close_), o_in };
return mp_obj_str_format(MP_ARRAY_SIZE(args), args); return mp_obj_str_format(MP_ARRAY_SIZE(args), args);
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_bin_obj, mp_builtin_bin); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_bin_obj, mp_builtin_bin);
STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
@ -170,7 +164,6 @@ STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
return mp_const_false; return mp_const_false;
} }
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable);
STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
@ -209,10 +202,9 @@ STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
} }
#endif #endif
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_chr_obj, mp_builtin_chr); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_chr_obj, mp_builtin_chr);
STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t mp_builtin_dir(mp_uint_t n_args, const mp_obj_t *args) {
// TODO make this function more general and less of a hack // TODO make this function more general and less of a hack
mp_obj_dict_t *dict = NULL; mp_obj_dict_t *dict = NULL;
@ -238,7 +230,7 @@ STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
mp_obj_t dir = mp_obj_new_list(0, NULL); mp_obj_t dir = mp_obj_new_list(0, NULL);
if (dict != NULL) { if (dict != NULL) {
for (uint i = 0; i < dict->map.alloc; i++) { for (mp_uint_t i = 0; i < dict->map.alloc; i++) {
if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) { if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) {
mp_obj_list_append(dir, dict->map.table[i].key); mp_obj_list_append(dir, dict->map.table[i].key);
} }
@ -247,7 +239,6 @@ STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
return dir; return dir;
} }
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_dir_obj, 0, 1, mp_builtin_dir); MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_dir_obj, 0, 1, mp_builtin_dir);
STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) { STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
@ -262,29 +253,25 @@ STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "unsupported operand type(s) for divmod(): '%s' and '%s'", mp_obj_get_type_str(o1_in), mp_obj_get_type_str(o2_in))); nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "unsupported operand type(s) for divmod(): '%s' and '%s'", mp_obj_get_type_str(o1_in), mp_obj_get_type_str(o2_in)));
} }
} }
MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_divmod_obj, mp_builtin_divmod); MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_divmod_obj, mp_builtin_divmod);
STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
// TODO hash will generally overflow small integer; can we safely truncate it? // TODO hash will generally overflow small integer; can we safely truncate it?
return mp_obj_new_int(mp_obj_hash(o_in)); return mp_obj_new_int(mp_obj_hash(o_in));
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hash_obj, mp_builtin_hash); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hash_obj, mp_builtin_hash);
STATIC mp_obj_t mp_builtin_hex(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_hex(mp_obj_t o_in) {
return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_x), o_in); return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_x), o_in);
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex);
STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
return mp_getiter(o_in); return mp_getiter(o_in);
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_iter_obj, mp_builtin_iter); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_iter_obj, mp_builtin_iter);
STATIC mp_obj_t mp_builtin_min_max(uint n_args, const mp_obj_t *args, mp_map_t *kwargs, int op) { STATIC mp_obj_t mp_builtin_min_max(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs, mp_uint_t op) {
mp_map_elem_t *key_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_key), MP_MAP_LOOKUP); mp_map_elem_t *key_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_key), MP_MAP_LOOKUP);
mp_obj_t key_fn = key_elem == NULL ? MP_OBJ_NULL : key_elem->value; mp_obj_t key_fn = key_elem == NULL ? MP_OBJ_NULL : key_elem->value;
if (n_args == 1) { if (n_args == 1) {
@ -319,12 +306,12 @@ STATIC mp_obj_t mp_builtin_min_max(uint n_args, const mp_obj_t *args, mp_map_t *
} }
} }
STATIC mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) { STATIC mp_obj_t mp_builtin_max(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_MORE); return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_MORE);
} }
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_max_obj, 1, mp_builtin_max); MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_max_obj, 1, mp_builtin_max);
STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) { STATIC mp_obj_t mp_builtin_min(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_LESS); return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_LESS);
} }
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_min_obj, 1, mp_builtin_min); MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_min_obj, 1, mp_builtin_min);
@ -337,17 +324,15 @@ STATIC mp_obj_t mp_builtin_next(mp_obj_t o) {
return ret; return ret;
} }
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_next_obj, mp_builtin_next); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_next_obj, mp_builtin_next);
STATIC mp_obj_t mp_builtin_oct(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_oct(mp_obj_t o_in) {
return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_o), o_in); return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_o), o_in);
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_oct_obj, mp_builtin_oct); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_oct_obj, mp_builtin_oct);
STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
uint len; mp_uint_t len;
const char *str = mp_obj_str_get_data(o_in, &len); const char *str = mp_obj_str_get_data(o_in, &len);
#if MICROPY_PY_BUILTINS_STR_UNICODE #if MICROPY_PY_BUILTINS_STR_UNICODE
mp_uint_t charlen = unichar_charlen(str, len); mp_uint_t charlen = unichar_charlen(str, len);
@ -376,26 +361,24 @@ STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
} }
#endif #endif
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord);
STATIC mp_obj_t mp_builtin_pow(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t mp_builtin_pow(mp_uint_t n_args, const mp_obj_t *args) {
assert(2 <= n_args && n_args <= 3); assert(2 <= n_args && n_args <= 3);
switch (n_args) { switch (n_args) {
case 2: return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]); case 2: return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]);
default: return mp_binary_op(MP_BINARY_OP_MODULO, mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]), args[2]); // TODO optimise... default: return mp_binary_op(MP_BINARY_OP_MODULO, mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]), args[2]); // TODO optimise...
} }
} }
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow); MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow);
STATIC mp_obj_t mp_builtin_print(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) { STATIC mp_obj_t mp_builtin_print(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
mp_map_elem_t *sep_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_sep), MP_MAP_LOOKUP); mp_map_elem_t *sep_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_sep), MP_MAP_LOOKUP);
mp_map_elem_t *end_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_end), MP_MAP_LOOKUP); mp_map_elem_t *end_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_end), MP_MAP_LOOKUP);
const char *sep_data = " "; const char *sep_data = " ";
uint sep_len = 1; mp_uint_t sep_len = 1;
const char *end_data = "\n"; const char *end_data = "\n";
uint end_len = 1; mp_uint_t end_len = 1;
if (sep_elem != NULL && sep_elem->value != mp_const_none) { if (sep_elem != NULL && sep_elem->value != mp_const_none) {
sep_data = mp_obj_str_get_data(sep_elem->value, &sep_len); sep_data = mp_obj_str_get_data(sep_elem->value, &sep_len);
} }
@ -434,7 +417,6 @@ STATIC mp_obj_t mp_builtin_print(uint n_args, const mp_obj_t *args, mp_map_t *kw
#endif #endif
return mp_const_none; return mp_const_none;
} }
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_print_obj, 0, mp_builtin_print); MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_print_obj, 0, mp_builtin_print);
STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
@ -447,7 +429,7 @@ STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_repr_obj, mp_builtin_repr); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_repr_obj, mp_builtin_repr);
STATIC mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t mp_builtin_sum(mp_uint_t n_args, const mp_obj_t *args) {
assert(1 <= n_args && n_args <= 2); assert(1 <= n_args && n_args <= 2);
mp_obj_t value; mp_obj_t value;
switch (n_args) { switch (n_args) {
@ -461,10 +443,9 @@ STATIC mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) {
} }
return value; return value;
} }
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj, 1, 2, mp_builtin_sum); MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj, 1, 2, mp_builtin_sum);
STATIC mp_obj_t mp_builtin_sorted(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) { STATIC mp_obj_t mp_builtin_sorted(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
assert(n_args >= 1); assert(n_args >= 1);
if (n_args > 1) { if (n_args > 1) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError,
@ -475,7 +456,6 @@ STATIC mp_obj_t mp_builtin_sorted(uint n_args, const mp_obj_t *args, mp_map_t *k
return self; return self;
} }
MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_sorted_obj, 1, mp_builtin_sorted); MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_sorted_obj, 1, mp_builtin_sorted);
STATIC mp_obj_t mp_builtin_id(mp_obj_t o_in) { STATIC mp_obj_t mp_builtin_id(mp_obj_t o_in) {
@ -495,7 +475,6 @@ STATIC mp_obj_t mp_builtin_id(mp_obj_t o_in) {
return mp_obj_new_int_from_uint((mp_uint_t)id); return mp_obj_new_int_from_uint((mp_uint_t)id);
} }
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_builtin_id); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_builtin_id);
// See mp_load_attr() if making any changes // See mp_load_attr() if making any changes
@ -514,7 +493,7 @@ STATIC inline mp_obj_t mp_load_attr_default(mp_obj_t base, qstr attr, mp_obj_t d
} }
} }
STATIC mp_obj_t mp_builtin_getattr(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t mp_builtin_getattr(mp_uint_t n_args, const mp_obj_t *args) {
mp_obj_t attr = args[1]; mp_obj_t attr = args[1];
if (MP_OBJ_IS_TYPE(attr, &mp_type_str)) { if (MP_OBJ_IS_TYPE(attr, &mp_type_str)) {
attr = mp_obj_str_intern(attr); attr = mp_obj_str_intern(attr);
@ -527,7 +506,6 @@ STATIC mp_obj_t mp_builtin_getattr(uint n_args, const mp_obj_t *args) {
} }
return mp_load_attr_default(args[0], MP_OBJ_QSTR_VALUE(attr), defval); return mp_load_attr_default(args[0], MP_OBJ_QSTR_VALUE(attr), defval);
} }
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_getattr_obj, 2, 3, mp_builtin_getattr); MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_getattr_obj, 2, 3, mp_builtin_getattr);
STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) { STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
@ -542,7 +520,6 @@ STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
return MP_BOOL(dest[0] != MP_OBJ_NULL); return MP_BOOL(dest[0] != MP_OBJ_NULL);
} }
MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_hasattr_obj, mp_builtin_hasattr); MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_hasattr_obj, mp_builtin_hasattr);
// These are defined in terms of MicroPython API functions right away // These are defined in terms of MicroPython API functions right away

View File

@ -41,7 +41,7 @@
#include "builtin.h" #include "builtin.h"
STATIC mp_obj_t parse_compile_execute(mp_obj_t o_in, mp_parse_input_kind_t parse_input_kind) { STATIC mp_obj_t parse_compile_execute(mp_obj_t o_in, mp_parse_input_kind_t parse_input_kind) {
uint str_len; mp_uint_t str_len;
const char *str = mp_obj_str_get_data(o_in, &str_len); const char *str = mp_obj_str_get_data(o_in, &str_len);
// create the lexer // create the lexer

View File

@ -84,7 +84,7 @@ STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *d
// go through each path looking for a directory or file // go through each path looking for a directory or file
for (int i = 0; i < path_num; i++) { for (int i = 0; i < path_num; i++) {
vstr_reset(dest); vstr_reset(dest);
uint p_len; mp_uint_t p_len;
const char *p = mp_obj_str_get_data(path_items[i], &p_len); const char *p = mp_obj_str_get_data(path_items[i], &p_len);
if (p_len > 0) { if (p_len > 0) {
vstr_add_strn(dest, p, p_len); vstr_add_strn(dest, p, p_len);
@ -185,8 +185,8 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
} }
} }
uint mod_len; mp_uint_t mod_len;
const char *mod_str = (const char*)mp_obj_str_get_data(module_name, &mod_len); const char *mod_str = mp_obj_str_get_data(module_name, &mod_len);
if (level != 0) { if (level != 0) {
// What we want to do here is to take name of current module, // What we want to do here is to take name of current module,
@ -204,8 +204,8 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
printf("\n"); printf("\n");
#endif #endif
uint this_name_l; mp_uint_t this_name_l;
const char *this_name = (const char*)mp_obj_str_get_data(this_name_q, &this_name_l); const char *this_name = mp_obj_str_get_data(this_name_q, &this_name_l);
uint dots_seen = 0; uint dots_seen = 0;
const char *p = this_name + this_name_l - 1; const char *p = this_name + this_name_l - 1;
@ -353,5 +353,4 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
// Otherwise, we need to return top-level package // Otherwise, we need to return top-level package
return top_module_obj; return top_module_obj;
} }
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin___import___obj, 1, 5, mp_builtin___import__); MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin___import___obj, 1, 5, mp_builtin___import__);

View File

@ -365,17 +365,17 @@ mp_obj_t mp_obj_new_bool(bool value);
mp_obj_t mp_obj_new_cell(mp_obj_t obj); mp_obj_t mp_obj_new_cell(mp_obj_t obj);
mp_obj_t mp_obj_new_int(mp_int_t value); mp_obj_t mp_obj_new_int(mp_int_t value);
mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value); mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value);
mp_obj_t mp_obj_new_int_from_str_len(const char **str, uint len, bool neg, uint base); mp_obj_t mp_obj_new_int_from_str_len(const char **str, mp_uint_t len, bool neg, mp_uint_t base);
mp_obj_t mp_obj_new_int_from_ll(long long val); // this must return a multi-precision integer object (or raise an overflow exception) mp_obj_t mp_obj_new_int_from_ll(long long val); // this must return a multi-precision integer object (or raise an overflow exception)
mp_obj_t mp_obj_new_str(const char* data, uint len, bool make_qstr_if_not_already); mp_obj_t mp_obj_new_str(const char* data, mp_uint_t len, bool make_qstr_if_not_already);
mp_obj_t mp_obj_new_bytes(const byte* data, uint len); mp_obj_t mp_obj_new_bytes(const byte* data, mp_uint_t len);
#if MICROPY_PY_BUILTINS_FLOAT #if MICROPY_PY_BUILTINS_FLOAT
mp_obj_t mp_obj_new_float(mp_float_t val); mp_obj_t mp_obj_new_float(mp_float_t val);
mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag); mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag);
#endif #endif
mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type); mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type);
mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg); mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg);
mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, uint n_args, const mp_obj_t *args); mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, mp_uint_t n_args, const mp_obj_t *args);
mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg); mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg);
mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); // counts args by number of % symbols in fmt, excluding %%; can only handle void* sizes (ie no float/double!) mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); // counts args by number of % symbols in fmt, excluding %%; can only handle void* sizes (ie no float/double!)
mp_obj_t mp_obj_new_fun_bc(mp_uint_t scope_flags, qstr *args, mp_uint_t n_pos_args, mp_uint_t n_kwonly_args, mp_obj_t def_args, mp_obj_t def_kw_args, const byte *code); mp_obj_t mp_obj_new_fun_bc(mp_uint_t scope_flags, qstr *args, mp_uint_t n_pos_args, mp_uint_t n_kwonly_args, mp_obj_t def_args, mp_obj_t def_kw_args, const byte *code);
@ -383,7 +383,7 @@ mp_obj_t mp_obj_new_fun_native(mp_uint_t n_args, void *fun_data);
mp_obj_t mp_obj_new_fun_viper(mp_uint_t n_args, void *fun_data, mp_uint_t type_sig); mp_obj_t mp_obj_new_fun_viper(mp_uint_t n_args, void *fun_data, mp_uint_t type_sig);
mp_obj_t mp_obj_new_fun_asm(mp_uint_t n_args, void *fun_data); mp_obj_t mp_obj_new_fun_asm(mp_uint_t n_args, void *fun_data);
mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun); mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun);
mp_obj_t mp_obj_new_closure(mp_obj_t fun, uint n_closed, const mp_obj_t *closed); mp_obj_t mp_obj_new_closure(mp_obj_t fun, mp_uint_t n_closed, const mp_obj_t *closed);
mp_obj_t mp_obj_new_tuple(mp_uint_t n, const mp_obj_t *items); mp_obj_t mp_obj_new_tuple(mp_uint_t n, const mp_obj_t *items);
mp_obj_t mp_obj_new_list(mp_uint_t n, mp_obj_t *items); mp_obj_t mp_obj_new_list(mp_uint_t n, mp_obj_t *items);
mp_obj_t mp_obj_new_dict(mp_uint_t n_args); mp_obj_t mp_obj_new_dict(mp_uint_t n_args);
@ -463,17 +463,17 @@ mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in);
void mp_init_emergency_exception_buf(void); void mp_init_emergency_exception_buf(void);
// str // str
mp_obj_t mp_obj_str_builder_start(const mp_obj_type_t *type, uint len, byte **data); mp_obj_t mp_obj_str_builder_start(const mp_obj_type_t *type, mp_uint_t len, byte **data);
mp_obj_t mp_obj_str_builder_end(mp_obj_t o_in); mp_obj_t mp_obj_str_builder_end(mp_obj_t o_in);
mp_obj_t mp_obj_str_builder_end_with_len(mp_obj_t o_in, mp_uint_t len); mp_obj_t mp_obj_str_builder_end_with_len(mp_obj_t o_in, mp_uint_t len);
bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2); bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2);
uint mp_obj_str_get_hash(mp_obj_t self_in); mp_uint_t mp_obj_str_get_hash(mp_obj_t self_in);
uint mp_obj_str_get_len(mp_obj_t self_in); mp_uint_t mp_obj_str_get_len(mp_obj_t self_in);
qstr mp_obj_str_get_qstr(mp_obj_t self_in); // use this if you will anyway convert the string to a qstr qstr mp_obj_str_get_qstr(mp_obj_t self_in); // use this if you will anyway convert the string to a qstr
const char *mp_obj_str_get_str(mp_obj_t self_in); // use this only if you need the string to be null terminated const char *mp_obj_str_get_str(mp_obj_t self_in); // use this only if you need the string to be null terminated
const char *mp_obj_str_get_data(mp_obj_t self_in, uint *len); const char *mp_obj_str_get_data(mp_obj_t self_in, mp_uint_t *len);
mp_obj_t mp_obj_str_intern(mp_obj_t str); mp_obj_t mp_obj_str_intern(mp_obj_t str);
void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *env, const byte *str_data, uint str_len, bool is_bytes); void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *env, const byte *str_data, mp_uint_t str_len, bool is_bytes);
#if MICROPY_PY_BUILTINS_FLOAT #if MICROPY_PY_BUILTINS_FLOAT
// float // float
@ -522,8 +522,8 @@ void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item);
void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step); void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step);
// array // array
uint mp_obj_array_len(mp_obj_t self_in); mp_uint_t mp_obj_array_len(mp_obj_t self_in);
mp_obj_t mp_obj_new_bytearray_by_ref(uint n, void *items); mp_obj_t mp_obj_new_bytearray_by_ref(mp_uint_t n, void *items);
// functions // functions
#define MP_OBJ_FUN_ARGS_MAX (0xffff) // to set maximum value in n_args_max below #define MP_OBJ_FUN_ARGS_MAX (0xffff) // to set maximum value in n_args_max below
@ -569,17 +569,17 @@ typedef struct {
mp_int_t step; mp_int_t step;
} mp_bound_slice_t; } mp_bound_slice_t;
void mp_seq_multiply(const void *items, uint item_sz, uint len, uint times, void *dest); void mp_seq_multiply(const void *items, mp_uint_t item_sz, mp_uint_t len, mp_uint_t times, void *dest);
#if MICROPY_PY_BUILTINS_SLICE #if MICROPY_PY_BUILTINS_SLICE
bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice_t *indexes); bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice_t *indexes);
#endif #endif
#define mp_seq_copy(dest, src, len, item_t) memcpy(dest, src, len * sizeof(item_t)) #define mp_seq_copy(dest, src, len, item_t) memcpy(dest, src, len * sizeof(item_t))
#define mp_seq_cat(dest, src1, len1, src2, len2, item_t) { memcpy(dest, src1, (len1) * sizeof(item_t)); memcpy(dest + (len1), src2, (len2) * sizeof(item_t)); } #define mp_seq_cat(dest, src1, len1, src2, len2, item_t) { memcpy(dest, src1, (len1) * sizeof(item_t)); memcpy(dest + (len1), src2, (len2) * sizeof(item_t)); }
bool mp_seq_cmp_bytes(int op, const byte *data1, uint len1, const byte *data2, uint len2); bool mp_seq_cmp_bytes(int op, const byte *data1, mp_uint_t len1, const byte *data2, mp_uint_t len2);
bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, uint len1, const mp_obj_t *items2, uint len2); bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, mp_uint_t len1, const mp_obj_t *items2, mp_uint_t len2);
mp_obj_t mp_seq_index_obj(const mp_obj_t *items, uint len, uint n_args, const mp_obj_t *args); mp_obj_t mp_seq_index_obj(const mp_obj_t *items, mp_uint_t len, mp_uint_t n_args, const mp_obj_t *args);
mp_obj_t mp_seq_count_obj(const mp_obj_t *items, uint len, mp_obj_t value); mp_obj_t mp_seq_count_obj(const mp_obj_t *items, mp_uint_t len, mp_obj_t value);
mp_obj_t mp_seq_extract_slice(uint len, const mp_obj_t *seq, mp_bound_slice_t *indexes); mp_obj_t mp_seq_extract_slice(mp_uint_t len, const mp_obj_t *seq, mp_bound_slice_t *indexes);
// Helper to clear stale pointers from allocated, but unused memory, to preclude GC problems // Helper to clear stale pointers from allocated, but unused memory, to preclude GC problems
#define mp_seq_clear(start, len, alloc_len, item_sz) memset((byte*)(start) + (len) * (item_sz), 0, ((alloc_len) - (len)) * (item_sz)) #define mp_seq_clear(start, len, alloc_len, item_sz) memset((byte*)(start) + (len) * (item_sz), 0, ((alloc_len) - (len)) * (item_sz))
#define mp_seq_replace_slice_no_grow(dest, dest_len, beg, end, slice, slice_len, item_t) \ #define mp_seq_replace_slice_no_grow(dest, dest_len, beg, end, slice, slice_len, item_t) \

View File

@ -108,7 +108,7 @@ STATIC mp_obj_t array_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
mp_arg_check_num(n_args, n_kw, 1, 2, false); mp_arg_check_num(n_args, n_kw, 1, 2, false);
// get typecode // get typecode
uint l; mp_uint_t l;
const char *typecode = mp_obj_str_get_data(args[0], &l); const char *typecode = mp_obj_str_get_data(args[0], &l);
if (n_args == 1) { if (n_args == 1) {
@ -277,7 +277,7 @@ STATIC mp_obj_array_t *array_new(char typecode, uint n) {
return o; return o;
} }
uint mp_obj_array_len(mp_obj_t self_in) { mp_uint_t mp_obj_array_len(mp_obj_t self_in) {
return ((mp_obj_array_t *)self_in)->len; return ((mp_obj_array_t *)self_in)->len;
} }
@ -288,7 +288,7 @@ mp_obj_t mp_obj_new_bytearray(uint n, void *items) {
} }
// Create bytearray which references specified memory area // Create bytearray which references specified memory area
mp_obj_t mp_obj_new_bytearray_by_ref(uint n, void *items) { mp_obj_t mp_obj_new_bytearray_by_ref(mp_uint_t n, void *items) {
mp_obj_array_t *o = m_new_obj(mp_obj_array_t); mp_obj_array_t *o = m_new_obj(mp_obj_array_t);
o->base.type = &mp_type_array; o->base.type = &mp_type_array;
o->typecode = BYTEARRAY_TYPECODE; o->typecode = BYTEARRAY_TYPECODE;

View File

@ -89,7 +89,7 @@ const mp_obj_type_t closure_type = {
.call = closure_call, .call = closure_call,
}; };
mp_obj_t mp_obj_new_closure(mp_obj_t fun, uint n_closed_over, const mp_obj_t *closed) { mp_obj_t mp_obj_new_closure(mp_obj_t fun, mp_uint_t n_closed_over, const mp_obj_t *closed) {
mp_obj_closure_t *o = m_new_obj_var(mp_obj_closure_t, mp_obj_t, n_closed_over); mp_obj_closure_t *o = m_new_obj_var(mp_obj_closure_t, mp_obj_t, n_closed_over);
o->base.type = &closure_type; o->base.type = &closure_type;
o->fun = fun; o->fun = fun;

View File

@ -84,7 +84,7 @@ STATIC mp_obj_t complex_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n
case 1: case 1:
if (MP_OBJ_IS_STR(args[0])) { if (MP_OBJ_IS_STR(args[0])) {
// a string, parse it // a string, parse it
uint l; mp_uint_t l;
const char *s = mp_obj_str_get_data(args[0], &l); const char *s = mp_obj_str_get_data(args[0], &l);
return mp_parse_num_decimal(s, l, true, true); return mp_parse_num_decimal(s, l, true, true);
} else if (MP_OBJ_IS_TYPE(args[0], &mp_type_complex)) { } else if (MP_OBJ_IS_TYPE(args[0], &mp_type_complex)) {

View File

@ -296,7 +296,7 @@ mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg)
return mp_obj_new_exception_args(exc_type, 1, &arg); return mp_obj_new_exception_args(exc_type, 1, &arg);
} }
mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, uint n_args, const mp_obj_t *args) { mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, mp_uint_t n_args, const mp_obj_t *args) {
assert(exc_type->make_new == mp_obj_exception_make_new); assert(exc_type->make_new == mp_obj_exception_make_new);
return exc_type->make_new((mp_obj_t)exc_type, n_args, 0, args); return exc_type->make_new((mp_obj_t)exc_type, n_args, 0, args);
} }

View File

@ -77,7 +77,7 @@ STATIC mp_obj_t float_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
default: default:
if (MP_OBJ_IS_STR(args[0])) { if (MP_OBJ_IS_STR(args[0])) {
// a string, parse it // a string, parse it
uint l; mp_uint_t l;
const char *s = mp_obj_str_get_data(args[0], &l); const char *s = mp_obj_str_get_data(args[0], &l);
return mp_parse_num_decimal(s, l, false, false); return mp_parse_num_decimal(s, l, false, false);
} else if (MP_OBJ_IS_TYPE(args[0], &mp_type_float)) { } else if (MP_OBJ_IS_TYPE(args[0], &mp_type_float)) {

View File

@ -60,7 +60,7 @@ STATIC mp_obj_t mp_obj_int_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_
return args[0]; return args[0];
} else if (MP_OBJ_IS_STR_OR_BYTES(args[0])) { } else if (MP_OBJ_IS_STR_OR_BYTES(args[0])) {
// a string, parse it // a string, parse it
uint l; mp_uint_t l;
const char *s = mp_obj_str_get_data(args[0], &l); const char *s = mp_obj_str_get_data(args[0], &l);
return mp_parse_num_integer(s, l, 0); return mp_parse_num_integer(s, l, 0);
#if MICROPY_PY_BUILTINS_FLOAT #if MICROPY_PY_BUILTINS_FLOAT
@ -76,7 +76,7 @@ STATIC mp_obj_t mp_obj_int_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_
default: { default: {
// should be a string, parse it // should be a string, parse it
// TODO proper error checking of argument types // TODO proper error checking of argument types
uint l; mp_uint_t l;
const char *s = mp_obj_str_get_data(args[0], &l); const char *s = mp_obj_str_get_data(args[0], &l);
return mp_parse_num_integer(s, l, mp_obj_get_int(args[1])); return mp_parse_num_integer(s, l, mp_obj_get_int(args[1]));
} }

View File

@ -290,9 +290,9 @@ mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) {
return mp_obj_new_int_from_ll(value); return mp_obj_new_int_from_ll(value);
} }
mp_obj_t mp_obj_new_int_from_str_len(const char **str, uint len, bool neg, uint base) { mp_obj_t mp_obj_new_int_from_str_len(const char **str, mp_uint_t len, bool neg, mp_uint_t base) {
mp_obj_int_t *o = mp_obj_int_new_mpz(); mp_obj_int_t *o = mp_obj_int_new_mpz();
uint n = mpz_set_from_str(&o->mpz, *str, len, neg, base); mp_uint_t n = mpz_set_from_str(&o->mpz, *str, len, neg, base);
*str += n; *str += n;
return o; return o;
} }

View File

@ -53,7 +53,7 @@ STATIC NORETURN void arg_type_mixup();
/* str */ /* str */
void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *env, void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *env,
const byte *str_data, uint str_len, bool is_bytes) { const byte *str_data, mp_uint_t str_len, bool is_bytes) {
// this escapes characters, but it will be very slow to print (calling print many times) // this escapes characters, but it will be very slow to print (calling print many times)
bool has_single_quote = false; bool has_single_quote = false;
bool has_double_quote = false; bool has_double_quote = false;
@ -483,7 +483,7 @@ STATIC mp_obj_t str_split(mp_uint_t n_args, const mp_obj_t *args) {
arg_type_mixup(); arg_type_mixup();
} }
uint sep_len; mp_uint_t sep_len;
const char *sep_str = mp_obj_str_get_data(sep, &sep_len); const char *sep_str = mp_obj_str_get_data(sep, &sep_len);
if (sep_len == 0) { if (sep_len == 0) {
@ -535,7 +535,7 @@ STATIC mp_obj_t str_rsplit(mp_uint_t n_args, const mp_obj_t *args) {
if (sep == mp_const_none) { if (sep == mp_const_none) {
assert(!"TODO: rsplit(None,n) not implemented"); assert(!"TODO: rsplit(None,n) not implemented");
} else { } else {
uint sep_len; mp_uint_t sep_len;
const char *sep_str = mp_obj_str_get_data(sep, &sep_len); const char *sep_str = mp_obj_str_get_data(sep, &sep_len);
if (sep_len == 0) { if (sep_len == 0) {
@ -1121,9 +1121,8 @@ mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args) {
mp_obj_print_helper((void (*)(void*, const char*, ...))vstr_printf, vstr, arg, PRINT_STR); mp_obj_print_helper((void (*)(void*, const char*, ...))vstr_printf, vstr, arg, PRINT_STR);
break; break;
case 's': case 's': {
{ mp_uint_t len;
uint len;
const char *s = mp_obj_str_get_data(arg, &len); const char *s = mp_obj_str_get_data(arg, &len);
if (precision < 0) { if (precision < 0) {
precision = len; precision = len;
@ -1249,7 +1248,7 @@ not_enough_args:
switch (*str) { switch (*str) {
case 'c': case 'c':
if (MP_OBJ_IS_STR(arg)) { if (MP_OBJ_IS_STR(arg)) {
uint len; mp_uint_t len;
const char *s = mp_obj_str_get_data(arg, &len); const char *s = mp_obj_str_get_data(arg, &len);
if (len != 1) { if (len != 1) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "%%c requires int or char")); nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "%%c requires int or char"));
@ -1735,7 +1734,7 @@ const mp_obj_type_t mp_type_bytes = {
STATIC const mp_obj_str_t empty_bytes_obj = {{&mp_type_bytes}, 0, 0, NULL}; STATIC const mp_obj_str_t empty_bytes_obj = {{&mp_type_bytes}, 0, 0, NULL};
const mp_obj_t mp_const_empty_bytes = (mp_obj_t)&empty_bytes_obj; const mp_obj_t mp_const_empty_bytes = (mp_obj_t)&empty_bytes_obj;
mp_obj_t mp_obj_str_builder_start(const mp_obj_type_t *type, uint len, byte **data) { mp_obj_t mp_obj_str_builder_start(const mp_obj_type_t *type, mp_uint_t len, byte **data) {
mp_obj_str_t *o = m_new_obj(mp_obj_str_t); mp_obj_str_t *o = m_new_obj(mp_obj_str_t);
o->base.type = type; o->base.type = type;
o->len = len; o->len = len;
@ -1778,7 +1777,7 @@ mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, uin
return o; return o;
} }
mp_obj_t mp_obj_new_str(const char* data, uint len, bool make_qstr_if_not_already) { mp_obj_t mp_obj_new_str(const char* data, mp_uint_t len, bool make_qstr_if_not_already) {
if (make_qstr_if_not_already) { if (make_qstr_if_not_already) {
// use existing, or make a new qstr // use existing, or make a new qstr
return MP_OBJ_NEW_QSTR(qstr_from_strn(data, len)); return MP_OBJ_NEW_QSTR(qstr_from_strn(data, len));
@ -1799,7 +1798,7 @@ mp_obj_t mp_obj_str_intern(mp_obj_t str) {
return MP_OBJ_NEW_QSTR(qstr_from_strn((const char*)data, len)); return MP_OBJ_NEW_QSTR(qstr_from_strn((const char*)data, len));
} }
mp_obj_t mp_obj_new_bytes(const byte* data, uint len) { mp_obj_t mp_obj_new_bytes(const byte* data, mp_uint_t len) {
return mp_obj_new_str_of_type(&mp_type_bytes, data, len); return mp_obj_new_str_of_type(&mp_type_bytes, data, len);
} }
@ -1830,7 +1829,7 @@ STATIC void arg_type_mixup() {
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "Can't mix str and bytes arguments")); nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "Can't mix str and bytes arguments"));
} }
uint mp_obj_str_get_hash(mp_obj_t self_in) { mp_uint_t mp_obj_str_get_hash(mp_obj_t self_in) {
// TODO: This has too big overhead for hash accessor // TODO: This has too big overhead for hash accessor
if (MP_OBJ_IS_STR(self_in) || MP_OBJ_IS_TYPE(self_in, &mp_type_bytes)) { if (MP_OBJ_IS_STR(self_in) || MP_OBJ_IS_TYPE(self_in, &mp_type_bytes)) {
GET_STR_HASH(self_in, h); GET_STR_HASH(self_in, h);
@ -1840,7 +1839,7 @@ uint mp_obj_str_get_hash(mp_obj_t self_in) {
} }
} }
uint mp_obj_str_get_len(mp_obj_t self_in) { mp_uint_t mp_obj_str_get_len(mp_obj_t self_in) {
// TODO This has a double check for the type, one in obj.c and one here // TODO This has a double check for the type, one in obj.c and one here
if (MP_OBJ_IS_STR(self_in) || MP_OBJ_IS_TYPE(self_in, &mp_type_bytes)) { if (MP_OBJ_IS_STR(self_in) || MP_OBJ_IS_TYPE(self_in, &mp_type_bytes)) {
GET_STR_LEN(self_in, l); GET_STR_LEN(self_in, l);
@ -1875,7 +1874,7 @@ const char *mp_obj_str_get_str(mp_obj_t self_in) {
} }
} }
const char *mp_obj_str_get_data(mp_obj_t self_in, uint *len) { const char *mp_obj_str_get_data(mp_obj_t self_in, mp_uint_t *len) {
if (MP_OBJ_IS_STR_OR_BYTES(self_in)) { if (MP_OBJ_IS_STR_OR_BYTES(self_in)) {
GET_STR_DATA_LEN(self_in, s, l); GET_STR_DATA_LEN(self_in, s, l);
*len = l; *len = l;

View File

@ -1094,7 +1094,7 @@ import_error:
} }
mp_load_method_maybe(module, MP_QSTR___name__, dest); mp_load_method_maybe(module, MP_QSTR___name__, dest);
uint pkg_name_len; mp_uint_t pkg_name_len;
const char *pkg_name = mp_obj_str_get_data(dest[0], &pkg_name_len); const char *pkg_name = mp_obj_str_get_data(dest[0], &pkg_name_len);
const uint dot_name_len = pkg_name_len + 1 + qstr_len(name); const uint dot_name_len = pkg_name_len + 1 + qstr_len(name);

View File

@ -43,7 +43,7 @@
// Implements backend of sequence * integer operation. Assumes elements are // Implements backend of sequence * integer operation. Assumes elements are
// memory-adjacent in sequence. // memory-adjacent in sequence.
void mp_seq_multiply(const void *items, uint item_sz, uint len, uint times, void *dest) { void mp_seq_multiply(const void *items, mp_uint_t item_sz, mp_uint_t len, mp_uint_t times, void *dest) {
for (int i = 0; i < times; i++) { for (int i = 0; i < times; i++) {
uint copy_sz = item_sz * len; uint copy_sz = item_sz * len;
memcpy(dest, items, copy_sz); memcpy(dest, items, copy_sz);
@ -102,7 +102,7 @@ bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice
#endif #endif
mp_obj_t mp_seq_extract_slice(uint len, const mp_obj_t *seq, mp_bound_slice_t *indexes) { mp_obj_t mp_seq_extract_slice(mp_uint_t len, const mp_obj_t *seq, mp_bound_slice_t *indexes) {
mp_int_t start = indexes->start, stop = indexes->stop; mp_int_t start = indexes->start, stop = indexes->stop;
mp_int_t step = indexes->step; mp_int_t step = indexes->step;
@ -125,7 +125,7 @@ mp_obj_t mp_seq_extract_slice(uint len, const mp_obj_t *seq, mp_bound_slice_t *i
// Special-case comparison function for sequences of bytes // Special-case comparison function for sequences of bytes
// Don't pass MP_BINARY_OP_NOT_EQUAL here // Don't pass MP_BINARY_OP_NOT_EQUAL here
bool mp_seq_cmp_bytes(int op, const byte *data1, uint len1, const byte *data2, uint len2) { bool mp_seq_cmp_bytes(int op, const byte *data1, mp_uint_t len1, const byte *data2, mp_uint_t len2) {
if (op == MP_BINARY_OP_EQUAL && len1 != len2) { if (op == MP_BINARY_OP_EQUAL && len1 != len2) {
return false; return false;
} }
@ -169,7 +169,7 @@ bool mp_seq_cmp_bytes(int op, const byte *data1, uint len1, const byte *data2, u
// Special-case comparison function for sequences of mp_obj_t // Special-case comparison function for sequences of mp_obj_t
// Don't pass MP_BINARY_OP_NOT_EQUAL here // Don't pass MP_BINARY_OP_NOT_EQUAL here
bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, uint len1, const mp_obj_t *items2, uint len2) { bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, mp_uint_t len1, const mp_obj_t *items2, mp_uint_t len2) {
if (op == MP_BINARY_OP_EQUAL && len1 != len2) { if (op == MP_BINARY_OP_EQUAL && len1 != len2) {
return false; return false;
} }
@ -218,7 +218,7 @@ bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, uint len1, const mp_obj_t *
} }
// Special-case of index() which searches for mp_obj_t // Special-case of index() which searches for mp_obj_t
mp_obj_t mp_seq_index_obj(const mp_obj_t *items, uint len, uint n_args, const mp_obj_t *args) { mp_obj_t mp_seq_index_obj(const mp_obj_t *items, mp_uint_t len, mp_uint_t n_args, const mp_obj_t *args) {
mp_obj_type_t *type = mp_obj_get_type(args[0]); mp_obj_type_t *type = mp_obj_get_type(args[0]);
mp_obj_t *value = args[1]; mp_obj_t *value = args[1];
uint start = 0; uint start = 0;
@ -241,7 +241,7 @@ mp_obj_t mp_seq_index_obj(const mp_obj_t *items, uint len, uint n_args, const mp
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "object not in sequence")); nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "object not in sequence"));
} }
mp_obj_t mp_seq_count_obj(const mp_obj_t *items, uint len, mp_obj_t value) { mp_obj_t mp_seq_count_obj(const mp_obj_t *items, mp_uint_t len, mp_obj_t value) {
mp_uint_t count = 0; mp_uint_t count = 0;
for (uint i = 0; i < len; i++) { for (uint i = 0; i < len; i++) {
if (mp_obj_equal(items[i], value)) { if (mp_obj_equal(items[i], value)) {

View File

@ -124,7 +124,7 @@ STATIC ffi_type *char2ffi_type(char c)
STATIC ffi_type *get_ffi_type(mp_obj_t o_in) STATIC ffi_type *get_ffi_type(mp_obj_t o_in)
{ {
if (MP_OBJ_IS_STR(o_in)) { if (MP_OBJ_IS_STR(o_in)) {
uint len; mp_uint_t len;
const char *s = mp_obj_str_get_data(o_in, &len); const char *s = mp_obj_str_get_data(o_in, &len);
ffi_type *t = char2ffi_type(*s); ffi_type *t = char2ffi_type(*s);
if (t != NULL) { if (t != NULL) {

View File

@ -44,7 +44,7 @@
STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) { STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) {
struct stat sb; struct stat sb;
uint len; mp_uint_t len;
const char *path = mp_obj_str_get_data(path_in, &len); const char *path = mp_obj_str_get_data(path_in, &len);
int res = stat(path, &sb); int res = stat(path, &sb);

View File

@ -88,7 +88,7 @@ STATIC mp_obj_t mod_termios_tcsetattr(mp_obj_t fd_in, mp_obj_t when_in, mp_obj_t
if (i == VMIN || i == VTIME) { if (i == VMIN || i == VTIME) {
term.c_cc[i] = mp_obj_get_int(cc->items[i]); term.c_cc[i] = mp_obj_get_int(cc->items[i]);
} else { } else {
uint len; mp_uint_t len;
term.c_cc[i] = *mp_obj_str_get_data(cc->items[i], &len); term.c_cc[i] = *mp_obj_str_get_data(cc->items[i], &len);
} }
} }