parent
50912e7f5d
commit
ff8dd3f486
@ -35,6 +35,7 @@
|
||||
#if MICROPY_PY_UBINASCII
|
||||
|
||||
STATIC mp_obj_t mod_binascii_hexlify(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
mp_buffer_info_t bufinfo;
|
||||
mp_get_buffer_raise(args[0], &bufinfo, MP_BUFFER_READ);
|
||||
|
||||
|
@ -122,6 +122,7 @@ STATIC NORETURN void syntax_error(void) {
|
||||
}
|
||||
|
||||
STATIC mp_obj_t uctypes_struct_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;
|
||||
if (n_args < 2 || n_args > 3) {
|
||||
syntax_error();
|
||||
}
|
||||
@ -137,6 +138,7 @@ STATIC mp_obj_t uctypes_struct_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_u
|
||||
}
|
||||
|
||||
STATIC void uctypes_struct_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_uctypes_struct_t *self = self_in;
|
||||
const char *typen = "unk";
|
||||
if (MP_OBJ_IS_TYPE(self->desc, &mp_type_dict)) {
|
||||
|
@ -71,6 +71,7 @@ STATIC mp_obj_t hash_digest(mp_obj_t self_in) {
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(hash_digest_obj, hash_digest);
|
||||
|
||||
STATIC mp_obj_t hash_hexdigest(mp_obj_t self_in) {
|
||||
(void)self_in;
|
||||
mp_not_implemented("");
|
||||
#if 0
|
||||
mp_obj_hash_t *self = self_in;
|
||||
|
@ -52,6 +52,7 @@ typedef struct _mp_obj_match_t {
|
||||
|
||||
|
||||
STATIC void match_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_match_t *self = self_in;
|
||||
print(env, "<match num=%d @%p>", self->num_matches);
|
||||
}
|
||||
@ -82,11 +83,13 @@ STATIC const mp_obj_type_t match_type = {
|
||||
};
|
||||
|
||||
STATIC void re_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_re_t *self = self_in;
|
||||
print(env, "<re %p>", self);
|
||||
}
|
||||
|
||||
STATIC mp_obj_t re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
mp_obj_re_t *self = args[0];
|
||||
Subject subj;
|
||||
mp_uint_t len;
|
||||
@ -192,6 +195,7 @@ STATIC mp_obj_t mod_re_compile(uint n_args, const mp_obj_t *args) {
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_compile_obj, 1, 2, mod_re_compile);
|
||||
|
||||
STATIC mp_obj_t mod_re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
mp_obj_re_t *self = mod_re_compile(1, args);
|
||||
|
||||
const mp_obj_t args2[] = {self, args[1]};
|
||||
|
@ -55,6 +55,7 @@ STATIC int mod_uzlib_grow_buf(TINF_DATA *d, unsigned alloc_req) {
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mod_uzlib_decompress(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
mp_obj_t data = args[0];
|
||||
mp_buffer_info_t bufinfo;
|
||||
mp_get_buffer_raise(data, &bufinfo, MP_BUFFER_READ);
|
||||
|
@ -145,6 +145,7 @@ void asm_x86_start_pass(asm_x86_t *as, mp_uint_t pass) {
|
||||
}
|
||||
|
||||
void asm_x86_end_pass(asm_x86_t *as) {
|
||||
(void)as;
|
||||
}
|
||||
|
||||
// all functions must go through this one to emit bytes
|
||||
|
@ -75,6 +75,8 @@ STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_t globals, mp_obj_t loc
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mp_builtin_compile(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
|
||||
// get the source
|
||||
mp_uint_t str_len;
|
||||
const char *str = mp_obj_str_get_data(args[0], &str_len);
|
||||
|
@ -3210,6 +3210,9 @@ STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
|
||||
EMIT_ARG(store_id, MP_QSTR___doc__);
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void)comp;
|
||||
(void)pn;
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -3514,7 +3517,7 @@ STATIC void compile_scope_inline_asm(compiler_t *comp, scope_t *scope, pass_kind
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC void compile_scope_compute_things(compiler_t *comp, scope_t *scope) {
|
||||
STATIC void scope_compute_things(scope_t *scope) {
|
||||
#if !MICROPY_EMIT_CPYTHON
|
||||
// in Micro Python we put the *x parameter after all other parameters (except **y)
|
||||
if (scope->scope_flags & MP_SCOPE_FLAG_VARARGS) {
|
||||
@ -3678,7 +3681,7 @@ mp_obj_t mp_compile(mp_parse_node_t pn, qstr source_file, uint emit_opt, bool is
|
||||
|
||||
// compute some things related to scope and identifiers
|
||||
for (scope_t *s = comp->scope_head; s != NULL && comp->compile_error == MP_OBJ_NULL; s = s->next) {
|
||||
compile_scope_compute_things(comp, s);
|
||||
scope_compute_things(s);
|
||||
}
|
||||
|
||||
// finish with pass 1
|
||||
|
12
py/emitbc.c
12
py/emitbc.c
@ -268,6 +268,10 @@ STATIC void emit_write_bytecode_byte_signed_label(emit_t* emit, byte b1, mp_uint
|
||||
}
|
||||
|
||||
STATIC void emit_bc_set_native_type(emit_t *emit, mp_uint_t op, mp_uint_t arg1, qstr arg2) {
|
||||
(void)emit;
|
||||
(void)op;
|
||||
(void)arg1;
|
||||
(void)arg2;
|
||||
}
|
||||
|
||||
STATIC void emit_bc_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
|
||||
@ -499,6 +503,7 @@ STATIC void emit_bc_load_null(emit_t *emit) {
|
||||
};
|
||||
|
||||
STATIC void emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
|
||||
(void)qst;
|
||||
assert(local_num >= 0);
|
||||
emit_bc_pre(emit, 1);
|
||||
if (local_num <= 15) {
|
||||
@ -509,11 +514,13 @@ STATIC void emit_bc_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
|
||||
}
|
||||
|
||||
STATIC void emit_bc_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
|
||||
(void)qst;
|
||||
emit_bc_pre(emit, 1);
|
||||
emit_write_bytecode_byte_uint(emit, MP_BC_LOAD_DEREF, local_num);
|
||||
}
|
||||
|
||||
STATIC void emit_bc_load_name(emit_t *emit, qstr qst) {
|
||||
(void)qst;
|
||||
emit_bc_pre(emit, 1);
|
||||
emit_write_bytecode_byte_qstr(emit, MP_BC_LOAD_NAME, qst);
|
||||
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
|
||||
@ -522,6 +529,7 @@ STATIC void emit_bc_load_name(emit_t *emit, qstr qst) {
|
||||
}
|
||||
|
||||
STATIC void emit_bc_load_global(emit_t *emit, qstr qst) {
|
||||
(void)qst;
|
||||
emit_bc_pre(emit, 1);
|
||||
emit_write_bytecode_byte_qstr(emit, MP_BC_LOAD_GLOBAL, qst);
|
||||
if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
|
||||
@ -553,6 +561,7 @@ STATIC void emit_bc_load_subscr(emit_t *emit) {
|
||||
}
|
||||
|
||||
STATIC void emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
|
||||
(void)qst;
|
||||
assert(local_num >= 0);
|
||||
emit_bc_pre(emit, -1);
|
||||
if (local_num <= 15) {
|
||||
@ -563,6 +572,7 @@ STATIC void emit_bc_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
|
||||
}
|
||||
|
||||
STATIC void emit_bc_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
|
||||
(void)qst;
|
||||
emit_bc_pre(emit, -1);
|
||||
emit_write_bytecode_byte_uint(emit, MP_BC_STORE_DEREF, local_num);
|
||||
}
|
||||
@ -591,10 +601,12 @@ STATIC void emit_bc_store_subscr(emit_t *emit) {
|
||||
}
|
||||
|
||||
STATIC void emit_bc_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
|
||||
(void)qst;
|
||||
emit_write_bytecode_byte_uint(emit, MP_BC_DELETE_FAST, local_num);
|
||||
}
|
||||
|
||||
STATIC void emit_bc_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
|
||||
(void)qst;
|
||||
emit_write_bytecode_byte_uint(emit, MP_BC_DELETE_DEREF, local_num);
|
||||
}
|
||||
|
||||
|
@ -92,6 +92,8 @@ void mp_emit_glue_assign_native(mp_raw_code_t *rc, mp_raw_code_kind_t kind, void
|
||||
fwrite(fun_data, fun_len, 1, fp_write_code);
|
||||
fclose(fp_write_code);
|
||||
#endif
|
||||
#else
|
||||
(void)fun_len;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -740,6 +740,8 @@ STATIC void emit_native_adjust_stack_size(emit_t *emit, mp_int_t delta) {
|
||||
}
|
||||
|
||||
STATIC void emit_native_set_source_line(emit_t *emit, mp_uint_t source_line) {
|
||||
(void)emit;
|
||||
(void)source_line;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -905,6 +907,7 @@ STATIC void emit_pre_pop_reg_reg_reg(emit_t *emit, vtype_kind_t *vtypea, int reg
|
||||
}
|
||||
|
||||
STATIC void emit_post(emit_t *emit) {
|
||||
(void)emit;
|
||||
}
|
||||
|
||||
STATIC void emit_post_top_set_vtype(emit_t *emit, vtype_kind_t new_vtype) {
|
||||
@ -1247,6 +1250,9 @@ STATIC void emit_native_load_fast(emit_t *emit, qstr qst, mp_uint_t local_num) {
|
||||
STATIC void emit_native_load_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
|
||||
// not implemented
|
||||
// in principle could support this quite easily (ldr r0, [r0, #0]) and then get closed over variables!
|
||||
(void)emit;
|
||||
(void)qst;
|
||||
(void)local_num;
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@ -1465,6 +1471,9 @@ STATIC void emit_native_store_fast(emit_t *emit, qstr qst, mp_uint_t local_num)
|
||||
|
||||
STATIC void emit_native_store_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
|
||||
// not implemented
|
||||
(void)emit;
|
||||
(void)qst;
|
||||
(void)local_num;
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@ -1634,10 +1643,16 @@ STATIC void emit_native_delete_fast(emit_t *emit, qstr qst, mp_uint_t local_num)
|
||||
// local is automatically deleted for exception block "as" var, and the message
|
||||
// breaks tests.
|
||||
//mp_emitter_warning(emit->pass, "Native codegeneration doesn't support deleting local");
|
||||
(void)emit;
|
||||
(void)qst;
|
||||
(void)local_num;
|
||||
}
|
||||
|
||||
STATIC void emit_native_delete_deref(emit_t *emit, qstr qst, mp_uint_t local_num) {
|
||||
// TODO implement me!
|
||||
(void)emit;
|
||||
(void)qst;
|
||||
(void)local_num;
|
||||
}
|
||||
|
||||
STATIC void emit_native_delete_name(emit_t *emit, qstr qst) {
|
||||
@ -1711,7 +1726,7 @@ STATIC void emit_native_jump(emit_t *emit, mp_uint_t label) {
|
||||
emit_post(emit);
|
||||
}
|
||||
|
||||
STATIC void emit_native_jump_helper(emit_t *emit, mp_uint_t label, bool pop) {
|
||||
STATIC void emit_native_jump_helper(emit_t *emit, bool pop) {
|
||||
vtype_kind_t vtype = peek_vtype(emit, 0);
|
||||
switch (vtype) {
|
||||
case VTYPE_PYOBJ:
|
||||
@ -1744,21 +1759,21 @@ STATIC void emit_native_jump_helper(emit_t *emit, mp_uint_t label, bool pop) {
|
||||
|
||||
STATIC void emit_native_pop_jump_if_true(emit_t *emit, mp_uint_t label) {
|
||||
DEBUG_printf("pop_jump_if_true(label=" UINT_FMT ")\n", label);
|
||||
emit_native_jump_helper(emit, label, true);
|
||||
emit_native_jump_helper(emit, true);
|
||||
ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, label);
|
||||
emit_post(emit);
|
||||
}
|
||||
|
||||
STATIC void emit_native_pop_jump_if_false(emit_t *emit, mp_uint_t label) {
|
||||
DEBUG_printf("pop_jump_if_false(label=" UINT_FMT ")\n", label);
|
||||
emit_native_jump_helper(emit, label, true);
|
||||
emit_native_jump_helper(emit, true);
|
||||
ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, label);
|
||||
emit_post(emit);
|
||||
}
|
||||
|
||||
STATIC void emit_native_jump_if_true_or_pop(emit_t *emit, mp_uint_t label) {
|
||||
DEBUG_printf("jump_if_true_or_pop(label=" UINT_FMT ")\n", label);
|
||||
emit_native_jump_helper(emit, label, false);
|
||||
emit_native_jump_helper(emit, false);
|
||||
ASM_JUMP_IF_REG_NONZERO(emit->as, REG_RET, label);
|
||||
adjust_stack(emit, -1);
|
||||
emit_post(emit);
|
||||
@ -1766,26 +1781,31 @@ STATIC void emit_native_jump_if_true_or_pop(emit_t *emit, mp_uint_t label) {
|
||||
|
||||
STATIC void emit_native_jump_if_false_or_pop(emit_t *emit, mp_uint_t label) {
|
||||
DEBUG_printf("jump_if_false_or_pop(label=" UINT_FMT ")\n", label);
|
||||
emit_native_jump_helper(emit, label, false);
|
||||
emit_native_jump_helper(emit, false);
|
||||
ASM_JUMP_IF_REG_ZERO(emit->as, REG_RET, label);
|
||||
adjust_stack(emit, -1);
|
||||
emit_post(emit);
|
||||
}
|
||||
|
||||
STATIC void emit_native_break_loop(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) {
|
||||
(void)except_depth;
|
||||
emit_native_jump(emit, label & ~MP_EMIT_BREAK_FROM_FOR); // TODO properly
|
||||
}
|
||||
|
||||
STATIC void emit_native_continue_loop(emit_t *emit, mp_uint_t label, mp_uint_t except_depth) {
|
||||
(void)except_depth;
|
||||
emit_native_jump(emit, label); // TODO properly
|
||||
}
|
||||
|
||||
STATIC void emit_native_setup_with(emit_t *emit, mp_uint_t label) {
|
||||
// not supported, or could be with runtime call
|
||||
(void)emit;
|
||||
(void)label;
|
||||
assert(0);
|
||||
}
|
||||
|
||||
STATIC void emit_native_with_cleanup(emit_t *emit) {
|
||||
(void)emit;
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@ -1845,6 +1865,7 @@ STATIC void emit_native_pop_block(emit_t *emit) {
|
||||
}
|
||||
|
||||
STATIC void emit_native_pop_except(emit_t *emit) {
|
||||
(void)emit;
|
||||
/*
|
||||
emit_native_pre(emit);
|
||||
emit_call(emit, MP_F_NLR_POP);
|
||||
@ -2139,6 +2160,11 @@ STATIC void emit_native_make_function(emit_t *emit, scope_t *scope, mp_uint_t n_
|
||||
}
|
||||
|
||||
STATIC void emit_native_make_closure(emit_t *emit, scope_t *scope, mp_uint_t n_closed_over, mp_uint_t n_pos_defaults, mp_uint_t n_kw_defaults) {
|
||||
(void)emit;
|
||||
(void)scope;
|
||||
(void)n_closed_over;
|
||||
(void)n_pos_defaults;
|
||||
(void)n_kw_defaults;
|
||||
assert(0);
|
||||
}
|
||||
|
||||
@ -2238,10 +2264,12 @@ STATIC void emit_native_raise_varargs(emit_t *emit, mp_uint_t n_args) {
|
||||
|
||||
STATIC void emit_native_yield_value(emit_t *emit) {
|
||||
// not supported (for now)
|
||||
(void)emit;
|
||||
assert(0);
|
||||
}
|
||||
STATIC void emit_native_yield_from(emit_t *emit) {
|
||||
// not supported (for now)
|
||||
(void)emit;
|
||||
assert(0);
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,7 @@ void emit_pass1_free(emit_t *emit) {
|
||||
}
|
||||
|
||||
STATIC void emit_pass1_dummy(emit_t *emit) {
|
||||
(void)emit;
|
||||
}
|
||||
|
||||
STATIC void emit_pass1_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope) {
|
||||
@ -50,9 +51,11 @@ STATIC void emit_pass1_start_pass(emit_t *emit, pass_kind_t pass, scope_t *scope
|
||||
}
|
||||
|
||||
STATIC void emit_pass1_end_pass(emit_t *emit) {
|
||||
(void)emit;
|
||||
}
|
||||
|
||||
STATIC bool emit_pass1_last_emit_was_return_value(emit_t *emit) {
|
||||
(void)emit;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_micropython_mem_peak_obj, mp_micropython_mem
|
||||
#endif
|
||||
|
||||
mp_obj_t mp_micropython_mem_info(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
(void)args;
|
||||
#if MICROPY_MEM_STATS
|
||||
printf("mem: total=" UINT_FMT ", current=" UINT_FMT ", peak=" UINT_FMT "\n",
|
||||
m_get_total_bytes_allocated(), m_get_current_bytes_allocated(), m_get_peak_bytes_allocated());
|
||||
@ -69,6 +70,8 @@ mp_obj_t mp_micropython_mem_info(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
// arg given means dump gc allocation table
|
||||
gc_dump_alloc_table();
|
||||
}
|
||||
#else
|
||||
(void)n_args;
|
||||
#endif
|
||||
return mp_const_none;
|
||||
}
|
||||
|
6
py/mpz.c
6
py/mpz.c
@ -198,10 +198,10 @@ STATIC mp_uint_t mpn_sub(mpz_dig_t *idig, const mpz_dig_t *jdig, mp_uint_t jlen,
|
||||
|
||||
/* computes i = j & k
|
||||
returns number of digits in i
|
||||
assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen
|
||||
assumes enough memory in i; assumes normalised j, k; assumes jlen >= klen (jlen argument not needed)
|
||||
can have i, j, k pointing to same memory
|
||||
*/
|
||||
STATIC mp_uint_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, mp_uint_t jlen, const mpz_dig_t *kdig, mp_uint_t klen) {
|
||||
STATIC mp_uint_t mpn_and(mpz_dig_t *idig, const mpz_dig_t *jdig, const mpz_dig_t *kdig, mp_uint_t klen) {
|
||||
mpz_dig_t *oidig = idig;
|
||||
|
||||
for (; klen > 0; --klen, ++idig, ++jdig, ++kdig) {
|
||||
@ -1081,7 +1081,7 @@ void mpz_and_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs) {
|
||||
}
|
||||
// do the and'ing
|
||||
mpz_need_dig(dest, rhs->len);
|
||||
dest->len = mpn_and(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len);
|
||||
dest->len = mpn_and(dest->dig, lhs->dig, rhs->dig, rhs->len);
|
||||
dest->neg = 0;
|
||||
} else {
|
||||
// TODO both args are negative
|
||||
|
@ -77,6 +77,7 @@ STATIC mp_int_t array_get_buffer(mp_obj_t o_in, mp_buffer_info_t *bufinfo, mp_ui
|
||||
|
||||
#if MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_ARRAY
|
||||
STATIC void array_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_array_t *o = o_in;
|
||||
if (o->typecode == BYTEARRAY_TYPECODE) {
|
||||
print(env, "bytearray(b");
|
||||
@ -168,6 +169,7 @@ STATIC mp_obj_t array_construct(char typecode, mp_obj_t initializer) {
|
||||
|
||||
#if MICROPY_PY_ARRAY
|
||||
STATIC mp_obj_t array_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, 1, 2, false);
|
||||
|
||||
// get typecode
|
||||
@ -186,6 +188,7 @@ STATIC mp_obj_t array_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
|
||||
|
||||
#if MICROPY_PY_BUILTINS_BYTEARRAY
|
||||
STATIC mp_obj_t bytearray_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);
|
||||
|
||||
if (n_args == 0) {
|
||||
|
@ -53,6 +53,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, 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) {
|
||||
|
@ -37,6 +37,7 @@ typedef struct _mp_obj_bound_meth_t {
|
||||
|
||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
|
||||
STATIC void bound_meth_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_bound_meth_t *o = o_in;
|
||||
print(env, "<bound_method %p ", o);
|
||||
mp_obj_print_helper(print, env, o->self, PRINT_REPR);
|
||||
|
@ -43,6 +43,7 @@ void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj) {
|
||||
|
||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
|
||||
STATIC void cell_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_cell_t *o = o_in;
|
||||
print(env, "<cell %p ", o->obj);
|
||||
if (o->obj == MP_OBJ_NULL) {
|
||||
|
@ -61,6 +61,7 @@ STATIC mp_obj_t closure_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw,
|
||||
|
||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
|
||||
STATIC void closure_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_closure_t *o = o_in;
|
||||
print(env, "<closure ");
|
||||
mp_obj_print_helper(print, env, o->fun, PRINT_REPR);
|
||||
|
@ -49,6 +49,7 @@ typedef struct _mp_obj_complex_t {
|
||||
} mp_obj_complex_t;
|
||||
|
||||
STATIC void complex_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_complex_t *o = o_in;
|
||||
#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
|
||||
char buf[16];
|
||||
@ -76,6 +77,7 @@ STATIC void complex_print(void (*print)(void *env, const char *fmt, ...), void *
|
||||
}
|
||||
|
||||
STATIC mp_obj_t complex_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) {
|
||||
|
@ -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) {
|
||||
|
@ -114,6 +114,8 @@ STATIC mp_obj_t uni_unary_op(mp_uint_t op, mp_obj_t self_in) {
|
||||
}
|
||||
|
||||
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();
|
||||
@ -160,6 +162,7 @@ STATIC mp_obj_t str_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw,
|
||||
// be capped to the first/last character of the string, depending on is_slice.
|
||||
const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, mp_uint_t self_len,
|
||||
mp_obj_t index, bool is_slice) {
|
||||
(void)type;
|
||||
mp_int_t i;
|
||||
// Copied from mp_get_index; I don't want bounds checking, just give me
|
||||
// the integer as-is. (I can't bounds-check without scanning the whole
|
||||
|
@ -62,6 +62,8 @@ void mp_obj_tuple_print(void (*print)(void *env, const char *fmt, ...), void *en
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mp_obj_tuple_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) {
|
||||
|
@ -671,11 +671,14 @@ STATIC mp_obj_t instance_getiter(mp_obj_t self_in) {
|
||||
// - 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) {
|
||||
(void)kind;
|
||||
mp_obj_type_t *self = self_in;
|
||||
print(env, "<class '%s'>", qstr_str(self->name));
|
||||
}
|
||||
|
||||
STATIC mp_obj_t type_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, 1, 3, false);
|
||||
|
||||
switch (n_args) {
|
||||
@ -841,6 +844,7 @@ typedef struct _mp_obj_super_t {
|
||||
} 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) {
|
||||
(void)kind;
|
||||
mp_obj_super_t *self = self_in;
|
||||
print(env, "<super: ");
|
||||
mp_obj_print_helper(print, env, self->type, PRINT_STR);
|
||||
@ -850,6 +854,7 @@ STATIC void super_print(void (*print)(void *env, const char *fmt, ...), void *en
|
||||
}
|
||||
|
||||
STATIC mp_obj_t super_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 != 2 || n_kw != 0) {
|
||||
// 0 arguments are turned into 2 in the compiler
|
||||
// 1 argument is not yet implemented
|
||||
|
@ -40,7 +40,7 @@ STATIC mp_obj_t zip_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw,
|
||||
mp_arg_check_num(n_args, n_kw, 0, MP_OBJ_FUN_ARGS_MAX, false);
|
||||
|
||||
mp_obj_zip_t *o = m_new_obj_var(mp_obj_zip_t, mp_obj_t, n_args);
|
||||
o->base.type = &mp_type_zip;
|
||||
o->base.type = type_in;
|
||||
o->n_iters = n_args;
|
||||
for (mp_uint_t i = 0; i < n_args; i++) {
|
||||
o->iters[i] = mp_getiter(args[i]);
|
||||
|
@ -29,6 +29,7 @@
|
||||
// find real radix base, and strip preceding '0x', '0o' and '0b'
|
||||
// puts base in *base, and returns number of bytes to skip the prefix
|
||||
mp_uint_t mp_parse_num_base(const char *str, mp_uint_t len, mp_uint_t *base) {
|
||||
(void)len; // TODO use given len?
|
||||
const byte *p = (const byte*)str;
|
||||
unichar c = *(p++);
|
||||
if ((*base == 0 || *base == 16) && c == '0') {
|
||||
|
@ -179,6 +179,8 @@ int pfenv_print_int(const pfenv_t *pfenv, mp_uint_t x, int sgn, int base, int ba
|
||||
}
|
||||
|
||||
int pfenv_print_mp_int(const pfenv_t *pfenv, mp_obj_t x, int sgn, int base, int base_char, int flags, char fill, int width, int prec) {
|
||||
(void)sgn; // TODO why is sgn unused?
|
||||
|
||||
if (!MP_OBJ_IS_INT(x)) {
|
||||
// This will convert booleans to int, or raise an error for
|
||||
// non-integer types.
|
||||
|
@ -196,6 +196,7 @@ int pfenv_printf(const pfenv_t *pfenv, const char *fmt, ...) {
|
||||
}
|
||||
|
||||
void printf_wrapper(void *env, const char *fmt, ...) {
|
||||
(void)env;
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vprintf(fmt, args);
|
||||
|
@ -98,6 +98,8 @@ bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice
|
||||
#endif
|
||||
|
||||
mp_obj_t mp_seq_extract_slice(mp_uint_t len, const mp_obj_t *seq, mp_bound_slice_t *indexes) {
|
||||
(void)len; // TODO can we remove len from the arg list?
|
||||
|
||||
mp_int_t start = indexes->start, stop = indexes->stop;
|
||||
mp_int_t step = indexes->step;
|
||||
|
||||
|
@ -61,6 +61,7 @@ extern const mp_obj_type_t mp_type_fileio;
|
||||
extern const mp_obj_type_t mp_type_textio;
|
||||
|
||||
STATIC void fdfile_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_fdfile_t *self = self_in;
|
||||
print(env, "<io.%s %d>", mp_obj_get_type_str(self), self->fd);
|
||||
}
|
||||
@ -123,6 +124,7 @@ STATIC mp_obj_t fdfile_close(mp_obj_t self_in) {
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(fdfile_close_obj, fdfile_close);
|
||||
|
||||
STATIC mp_obj_t fdfile___exit__(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
return fdfile_close(args[0]);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(fdfile___exit___obj, 4, 4, fdfile___exit__);
|
||||
|
@ -161,6 +161,7 @@ STATIC mp_obj_t return_ffi_value(ffi_arg val, char type)
|
||||
// FFI module
|
||||
|
||||
STATIC void ffimod_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_ffimod_t *self = self_in;
|
||||
print(env, "<ffimod %p>", self->handle);
|
||||
}
|
||||
@ -173,6 +174,7 @@ STATIC mp_obj_t ffimod_close(mp_obj_t self_in) {
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(ffimod_close_obj, ffimod_close);
|
||||
|
||||
STATIC mp_obj_t ffimod_func(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args; // always 4
|
||||
mp_obj_ffimod_t *self = args[0];
|
||||
const char *rettype = mp_obj_str_get_str(args[1]);
|
||||
const char *symname = mp_obj_str_get_str(args[2]);
|
||||
@ -267,6 +269,9 @@ STATIC mp_obj_t ffimod_var(mp_obj_t self_in, mp_obj_t vartype_in, mp_obj_t symna
|
||||
MP_DEFINE_CONST_FUN_OBJ_3(ffimod_var_obj, ffimod_var);
|
||||
|
||||
STATIC mp_obj_t ffimod_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args) {
|
||||
(void)n_args;
|
||||
(void)n_kw;
|
||||
|
||||
const char *fname = mp_obj_str_get_str(args[0]);
|
||||
void *mod = dlopen(fname, RTLD_NOW | RTLD_LOCAL);
|
||||
|
||||
@ -298,6 +303,7 @@ STATIC const mp_obj_type_t ffimod_type = {
|
||||
// FFI function
|
||||
|
||||
STATIC void ffifunc_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_ffifunc_t *self = self_in;
|
||||
print(env, "<ffifunc %p>", self->func);
|
||||
}
|
||||
@ -366,6 +372,7 @@ STATIC const mp_obj_type_t ffifunc_type = {
|
||||
// FFI callback for Python function
|
||||
|
||||
STATIC void fficallback_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_fficallback_t *self = self_in;
|
||||
print(env, "<fficallback %p>", self->func);
|
||||
}
|
||||
@ -379,6 +386,7 @@ STATIC const mp_obj_type_t fficallback_type = {
|
||||
// FFI variable
|
||||
|
||||
STATIC void ffivar_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_ffivar_t *self = self_in;
|
||||
// Variable value printed as cast to int
|
||||
print(env, "<ffivar @%p: 0x%x>", self->var, *(int*)self->var);
|
||||
|
@ -83,6 +83,7 @@ STATIC mp_obj_socket_t *socket_new(int fd) {
|
||||
|
||||
|
||||
STATIC void socket_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t self_in, mp_print_kind_t kind) {
|
||||
(void)kind;
|
||||
mp_obj_socket_t *self = self_in;
|
||||
print(env, "<_socket %d>", self->fd);
|
||||
}
|
||||
@ -206,6 +207,7 @@ STATIC mp_obj_t socket_send(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_send_obj, 2, 3, socket_send);
|
||||
|
||||
STATIC mp_obj_t socket_setsockopt(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
(void)n_args; // always 4
|
||||
mp_obj_socket_t *self = args[0];
|
||||
int level = MP_OBJ_SMALL_INT_VALUE(args[1]);
|
||||
int option = mp_obj_get_int(args[2]);
|
||||
@ -259,6 +261,9 @@ STATIC mp_obj_t socket_makefile(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(socket_makefile_obj, 1, 3, socket_makefile);
|
||||
|
||||
STATIC mp_obj_t socket_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;
|
||||
(void)n_kw;
|
||||
|
||||
int family = AF_INET;
|
||||
int type = SOCK_STREAM;
|
||||
int proto = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user