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().
This commit is contained in:
Paul Sokolovsky 2014-02-12 18:15:40 +02:00
parent 1d1e38d911
commit d5df6cd44a
25 changed files with 268 additions and 270 deletions

View File

@ -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

View File

@ -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,

View File

@ -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;

View File

@ -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);
}

View File

@ -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 },

View File

@ -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);

View File

@ -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) {

View File

@ -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,
};

View File

@ -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) {
}
}
static mp_obj_t float_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
STATIC mp_obj_t float_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_obj_float_t *lhs = lhs_in;
if (MP_OBJ_IS_TYPE(rhs_in, &complex_type)) {
return mp_obj_complex_binary_op(op, lhs->value, 0, rhs_in);

View File

@ -18,7 +18,7 @@
// mp_obj_fun_native_t defined in obj.h
void check_nargs(mp_obj_fun_native_t *self, int n_args, int n_kw) {
STATIC void check_nargs(mp_obj_fun_native_t *self, int n_args, int n_kw) {
if (n_kw && !self->is_kw) {
nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError,
"function does not take keyword arguments"));
@ -44,7 +44,7 @@ void check_nargs(mp_obj_fun_native_t *self, int n_args, int n_kw) {
}
}
mp_obj_t fun_native_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t fun_native_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
assert(MP_OBJ_IS_TYPE(self_in, &fun_native_type));
mp_obj_fun_native_t *self = self_in;
@ -140,7 +140,7 @@ typedef struct _mp_obj_fun_bc_t {
mp_obj_t def_args[]; // values of default args, if any
} mp_obj_fun_bc_t;
mp_obj_t fun_bc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
mp_obj_fun_bc_t *self = self_in;
if (n_args < self->n_args - self->n_def_args || n_args > self->n_args) {
@ -207,7 +207,7 @@ typedef machine_uint_t (*inline_asm_fun_2_t)(machine_uint_t, machine_uint_t);
typedef machine_uint_t (*inline_asm_fun_3_t)(machine_uint_t, machine_uint_t, machine_uint_t);
// convert a Micro Python object to a sensible value for inline asm
machine_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
STATIC machine_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
// TODO for byte_array, pass pointer to the array
if (MP_OBJ_IS_SMALL_INT(obj)) {
return MP_OBJ_SMALL_INT_VALUE(obj);
@ -245,11 +245,11 @@ machine_uint_t convert_obj_for_inline_asm(mp_obj_t obj) {
}
// convert a return value from inline asm to a sensible Micro Python object
mp_obj_t convert_val_from_inline_asm(machine_uint_t val) {
STATIC mp_obj_t convert_val_from_inline_asm(machine_uint_t val) {
return MP_OBJ_NEW_SMALL_INT(val);
}
mp_obj_t fun_asm_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
mp_obj_fun_asm_t *self = self_in;
if (n_args != self->n_args) {
@ -276,7 +276,7 @@ mp_obj_t fun_asm_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *
return convert_val_from_inline_asm(ret);
}
static const mp_obj_type_t fun_asm_type = {
STATIC const mp_obj_type_t fun_asm_type = {
{ &mp_const_type },
"function",
.call = fun_asm_call,

View File

@ -19,7 +19,7 @@ typedef struct _mp_obj_gen_wrap_t {
mp_obj_t *fun;
} mp_obj_gen_wrap_t;
mp_obj_t gen_wrap_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
mp_obj_gen_wrap_t *self = self_in;
mp_obj_t self_fun = self->fun;
assert(MP_OBJ_IS_TYPE(self_fun, &fun_bc_type));
@ -70,7 +70,7 @@ mp_obj_t gen_instance_getiter(mp_obj_t self_in) {
return self_in;
}
static mp_obj_t gen_next_send(mp_obj_t self_in, mp_obj_t send_value) {
STATIC mp_obj_t gen_next_send(mp_obj_t self_in, mp_obj_t send_value) {
mp_obj_gen_instance_t *self = self_in;
if (self->ip == 0) {
return mp_const_stop_iteration;
@ -105,16 +105,16 @@ mp_obj_t gen_instance_iternext(mp_obj_t self_in) {
return gen_next_send(self_in, mp_const_none);
}
static mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) {
STATIC mp_obj_t gen_instance_send(mp_obj_t self_in, mp_obj_t send_value) {
mp_obj_t ret = gen_next_send(self_in, send_value);
if (ret == mp_const_stop_iteration) {
nlr_jump(mp_obj_new_exception(MP_QSTR_StopIteration));
}
return ret;
}
static MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(gen_instance_send_obj, gen_instance_send);
static const mp_method_t gen_type_methods[] = {
STATIC const mp_method_t gen_type_methods[] = {
{ "send", &gen_instance_send_obj },
{ NULL, NULL }, // end-of-list sentinel
};

View File

@ -15,7 +15,7 @@ typedef struct _mp_obj_getitem_iter_t {
mp_obj_t args[3];
} mp_obj_getitem_iter_t;
static mp_obj_t it_iternext(mp_obj_t self_in) {
STATIC mp_obj_t it_iternext(mp_obj_t self_in) {
mp_obj_getitem_iter_t *self = self_in;
nlr_buf_t nlr;
if (nlr_push(&nlr) == 0) {
@ -36,7 +36,7 @@ static mp_obj_t it_iternext(mp_obj_t self_in) {
}
}
static const mp_obj_type_t it_type = {
STATIC const mp_obj_type_t it_type = {
{ &mp_const_type },
"iterator",
.iternext = it_iternext

View File

@ -12,7 +12,7 @@
// This dispatcher function is expected to be independent of the implementation
// of long int
static mp_obj_t int_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t int_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) {

View File

@ -13,7 +13,7 @@
#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
static mp_obj_t mp_obj_new_int_from_ll(long long val);
STATIC mp_obj_t mp_obj_new_int_from_ll(long long val);
// Python3 no longer has "l" suffix for long ints. We allow to use it
// for debugging purpose though.

View File

@ -19,9 +19,9 @@ typedef struct _mp_obj_list_t {
mp_obj_t *items;
} mp_obj_list_t;
static mp_obj_t mp_obj_new_list_iterator(mp_obj_list_t *list, int cur);
static mp_obj_list_t *list_new(uint n);
static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in);
STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_list_t *list, int cur);
STATIC mp_obj_list_t *list_new(uint n);
STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in);
// TODO: Move to mpconfig.h
#define LIST_MIN_ALLOC 4
@ -29,7 +29,7 @@ static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in);
/******************************************************************************/
/* list */
static void list_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
STATIC void list_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
mp_obj_list_t *o = o_in;
print(env, "[");
for (int i = 0; i < o->len; i++) {
@ -41,7 +41,7 @@ static void list_print(void (*print)(void *env, const char *fmt, ...), void *env
print(env, "]");
}
static mp_obj_t list_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t list_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) {
@ -68,7 +68,7 @@ static mp_obj_t list_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
}
// Don't pass RT_BINARY_OP_NOT_EQUAL here
static bool list_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
STATIC bool list_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
assert(MP_OBJ_IS_TYPE(self_in, &list_type));
if (!MP_OBJ_IS_TYPE(another_in, &list_type)) {
return false;
@ -79,7 +79,7 @@ static bool list_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len);
}
static mp_obj_t list_unary_op(int op, mp_obj_t self_in) {
STATIC mp_obj_t list_unary_op(int op, mp_obj_t self_in) {
mp_obj_list_t *self = self_in;
switch (op) {
case RT_UNARY_OP_BOOL: return MP_BOOL(self->len != 0);
@ -88,7 +88,7 @@ static mp_obj_t list_unary_op(int op, mp_obj_t self_in) {
}
}
static mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
STATIC mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
mp_obj_list_t *o = lhs;
switch (op) {
case RT_BINARY_OP_SUBSCR:
@ -150,7 +150,7 @@ static mp_obj_t list_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
}
}
static mp_obj_t list_getiter(mp_obj_t o_in) {
STATIC mp_obj_t list_getiter(mp_obj_t o_in) {
return mp_obj_new_list_iterator(o_in, 0);
}
@ -166,7 +166,7 @@ mp_obj_t mp_obj_list_append(mp_obj_t self_in, mp_obj_t arg) {
return mp_const_none; // return None, as per CPython
}
static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) {
STATIC mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) {
assert(MP_OBJ_IS_TYPE(self_in, &list_type));
assert(MP_OBJ_IS_TYPE(arg_in, &list_type));
mp_obj_list_t *self = self_in;
@ -183,7 +183,7 @@ static mp_obj_t list_extend(mp_obj_t self_in, mp_obj_t arg_in) {
return mp_const_none; // return None, as per CPython
}
static mp_obj_t list_pop(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t list_pop(uint n_args, const mp_obj_t *args) {
assert(1 <= n_args && n_args <= 2);
assert(MP_OBJ_IS_TYPE(args[0], &list_type));
mp_obj_list_t *self = args[0];
@ -202,7 +202,7 @@ static mp_obj_t list_pop(uint n_args, const mp_obj_t *args) {
}
// TODO make this conform to CPython's definition of sort
static void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, bool reversed) {
STATIC void mp_quicksort(mp_obj_t *head, mp_obj_t *tail, mp_obj_t key_fn, bool reversed) {
int op = reversed ? RT_BINARY_OP_MORE : RT_BINARY_OP_LESS;
while (head < tail) {
mp_obj_t *h = head - 1;
@ -242,7 +242,7 @@ mp_obj_t mp_obj_list_sort(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) {
return mp_const_none; // return None, as per CPython
}
static mp_obj_t list_clear(mp_obj_t self_in) {
STATIC mp_obj_t list_clear(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &list_type));
mp_obj_list_t *self = self_in;
self->len = 0;
@ -251,26 +251,26 @@ static mp_obj_t list_clear(mp_obj_t self_in) {
return mp_const_none;
}
static mp_obj_t list_copy(mp_obj_t self_in) {
STATIC mp_obj_t list_copy(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &list_type));
mp_obj_list_t *self = self_in;
return mp_obj_new_list(self->len, self->items);
}
static mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) {
STATIC mp_obj_t list_count(mp_obj_t self_in, mp_obj_t value) {
assert(MP_OBJ_IS_TYPE(self_in, &list_type));
mp_obj_list_t *self = self_in;
return mp_seq_count_obj(self->items, self->len, value);
}
static mp_obj_t list_index(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t list_index(uint n_args, const mp_obj_t *args) {
assert(2 <= n_args && n_args <= 4);
assert(MP_OBJ_IS_TYPE(args[0], &list_type));
mp_obj_list_t *self = args[0];
return mp_seq_index_obj(self->items, self->len, n_args, args);
}
static mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) {
STATIC mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) {
assert(MP_OBJ_IS_TYPE(self_in, &list_type));
mp_obj_list_t *self = self_in;
// insert has its own strange index logic
@ -295,7 +295,7 @@ static mp_obj_t list_insert(mp_obj_t self_in, mp_obj_t idx, mp_obj_t obj) {
return mp_const_none;
}
static mp_obj_t list_remove(mp_obj_t self_in, mp_obj_t value) {
STATIC mp_obj_t list_remove(mp_obj_t self_in, mp_obj_t value) {
assert(MP_OBJ_IS_TYPE(self_in, &list_type));
mp_obj_t args[] = {self_in, value};
args[1] = list_index(2, args);
@ -304,7 +304,7 @@ static mp_obj_t list_remove(mp_obj_t self_in, mp_obj_t value) {
return mp_const_none;
}
static mp_obj_t list_reverse(mp_obj_t self_in) {
STATIC mp_obj_t list_reverse(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &list_type));
mp_obj_list_t *self = self_in;
@ -318,19 +318,19 @@ static mp_obj_t list_reverse(mp_obj_t self_in) {
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_2(list_append_obj, mp_obj_list_append);
static MP_DEFINE_CONST_FUN_OBJ_2(list_extend_obj, list_extend);
static MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, list_clear);
static MP_DEFINE_CONST_FUN_OBJ_1(list_copy_obj, list_copy);
static MP_DEFINE_CONST_FUN_OBJ_2(list_count_obj, list_count);
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_index_obj, 2, 4, list_index);
static MP_DEFINE_CONST_FUN_OBJ_3(list_insert_obj, list_insert);
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_pop_obj, 1, 2, list_pop);
static MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, list_remove);
static MP_DEFINE_CONST_FUN_OBJ_1(list_reverse_obj, list_reverse);
static MP_DEFINE_CONST_FUN_OBJ_KW(list_sort_obj, 0, mp_obj_list_sort);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_append_obj, mp_obj_list_append);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_extend_obj, list_extend);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_clear_obj, list_clear);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_copy_obj, list_copy);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_count_obj, list_count);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_index_obj, 2, 4, list_index);
STATIC MP_DEFINE_CONST_FUN_OBJ_3(list_insert_obj, list_insert);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(list_pop_obj, 1, 2, list_pop);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(list_remove_obj, list_remove);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(list_reverse_obj, list_reverse);
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(list_sort_obj, 0, mp_obj_list_sort);
static const mp_method_t list_type_methods[] = {
STATIC const mp_method_t list_type_methods[] = {
{ "append", &list_append_obj },
{ "clear", &list_clear_obj },
{ "copy", &list_copy_obj },
@ -356,7 +356,7 @@ const mp_obj_type_t list_type = {
.methods = list_type_methods,
};
static mp_obj_list_t *list_new(uint n) {
STATIC mp_obj_list_t *list_new(uint n) {
mp_obj_list_t *o = m_new_obj(mp_obj_list_t);
o->base.type = &list_type;
o->alloc = n < LIST_MIN_ALLOC ? LIST_MIN_ALLOC : n;
@ -407,7 +407,7 @@ mp_obj_t list_it_iternext(mp_obj_t self_in) {
}
}
static const mp_obj_type_t list_it_type = {
STATIC const mp_obj_type_t list_it_type = {
{ &mp_const_type },
"list_iterator",
.iternext = list_it_iternext,

View File

@ -15,7 +15,7 @@ typedef struct _mp_obj_map_t {
mp_obj_t iters[];
} mp_obj_map_t;
static mp_obj_t map_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t map_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, "map must have at least 2 arguments and no keyword arguments"));
}
@ -30,11 +30,11 @@ static mp_obj_t map_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
return o;
}
static mp_obj_t map_getiter(mp_obj_t self_in) {
STATIC mp_obj_t map_getiter(mp_obj_t self_in) {
return self_in;
}
static mp_obj_t map_iternext(mp_obj_t self_in) {
STATIC mp_obj_t map_iternext(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &map_type));
mp_obj_map_t *self = self_in;
mp_obj_t *nextses = m_new(mp_obj_t, self->n_iters);

View File

@ -17,12 +17,12 @@ typedef struct _mp_obj_module_t {
mp_map_t *globals;
} mp_obj_module_t;
static void module_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
STATIC void module_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
mp_obj_module_t *self = self_in;
print(env, "<module '%s' from '-unknown-file-'>", qstr_str(self->name));
}
static void module_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
STATIC void module_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
mp_obj_module_t *self = self_in;
mp_map_elem_t *elem = mp_map_lookup(self->globals, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP);
if (elem != NULL) {
@ -30,7 +30,7 @@ static void module_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
}
}
static bool module_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
STATIC bool module_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
mp_obj_module_t *self = self_in;
// TODO CPython allows STORE_ATTR to a module, but is this the correct implementation?
mp_map_lookup(self->globals, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value;

View File

@ -12,11 +12,11 @@ typedef struct _mp_obj_none_t {
mp_obj_base_t base;
} mp_obj_none_t;
static void none_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
STATIC void none_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
print(env, "None");
}
static mp_obj_t none_unary_op(int op, mp_obj_t o_in) {
STATIC mp_obj_t none_unary_op(int op, mp_obj_t o_in) {
switch (op) {
case RT_UNARY_OP_BOOL: return mp_const_false;
default: return MP_OBJ_NULL; // op not supported for None
@ -30,10 +30,10 @@ const mp_obj_type_t none_type = {
.unary_op = none_unary_op,
};
static const mp_obj_none_t none_obj = {{&none_type}};
STATIC const mp_obj_none_t none_obj = {{&none_type}};
const mp_obj_t mp_const_none = (mp_obj_t)&none_obj;
// the stop-iteration object just needs to be something unique
// it's not the StopIteration exception
static const mp_obj_none_t stop_it_obj = {{&none_type}};
STATIC const mp_obj_none_t stop_it_obj = {{&none_type}};
const mp_obj_t mp_const_stop_iteration = (mp_obj_t)&stop_it_obj;

View File

@ -18,12 +18,12 @@ typedef struct _mp_obj_range_t {
machine_int_t step;
} mp_obj_range_t;
mp_obj_t range_getiter(mp_obj_t o_in) {
STATIC mp_obj_t range_getiter(mp_obj_t o_in) {
mp_obj_range_t *o = o_in;
return mp_obj_new_range_iterator(o->start, o->stop, o->step);
}
static const mp_obj_type_t range_type = {
STATIC const mp_obj_type_t range_type = {
{ &mp_const_type} ,
"range",
.getiter = range_getiter,
@ -50,7 +50,7 @@ typedef struct _mp_obj_range_it_t {
machine_int_t step;
} mp_obj_range_it_t;
mp_obj_t range_it_iternext(mp_obj_t o_in) {
STATIC mp_obj_t range_it_iternext(mp_obj_t o_in) {
mp_obj_range_it_t *o = o_in;
if ((o->step > 0 && o->cur < o->stop) || (o->step < 0 && o->cur > o->stop)) {
mp_obj_t o_out = MP_OBJ_NEW_SMALL_INT(o->cur);
@ -61,7 +61,7 @@ mp_obj_t range_it_iternext(mp_obj_t o_in) {
}
}
static const mp_obj_type_t range_it_type = {
STATIC const mp_obj_type_t range_it_type = {
{ &mp_const_type },
"range_iterator",
.iternext = range_it_iternext,

View File

@ -23,9 +23,9 @@ typedef struct _mp_obj_set_it_t {
machine_uint_t cur;
} mp_obj_set_it_t;
static mp_obj_t set_it_iternext(mp_obj_t self_in);
STATIC mp_obj_t set_it_iternext(mp_obj_t self_in);
void set_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
STATIC void set_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
mp_obj_set_t *self = self_in;
if (self->set.used == 0) {
print(env, "set()");
@ -46,7 +46,7 @@ void set_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj
}
static mp_obj_t set_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t set_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) {
@ -77,7 +77,7 @@ const mp_obj_type_t set_it_type = {
.iternext = set_it_iternext,
};
static mp_obj_t set_it_iternext(mp_obj_t self_in) {
STATIC mp_obj_t set_it_iternext(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &set_it_type));
mp_obj_set_it_t *self = self_in;
machine_uint_t max = self->set->set.alloc;
@ -93,7 +93,7 @@ static mp_obj_t set_it_iternext(mp_obj_t self_in) {
return mp_const_stop_iteration;
}
static mp_obj_t set_getiter(mp_obj_t set_in) {
STATIC mp_obj_t set_getiter(mp_obj_t set_in) {
mp_obj_set_it_t *o = m_new_obj(mp_obj_set_it_t);
o->base.type = &set_it_type;
o->set = (mp_obj_set_t *)set_in;
@ -105,15 +105,15 @@ static mp_obj_t set_getiter(mp_obj_t set_in) {
/******************************************************************************/
/* set methods */
static mp_obj_t set_add(mp_obj_t self_in, mp_obj_t item) {
STATIC mp_obj_t set_add(mp_obj_t self_in, mp_obj_t item) {
assert(MP_OBJ_IS_TYPE(self_in, &set_type));
mp_obj_set_t *self = self_in;
mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND);
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_2(set_add_obj, set_add);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_add_obj, set_add);
static mp_obj_t set_clear(mp_obj_t self_in) {
STATIC mp_obj_t set_clear(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &set_type));
mp_obj_set_t *self = self_in;
@ -121,9 +121,9 @@ static mp_obj_t set_clear(mp_obj_t self_in) {
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_1(set_clear_obj, set_clear);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_clear_obj, set_clear);
static mp_obj_t set_copy(mp_obj_t self_in) {
STATIC mp_obj_t set_copy(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &set_type));
mp_obj_set_t *self = self_in;
@ -135,17 +135,17 @@ static mp_obj_t set_copy(mp_obj_t self_in) {
return other;
}
static MP_DEFINE_CONST_FUN_OBJ_1(set_copy_obj, set_copy);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_copy_obj, set_copy);
static mp_obj_t set_discard(mp_obj_t self_in, mp_obj_t item) {
STATIC mp_obj_t set_discard(mp_obj_t self_in, mp_obj_t item) {
assert(MP_OBJ_IS_TYPE(self_in, &set_type));
mp_obj_set_t *self = self_in;
mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND);
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_2(set_discard_obj, set_discard);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_discard_obj, set_discard);
static mp_obj_t set_diff_int(int n_args, const mp_obj_t *args, bool update) {
STATIC mp_obj_t set_diff_int(int n_args, const mp_obj_t *args, bool update) {
assert(n_args > 0);
assert(MP_OBJ_IS_TYPE(args[0], &set_type));
mp_obj_set_t *self;
@ -172,18 +172,18 @@ static mp_obj_t set_diff_int(int n_args, const mp_obj_t *args, bool update) {
return self;
}
static mp_obj_t set_diff(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t set_diff(uint n_args, const mp_obj_t *args) {
return set_diff_int(n_args, args, false);
}
static MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_obj, 1, set_diff);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_obj, 1, set_diff);
static mp_obj_t set_diff_update(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t set_diff_update(uint n_args, const mp_obj_t *args) {
set_diff_int(n_args, args, true);
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_update_obj, 1, set_diff_update);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_diff_update_obj, 1, set_diff_update);
static mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) {
STATIC mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update) {
assert(MP_OBJ_IS_TYPE(self_in, &set_type));
if (self_in == other) {
return update ? mp_const_none : set_copy(self_in);
@ -210,17 +210,17 @@ static mp_obj_t set_intersect_int(mp_obj_t self_in, mp_obj_t other, bool update)
return update ? mp_const_none : out;
}
static mp_obj_t set_intersect(mp_obj_t self_in, mp_obj_t other) {
STATIC mp_obj_t set_intersect(mp_obj_t self_in, mp_obj_t other) {
return set_intersect_int(self_in, other, false);
}
static MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_obj, set_intersect);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_obj, set_intersect);
static mp_obj_t set_intersect_update(mp_obj_t self_in, mp_obj_t other) {
STATIC mp_obj_t set_intersect_update(mp_obj_t self_in, mp_obj_t other) {
return set_intersect_int(self_in, other, true);
}
static MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_update_obj, set_intersect_update);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_intersect_update_obj, set_intersect_update);
static mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) {
STATIC mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) {
assert(MP_OBJ_IS_TYPE(self_in, &set_type));
mp_obj_set_t *self = self_in;
@ -233,9 +233,9 @@ static mp_obj_t set_isdisjoint(mp_obj_t self_in, mp_obj_t other) {
}
return mp_const_true;
}
static MP_DEFINE_CONST_FUN_OBJ_2(set_isdisjoint_obj, set_isdisjoint);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_isdisjoint_obj, set_isdisjoint);
static mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool proper) {
STATIC mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool proper) {
mp_obj_set_t *self;
bool cleanup_self = false;
if (MP_OBJ_IS_TYPE(self_in, &set_type)) {
@ -274,25 +274,25 @@ static mp_obj_t set_issubset_internal(mp_obj_t self_in, mp_obj_t other_in, bool
}
return MP_BOOL(out);
}
static mp_obj_t set_issubset(mp_obj_t self_in, mp_obj_t other_in) {
STATIC mp_obj_t set_issubset(mp_obj_t self_in, mp_obj_t other_in) {
return set_issubset_internal(self_in, other_in, false);
}
static MP_DEFINE_CONST_FUN_OBJ_2(set_issubset_obj, set_issubset);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_issubset_obj, set_issubset);
static mp_obj_t set_issubset_proper(mp_obj_t self_in, mp_obj_t other_in) {
STATIC mp_obj_t set_issubset_proper(mp_obj_t self_in, mp_obj_t other_in) {
return set_issubset_internal(self_in, other_in, true);
}
static mp_obj_t set_issuperset(mp_obj_t self_in, mp_obj_t other_in) {
STATIC mp_obj_t set_issuperset(mp_obj_t self_in, mp_obj_t other_in) {
return set_issubset_internal(other_in, self_in, false);
}
static MP_DEFINE_CONST_FUN_OBJ_2(set_issuperset_obj, set_issuperset);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_issuperset_obj, set_issuperset);
static mp_obj_t set_issuperset_proper(mp_obj_t self_in, mp_obj_t other_in) {
STATIC mp_obj_t set_issuperset_proper(mp_obj_t self_in, mp_obj_t other_in) {
return set_issubset_internal(other_in, self_in, true);
}
static mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) {
STATIC mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) {
assert(MP_OBJ_IS_TYPE(self_in, &set_type));
mp_obj_set_t *self = self_in;
if (!MP_OBJ_IS_TYPE(other_in, &set_type)) {
@ -305,7 +305,7 @@ static mp_obj_t set_equal(mp_obj_t self_in, mp_obj_t other_in) {
return set_issubset(self_in, other_in);
}
static mp_obj_t set_pop(mp_obj_t self_in) {
STATIC mp_obj_t set_pop(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &set_type));
mp_obj_set_t *self = self_in;
@ -316,9 +316,9 @@ static mp_obj_t set_pop(mp_obj_t self_in) {
MP_MAP_LOOKUP_REMOVE_IF_FOUND | MP_MAP_LOOKUP_FIRST);
return obj;
}
static MP_DEFINE_CONST_FUN_OBJ_1(set_pop_obj, set_pop);
STATIC MP_DEFINE_CONST_FUN_OBJ_1(set_pop_obj, set_pop);
static mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
STATIC mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
assert(MP_OBJ_IS_TYPE(self_in, &set_type));
mp_obj_set_t *self = self_in;
if (mp_set_lookup(&self->set, item, MP_MAP_LOOKUP_REMOVE_IF_FOUND) == MP_OBJ_NULL) {
@ -326,9 +326,9 @@ static mp_obj_t set_remove(mp_obj_t self_in, mp_obj_t item) {
}
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_2(set_remove_obj, set_remove);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_remove_obj, set_remove);
static mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other_in) {
STATIC mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other_in) {
assert(MP_OBJ_IS_TYPE(self_in, &set_type));
mp_obj_set_t *self = self_in;
mp_obj_t iter = rt_getiter(other_in);
@ -338,17 +338,17 @@ static mp_obj_t set_symmetric_difference_update(mp_obj_t self_in, mp_obj_t other
}
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_update_obj, set_symmetric_difference_update);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_update_obj, set_symmetric_difference_update);
static mp_obj_t set_symmetric_difference(mp_obj_t self_in, mp_obj_t other_in) {
STATIC mp_obj_t set_symmetric_difference(mp_obj_t self_in, mp_obj_t other_in) {
assert(MP_OBJ_IS_TYPE(self_in, &set_type));
self_in = set_copy(self_in);
set_symmetric_difference_update(self_in, other_in);
return self_in;
}
static MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_obj, set_symmetric_difference);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_symmetric_difference_obj, set_symmetric_difference);
static void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
STATIC void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
mp_obj_t iter = rt_getiter(other_in);
mp_obj_t next;
while ((next = rt_iternext(iter)) != mp_const_stop_iteration) {
@ -356,7 +356,7 @@ static void set_update_int(mp_obj_set_t *self, mp_obj_t other_in) {
}
}
static mp_obj_t set_update(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t set_update(uint n_args, const mp_obj_t *args) {
assert(n_args > 0);
assert(MP_OBJ_IS_TYPE(args[0], &set_type));
@ -366,18 +366,18 @@ static mp_obj_t set_update(uint n_args, const mp_obj_t *args) {
return mp_const_none;
}
static MP_DEFINE_CONST_FUN_OBJ_VAR(set_update_obj, 1, set_update);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(set_update_obj, 1, set_update);
static mp_obj_t set_union(mp_obj_t self_in, mp_obj_t other_in) {
STATIC mp_obj_t set_union(mp_obj_t self_in, mp_obj_t other_in) {
assert(MP_OBJ_IS_TYPE(self_in, &set_type));
mp_obj_set_t *self = set_copy(self_in);
set_update_int(self, other_in);
return self;
}
static MP_DEFINE_CONST_FUN_OBJ_2(set_union_obj, set_union);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(set_union_obj, set_union);
static mp_obj_t set_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
STATIC mp_obj_t set_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
mp_obj_t args[] = {lhs, rhs};
switch (op) {
case RT_BINARY_OP_OR:
@ -424,7 +424,7 @@ static mp_obj_t set_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
/* set constructors & public C API */
static const mp_method_t set_type_methods[] = {
STATIC const mp_method_t set_type_methods[] = {
{ "add", &set_add_obj },
{ "clear", &set_clear_obj },
{ "copy", &set_copy_obj },

View File

@ -27,7 +27,7 @@ const mp_obj_type_t ellipsis_type = {
.print = ellipsis_print,
};
static const mp_obj_ellipsis_t ellipsis_obj = {{&ellipsis_type}};
STATIC const mp_obj_ellipsis_t ellipsis_obj = {{&ellipsis_type}};
const mp_obj_t mp_const_ellipsis = (mp_obj_t)&ellipsis_obj;
/******************************************************************************/

View File

@ -28,8 +28,8 @@ typedef struct _mp_obj_str_t {
// use this macro to extract the string data and length
#define GET_STR_DATA_LEN(str_obj_in, str_data, str_len) const byte *str_data; uint str_len; if (MP_OBJ_IS_QSTR(str_obj_in)) { str_data = qstr_data(MP_OBJ_QSTR_VALUE(str_obj_in), &str_len); } else { str_len = ((mp_obj_str_t*)str_obj_in)->len; str_data = ((mp_obj_str_t*)str_obj_in)->data; }
static mp_obj_t mp_obj_new_str_iterator(mp_obj_t str);
static mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str);
STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str);
STATIC mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str);
/******************************************************************************/
/* str */
@ -67,7 +67,7 @@ void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *e
print(env, "%c", quote_char);
}
static void str_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
STATIC void str_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
GET_STR_DATA_LEN(self_in, str_data, str_len);
bool is_bytes = MP_OBJ_IS_TYPE(self_in, &bytes_type);
if (kind == PRINT_STR && !is_bytes) {
@ -82,7 +82,7 @@ static void str_print(void (*print)(void *env, const char *fmt, ...), void *env,
// like strstr but with specified length and allows \0 bytes
// TODO replace with something more efficient/standard
static const byte *find_subbytes(const byte *haystack, uint hlen, const byte *needle, uint nlen) {
STATIC const byte *find_subbytes(const byte *haystack, uint hlen, const byte *needle, uint nlen) {
if (hlen >= nlen) {
for (uint i = 0; i <= hlen - nlen; i++) {
bool found = true;
@ -100,7 +100,7 @@ static const byte *find_subbytes(const byte *haystack, uint hlen, const byte *ne
return NULL;
}
static mp_obj_t str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
STATIC mp_obj_t str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
GET_STR_DATA_LEN(lhs_in, lhs_data, lhs_len);
switch (op) {
case RT_BINARY_OP_SUBSCR:
@ -188,7 +188,7 @@ static mp_obj_t str_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
return MP_OBJ_NULL; // op not supported
}
static mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
STATIC mp_obj_t str_join(mp_obj_t self_in, mp_obj_t arg) {
assert(MP_OBJ_IS_STR(self_in));
// get separation string
@ -240,7 +240,7 @@ bad_arg:
#define is_ws(c) ((c) == ' ' || (c) == '\t')
static mp_obj_t str_split(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t str_split(uint n_args, const mp_obj_t *args) {
int splits = -1;
mp_obj_t sep = mp_const_none;
if (n_args > 1) {
@ -278,7 +278,7 @@ static mp_obj_t str_split(uint n_args, const mp_obj_t *args) {
return res;
}
static mp_obj_t str_find(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t str_find(uint n_args, const mp_obj_t *args) {
assert(2 <= n_args && n_args <= 4);
assert(MP_OBJ_IS_STR(args[0]));
assert(MP_OBJ_IS_STR(args[1]));
@ -311,7 +311,7 @@ static mp_obj_t str_find(uint n_args, const mp_obj_t *args) {
}
// TODO: (Much) more variety in args
static mp_obj_t str_startswith(mp_obj_t self_in, mp_obj_t arg) {
STATIC mp_obj_t str_startswith(mp_obj_t self_in, mp_obj_t arg) {
GET_STR_DATA_LEN(self_in, str, str_len);
GET_STR_DATA_LEN(arg, prefix, prefix_len);
if (prefix_len > str_len) {
@ -320,7 +320,7 @@ static mp_obj_t str_startswith(mp_obj_t self_in, mp_obj_t arg) {
return MP_BOOL(memcmp(str, prefix, prefix_len) == 0);
}
static bool chr_in_str(const byte* const str, const size_t str_len, int c) {
STATIC bool chr_in_str(const byte* const str, const size_t str_len, int c) {
for (size_t i = 0; i < str_len; i++) {
if (str[i] == c) {
return true;
@ -329,7 +329,7 @@ static bool chr_in_str(const byte* const str, const size_t str_len, int c) {
return false;
}
static mp_obj_t str_strip(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t str_strip(uint n_args, const mp_obj_t *args) {
assert(1 <= n_args && n_args <= 2);
assert(MP_OBJ_IS_STR(args[0]));
@ -403,7 +403,7 @@ mp_obj_t str_format(uint n_args, const mp_obj_t *args) {
return s;
}
static mp_obj_t str_replace(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t str_replace(uint n_args, const mp_obj_t *args) {
assert(MP_OBJ_IS_STR(args[0]));
assert(MP_OBJ_IS_STR(args[1]));
assert(MP_OBJ_IS_STR(args[2]));
@ -487,15 +487,15 @@ static mp_obj_t str_replace(uint n_args, const mp_obj_t *args) {
return mp_obj_str_builder_end(replaced_str);
}
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_find_obj, 2, 4, str_find);
static MP_DEFINE_CONST_FUN_OBJ_2(str_join_obj, str_join);
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_split_obj, 1, 3, str_split);
static MP_DEFINE_CONST_FUN_OBJ_2(str_startswith_obj, str_startswith);
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_strip_obj, 1, 2, str_strip);
static MP_DEFINE_CONST_FUN_OBJ_VAR(str_format_obj, 1, str_format);
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_replace_obj, 3, 4, str_replace);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_find_obj, 2, 4, str_find);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(str_join_obj, str_join);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_split_obj, 1, 3, str_split);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(str_startswith_obj, str_startswith);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_strip_obj, 1, 2, str_strip);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR(str_format_obj, 1, str_format);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(str_replace_obj, 3, 4, str_replace);
static const mp_method_t str_type_methods[] = {
STATIC const mp_method_t str_type_methods[] = {
{ "find", &str_find_obj },
{ "join", &str_join_obj },
{ "split", &str_split_obj },
@ -541,7 +541,7 @@ mp_obj_t mp_obj_str_builder_end(mp_obj_t o_in) {
return o;
}
static mp_obj_t str_new(const mp_obj_type_t *type, const byte* data, uint len) {
STATIC mp_obj_t str_new(const mp_obj_type_t *type, const byte* data, uint len) {
mp_obj_str_t *o = m_new_obj_var(mp_obj_str_t, byte, len + 1);
o->base.type = type;
o->hash = qstr_compute_hash(data, len);
@ -654,7 +654,7 @@ typedef struct _mp_obj_str_it_t {
machine_uint_t cur;
} mp_obj_str_it_t;
static mp_obj_t str_it_iternext(mp_obj_t self_in) {
STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
mp_obj_str_it_t *self = self_in;
GET_STR_DATA_LEN(self->str, str, len);
if (self->cur < len) {
@ -666,13 +666,13 @@ static mp_obj_t str_it_iternext(mp_obj_t self_in) {
}
}
static const mp_obj_type_t str_it_type = {
STATIC const mp_obj_type_t str_it_type = {
{ &mp_const_type },
"str_iterator",
.iternext = str_it_iternext,
};
static mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
STATIC mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
mp_obj_str_it_t *self = self_in;
GET_STR_DATA_LEN(self->str, str, len);
if (self->cur < len) {
@ -684,7 +684,7 @@ static mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
}
}
static const mp_obj_type_t bytes_it_type = {
STATIC const mp_obj_type_t bytes_it_type = {
{ &mp_const_type },
"bytes_iterator",
.iternext = bytes_it_iternext,

View File

@ -12,7 +12,7 @@
#include "runtime.h"
#include "objtuple.h"
static mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, int cur);
STATIC mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, int cur);
/******************************************************************************/
/* tuple */
@ -32,7 +32,7 @@ void tuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_o
print(env, ")");
}
static mp_obj_t tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t tuple_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) {
@ -75,7 +75,7 @@ static mp_obj_t tuple_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
}
// Don't pass RT_BINARY_OP_NOT_EQUAL here
static bool tuple_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
STATIC bool tuple_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
assert(MP_OBJ_IS_TYPE(self_in, &tuple_type));
if (!MP_OBJ_IS_TYPE(another_in, &tuple_type)) {
return false;
@ -86,7 +86,7 @@ static bool tuple_cmp_helper(int op, mp_obj_t self_in, mp_obj_t another_in) {
return mp_seq_cmp_objs(op, self->items, self->len, another->items, another->len);
}
static mp_obj_t tuple_unary_op(int op, mp_obj_t self_in) {
STATIC mp_obj_t tuple_unary_op(int op, mp_obj_t self_in) {
mp_obj_tuple_t *self = self_in;
switch (op) {
case RT_UNARY_OP_BOOL: return MP_BOOL(self->len != 0);
@ -95,7 +95,7 @@ static mp_obj_t tuple_unary_op(int op, mp_obj_t self_in) {
}
}
static mp_obj_t tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
STATIC mp_obj_t tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
mp_obj_tuple_t *o = lhs;
switch (op) {
case RT_BINARY_OP_SUBSCR:
@ -149,25 +149,25 @@ static mp_obj_t tuple_binary_op(int op, mp_obj_t lhs, mp_obj_t rhs) {
}
}
static mp_obj_t tuple_getiter(mp_obj_t o_in) {
STATIC mp_obj_t tuple_getiter(mp_obj_t o_in) {
return mp_obj_new_tuple_iterator(o_in, 0);
}
static mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) {
STATIC mp_obj_t tuple_count(mp_obj_t self_in, mp_obj_t value) {
assert(MP_OBJ_IS_TYPE(self_in, &tuple_type));
mp_obj_tuple_t *self = self_in;
return mp_seq_count_obj(self->items, self->len, value);
}
static MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count);
STATIC MP_DEFINE_CONST_FUN_OBJ_2(tuple_count_obj, tuple_count);
static mp_obj_t tuple_index(uint n_args, const mp_obj_t *args) {
STATIC mp_obj_t tuple_index(uint n_args, const mp_obj_t *args) {
assert(MP_OBJ_IS_TYPE(args[0], &tuple_type));
mp_obj_tuple_t *self = args[0];
return mp_seq_index_obj(self->items, self->len, n_args, args);
}
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(tuple_index_obj, 2, 4, tuple_index);
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(tuple_index_obj, 2, 4, tuple_index);
static const mp_method_t tuple_type_methods[] = {
STATIC const mp_method_t tuple_type_methods[] = {
{ "count", &tuple_count_obj },
{ "index", &tuple_index_obj },
{ NULL, NULL }, // end-of-list sentinel
@ -185,7 +185,7 @@ const mp_obj_type_t tuple_type = {
};
// the zero-length tuple
static const mp_obj_tuple_t empty_tuple_obj = {{&tuple_type}, 0};
STATIC const mp_obj_tuple_t empty_tuple_obj = {{&tuple_type}, 0};
const mp_obj_t mp_const_empty_tuple = (mp_obj_t)&empty_tuple_obj;
mp_obj_t mp_obj_new_tuple(uint n, const mp_obj_t *items) {
@ -229,7 +229,7 @@ typedef struct _mp_obj_tuple_it_t {
machine_uint_t cur;
} mp_obj_tuple_it_t;
static mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
STATIC mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
mp_obj_tuple_it_t *self = self_in;
if (self->cur < self->tuple->len) {
mp_obj_t o_out = self->tuple->items[self->cur];
@ -240,13 +240,13 @@ static mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
}
}
static const mp_obj_type_t tuple_it_type = {
STATIC const mp_obj_type_t tuple_it_type = {
{ &mp_const_type },
"tuple_iterator",
.iternext = tuple_it_iternext,
};
static mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, int cur) {
STATIC mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, int cur) {
mp_obj_tuple_it_t *o = m_new_obj(mp_obj_tuple_it_t);
o->base.type = &tuple_it_type;
o->tuple = tuple;

View File

@ -21,7 +21,7 @@ typedef struct _mp_obj_class_t {
mp_map_t members;
} mp_obj_class_t;
static mp_obj_t mp_obj_new_class(mp_obj_t class) {
STATIC mp_obj_t mp_obj_new_class(mp_obj_t class) {
mp_obj_class_t *o = m_new_obj(mp_obj_class_t);
o->base.type = class;
mp_map_init(&o->members, 0);
@ -29,7 +29,7 @@ static mp_obj_t mp_obj_new_class(mp_obj_t class) {
}
// will return MP_OBJ_NULL if not found
static mp_obj_t mp_obj_class_lookup(const mp_obj_type_t *type, qstr attr) {
STATIC mp_obj_t mp_obj_class_lookup(const mp_obj_type_t *type, qstr attr) {
for (;;) {
if (type->locals_dict != NULL) {
// search locals_dict (the dynamically created set of methods/attributes)
@ -77,11 +77,11 @@ static mp_obj_t mp_obj_class_lookup(const mp_obj_type_t *type, qstr attr) {
}
}
static void class_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
STATIC void class_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
print(env, "<%s object at %p>", mp_obj_get_type_str(self_in), self_in);
}
static mp_obj_t class_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t class_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
assert(MP_OBJ_IS_TYPE(self_in, &mp_const_type));
mp_obj_type_t *self = self_in;
@ -116,7 +116,7 @@ static mp_obj_t class_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const m
return o;
}
static const qstr unary_op_method_name[] = {
STATIC const qstr unary_op_method_name[] = {
[RT_UNARY_OP_BOOL] = MP_QSTR___bool__,
[RT_UNARY_OP_LEN] = MP_QSTR___len__,
//[RT_UNARY_OP_POSITIVE,
@ -125,7 +125,7 @@ static const qstr unary_op_method_name[] = {
[RT_UNARY_OP_NOT] = MP_QSTR_, // don't need to implement this, used to make sure array has full size
};
static mp_obj_t class_unary_op(int op, mp_obj_t self_in) {
STATIC mp_obj_t class_unary_op(int op, mp_obj_t self_in) {
mp_obj_class_t *self = self_in;
qstr op_name = unary_op_method_name[op];
if (op_name == 0) {
@ -139,7 +139,7 @@ static mp_obj_t class_unary_op(int op, mp_obj_t self_in) {
}
}
static const qstr binary_op_method_name[] = {
STATIC const qstr binary_op_method_name[] = {
[RT_BINARY_OP_SUBSCR] = MP_QSTR___getitem__,
/*
RT_BINARY_OP_OR,
@ -180,7 +180,7 @@ static const qstr binary_op_method_name[] = {
[RT_BINARY_OP_EXCEPTION_MATCH] = MP_QSTR_, // not implemented, used to make sure array has full size
};
static mp_obj_t class_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
STATIC mp_obj_t class_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
mp_obj_class_t *lhs = lhs_in;
qstr op_name = binary_op_method_name[op];
if (op_name == 0) {
@ -194,7 +194,7 @@ static mp_obj_t class_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
}
}
static void class_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
STATIC void class_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
// logic: look in obj members then class locals (TODO check this against CPython)
mp_obj_class_t *self = self_in;
mp_map_elem_t *elem = mp_map_lookup(&self->members, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP);
@ -231,7 +231,7 @@ static void class_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
}
}
static bool class_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
STATIC bool class_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
mp_obj_class_t *self = self_in;
mp_map_lookup(&self->members, MP_OBJ_NEW_QSTR(attr), MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = value;
return true;
@ -255,12 +255,12 @@ bool class_store_item(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
// - there is a constant mp_obj_type_t (called mp_const_type) for the 'type' object
// - creating a new class (a new type) creates a new mp_obj_type_t
static void type_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
STATIC void type_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
mp_obj_type_t *self = self_in;
print(env, "<class '%s'>", self->name);
}
static mp_obj_t type_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t type_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) {
@ -278,7 +278,7 @@ static mp_obj_t type_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
}
}
static mp_obj_t type_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t type_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
// instantiate an instance of a class
mp_obj_type_t *self = self_in;
@ -295,7 +295,7 @@ static mp_obj_t type_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj
}
// for fail, do nothing; for attr, dest[0] = value; for method, dest[0] = method, dest[1] = self
static void type_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
STATIC void type_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
assert(MP_OBJ_IS_TYPE(self_in, &mp_const_type));
mp_obj_type_t *self = self_in;
mp_obj_t member = mp_obj_class_lookup(self, attr);
@ -317,7 +317,7 @@ static void type_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
}
}
static bool type_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
STATIC bool type_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
assert(MP_OBJ_IS_TYPE(self_in, &mp_const_type));
mp_obj_type_t *self = self_in;
@ -370,7 +370,7 @@ typedef struct _mp_obj_super_t {
mp_obj_t obj;
} mp_obj_super_t;
static void super_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
STATIC void super_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
mp_obj_super_t *self = self_in;
print(env, "<super: ");
mp_obj_print_helper(print, env, self->type, PRINT_STR);
@ -379,7 +379,7 @@ static void super_print(void (*print)(void *env, const char *fmt, ...), void *en
print(env, ">");
}
static mp_obj_t super_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t super_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) {
// 0 arguments are turned into 2 in the compiler
// 1 argument is not yet implemented
@ -389,7 +389,7 @@ static mp_obj_t super_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const m
}
// for fail, do nothing; for attr, dest[0] = value; for method, dest[0] = method, dest[1] = self
static void super_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
STATIC void super_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
assert(MP_OBJ_IS_TYPE(self_in, &super_type));
mp_obj_super_t *self = self_in;
@ -454,7 +454,7 @@ mp_obj_t mp_obj_new_super(mp_obj_t type, mp_obj_t obj) {
/******************************************************************************/
// built-ins specific to types
static mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) {
STATIC mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) {
if (!MP_OBJ_IS_TYPE(object, &mp_const_type)) {
nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError, "issubclass() arg 1 must be a class"));
}
@ -498,7 +498,7 @@ static mp_obj_t mp_builtin_issubclass(mp_obj_t object, mp_obj_t classinfo) {
MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_issubclass_obj, mp_builtin_issubclass);
static mp_obj_t mp_builtin_isinstance(mp_obj_t object, mp_obj_t classinfo) {
STATIC mp_obj_t mp_builtin_isinstance(mp_obj_t object, mp_obj_t classinfo) {
return mp_builtin_issubclass(mp_obj_get_type(object), classinfo);
}
@ -507,7 +507,7 @@ MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_isinstance_obj, mp_builtin_isinstance);
/******************************************************************************/
// staticmethod and classmethod types (probably should go in a different file)
static mp_obj_t static_class_method_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t static_class_method_make_new(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *args) {
assert(self_in == &mp_type_staticmethod || self_in == &mp_type_classmethod);
if (n_args != 1 || n_kw != 0) {

View File

@ -13,7 +13,7 @@ typedef struct _mp_obj_zip_t {
mp_obj_t iters[];
} mp_obj_zip_t;
static mp_obj_t zip_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
STATIC mp_obj_t zip_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
// TODO check n_kw == 0
mp_obj_zip_t *o = m_new_obj_var(mp_obj_zip_t, mp_obj_t, n_args);
@ -25,11 +25,11 @@ static mp_obj_t zip_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
return o;
}
static mp_obj_t zip_getiter(mp_obj_t self_in) {
STATIC mp_obj_t zip_getiter(mp_obj_t self_in) {
return self_in;
}
static mp_obj_t zip_iternext(mp_obj_t self_in) {
STATIC mp_obj_t zip_iternext(mp_obj_t self_in) {
assert(MP_OBJ_IS_TYPE(self_in, &zip_type));
mp_obj_zip_t *self = self_in;
mp_obj_t *items;