Commit ff8dd3f4 authored by Damien George's avatar Damien George
Browse files

py, unix: Allow to compile with -Wunused-parameter.

See issue #699.
parent 50912e7f
......@@ -74,6 +74,7 @@ STATIC void dict_print(void (*print)(void *env, const char *fmt, ...), void *env
}
STATIC mp_obj_t dict_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
(void)type_in;
mp_obj_t dict = mp_obj_new_dict(0);
if (n_args > 0 || n_kw > 0) {
mp_obj_t args2[2] = {dict, args[0]}; // args[0] is always valid, even if it's not a positional arg
......@@ -446,6 +447,7 @@ STATIC mp_obj_t dict_view_getiter(mp_obj_t view_in) {
}
STATIC void dict_view_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
assert(MP_OBJ_IS_TYPE(self_in, &dict_view_type));
mp_obj_dict_view_t *self = self_in;
bool first = true;
......
......@@ -51,12 +51,12 @@ STATIC mp_obj_t enumerate_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t
// create enumerate object
mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t);
o->base.type = &mp_type_enumerate;
o->base.type = type_in;
o->iter = mp_getiter(vals[0].u_obj);
o->cur = vals[1].u_int;
#else
mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t);
o->base.type = &mp_type_enumerate;
o->base.type = type_in;
o->iter = mp_getiter(args[0]);
o->cur = n_args > 1 ? mp_obj_get_int(args[1]) : 0;
#endif
......
......@@ -39,7 +39,7 @@ STATIC mp_obj_t filter_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_
}
assert(n_args == 2);
mp_obj_filter_t *o = m_new_obj(mp_obj_filter_t);
o->base.type = &mp_type_filter;
o->base.type = type_in;
o->fun = args[0];
o->iter = mp_getiter(args[1]);
return o;
......
......@@ -42,6 +42,7 @@
#endif
STATIC void float_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_float_t *o = o_in;
#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
char buf[16];
......@@ -63,6 +64,7 @@ STATIC void float_print(void (*print)(void *env, const char *fmt, ...), void *en
}
STATIC mp_obj_t float_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
(void)type_in;
mp_arg_check_num(n_args, n_kw, 0, 1, false);
switch (n_args) {
......
......@@ -116,6 +116,7 @@ const char *mp_obj_fun_get_name(mp_const_obj_t fun_in) {
#if MICROPY_CPYTHON_COMPAT
STATIC void fun_bc_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_fun_bc_t *o = o_in;
print(env, "<function %s at 0x%x>", mp_obj_fun_get_name(o), o);
}
......
......@@ -95,6 +95,7 @@ mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun) {
/* generator instance */
STATIC void gen_instance_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_gen_instance_t *self = self_in;
print(env, "<generator object '%s' at %p>", mp_obj_code_get_name(self->code_state.code_info), self_in);
}
......
......@@ -42,6 +42,7 @@
// This dispatcher function is expected to be independent of the implementation of long int
STATIC mp_obj_t mp_obj_int_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
(void)type_in;
mp_arg_check_num(n_args, n_kw, 0, 2, false);
switch (n_args) {
......@@ -78,6 +79,7 @@ STATIC mp_obj_t mp_obj_int_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_
}
void mp_obj_int_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
// The size of this buffer is rather arbitrary. If it's not large
// enough, a dynamic one will be allocated.
char stack_buf[sizeof(mp_int_t) * 4];
......@@ -311,6 +313,7 @@ STATIC mp_obj_t int_from_bytes(mp_uint_t n_args, const mp_obj_t *args) {
// TODO: Support long ints
// TODO: Support byteorder param (assumes 'little' at the moment)
// TODO: Support signed param (assumes signed=False at the moment)
(void)n_args;
// get the buffer info
mp_buffer_info_t bufinfo;
......@@ -332,6 +335,7 @@ STATIC mp_obj_t int_to_bytes(mp_uint_t n_args, const mp_obj_t *args) {
// TODO: Support long ints
// TODO: Support byteorder param (assumes 'little')
// TODO: Support signed param (assumes signed=False)
(void)n_args;
mp_int_t val = mp_obj_int_get_checked(args[0]);
mp_uint_t len = MP_OBJ_SMALL_INT_VALUE(args[1]);
......
......@@ -68,6 +68,7 @@ STATIC mp_obj_t list_extend_from_iter(mp_obj_t list, mp_obj_t iterable) {
}
STATIC mp_obj_t list_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
(void)type_in;
mp_arg_check_num(n_args, n_kw, 0, 1, false);
switch (n_args) {
......
......@@ -43,7 +43,7 @@ STATIC mp_obj_t map_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw,
}
assert(n_args >= 2);
mp_obj_map_t *o = m_new_obj_var(mp_obj_map_t, mp_obj_t, n_args - 1);
o->base.type = &mp_type_map;
o->base.type = type_in;
o->n_iters = n_args - 1;
o->fun = args[0];
for (mp_uint_t i = 0; i < n_args - 1; i++) {
......
......@@ -34,6 +34,7 @@
#include "py/builtin.h"
STATIC void module_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_module_t *self = self_in;
const char *name = qstr_str(self->name);
......
......@@ -53,6 +53,7 @@ STATIC mp_uint_t namedtuple_find_field(mp_obj_namedtuple_type_t *type, qstr name
}
STATIC void namedtuple_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_namedtuple_t *o = o_in;
print(env, "%s(", qstr_str(o->tuple.base.type->name));
const mp_obj_t *fields = ((mp_obj_namedtuple_type_t*)o->tuple.base.type)->fields;
......@@ -76,6 +77,9 @@ STATIC void namedtuple_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
}
STATIC bool namedtuple_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
(void)self_in;
(void)attr;
(void)value;
nlr_raise(mp_obj_new_exception_msg(&mp_type_AttributeError, "can't set attribute"));
}
......
......@@ -35,6 +35,7 @@ typedef struct _mp_obj_none_t {
} 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) {
(void)self_in;
if (MICROPY_PY_UJSON && kind == PRINT_JSON) {
print(env, "null");
} else {
......@@ -43,6 +44,7 @@ STATIC void none_print(void (*print)(void *env, const char *fmt, ...), void *env
}
STATIC mp_obj_t none_unary_op(mp_uint_t op, mp_obj_t o_in) {
(void)o_in;
switch (op) {
case MP_UNARY_OP_BOOL: return mp_const_false;
default: return MP_OBJ_NULL; // op not supported
......
......@@ -37,17 +37,19 @@ typedef struct _mp_obj_object_t {
} mp_obj_object_t;
STATIC mp_obj_t object_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
(void)args;
if (n_args != 0 || n_kw != 0) {
nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "object takes no arguments"));
}
mp_obj_object_t *o = m_new_obj(mp_obj_object_t);
o->base.type = &mp_type_object;
o->base.type = type_in;
return o;
}
#if MICROPY_CPYTHON_COMPAT
STATIC mp_obj_t object___init__(mp_obj_t self) {
(void)self;
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__);
......
......@@ -41,7 +41,7 @@ STATIC mp_obj_t property_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t
mp_arg_check_num(n_args, n_kw, 0, 4, false);
mp_obj_property_t *o = m_new_obj(mp_obj_property_t);
o->base.type = &mp_type_property;
o->base.type = type_in;
if (n_args >= 4) {
// doc ignored
}
......
......@@ -80,6 +80,7 @@ typedef struct _mp_obj_range_t {
} mp_obj_range_t;
STATIC void range_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_range_t *self = self_in;
print(env, "range(%d, %d", self->start, self->stop);
if (self->step == 1) {
......@@ -93,7 +94,7 @@ STATIC mp_obj_t range_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
mp_arg_check_num(n_args, n_kw, 1, 3, false);
mp_obj_range_t *o = m_new_obj(mp_obj_range_t);
o->base.type = &mp_type_range;
o->base.type = type_in;
o->start = 0;
o->step = 1;
......
......@@ -40,7 +40,7 @@ STATIC mp_obj_t reversed_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t
mp_arg_check_num(n_args, n_kw, 1, 1, false);
mp_obj_reversed_t *o = m_new_obj(mp_obj_reversed_t);
o->base.type = &mp_type_reversed;
o->base.type = type_in;
o->seq = args[0];
o->cur_index = mp_obj_get_int(mp_obj_len(args[0])); // start at the end of the sequence
......
......@@ -80,6 +80,7 @@ STATIC void check_set(mp_obj_t o) {
}
STATIC void set_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_set_t *self = self_in;
#if MICROPY_PY_BUILTINS_FROZENSET
bool is_frozen = MP_OBJ_IS_TYPE(self_in, &mp_type_frozenset);
......
......@@ -39,6 +39,8 @@ typedef struct _mp_obj_ellipsis_t {
} mp_obj_ellipsis_t;
STATIC void ellipsis_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
(void)self_in;
(void)kind;
print(env, "Ellipsis");
}
......@@ -65,6 +67,7 @@ typedef struct _mp_obj_slice_t {
} mp_obj_slice_t;
STATIC void slice_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_slice_t *o = o_in;
print(env, "slice(");
mp_obj_print_helper(print, env, o->start, PRINT_REPR);
......
......@@ -132,6 +132,8 @@ STATIC void str_print(void (*print)(void *env, const char *fmt, ...), void *env,
#if !MICROPY_PY_BUILTINS_STR_UNICODE || MICROPY_CPYTHON_COMPAT
STATIC mp_obj_t str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
(void)type_in;
#if MICROPY_CPYTHON_COMPAT
if (n_kw != 0) {
mp_arg_error_unimpl_kw();
......@@ -171,6 +173,8 @@ STATIC mp_obj_t str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw,
#endif
STATIC mp_obj_t bytes_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
(void)type_in;
if (n_args == 0) {
return mp_const_empty_bytes;
}
......
......@@ -43,11 +43,13 @@ typedef struct _mp_obj_stringio_t {
} mp_obj_stringio_t;
STATIC void stringio_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
(void)kind;
mp_obj_stringio_t *self = self_in;
print(env, self->base.type == &mp_type_stringio ? "<io.StringIO 0x%x>" : "<io.BytesIO 0x%x>", self->vstr);
}
STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *errcode) {
(void)errcode;
mp_obj_stringio_t *o = o_in;
mp_uint_t remaining = o->vstr->len - o->pos;
if (size > remaining) {
......@@ -59,6 +61,7 @@ STATIC mp_uint_t stringio_read(mp_obj_t o_in, void *buf, mp_uint_t size, int *er
}
STATIC mp_uint_t stringio_write(mp_obj_t o_in, const void *buf, mp_uint_t size, int *errcode) {
(void)errcode;
mp_obj_stringio_t *o = o_in;
mp_uint_t remaining = o->vstr->alloc - o->pos;
if (size > remaining) {
......@@ -92,6 +95,7 @@ STATIC mp_obj_t stringio_close(mp_obj_t self_in) {
STATIC MP_DEFINE_CONST_FUN_OBJ_1(stringio_close_obj, stringio_close);
STATIC mp_obj_t stringio___exit__(mp_uint_t n_args, const mp_obj_t *args) {
(void)n_args;
return stringio_close(args[0]);
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(stringio___exit___obj, 4, 4, stringio___exit__);
......@@ -105,6 +109,7 @@ STATIC mp_obj_stringio_t *stringio_new(mp_obj_t type_in) {
}
STATIC mp_obj_t stringio_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
(void)n_kw; // TODO check n_kw==0
mp_obj_stringio_t *o = stringio_new(type_in);
if (n_args > 0) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment