Commit d5df6cd4 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

Replace global "static" -> "STATIC", to allow "analysis builds". Part 1.

Some tools do not support local/static symbols (one example is GNU ld map file).
Exposing all functions will allow to do detailed size comparisons, etc.

Also, added bunch of statics where they were missing, and replaced few identity
functions with global mp_identity().
parent 1d1e38d9
...@@ -110,6 +110,12 @@ typedef long long mp_longint_impl_t; ...@@ -110,6 +110,12 @@ typedef long long mp_longint_impl_t;
/*****************************************************************************/ /*****************************************************************************/
/* Miscellaneous settings */ /* Miscellaneous settings */
// Allow to override static modifier for global objects, e.g. to use with
// object code analysis tools which don't support static symbols.
#ifndef STATIC
#define STATIC static
#endif
#define BITS_PER_BYTE (8) #define BITS_PER_BYTE (8)
#define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD) #define BITS_PER_WORD (BITS_PER_BYTE * BYTES_PER_WORD)
// machine_int_t value with most significant bit set // machine_int_t value with most significant bit set
......
...@@ -29,14 +29,14 @@ typedef struct _mp_obj_array_t { ...@@ -29,14 +29,14 @@ typedef struct _mp_obj_array_t {
void *items; void *items;
} mp_obj_array_t; } mp_obj_array_t;
static mp_obj_t array_iterator_new(mp_obj_t array_in); STATIC mp_obj_t array_iterator_new(mp_obj_t array_in);
static mp_obj_array_t *array_new(char typecode, uint n); STATIC mp_obj_array_t *array_new(char typecode, uint n);
static mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg); STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg);
/******************************************************************************/ /******************************************************************************/
/* array */ /* array */
static machine_int_t array_get_el_size(char typecode) { STATIC machine_int_t array_get_el_size(char typecode) {
// This assumes that unsigned and signed types are of the same type, // This assumes that unsigned and signed types are of the same type,
// which is invariant for [u]intN_t. // which is invariant for [u]intN_t.
switch (typecode) { switch (typecode) {
...@@ -57,7 +57,7 @@ static machine_int_t array_get_el_size(char typecode) { ...@@ -57,7 +57,7 @@ static machine_int_t array_get_el_size(char typecode) {
return -1; return -1;
} }
static machine_int_t array_get_el(mp_obj_array_t *o, int index) { STATIC machine_int_t array_get_el(mp_obj_array_t *o, int index) {
machine_int_t val = 0; machine_int_t val = 0;
switch (o->typecode) { switch (o->typecode) {
case 'b': case 'b':
...@@ -89,7 +89,7 @@ static machine_int_t array_get_el(mp_obj_array_t *o, int index) { ...@@ -89,7 +89,7 @@ static machine_int_t array_get_el(mp_obj_array_t *o, int index) {
return val; return val;
} }
static void array_set_el(mp_obj_array_t *o, int index, mp_obj_t val_in) { STATIC void array_set_el(mp_obj_array_t *o, int index, mp_obj_t val_in) {
machine_int_t val = mp_obj_int_get(val_in); machine_int_t val = mp_obj_int_get(val_in);
switch (o->typecode) { switch (o->typecode) {
case 'b': case 'b':
...@@ -121,7 +121,7 @@ static void array_set_el(mp_obj_array_t *o, int index, mp_obj_t val_in) { ...@@ -121,7 +121,7 @@ static void array_set_el(mp_obj_array_t *o, int index, mp_obj_t val_in) {
} }
static void array_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) { STATIC void array_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
mp_obj_array_t *o = o_in; mp_obj_array_t *o = o_in;
if (o->typecode == BYTEARRAY_TYPECODE) { if (o->typecode == BYTEARRAY_TYPECODE) {
print(env, "bytearray(b", o->typecode); print(env, "bytearray(b", o->typecode);
...@@ -142,7 +142,7 @@ static void array_print(void (*print)(void *env, const char *fmt, ...), void *en ...@@ -142,7 +142,7 @@ static void array_print(void (*print)(void *env, const char *fmt, ...), void *en
print(env, ")"); print(env, ")");
} }
static mp_obj_t array_construct(char typecode, mp_obj_t initializer) { STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
uint len; uint len;
// Try to create array of exact len if initializer len is known // Try to create array of exact len if initializer len is known
mp_obj_t len_in = mp_obj_len_maybe(initializer); mp_obj_t len_in = mp_obj_len_maybe(initializer);
...@@ -168,7 +168,7 @@ static mp_obj_t array_construct(char typecode, mp_obj_t initializer) { ...@@ -168,7 +168,7 @@ static mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
return array; return array;
} }
static mp_obj_t array_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { STATIC mp_obj_t array_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
if (n_args < 1 || n_args > 2) { if (n_args < 1 || n_args > 2) {
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "unexpected # of arguments, %d given", n_args)); nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "unexpected # of arguments, %d given", n_args));
} }
...@@ -184,12 +184,12 @@ static mp_obj_t array_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m ...@@ -184,12 +184,12 @@ static mp_obj_t array_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
// This is top-level factory function, not virtual method // This is top-level factory function, not virtual method
// TODO: "bytearray" really should be type, not function // TODO: "bytearray" really should be type, not function
static mp_obj_t mp_builtin_bytearray(mp_obj_t arg) { STATIC mp_obj_t mp_builtin_bytearray(mp_obj_t arg) {
return array_construct(BYTEARRAY_TYPECODE, arg); return array_construct(BYTEARRAY_TYPECODE, arg);
} }
MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_bytearray_obj, mp_builtin_bytearray); MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_bytearray_obj, mp_builtin_bytearray);
static mp_obj_t array_unary_op(int op, mp_obj_t o_in) { STATIC mp_obj_t array_unary_op(int op, mp_obj_t o_in) {
mp_obj_array_t *o = o_in; mp_obj_array_t *o = o_in;
switch (op) { switch (op) {
case RT_UNARY_OP_BOOL: return MP_BOOL(o->len != 0); case RT_UNARY_OP_BOOL: return MP_BOOL(o->len != 0);
...@@ -198,7 +198,7 @@ static mp_obj_t array_unary_op(int op, mp_obj_t o_in) { ...@@ -198,7 +198,7 @@ static mp_obj_t array_unary_op(int op, mp_obj_t o_in) {
} }
} }
static mp_obj_t array_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) { STATIC mp_obj_t array_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
mp_obj_array_t *o = lhs; mp_obj_array_t *o = lhs;
switch (op) { switch (op) {
case RT_BINARY_OP_SUBSCR: case RT_BINARY_OP_SUBSCR:
...@@ -214,7 +214,7 @@ static mp_obj_t array_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) { ...@@ -214,7 +214,7 @@ static mp_obj_t array_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
} }
} }
static mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) { STATIC mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
assert(MP_OBJ_IS_TYPE(self_in, &array_type)); assert(MP_OBJ_IS_TYPE(self_in, &array_type));
mp_obj_array_t *self = self_in; mp_obj_array_t *self = self_in;
if (self->free == 0) { if (self->free == 0) {
...@@ -227,23 +227,23 @@ static mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) { ...@@ -227,23 +227,23 @@ static mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
self->free--; self->free--;
return mp_const_none; // return None, as per CPython return mp_const_none; // return None, as per CPython
} }
static MP_DEFINE_CONST_FUN_OBJ_2(array_append_obj, array_append); STATIC MP_DEFINE_CONST_FUN_OBJ_2(array_append_obj, array_append);
static bool array_store_item(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) { STATIC bool array_store_item(mp_obj_t self_in, mp_obj_t index_in, mp_obj_t value) {
mp_obj_array_t *o = self_in; mp_obj_array_t *o = self_in;
uint index = mp_get_index(o->base.type, o->len, index_in); uint index = mp_get_index(o->base.type, o->len, index_in);
array_set_el(o, index, value); array_set_el(o, index, value);
return true; return true;
} }
static machine_int_t array_get_buffer(mp_obj_t o_in, buffer_info_t *bufinfo, int flags) { STATIC machine_int_t array_get_buffer(mp_obj_t o_in, buffer_info_t *bufinfo, int flags) {
mp_obj_array_t *o = o_in; mp_obj_array_t *o = o_in;
bufinfo->buf = o->items; bufinfo->buf = o->items;
bufinfo->len = o->len * array_get_el_size(o->typecode); bufinfo->len = o->len * array_get_el_size(o->typecode);
return 0; return 0;
} }
static const mp_method_t array_type_methods[] = { STATIC const mp_method_t array_type_methods[] = {
{ "append", &array_append_obj }, { "append", &array_append_obj },
{ NULL, NULL }, { NULL, NULL },
}; };
...@@ -261,7 +261,7 @@ const mp_obj_type_t array_type = { ...@@ -261,7 +261,7 @@ const mp_obj_type_t array_type = {
.buffer_p = { .get_buffer = array_get_buffer }, .buffer_p = { .get_buffer = array_get_buffer },
}; };
static mp_obj_array_t *array_new(char typecode, uint n) { STATIC mp_obj_array_t *array_new(char typecode, uint n) {
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 = &array_type; o->base.type = &array_type;
o->typecode = typecode; o->typecode = typecode;
...@@ -311,7 +311,7 @@ mp_obj_t array_it_iternext(mp_obj_t self_in) { ...@@ -311,7 +311,7 @@ mp_obj_t array_it_iternext(mp_obj_t self_in) {
} }
} }
static const mp_obj_type_t array_it_type = { STATIC const mp_obj_type_t array_it_type = {
{ &mp_const_type }, { &mp_const_type },
"array_iterator", "array_iterator",
.iternext = array_it_iternext, .iternext = array_it_iternext,
......
...@@ -14,7 +14,7 @@ typedef struct _mp_obj_bool_t { ...@@ -14,7 +14,7 @@ typedef struct _mp_obj_bool_t {
bool value; bool value;
} mp_obj_bool_t; } mp_obj_bool_t;
static void bool_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) { STATIC void bool_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
mp_obj_bool_t *self = self_in; mp_obj_bool_t *self = self_in;
if (self->value) { if (self->value) {
print(env, "True"); print(env, "True");
...@@ -23,7 +23,7 @@ static void bool_print(void (*print)(void *env, const char *fmt, ...), void *env ...@@ -23,7 +23,7 @@ static void bool_print(void (*print)(void *env, const char *fmt, ...), void *env
} }
} }
static mp_obj_t bool_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { STATIC mp_obj_t bool_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
// TODO check n_kw == 0 // TODO check n_kw == 0
switch (n_args) { switch (n_args) {
...@@ -33,7 +33,7 @@ static mp_obj_t bool_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp ...@@ -33,7 +33,7 @@ static mp_obj_t bool_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
} }
} }
static mp_obj_t bool_unary_op(int op, mp_obj_t o_in) { STATIC mp_obj_t bool_unary_op(int op, mp_obj_t o_in) {
machine_int_t value = ((mp_obj_bool_t*)o_in)->value; machine_int_t value = ((mp_obj_bool_t*)o_in)->value;
switch (op) { switch (op) {
case RT_UNARY_OP_BOOL: return o_in; case RT_UNARY_OP_BOOL: return o_in;
...@@ -53,8 +53,8 @@ const mp_obj_type_t bool_type = { ...@@ -53,8 +53,8 @@ const mp_obj_type_t bool_type = {
.unary_op = bool_unary_op, .unary_op = bool_unary_op,
}; };
static const mp_obj_bool_t false_obj = {{&bool_type}, false}; STATIC const mp_obj_bool_t false_obj = {{&bool_type}, false};
static const mp_obj_bool_t true_obj = {{&bool_type}, true}; STATIC const mp_obj_bool_t true_obj = {{&bool_type}, true};
const mp_obj_t mp_const_false = (mp_obj_t)&false_obj; const mp_obj_t mp_const_false = (mp_obj_t)&false_obj;
const mp_obj_t mp_const_true = (mp_obj_t)&true_obj; const mp_obj_t mp_const_true = (mp_obj_t)&true_obj;
...@@ -21,7 +21,7 @@ typedef struct _mp_obj_complex_t { ...@@ -21,7 +21,7 @@ typedef struct _mp_obj_complex_t {
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);
void complex_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) { STATIC void complex_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
mp_obj_complex_t *o = o_in; mp_obj_complex_t *o = o_in;
if (o->real == 0) { if (o->real == 0) {
print(env, "%.8gj", (double) o->imag); print(env, "%.8gj", (double) o->imag);
...@@ -30,7 +30,7 @@ void complex_print(void (*print)(void *env, const char *fmt, ...), void *env, mp ...@@ -30,7 +30,7 @@ void complex_print(void (*print)(void *env, const char *fmt, ...), void *env, mp
} }
} }
static mp_obj_t complex_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { STATIC mp_obj_t complex_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
// TODO check n_kw == 0 // TODO check n_kw == 0
switch (n_args) { switch (n_args) {
...@@ -70,7 +70,7 @@ static mp_obj_t complex_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const ...@@ -70,7 +70,7 @@ static mp_obj_t complex_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
} }
} }
static mp_obj_t complex_unary_op(int op, mp_obj_t o_in) { STATIC mp_obj_t complex_unary_op(int op, mp_obj_t o_in) {
mp_obj_complex_t *o = o_in; mp_obj_complex_t *o = o_in;
switch (op) { switch (op) {
case RT_UNARY_OP_BOOL: return MP_BOOL(o->real != 0 || o->imag != 0); case RT_UNARY_OP_BOOL: return MP_BOOL(o->real != 0 || o->imag != 0);
...@@ -80,7 +80,7 @@ static mp_obj_t complex_unary_op(int op, mp_obj_t o_in) { ...@@ -80,7 +80,7 @@ static mp_obj_t complex_unary_op(int op, mp_obj_t o_in) {
} }
} }
static mp_obj_t complex_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) { STATIC mp_obj_t complex_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_obj_complex_t *lhs = lhs_in; mp_obj_complex_t *lhs = lhs_in;
return mp_obj_complex_binary_op(op, lhs->real, lhs->imag, rhs_in); return mp_obj_complex_binary_op(op, lhs->real, lhs->imag, rhs_in);
} }
......
...@@ -17,10 +17,10 @@ typedef struct _mp_obj_dict_t { ...@@ -17,10 +17,10 @@ typedef struct _mp_obj_dict_t {
mp_map_t map; mp_map_t map;
} mp_obj_dict_t; } mp_obj_dict_t;
static mp_obj_t mp_obj_new_dict_iterator(mp_obj_dict_t *dict, int cur); STATIC mp_obj_t mp_obj_new_dict_iterator(mp_obj_dict_t *dict, int cur);
static mp_map_elem_t *dict_it_iternext_elem(mp_obj_t self_in); STATIC mp_map_elem_t *dict_it_iternext_elem(mp_obj_t self_in);
static void dict_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) { STATIC void dict_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
mp_obj_dict_t *self = self_in; mp_obj_dict_t *self = self_in;
bool first = true; bool first = true;
print(env, "{"); print(env, "{");
...@@ -38,12 +38,12 @@ static void dict_print(void (*print)(void *env, const char *fmt, ...), void *env ...@@ -38,12 +38,12 @@ static void dict_print(void (*print)(void *env, const char *fmt, ...), void *env
print(env, "}"); print(env, "}");
} }
static mp_obj_t dict_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) { STATIC mp_obj_t dict_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
// TODO create from an iterable! // TODO create from an iterable!
return rt_build_map(0); return rt_build_map(0);
} }
static mp_obj_t dict_unary_op(int op, mp_obj_t self_in) { STATIC mp_obj_t dict_unary_op(int op, mp_obj_t self_in) {
mp_obj_dict_t *self = self_in; mp_obj_dict_t *self = self_in;
switch (op) { switch (op) {
case RT_UNARY_OP_BOOL: return MP_BOOL(self->map.used != 0); case RT_UNARY_OP_BOOL: return MP_BOOL(self->map.used != 0);
...@@ -52,7 +52,7 @@ static mp_obj_t dict_unary_op(int op, mp_obj_t self_in) { ...@@ -52,7 +52,7 @@ static mp_obj_t dict_unary_op(int op, mp_obj_t self_in) {
} }
} }
static mp_obj_t dict_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) { STATIC mp_obj_t dict_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_obj_dict_t *o = lhs_in; mp_obj_dict_t *o = lhs_in;
switch (op) { switch (op) {
case RT_BINARY_OP_SUBSCR: case RT_BINARY_OP_SUBSCR:
...@@ -86,7 +86,7 @@ typedef struct _mp_obj_dict_it_t { ...@@ -86,7 +86,7 @@ typedef struct _mp_obj_dict_it_t {
machine_uint_t cur; machine_uint_t cur;
} mp_obj_dict_it_t; } mp_obj_dict_it_t;
static mp_map_elem_t *dict_it_iternext_elem(mp_obj_t self_in) { STATIC mp_map_elem_t *dict_it_iternext_elem(mp_obj_t self_in) {
mp_obj_dict_it_t *self = self_in; mp_obj_dict_it_t *self = self_in;
machine_uint_t max = self->dict->map.alloc; machine_uint_t max = self->dict->map.alloc;
mp_map_elem_t *table = self->dict->map.table; mp_map_elem_t *table = self->dict->map.table;
...@@ -111,13 +111,13 @@ mp_obj_t dict_it_iternext(mp_obj_t self_in) { ...@@ -111,13 +111,13 @@ mp_obj_t dict_it_iternext(mp_obj_t self_in) {
} }
} }
static const mp_obj_type_t dict_it_type = { STATIC const mp_obj_type_t dict_it_type = {
{ &mp_const_type }, { &mp_const_type },
"dict_iterator", "dict_iterator",
.iternext = dict_it_iternext, .iternext = dict_it_iternext,
}; };
static mp_obj_t mp_obj_new_dict_iterator(mp_obj_dict_t *dict, int cur) { STATIC mp_obj_t mp_obj_new_dict_iterator(mp_obj_dict_t *dict, int cur) {
mp_obj_dict_it_t *o = m_new_obj(mp_obj_dict_it_t); mp_obj_dict_it_t *o = m_new_obj(mp_obj_dict_it_t);
o->base.type = &dict_it_type; o->base.type = &dict_it_type;
o->dict = dict; o->dict = dict;
...@@ -125,14 +125,14 @@ static mp_obj_t mp_obj_new_dict_iterator(mp_obj_dict_t *dict, int cur) { ...@@ -125,14 +125,14 @@ static mp_obj_t mp_obj_new_dict_iterator(mp_obj_dict_t *dict, int cur) {
return o; return o;
} }
static mp_obj_t dict_getiter(mp_obj_t o_in) { STATIC mp_obj_t dict_getiter(mp_obj_t o_in) {
return mp_obj_new_dict_iterator(o_in, 0); return mp_obj_new_dict_iterator(o_in, 0);
} }
/******************************************************************************/ /******************************************************************************/
/* dict methods */ /* dict methods */
static mp_obj_t dict_clear(mp_obj_t self_in) { STATIC mp_obj_t dict_clear(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &dict_type)); assert(MP_OBJ_IS_TYPE(self_in, &dict_type));
mp_obj_dict_t *self = self_in; mp_obj_dict_t *self = self_in;
...@@ -140,9 +140,9 @@ static mp_obj_t dict_clear(mp_obj_t self_in) { ...@@ -140,9 +140,9 @@ static mp_obj_t dict_clear(mp_obj_t self_in) {
return mp_const_none; return mp_const_none;
} }
static MP_DEFINE_CONST_FUN_OBJ_1(dict_clear_obj, dict_clear); STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_clear_obj, dict_clear);
static mp_obj_t dict_copy(mp_obj_t self_in) { STATIC mp_obj_t dict_copy(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &dict_type)); assert(MP_OBJ_IS_TYPE(self_in, &dict_type));
mp_obj_dict_t *self = self_in; mp_obj_dict_t *self = self_in;
mp_obj_dict_t *other = mp_obj_new_dict(self->map.alloc); mp_obj_dict_t *other = mp_obj_new_dict(self->map.alloc);
...@@ -150,10 +150,10 @@ static mp_obj_t dict_copy(mp_obj_t self_in) { ...@@ -150,10 +150,10 @@ static mp_obj_t dict_copy(mp_obj_t self_in) {
memcpy(other->map.table, self->map.table, self->map.alloc * sizeof(mp_map_elem_t)); memcpy(other->map.table, self->map.table, self->map.alloc * sizeof(mp_map_elem_t));
return other; return other;
} }
static MP_DEFINE_CONST_FUN_OBJ_1(dict_copy_obj, dict_copy); STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_copy_obj, dict_copy);
// this is a classmethod // this is a classmethod
static mp_obj_t dict_fromkeys(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t dict_fromkeys(uint n_args, const mp_obj_t *args) {
assert(2 <= n_args && n_args <= 3); assert(2 <= n_args && n_args <= 3);
mp_obj_t iter = rt_getiter(args[1]); mp_obj_t iter = rt_getiter(args[1]);
mp_obj_t len = mp_obj_len_maybe(iter); mp_obj_t len = mp_obj_len_maybe(iter);
...@@ -178,10 +178,10 @@ static mp_obj_t dict_fromkeys(uint n_args, const mp_obj_t *args) { ...@@ -178,10 +178,10 @@ static mp_obj_t dict_fromkeys(uint n_args, const mp_obj_t *args) {
return self; return self;
} }
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_fromkeys_fun_obj, 2, 3, dict_fromkeys); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_fromkeys_fun_obj, 2, 3, dict_fromkeys);
static MP_DEFINE_CONST_CLASSMETHOD_OBJ(dict_fromkeys_obj, (const mp_obj_t)&dict_fromkeys_fun_obj); STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(dict_fromkeys_obj, (const mp_obj_t)&dict_fromkeys_fun_obj);
static mp_obj_t dict_get_helper(mp_map_t *self, mp_obj_t key, mp_obj_t deflt, mp_map_lookup_kind_t lookup_kind) { STATIC mp_obj_t dict_get_helper(mp_map_t *self, mp_obj_t key, mp_obj_t deflt, mp_map_lookup_kind_t lookup_kind) {
mp_map_elem_t *elem = mp_map_lookup(self, key, lookup_kind); mp_map_elem_t *elem = mp_map_lookup(self, key, lookup_kind);
mp_obj_t value; mp_obj_t value;
if (elem == NULL || elem->value == NULL) { if (elem == NULL || elem->value == NULL) {
...@@ -207,7 +207,7 @@ static mp_obj_t dict_get_helper(mp_map_t *self, mp_obj_t key, mp_obj_t deflt, mp ...@@ -207,7 +207,7 @@ static mp_obj_t dict_get_helper(mp_map_t *self, mp_obj_t key, mp_obj_t deflt, mp
return value; return value;
} }
static mp_obj_t dict_get(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t dict_get(uint n_args, const mp_obj_t *args) {
assert(2 <= n_args && n_args <= 3); assert(2 <= n_args && n_args <= 3);
assert(MP_OBJ_IS_TYPE(args[0], &dict_type)); assert(MP_OBJ_IS_TYPE(args[0], &dict_type));
...@@ -216,9 +216,9 @@ static mp_obj_t dict_get(uint n_args, const mp_obj_t *args) { ...@@ -216,9 +216,9 @@ static mp_obj_t dict_get(uint n_args, const mp_obj_t *args) {
n_args == 3 ? args[2] : NULL, n_args == 3 ? args[2] : NULL,
MP_MAP_LOOKUP); MP_MAP_LOOKUP);
} }
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_get_obj, 2, 3, dict_get); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_get_obj, 2, 3, dict_get);
static mp_obj_t dict_pop(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t dict_pop(uint n_args, const mp_obj_t *args) {
assert(2 <= n_args && n_args <= 3); assert(2 <= n_args && n_args <= 3);
assert(MP_OBJ_IS_TYPE(args[0], &dict_type)); assert(MP_OBJ_IS_TYPE(args[0], &dict_type));
...@@ -227,10 +227,10 @@ static mp_obj_t dict_pop(uint n_args, const mp_obj_t *args) { ...@@ -227,10 +227,10 @@ static mp_obj_t dict_pop(uint n_args, const mp_obj_t *args) {
n_args == 3 ? args[2] : NULL, n_args == 3 ? args[2] : NULL,
MP_MAP_LOOKUP_REMOVE_IF_FOUND); MP_MAP_LOOKUP_REMOVE_IF_FOUND);
} }
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_pop_obj, 2, 3, dict_pop); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_pop_obj, 2, 3, dict_pop);
static mp_obj_t dict_setdefault(uint n_args, const mp_obj_t *args) { STATIC mp_obj_t dict_setdefault(uint n_args, const mp_obj_t *args) {
assert(2 <= n_args && n_args <= 3); assert(2 <= n_args && n_args <= 3);
assert(MP_OBJ_IS_TYPE(args[0], &dict_type)); assert(MP_OBJ_IS_TYPE(args[0], &dict_type));
...@@ -239,10 +239,10 @@ static mp_obj_t dict_setdefault(uint n_args, const mp_obj_t *args) { ...@@ -239,10 +239,10 @@ static mp_obj_t dict_setdefault(uint n_args, const mp_obj_t *args) {
n_args == 3 ? args[2] : NULL, n_args == 3 ? args[2] : NULL,
MP_MAP_LOOKUP_ADD_IF_NOT_FOUND); MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
} }
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_setdefault_obj, 2, 3, dict_setdefault); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(dict_setdefault_obj, 2, 3, dict_setdefault);
static mp_obj_t dict_popitem(mp_obj_t self_in) { STATIC mp_obj_t dict_popitem(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &dict_type)); assert(MP_OBJ_IS_TYPE(self_in, &dict_type));
mp_obj_dict_t *self = self_in; mp_obj_dict_t *self = self_in;
if (self->map.used == 0) { if (self->map.used == 0) {
...@@ -259,9 +259,9 @@ static mp_obj_t dict_popitem(mp_obj_t self_in) { ...@@ -259,9 +259,9 @@ static mp_obj_t dict_popitem(mp_obj_t self_in) {
return tuple; return tuple;
} }
static MP_DEFINE_CONST_FUN_OBJ_1(dict_popitem_obj, dict_popitem); STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_popitem_obj, dict_popitem);
static mp_obj_t dict_update(mp_obj_t self_in, mp_obj_t iterable) { STATIC mp_obj_t dict_update(mp_obj_t self_in, mp_obj_t iterable) {
assert(MP_OBJ_IS_TYPE(self_in, &dict_type)); assert(MP_OBJ_IS_TYPE(self_in, &dict_type));
mp_obj_dict_t *self = self_in; mp_obj_dict_t *self = self_in;
/* TODO: check for the "keys" method */ /* TODO: check for the "keys" method */
...@@ -285,14 +285,14 @@ static mp_obj_t dict_update(mp_obj_t self_in, mp_obj_t iterable) { ...@@ -285,14 +285,14 @@ static mp_obj_t dict_update(mp_obj_t self_in, mp_obj_t iterable) {
return mp_const_none; return mp_const_none;
} }
static MP_DEFINE_CONST_FUN_OBJ_2(dict_update_obj, dict_update); STATIC MP_DEFINE_CONST_FUN_OBJ_2(dict_update_obj, dict_update);
/******************************************************************************/ /******************************************************************************/
/* dict views */ /* dict views */
static const mp_obj_type_t dict_view_type; STATIC const mp_obj_type_t dict_view_type;
static const mp_obj_type_t dict_view_it_type; STATIC const mp_obj_type_t dict_view_it_type;
typedef enu