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;
/*****************************************************************************/
/* 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_WORD (BITS_PER_BYTE * BYTES_PER_WORD)
// machine_int_t value with most significant bit set
......
......@@ -29,14 +29,14 @@ typedef struct _mp_obj_array_t {
void *items;
} mp_obj_array_t;
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_t array_append(mp_obj_t self_in, mp_obj_t arg);
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_t array_append(mp_obj_t self_in, mp_obj_t arg);
/******************************************************************************/
/* 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,
// which is invariant for [u]intN_t.
switch (typecode) {
......@@ -57,7 +57,7 @@ static machine_int_t array_get_el_size(char typecode) {
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;
switch (o->typecode) {
case 'b':
......@@ -89,7 +89,7 @@ static machine_int_t array_get_el(mp_obj_array_t *o, int index) {
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);
switch (o->typecode) {
case 'b':
......@@ -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;
if (o->typecode == BYTEARRAY_TYPECODE) {
print(env, "bytearray(b", o->typecode);
......@@ -142,7 +142,7 @@ static void array_print(void (*print)(void *env, const char *fmt, ...), void *en
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;
// Try to create array of exact len if initializer len is known
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) {
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) {
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
// This is top-level factory function, not virtual method
// 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);
}
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;
switch (op) {
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) {
}
}
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;
switch (op) {
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) {
}
}
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));
mp_obj_array_t *self = self_in;
if (self->free == 0) {
......@@ -227,23 +227,23 @@ static mp_obj_t array_append(mp_obj_t self_in, mp_obj_t arg) {
self->free--;
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;
uint index = mp_get_index(o->base.type, o->len, index_in);
array_set_el(o, index, value);
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;
bufinfo->buf = o->items;
bufinfo->len = o->len * array_get_el_size(o->typecode);
return 0;
}
static const mp_method_t array_type_methods[] = {
STATIC const mp_method_t array_type_methods[] = {
{ "append", &array_append_obj },
{ NULL, NULL },
};
......@@ -261,7 +261,7 @@ const mp_obj_type_t array_type = {
.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);
o->base.type = &array_type;
o->typecode = typecode;
......@@ -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 },
"array_iterator",
.iternext = array_it_iternext,
......
......@@ -14,7 +14,7 @@ typedef struct _mp_obj_bool_t {
bool value;
} 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;
if (self->value) {
print(env, "True");
......@@ -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
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
}
}
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;
switch (op) {
case RT_UNARY_OP_BOOL: return o_in;
......@@ -53,8 +53,8 @@ const mp_obj_type_t bool_type = {
.unary_op = bool_unary_op,
};
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 false_obj = {{&bool_type}, false};
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_true = (mp_obj_t)&true_obj;
......@@ -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);
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;
if (o->real == 0) {
print(env, "%.8gj", (double) o->imag);
......@@ -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
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
}
}
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;
switch (op) {
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) {
}
}
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;
return mp_obj_complex_binary_op(op, lhs->real, lhs->imag, rhs_in);
}
......
......@@ -17,10 +17,10 @@ typedef struct _mp_obj_dict_t {
mp_map_t map;
} mp_obj_dict_t;
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_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 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;
bool first = true;
print(env, "{");
......@@ -38,12 +38,12 @@ static void dict_print(void (*print)(void *env, const char *fmt, ...), void *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!
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;
switch (op) {
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) {
}
}
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;
switch (op) {
case RT_BINARY_OP_SUBSCR:
......@@ -86,7 +86,7 @@ typedef struct _mp_obj_dict_it_t {
machine_uint_t cur;
} 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;
machine_uint_t max = self->dict->map.alloc;
mp_map_elem_t *table = self->dict->map.table;
......@@ -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 },
"dict_iterator",
.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);
o->base.type = &dict_it_type;
o->dict = dict;
......@@ -125,14 +125,14 @@ static mp_obj_t mp_obj_new_dict_iterator(mp_obj_dict_t *dict, int cur) {
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);
}
/******************************************************************************/
/* 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));
mp_obj_dict_t *self = self_in;
......@@ -140,9 +140,9 @@ static mp_obj_t dict_clear(mp_obj_t self_in) {
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));
mp_obj_dict_t *self = self_in;
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) {
memcpy(other->map.table, self->map.table, self->map.alloc * sizeof(mp_map_elem_t));
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
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);
mp_obj_t iter = rt_getiter(args[1]);
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) {
return self;
}
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_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_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_obj_t value;
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
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(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) {
n_args == 3 ? args[2] : NULL,
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(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) {
n_args == 3 ? args[2] : NULL,
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(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) {
n_args == 3 ? args[2] : NULL,
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));
mp_obj_dict_t *self = self_in;
if (self->map.used == 0) {
......@@ -259,9 +259,9 @@ static mp_obj_t dict_popitem(mp_obj_t self_in) {
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));
mp_obj_dict_t *self = self_in;
/* 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) {
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 */
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_type;
STATIC const mp_obj_type_t dict_view_it_type;
typedef enum _mp_dict_view_kind_t {
MP_DICT_VIEW_ITEMS,
......@@ -300,7 +300,7 @@ typedef enum _mp_dict_view_kind_t {
MP_DICT_VIEW_VALUES,
} mp_dict_view_kind_t;
static char *mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"};
STATIC char *mp_dict_view_names[] = {"dict_items", "dict_keys", "dict_values"};
typedef struct _mp_obj_dict_view_it_t {
mp_obj_base_t base;
......@@ -315,7 +315,7 @@ typedef struct _mp_obj_dict_view_t {
mp_dict_view_kind_t kind;
} mp_obj_dict_view_t;
static mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
STATIC mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &dict_view_it_type));
mp_obj_dict_view_it_t *self = self_in;
mp_map_elem_t *next = dict_it_iternext_elem(self->iter);
......@@ -340,14 +340,14 @@ static mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
}
}
static const mp_obj_type_t dict_view_it_type = {
STATIC const mp_obj_type_t dict_view_it_type = {
{ &mp_const_type },
"dict_view_iterator",
.iternext = dict_view_it_iternext,
.methods = NULL, /* set operations still to come */
};
static mp_obj_t dict_view_getiter(mp_obj_t view_in) {
STATIC mp_obj_t dict_view_getiter(mp_obj_t view_in) {
assert(MP_OBJ_IS_TYPE(view_in, &dict_view_type));
mp_obj_dict_view_t *view = view_in;
mp_obj_dict_view_it_t *o = m_new_obj(mp_obj_dict_view_it_t);
......@@ -357,7 +357,7 @@ static mp_obj_t dict_view_getiter(mp_obj_t view_in) {
return o;
}
static void dict_view_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
STATIC void dict_view_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
assert(MP_OBJ_IS_TYPE(self_in, &dict_view_type));
mp_obj_dict_view_t *self = self_in;
bool first = true;
......@@ -375,7 +375,7 @@ static void dict_view_print(void (*print)(void *env, const char *fmt, ...), void
print(env, "])");
}
static mp_obj_t dict_view_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
STATIC mp_obj_t dict_view_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
/* only supported for the 'keys' kind until sets and dicts are refactored */
mp_obj_dict_view_t *o = lhs_in;
if (o->kind != MP_DICT_VIEW_KEYS) return NULL;
......@@ -384,7 +384,7 @@ static mp_obj_t dict_view_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
}
static const mp_obj_type_t dict_view_type = {
STATIC const mp_obj_type_t dict_view_type = {
{ &mp_const_type },
"dict_view",
.print = dict_view_print,
......@@ -400,31 +400,31 @@ mp_obj_t mp_obj_new_dict_view(mp_obj_dict_t *dict, mp_dict_view_kind_t kind) {
return o;
}
static mp_obj_t dict_view(mp_obj_t self_in, mp_dict_view_kind_t kind) {
STATIC mp_obj_t dict_view(mp_obj_t self_in, mp_dict_view_kind_t kind) {
assert(MP_OBJ_IS_TYPE(self_in, &dict_type));
mp_obj_dict_t *self = self_in;
return mp_obj_new_dict_view(self, kind);
}
static mp_obj_t dict_items(mp_obj_t self_in) {
STATIC mp_obj_t dict_items(mp_obj_t self_in) {
return dict_view(self_in, MP_DICT_VIEW_ITEMS);
}
static MP_DEFINE_CONST_FUN_OBJ_1(dict_items_obj, dict_items);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_items_obj, dict_items);
static mp_obj_t dict_keys(mp_obj_t self_in) {
STATIC mp_obj_t dict_keys(mp_obj_t self_in) {
return dict_view(self_in, MP_DICT_VIEW_KEYS);
}
static MP_DEFINE_CONST_FUN_OBJ_1(dict_keys_obj, dict_keys);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_keys_obj, dict_keys);
static mp_obj_t dict_values(mp_obj_t self_in) {
STATIC mp_obj_t dict_values(mp_obj_t self_in) {
return dict_view(self_in, MP_DICT_VIEW_VALUES);
}
static MP_DEFINE_CONST_FUN_OBJ_1(dict_values_obj, dict_values);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(dict_values_obj, dict_values);
/******************************************************************************/
/* dict constructors & public C API */
static const mp_method_t dict_type_methods[] = {
STATIC const mp_method_t dict_type_methods[] = {
{ "clear", &dict_clear_obj },
{ "copy", &dict_copy_obj },
{ "fromkeys", &dict_fromkeys_obj },
......
......@@ -13,15 +13,11 @@ typedef struct _mp_obj_enumerate_t {
machine_int_t cur;
} mp_obj_enumerate_t;
static mp_obj_t enumerate_getiter(mp_obj_t self_in) {
return self_in;
}
static mp_obj_t enumerate_iternext(mp_obj_t self_in);
STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in);
/* TODO: enumerate is one of the ones that can take args or kwargs.
Sticking to args for now */
static mp_obj_t enumerate_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t enumerate_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
assert(n_args > 0);
mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t);
o->base.type = &enumerate_type;
......@@ -35,10 +31,10 @@ const mp_obj_type_t enumerate_type = {
"enumerate",
.make_new = enumerate_make_new,
.iternext = enumerate_iternext,
.getiter = enumerate_getiter,
.getiter = mp_identity,
};
static mp_obj_t enumerate_iternext(mp_obj_t self_in) {
STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &enumerate_type));
mp_obj_enumerate_t *self = self_in;
mp_obj_t next = rt_iternext(self->iter);
......
......@@ -22,7 +22,7 @@ typedef struct mp_obj_exception_t {
mp_obj_tuple_t args;
} mp_obj_exception_t;
void exception_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
STATIC void exception_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
mp_obj_exception_t *o = o_in;
if (o->msg != NULL) {
print(env, "%s: %s", qstr_str(o->id), vstr_str(o->msg));
......@@ -44,7 +44,7 @@ void exception_print(void (*print)(void *env, const char *fmt, ...), void *env,
}
}
static mp_obj_t exception_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t exception_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
mp_obj_exception_t *base = self_in;
if (n_kw != 0) {
......
......@@ -14,7 +14,7 @@ typedef struct _mp_obj_filter_t {
mp_obj_t iter;
} mp_obj_filter_t;
static mp_obj_t filter_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t filter_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
if (n_args != 2 || n_kw != 0) {
nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError, "filter expected 2 arguments"));
}
......@@ -26,11 +26,7 @@ static mp_obj_t filter_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
return o;
}
static mp_obj_t filter_getiter(mp_obj_t self_in) {
return self_in;
}
static mp_obj_t filter_iternext(mp_obj_t self_in) {
STATIC mp_obj_t filter_iternext(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &filter_type));
mp_obj_filter_t *self = self_in;
mp_obj_t next;
......@@ -52,6 +48,6 @@ const mp_obj_type_t filter_type = {
{ &mp_const_type },
"filter",
.make_new = filter_make_new,
.getiter = filter_getiter,
.getiter = mp_identity,
.iternext = filter_iternext,
};
......@@ -19,12 +19,12 @@ typedef struct _mp_obj_float_t {
mp_obj_t mp_obj_new_float(mp_float_t value);
static void float_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
STATIC void float_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
mp_obj_float_t *o = o_in;
print(env, "%.8g", (double) o->value);
}
static mp_obj_t float_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t float_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
// TODO check n_kw == 0
switch (n_args) {
......@@ -44,7 +44,7 @@ static mp_obj_t float_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
}
}
static mp_obj_t float_unary_op(int op, mp_obj_t o_in) {
STATIC mp_obj_t float_unary_op(int op, mp_obj_t o_in) {
mp_obj_float_t *o = o_in;
switch (op) {
case RT_UNARY_OP_BOOL: return MP_BOOL(o->value != 0);
......@@ -54,7 +54,7 @@ static mp_obj_t float_unary_op(int op, mp_obj_t o_in) {
}
}