Change mp_obj_type_t.name from const char * to qstr.

Ultimately all static strings should be qstr.  This entry in the type
structure is only used for printing error messages (to tell the type of
the bad argument), and printing objects that don't supply a .print method.
This commit is contained in:
Damien George 2014-02-15 11:34:50 +00:00
parent 8ac72b9d00
commit a71c83a1d1
47 changed files with 100 additions and 77 deletions

View File

@ -8,6 +8,9 @@ if platform.python_version_tuple()[0] == '2':
elif platform.python_version_tuple()[0] == '3':
from html.entities import codepoint2name
# add some custom names to map characters that aren't in HTML
codepoint2name[ord('.')] = 'dot'
# this must match the equivalent function in qstr.c
def compute_hash(qstr):
hash = 0

View File

@ -26,7 +26,7 @@ mp_obj_type_t *mp_obj_get_type(mp_obj_t o_in) {
}
const char *mp_obj_get_type_str(mp_obj_t o_in) {
return mp_obj_get_type(o_in)->name;
return qstr_str(mp_obj_get_type(o_in)->name);
}
void printf_wrapper(void *env, const char *fmt, ...) {
@ -41,7 +41,7 @@ void mp_obj_print_helper(void (*print)(void *env, const char *fmt, ...), void *e
if (type->print != NULL) {
type->print(print, env, o_in, kind);
} else {
print(env, "<%s>", type->name);
print(env, "<%s>", qstr_str(type->name));
}
}
@ -226,11 +226,11 @@ uint mp_get_index(const mp_obj_type_t *type, machine_uint_t len, mp_obj_t index)
i += len;
}
if (i < 0 || i >= len) {
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_IndexError, "%s index out of range", type->name));
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_IndexError, "%s index out of range", qstr_str(type->name)));
}
return i;
} else {
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "%s indices must be integers, not %s", type->name, mp_obj_get_type_str(index)));
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "%s indices must be integers, not %s", qstr_str(type->name), mp_obj_get_type_str(index)));
}
}

View File

@ -142,7 +142,7 @@ typedef struct _mp_stream_p_t {
struct _mp_obj_type_t {
mp_obj_base_t base;
const char *name;
qstr name;
mp_print_fun_t print;
mp_make_new_fun_t make_new; // to make an instance of the type
@ -150,6 +150,12 @@ struct _mp_obj_type_t {
mp_unary_op_fun_t unary_op; // can return NULL if op not supported
mp_binary_op_fun_t binary_op; // can return NULL if op not supported
mp_load_attr_fun_t load_attr;
mp_store_attr_fun_t store_attr;
// Implements container[index] = val; note that load_item is implemented
// by binary_op(RT_BINARY_OP_SUBSCR)
mp_store_item_fun_t store_item;
mp_fun_1_t getiter;
mp_fun_1_t iternext;
@ -161,12 +167,6 @@ struct _mp_obj_type_t {
const mp_method_t *methods;
mp_load_attr_fun_t load_attr;
mp_store_attr_fun_t store_attr;
// Implements container[index] = val; note that load_item is implemented
// by binary_op(RT_BINARY_OP_SUBSCR)
mp_store_item_fun_t store_item;
// these are for dynamically created types (classes)
mp_obj_t bases_tuple;
mp_obj_t locals_dict;
@ -200,7 +200,7 @@ extern const mp_obj_t mp_const_stop_iteration; // special object indicating end
// General API for objects
mp_obj_t mp_obj_new_type(const char *name, mp_obj_t bases_tuple, mp_obj_t locals_dict);
mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict);
mp_obj_t mp_obj_new_none(void);
mp_obj_t mp_obj_new_bool(bool value);
mp_obj_t mp_obj_new_cell(mp_obj_t obj);

View File

@ -161,7 +161,7 @@ STATIC const mp_method_t array_type_methods[] = {
const mp_obj_type_t array_type = {
{ &mp_const_type },
"array",
.name = MP_QSTR_array,
.print = array_print,
.make_new = array_make_new,
.getiter = array_iterator_new,
@ -223,7 +223,7 @@ mp_obj_t array_it_iternext(mp_obj_t self_in) {
STATIC const mp_obj_type_t array_it_type = {
{ &mp_const_type },
"array_iterator",
.name = MP_QSTR_iterator,
.iternext = array_it_iternext,
};

View File

@ -47,7 +47,7 @@ STATIC mp_obj_t bool_unary_op(int op, mp_obj_t o_in) {
const mp_obj_type_t bool_type = {
{ &mp_const_type },
"bool",
.name = MP_QSTR_bool,
.print = bool_print,
.make_new = bool_make_new,
.unary_op = bool_unary_op,

View File

@ -41,7 +41,7 @@ mp_obj_t bound_meth_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_
const mp_obj_type_t bound_meth_type = {
{ &mp_const_type },
"bound_method",
.name = MP_QSTR_bound_method,
.call = bound_meth_call,
};

View File

@ -26,7 +26,7 @@ void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj) {
const mp_obj_type_t cell_type = {
{ &mp_const_type },
"cell",
.name = MP_QSTR_, // should never need to print cell type
};
mp_obj_t mp_obj_new_cell(mp_obj_t obj) {

View File

@ -42,7 +42,7 @@ mp_obj_t closure_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj_t *
const mp_obj_type_t closure_type = {
{ &mp_const_type },
"closure",
.name = MP_QSTR_closure,
.call = closure_call,
};

View File

@ -87,7 +87,7 @@ STATIC mp_obj_t complex_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
const mp_obj_type_t complex_type = {
{ &mp_const_type },
"complex",
.name = MP_QSTR_complex,
.print = complex_print,
.make_new = complex_make_new,
.unary_op = complex_unary_op,

View File

@ -113,7 +113,7 @@ mp_obj_t dict_it_iternext(mp_obj_t self_in) {
STATIC const mp_obj_type_t dict_it_type = {
{ &mp_const_type },
"dict_iterator",
.name = MP_QSTR_iterator,
.iternext = dict_it_iternext,
};
@ -342,7 +342,7 @@ STATIC mp_obj_t dict_view_it_iternext(mp_obj_t self_in) {
STATIC const mp_obj_type_t dict_view_it_type = {
{ &mp_const_type },
"dict_view_iterator",
.name = MP_QSTR_iterator,
.iternext = dict_view_it_iternext,
.methods = NULL, /* set operations still to come */
};
@ -386,7 +386,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 = {
{ &mp_const_type },
"dict_view",
.name = MP_QSTR_dict_view,
.print = dict_view_print,
.binary_op = dict_view_binary_op,
.getiter = dict_view_getiter,
@ -441,7 +441,7 @@ STATIC const mp_method_t dict_type_methods[] = {
const mp_obj_type_t dict_type = {
{ &mp_const_type },
"dict",
.name = MP_QSTR_dict,
.print = dict_print,
.make_new = dict_make_new,
.unary_op = dict_unary_op,

View File

@ -28,7 +28,7 @@ STATIC mp_obj_t enumerate_make_new(mp_obj_t type_in, uint n_args, uint n_kw, con
const mp_obj_type_t enumerate_type = {
{ &mp_const_type },
"enumerate",
.name = MP_QSTR_enumerate,
.make_new = enumerate_make_new,
.iternext = enumerate_iternext,
.getiter = mp_identity,

View File

@ -63,7 +63,7 @@ STATIC mp_obj_t exception_call(mp_obj_t self_in, uint n_args, uint n_kw, const m
const mp_obj_type_t exception_type = {
{ &mp_const_type },
"exception",
.name = MP_QSTR_, // TODO proper exception names
.print = exception_print,
.call = exception_call,
};

View File

@ -46,7 +46,7 @@ STATIC mp_obj_t filter_iternext(mp_obj_t self_in) {
const mp_obj_type_t filter_type = {
{ &mp_const_type },
"filter",
.name = MP_QSTR_filter,
.make_new = filter_make_new,
.getiter = mp_identity,
.iternext = filter_iternext,

View File

@ -65,7 +65,7 @@ STATIC mp_obj_t float_binary_op(int op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
const mp_obj_type_t float_type = {
{ &mp_const_type },
"float",
.name = MP_QSTR_float,
.print = float_print,
.make_new = float_make_new,
.unary_op = float_unary_op,

View File

@ -90,7 +90,7 @@ STATIC mp_obj_t fun_native_call(mp_obj_t self_in, uint n_args, uint n_kw, const
const mp_obj_type_t fun_native_type = {
{ &mp_const_type },
"function",
.name = MP_QSTR_function,
.call = fun_native_call,
};
@ -160,7 +160,7 @@ STATIC mp_obj_t fun_bc_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_o
const mp_obj_type_t fun_bc_type = {
{ &mp_const_type },
"function",
.name = MP_QSTR_function,
.call = fun_bc_call,
};
@ -277,7 +277,7 @@ STATIC mp_obj_t fun_asm_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_
STATIC const mp_obj_type_t fun_asm_type = {
{ &mp_const_type },
"function",
.name = MP_QSTR_function,
.call = fun_asm_call,
};

View File

@ -39,7 +39,7 @@ STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp
const mp_obj_type_t gen_wrap_type = {
{ &mp_const_type },
"generator",
.name = MP_QSTR_generator,
.call = gen_wrap_call,
};
@ -121,7 +121,7 @@ STATIC const mp_method_t gen_type_methods[] = {
const mp_obj_type_t gen_instance_type = {
{ &mp_const_type },
"generator",
.name = MP_QSTR_generator,
.print = gen_instance_print,
.getiter = gen_instance_getiter,
.iternext = gen_instance_iternext,

View File

@ -38,7 +38,7 @@ STATIC mp_obj_t it_iternext(mp_obj_t self_in) {
STATIC const mp_obj_type_t it_type = {
{ &mp_const_type },
"iterator",
.name = MP_QSTR_iterator,
.iternext = it_iternext
};

View File

@ -99,7 +99,7 @@ machine_int_t mp_obj_int_get_checked(mp_obj_t self_in) {
const mp_obj_type_t int_type = {
{ &mp_const_type },
"int",
.name = MP_QSTR_int,
.print = int_print,
.make_new = int_make_new,
.unary_op = int_unary_op,

View File

@ -347,7 +347,7 @@ STATIC const mp_method_t list_type_methods[] = {
const mp_obj_type_t list_type = {
{ &mp_const_type },
"list",
.name = MP_QSTR_list,
.print = list_print,
.make_new = list_make_new,
.unary_op = list_unary_op,
@ -409,7 +409,7 @@ mp_obj_t list_it_iternext(mp_obj_t self_in) {
STATIC const mp_obj_type_t list_it_type = {
{ &mp_const_type },
"list_iterator",
.name = MP_QSTR_iterator,
.iternext = list_it_iternext,
};

View File

@ -52,7 +52,7 @@ STATIC mp_obj_t map_iternext(mp_obj_t self_in) {
const mp_obj_type_t map_type = {
{ &mp_const_type },
"map",
.name = MP_QSTR_map,
.make_new = map_make_new,
.getiter = map_getiter,
.iternext = map_iternext,

View File

@ -39,7 +39,7 @@ STATIC bool module_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
const mp_obj_type_t module_type = {
{ &mp_const_type },
"module",
.name = MP_QSTR_module,
.print = module_print,
.load_attr = module_load_attr,
.store_attr = module_store_attr,

View File

@ -25,7 +25,7 @@ STATIC mp_obj_t none_unary_op(int op, mp_obj_t o_in) {
const mp_obj_type_t none_type = {
{ &mp_const_type },
"NoneType",
.name = MP_QSTR_NoneType,
.print = none_print,
.unary_op = none_unary_op,
};

View File

@ -25,7 +25,7 @@ STATIC mp_obj_t range_getiter(mp_obj_t o_in) {
STATIC const mp_obj_type_t range_type = {
{ &mp_const_type} ,
"range",
.name = MP_QSTR_range,
.getiter = range_getiter,
};
@ -63,7 +63,7 @@ STATIC mp_obj_t range_it_iternext(mp_obj_t o_in) {
STATIC const mp_obj_type_t range_it_type = {
{ &mp_const_type },
"range_iterator",
.name = MP_QSTR_iterator,
.iternext = range_it_iternext,
};

View File

@ -73,7 +73,7 @@ STATIC mp_obj_t set_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_
const mp_obj_type_t set_it_type = {
{ &mp_const_type },
"set_iterator",
.name = MP_QSTR_iterator,
.iternext = set_it_iternext,
};
@ -447,7 +447,7 @@ STATIC const mp_method_t set_type_methods[] = {
const mp_obj_type_t set_type = {
{ &mp_const_type },
"set",
.name = MP_QSTR_set,
.print = set_print,
.make_new = set_make_new,
.binary_op = set_binary_op,

View File

@ -23,7 +23,7 @@ void ellipsis_print(void (*print)(void *env, const char *fmt, ...), void *env, m
const mp_obj_type_t ellipsis_type = {
{ &mp_const_type },
"ellipsis",
.name = MP_QSTR_Ellipsis,
.print = ellipsis_print,
};
@ -50,7 +50,7 @@ void slice_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_o
const mp_obj_type_t slice_type = {
{ &mp_const_type },
"slice",
.name = MP_QSTR_slice,
.print = slice_print,
};

View File

@ -508,7 +508,7 @@ STATIC const mp_method_t str_type_methods[] = {
const mp_obj_type_t str_type = {
{ &mp_const_type },
"str",
.name = MP_QSTR_str,
.print = str_print,
.binary_op = str_binary_op,
.getiter = mp_obj_new_str_iterator,
@ -518,7 +518,7 @@ const mp_obj_type_t str_type = {
// Reuses most of methods from str
const mp_obj_type_t bytes_type = {
{ &mp_const_type },
"bytes",
.name = MP_QSTR_bytes,
.print = str_print,
.binary_op = str_binary_op,
.getiter = mp_obj_new_bytes_iterator,
@ -668,7 +668,7 @@ STATIC mp_obj_t str_it_iternext(mp_obj_t self_in) {
STATIC const mp_obj_type_t str_it_type = {
{ &mp_const_type },
"str_iterator",
.name = MP_QSTR_iterator,
.iternext = str_it_iternext,
};
@ -686,7 +686,7 @@ STATIC mp_obj_t bytes_it_iternext(mp_obj_t self_in) {
STATIC const mp_obj_type_t bytes_it_type = {
{ &mp_const_type },
"bytes_iterator",
.name = MP_QSTR_iterator,
.iternext = bytes_it_iternext,
};

View File

@ -175,7 +175,7 @@ STATIC const mp_method_t tuple_type_methods[] = {
const mp_obj_type_t tuple_type = {
{ &mp_const_type },
"tuple",
.name = MP_QSTR_tuple,
.print = tuple_print,
.make_new = tuple_make_new,
.unary_op = tuple_unary_op,
@ -242,7 +242,7 @@ STATIC mp_obj_t tuple_it_iternext(mp_obj_t self_in) {
STATIC const mp_obj_type_t tuple_it_type = {
{ &mp_const_type },
"tuple_iterator",
.name = MP_QSTR_iterator,
.iternext = tuple_it_iternext,
};

View File

@ -257,7 +257,7 @@ bool class_store_item(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
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);
print(env, "<class '%s'>", qstr_str(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) {
@ -271,7 +271,7 @@ STATIC mp_obj_t type_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp
// args[0] = name
// args[1] = bases tuple
// args[2] = locals dict
return mp_obj_new_type(mp_obj_str_get_str(args[0]), args[1], args[2]);
return mp_obj_new_type(mp_obj_str_get_qstr(args[0]), args[1], args[2]);
default:
nlr_jump(mp_obj_new_exception_msg(MP_QSTR_TypeError, "type takes 1 or 3 arguments"));
@ -284,7 +284,7 @@ STATIC mp_obj_t type_call(mp_obj_t self_in, uint n_args, uint n_kw, const mp_obj
mp_obj_type_t *self = self_in;
if (self->make_new == NULL) {
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "cannot create '%s' instances", self->name));
nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_TypeError, "cannot create '%s' instances", qstr_str(self->name)));
}
// make new instance
@ -335,7 +335,7 @@ STATIC bool type_store_attr(mp_obj_t self_in, qstr attr, mp_obj_t value) {
const mp_obj_type_t mp_const_type = {
{ &mp_const_type },
"type",
.name = MP_QSTR_type,
.print = type_print,
.make_new = type_make_new,
.call = type_call,
@ -343,7 +343,7 @@ const mp_obj_type_t mp_const_type = {
.store_attr = type_store_attr,
};
mp_obj_t mp_obj_new_type(const char *name, mp_obj_t bases_tuple, mp_obj_t locals_dict) {
mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict) {
assert(MP_OBJ_IS_TYPE(bases_tuple, &tuple_type)); // Micro Python restriction, for now
assert(MP_OBJ_IS_TYPE(locals_dict, &dict_type)); // Micro Python restriction, for now
mp_obj_type_t *o = m_new0(mp_obj_type_t, 1);
@ -439,7 +439,7 @@ STATIC void super_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
const mp_obj_type_t super_type = {
{ &mp_const_type },
"super",
.name = MP_QSTR_super,
.print = super_print,
.make_new = super_make_new,
.load_attr = super_load_attr,
@ -521,12 +521,12 @@ STATIC mp_obj_t static_class_method_make_new(mp_obj_t self_in, uint n_args, uint
const mp_obj_type_t mp_type_staticmethod = {
{ &mp_const_type },
"staticmethod",
.name = MP_QSTR_staticmethod,
.make_new = static_class_method_make_new
};
const mp_obj_type_t mp_type_classmethod = {
{ &mp_const_type },
"classmethod",
.name = MP_QSTR_classmethod,
.make_new = static_class_method_make_new
};

View File

@ -52,7 +52,7 @@ STATIC mp_obj_t zip_iternext(mp_obj_t self_in) {
const mp_obj_type_t zip_type = {
{ &mp_const_type },
"zip",
.name = MP_QSTR_zip,
.make_new = zip_make_new,
.getiter = zip_getiter,
.iternext = zip_iternext,

View File

@ -44,6 +44,8 @@ Q(TypeError)
Q(ValueError)
Q(OverflowError)
Q(NoneType)
Q(abs)
Q(all)
Q(any)
@ -101,6 +103,15 @@ Q(format)
Q(key)
Q(reverse)
Q(bound_method)
Q(closure)
Q(dict_view)
Q(function)
Q(generator)
Q(iterator)
Q(module)
Q(slice)
Q(<module>)
Q(<lambda>)
Q(<listcomp>)

View File

@ -18,7 +18,7 @@ DFU=../tools/dfu.py
CROSS_COMPILE = arm-none-eabi-
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mabi=aapcs-linux -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant -Wdouble-promotion
CFLAGS = -I. -I$(PY_SRC) -I$(CMSIS_DIR) -I$(STMPERIPH_DIR) -I$(STMUSB_DIR) -Wall -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT)
CFLAGS = -I. -I$(PY_SRC) -I$(CMSIS_DIR) -I$(STMPERIPH_DIR) -I$(STMUSB_DIR) -Wall -Werror -ansi -std=gnu99 $(CFLAGS_CORTEX_M4) $(COPT)
CFLAGS += -I$(STMUSBD_DIR)
CFLAGS += -I$(STMUSBH_DIR)
CFLAGS += -I$(FATFS_DIR)

View File

@ -333,7 +333,7 @@ static const mp_method_t adc_all_methods[] = {
static const mp_obj_type_t adc_all_type = {
{ &mp_const_type },
"ADC_all",
.name = MP_QSTR_ADC,
.print = adc_all_print,
.methods = adc_all_methods,
};
@ -387,7 +387,7 @@ static const mp_method_t adc_methods[] = {
static const mp_obj_type_t adc_type = {
{ &mp_const_type },
"ADC",
.name = MP_QSTR_ADC,
.print = adc_print,
.methods = adc_methods,
};

View File

@ -61,7 +61,7 @@ static const mp_method_t file_methods[] = {
static const mp_obj_type_t file_obj_type = {
{ &mp_const_type },
"File",
.name = MP_QSTR_File,
.print = file_obj_print,
.methods = file_methods,
};

View File

@ -336,7 +336,7 @@ static const mp_method_t i2c_methods[] = {
static const mp_obj_type_t i2c_obj_type = {
{ &mp_const_type },
"I2C",
.name = MP_QSTR_I2C,
.print = i2c_obj_print,
.methods = i2c_methods,
};

View File

@ -287,7 +287,7 @@ static mp_obj_t pyb_lcd_init(void) {
lcd_next_line = 0;
// Micro Python interface
mp_obj_t o = mp_obj_new_type("LCD", mp_const_empty_tuple, mp_obj_new_dict(0));
mp_obj_t o = mp_obj_new_type(MP_QSTR_LCD, mp_const_empty_tuple, mp_obj_new_dict(0));
rt_store_attr(o, qstr_from_str("lcd8"), rt_make_function_n(2, lcd_draw_pixel_8));
rt_store_attr(o, qstr_from_str("clear"), rt_make_function_n(0, lcd_pix_clear));
rt_store_attr(o, qstr_from_str("get"), rt_make_function_n(2, lcd_pix_get));

View File

@ -149,7 +149,7 @@ static const mp_method_t led_methods[] = {
static const mp_obj_type_t led_obj_type = {
{ &mp_const_type },
"Led",
.name = MP_QSTR_Led,
.print = led_obj_print,
.methods = led_methods,
};

View File

@ -21,9 +21,12 @@ Q(hid)
Q(time)
Q(rand)
Q(Led)
Q(LCD)
Q(Servo)
Q(SDcard)
Q(I2C)
Q(gpio)
Q(Usart)
Q(ADC)
Q(open)
Q(File)

View File

@ -203,7 +203,7 @@ static const mp_method_t sdcard_methods[] = {
static const mp_obj_type_t sdcard_type = {
{ &mp_const_type },
"SDcard",
.name = MP_QSTR_SDcard,
.methods = sdcard_methods,
};

View File

@ -145,7 +145,7 @@ static const mp_method_t servo_methods[] = {
static const mp_obj_type_t servo_obj_type = {
{ &mp_const_type },
"Servo",
.name = MP_QSTR_Servo,
.print = servo_obj_print,
.methods = servo_methods,
};

View File

@ -243,7 +243,7 @@ static const mp_method_t usart_methods[] = {
static const mp_obj_type_t usart_obj_type = {
{ &mp_const_type },
"Usart",
.name = MP_QSTR_Usart,
.print = usart_obj_print,
.methods = usart_methods,
};

View File

@ -71,7 +71,7 @@ static const mp_method_t led_methods[] = {
static const mp_obj_type_t led_obj_type = {
{ &mp_const_type },
"Led",
.name = MP_QSTR_Led,
.print = led_obj_print,
.methods = led_methods,
};

View File

@ -190,7 +190,7 @@ static const mp_method_t servo_methods[] = {
static const mp_obj_type_t servo_obj_type = {
{ &mp_const_type },
"Servo",
.name = MP_QSTR_Servo,
.print = servo_obj_print,
.methods = servo_methods,
};

View File

@ -116,7 +116,7 @@ static const mp_method_t rawfile_type_methods[] = {
static const mp_obj_type_t rawfile_type = {
{ &mp_const_type },
"io.FileIO",
.name = MP_QSTR_io_dot_FileIO,
.print = fdfile_print,
.make_new = fdfile_make_new,
.getiter = mp_identity,

View File

@ -195,7 +195,7 @@ static const mp_method_t test_methods[] = {
static const mp_obj_type_t test_type = {
{ &mp_const_type },
"Test",
.name = MP_QSTR_Test,
.print = test_print,
.methods = test_methods,
};
@ -308,7 +308,7 @@ int main(int argc, char **argv) {
// test_obj = TestClass()
// test_obj.attr = 42
mp_obj_t test_class_type, test_class_instance;
test_class_type = mp_obj_new_type("TestClass", mp_const_empty_tuple, mp_obj_new_dict(0));
test_class_type = mp_obj_new_type(QSTR_FROM_STR_STATIC("TestClass"), mp_const_empty_tuple, mp_obj_new_dict(0));
rt_store_name(QSTR_FROM_STR_STATIC("test_obj"), test_class_instance = rt_call_function_0(test_class_type));
rt_store_attr(test_class_instance, QSTR_FROM_STR_STATIC("attr"), mp_obj_new_int(42));

View File

@ -1,5 +1,7 @@
// qstrs specific to this port
Q(Test)
Q(argv)
Q(open)
Q(stdin)
@ -13,3 +15,5 @@ Q(inet_aton)
Q(gethostbyname)
Q(getaddrinfo)
Q(microsocket)
Q(io.FileIO)

View File

@ -238,7 +238,7 @@ static const mp_method_t microsocket_type_methods[] = {
static const mp_obj_type_t microsocket_type = {
{ &mp_const_type },
"socket",
.name = MP_QSTR_socket,
.print = socket_print,
.make_new = socket_make_new,
.getiter = NULL,

View File

@ -5,3 +5,5 @@ Q(open)
Q(stdin)
Q(stdout)
Q(stderr)
Q(io.FileIO)