Commit 2801e6fa authored by Damien George's avatar Damien George
Browse files

py: Some trivial cosmetic changes, for code style consistency.

parent 7f59b4b2
...@@ -136,7 +136,7 @@ STATIC void mp_map_rehash(mp_map_t *map) { ...@@ -136,7 +136,7 @@ STATIC void mp_map_rehash(mp_map_t *map) {
// - returns slot, with key non-null and value=MP_OBJ_NULL if it was added // - returns slot, with key non-null and value=MP_OBJ_NULL if it was added
// MP_MAP_LOOKUP_REMOVE_IF_FOUND behaviour: // MP_MAP_LOOKUP_REMOVE_IF_FOUND behaviour:
// - returns NULL if not found, else the slot if was found in with key null and value non-null // - returns NULL if not found, else the slot if was found in with key null and value non-null
mp_map_elem_t* mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) { mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind) {
// Work out if we can compare just pointers // Work out if we can compare just pointers
bool compare_only_ptrs = map->all_keys_are_qstrs; bool compare_only_ptrs = map->all_keys_are_qstrs;
......
...@@ -224,7 +224,7 @@ void mp_map_init_fixed_table(mp_map_t *map, mp_uint_t n, const mp_obj_t *table); ...@@ -224,7 +224,7 @@ void mp_map_init_fixed_table(mp_map_t *map, mp_uint_t n, const mp_obj_t *table);
mp_map_t *mp_map_new(mp_uint_t n); mp_map_t *mp_map_new(mp_uint_t n);
void mp_map_deinit(mp_map_t *map); void mp_map_deinit(mp_map_t *map);
void mp_map_free(mp_map_t *map); void mp_map_free(mp_map_t *map);
mp_map_elem_t* mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind); mp_map_elem_t *mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind);
void mp_map_clear(mp_map_t *map); void mp_map_clear(mp_map_t *map);
void mp_map_dump(mp_map_t *map); void mp_map_dump(mp_map_t *map);
...@@ -511,7 +511,7 @@ void mp_obj_get_array_fixed_n(mp_obj_t o, mp_uint_t len, mp_obj_t **items); ...@@ -511,7 +511,7 @@ void mp_obj_get_array_fixed_n(mp_obj_t o, mp_uint_t len, mp_obj_t **items);
mp_uint_t mp_get_index(const mp_obj_type_t *type, mp_uint_t len, mp_obj_t index, bool is_slice); mp_uint_t mp_get_index(const mp_obj_type_t *type, mp_uint_t len, mp_obj_t index, bool is_slice);
mp_obj_t mp_obj_id(mp_obj_t o_in); mp_obj_t mp_obj_id(mp_obj_t o_in);
mp_obj_t mp_obj_len(mp_obj_t o_in); mp_obj_t mp_obj_len(mp_obj_t o_in);
mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); /* may return MP_OBJ_NULL */ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); // may return MP_OBJ_NULL
mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val); mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val);
// bool // bool
......
...@@ -79,7 +79,7 @@ STATIC void bound_meth_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) { ...@@ -79,7 +79,7 @@ STATIC void bound_meth_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
} }
#endif #endif
const mp_obj_type_t bound_meth_type = { STATIC const mp_obj_type_t mp_type_bound_meth = {
{ &mp_type_type }, { &mp_type_type },
.name = MP_QSTR_bound_method, .name = MP_QSTR_bound_method,
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
...@@ -93,7 +93,7 @@ const mp_obj_type_t bound_meth_type = { ...@@ -93,7 +93,7 @@ const mp_obj_type_t bound_meth_type = {
mp_obj_t mp_obj_new_bound_meth(mp_obj_t meth, mp_obj_t self) { mp_obj_t mp_obj_new_bound_meth(mp_obj_t meth, mp_obj_t self) {
mp_obj_bound_meth_t *o = m_new_obj(mp_obj_bound_meth_t); mp_obj_bound_meth_t *o = m_new_obj(mp_obj_bound_meth_t);
o->base.type = &bound_meth_type; o->base.type = &mp_type_bound_meth;
o->meth = meth; o->meth = meth;
o->self = self; o->self = self;
return o; return o;
......
...@@ -55,7 +55,7 @@ STATIC void cell_print(void (*print)(void *env, const char *fmt, ...), void *env ...@@ -55,7 +55,7 @@ STATIC void cell_print(void (*print)(void *env, const char *fmt, ...), void *env
} }
#endif #endif
const mp_obj_type_t cell_type = { STATIC const mp_obj_type_t mp_type_cell = {
{ &mp_type_type }, { &mp_type_type },
.name = MP_QSTR_, // cell representation is just value in < > .name = MP_QSTR_, // cell representation is just value in < >
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
...@@ -65,7 +65,7 @@ const mp_obj_type_t cell_type = { ...@@ -65,7 +65,7 @@ const mp_obj_type_t cell_type = {
mp_obj_t mp_obj_new_cell(mp_obj_t obj) { mp_obj_t mp_obj_new_cell(mp_obj_t obj) {
mp_obj_cell_t *o = m_new_obj(mp_obj_cell_t); mp_obj_cell_t *o = m_new_obj(mp_obj_cell_t);
o->base.type = &cell_type; o->base.type = &mp_type_cell;
o->obj = obj; o->obj = obj;
return o; return o;
} }
...@@ -61,7 +61,7 @@ STATIC const mp_obj_type_t it_type = { ...@@ -61,7 +61,7 @@ STATIC const mp_obj_type_t it_type = {
{ &mp_type_type }, { &mp_type_type },
.name = MP_QSTR_iterator, .name = MP_QSTR_iterator,
.getiter = mp_identity, .getiter = mp_identity,
.iternext = it_iternext .iternext = it_iternext,
}; };
// args are those returned from mp_load_method_maybe (ie either an attribute or a method) // args are those returned from mp_load_method_maybe (ie either an attribute or a method)
......
...@@ -789,7 +789,7 @@ STATIC mp_obj_t str_rstrip(mp_uint_t n_args, const mp_obj_t *args) { ...@@ -789,7 +789,7 @@ STATIC mp_obj_t str_rstrip(mp_uint_t n_args, const mp_obj_t *args) {
// Takes an int arg, but only parses unsigned numbers, and only changes // Takes an int arg, but only parses unsigned numbers, and only changes
// *num if at least one digit was parsed. // *num if at least one digit was parsed.
static int str_to_int(const char *str, int *num) { STATIC int str_to_int(const char *str, int *num) {
const char *s = str; const char *s = str;
if ('0' <= *s && *s <= '9') { if ('0' <= *s && *s <= '9') {
*num = 0; *num = 0;
...@@ -802,19 +802,19 @@ static int str_to_int(const char *str, int *num) { ...@@ -802,19 +802,19 @@ static int str_to_int(const char *str, int *num) {
return s - str; return s - str;
} }
static bool isalignment(char ch) { STATIC bool isalignment(char ch) {
return ch && strchr("<>=^", ch) != NULL; return ch && strchr("<>=^", ch) != NULL;
} }
static bool istype(char ch) { STATIC bool istype(char ch) {
return ch && strchr("bcdeEfFgGnosxX%", ch) != NULL; return ch && strchr("bcdeEfFgGnosxX%", ch) != NULL;
} }
static bool arg_looks_integer(mp_obj_t arg) { STATIC bool arg_looks_integer(mp_obj_t arg) {
return MP_OBJ_IS_TYPE(arg, &mp_type_bool) || MP_OBJ_IS_INT(arg); return MP_OBJ_IS_TYPE(arg, &mp_type_bool) || MP_OBJ_IS_INT(arg);
} }
static bool arg_looks_numeric(mp_obj_t arg) { STATIC bool arg_looks_numeric(mp_obj_t arg) {
return arg_looks_integer(arg) return arg_looks_integer(arg)
#if MICROPY_PY_BUILTINS_FLOAT #if MICROPY_PY_BUILTINS_FLOAT
|| MP_OBJ_IS_TYPE(arg, &mp_type_float) || MP_OBJ_IS_TYPE(arg, &mp_type_float)
...@@ -822,7 +822,7 @@ static bool arg_looks_numeric(mp_obj_t arg) { ...@@ -822,7 +822,7 @@ static bool arg_looks_numeric(mp_obj_t arg) {
; ;
} }
static mp_obj_t arg_as_int(mp_obj_t arg) { STATIC mp_obj_t arg_as_int(mp_obj_t arg) {
#if MICROPY_PY_BUILTINS_FLOAT #if MICROPY_PY_BUILTINS_FLOAT
if (MP_OBJ_IS_TYPE(arg, &mp_type_float)) { if (MP_OBJ_IS_TYPE(arg, &mp_type_float)) {
return mp_obj_new_int_from_float(mp_obj_get_float(arg)); return mp_obj_new_int_from_float(mp_obj_get_float(arg));
......
...@@ -1051,11 +1051,11 @@ STATIC mp_obj_t static_class_method_make_new(mp_obj_t self_in, mp_uint_t n_args, ...@@ -1051,11 +1051,11 @@ STATIC mp_obj_t static_class_method_make_new(mp_obj_t self_in, mp_uint_t n_args,
const mp_obj_type_t mp_type_staticmethod = { const mp_obj_type_t mp_type_staticmethod = {
{ &mp_type_type }, { &mp_type_type },
.name = MP_QSTR_staticmethod, .name = MP_QSTR_staticmethod,
.make_new = static_class_method_make_new .make_new = static_class_method_make_new,
}; };
const mp_obj_type_t mp_type_classmethod = { const mp_obj_type_t mp_type_classmethod = {
{ &mp_type_type }, { &mp_type_type },
.name = MP_QSTR_classmethod, .name = MP_QSTR_classmethod,
.make_new = static_class_method_make_new .make_new = static_class_method_make_new,
}; };
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
static const char pad_spaces[] = " "; static const char pad_spaces[] = " ";
static const char pad_zeroes[] = "0000000000000000"; static const char pad_zeroes[] = "0000000000000000";
void pfenv_vstr_add_strn(void *data, const char *str, mp_uint_t len){ void pfenv_vstr_add_strn(void *data, const char *str, mp_uint_t len) {
vstr_add_strn(data, str, len); vstr_add_strn(data, str, len);
} }
......
...@@ -67,9 +67,9 @@ byte* qstr_build_start(mp_uint_t len, byte **q_ptr); ...@@ -67,9 +67,9 @@ byte* qstr_build_start(mp_uint_t len, byte **q_ptr);
qstr qstr_build_end(byte *q_ptr); qstr qstr_build_end(byte *q_ptr);
mp_uint_t qstr_hash(qstr q); mp_uint_t qstr_hash(qstr q);
const char* qstr_str(qstr q); const char *qstr_str(qstr q);
mp_uint_t qstr_len(qstr q); mp_uint_t qstr_len(qstr q);
const byte* qstr_data(qstr q, mp_uint_t *len); const byte *qstr_data(qstr q, mp_uint_t *len);
void qstr_pool_info(mp_uint_t *n_pool, mp_uint_t *n_qstr, mp_uint_t *n_str_data_bytes, mp_uint_t *n_total_bytes); void qstr_pool_info(mp_uint_t *n_pool, mp_uint_t *n_qstr, mp_uint_t *n_str_data_bytes, mp_uint_t *n_total_bytes);
void qstr_dump_data(void); void qstr_dump_data(void);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment