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.
diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py
index c5ad708..f231a5d 100644
--- a/py/makeqstrdata.py
+++ b/py/makeqstrdata.py
@@ -8,6 +8,9 @@
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
diff --git a/py/obj.c b/py/obj.c
index 4e0184a..86c0edc 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -26,7 +26,7 @@
}
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 @@
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 @@
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)));
}
}
diff --git a/py/obj.h b/py/obj.h
index 4982d5b..bed119c 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -142,7 +142,7 @@
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 @@
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 @@
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 @@
// 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);
diff --git a/py/objarray.c b/py/objarray.c
index d1bc08b..4a70f9f 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -161,7 +161,7 @@
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 @@
STATIC const mp_obj_type_t array_it_type = {
{ &mp_const_type },
- "array_iterator",
+ .name = MP_QSTR_iterator,
.iternext = array_it_iternext,
};
diff --git a/py/objbool.c b/py/objbool.c
index fb38bdf..2dd019b 100644
--- a/py/objbool.c
+++ b/py/objbool.c
@@ -47,7 +47,7 @@
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,
diff --git a/py/objboundmeth.c b/py/objboundmeth.c
index 500e61b..72fbc23 100644
--- a/py/objboundmeth.c
+++ b/py/objboundmeth.c
@@ -41,7 +41,7 @@
const mp_obj_type_t bound_meth_type = {
{ &mp_const_type },
- "bound_method",
+ .name = MP_QSTR_bound_method,
.call = bound_meth_call,
};
diff --git a/py/objcell.c b/py/objcell.c
index 04c7f36..ce8f360 100644
--- a/py/objcell.c
+++ b/py/objcell.c
@@ -26,7 +26,7 @@
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) {
diff --git a/py/objclosure.c b/py/objclosure.c
index 0f4816e..39e38c9 100644
--- a/py/objclosure.c
+++ b/py/objclosure.c
@@ -42,7 +42,7 @@
const mp_obj_type_t closure_type = {
{ &mp_const_type },
- "closure",
+ .name = MP_QSTR_closure,
.call = closure_call,
};
diff --git a/py/objcomplex.c b/py/objcomplex.c
index e3dce36..3b5de03 100644
--- a/py/objcomplex.c
+++ b/py/objcomplex.c
@@ -87,7 +87,7 @@
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,
diff --git a/py/objdict.c b/py/objdict.c
index 3f1b208..15e738d 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -113,7 +113,7 @@
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 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 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 @@
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,
diff --git a/py/objenumerate.c b/py/objenumerate.c
index e7695a1..2ca4dcd 100644
--- a/py/objenumerate.c
+++ b/py/objenumerate.c
@@ -28,7 +28,7 @@
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,
diff --git a/py/objexcept.c b/py/objexcept.c
index 48d3de8..e2c154d 100644
--- a/py/objexcept.c
+++ b/py/objexcept.c
@@ -63,7 +63,7 @@
const mp_obj_type_t exception_type = {
{ &mp_const_type },
- "exception",
+ .name = MP_QSTR_, // TODO proper exception names
.print = exception_print,
.call = exception_call,
};
diff --git a/py/objfilter.c b/py/objfilter.c
index 6d7abcf..4dde7fa 100644
--- a/py/objfilter.c
+++ b/py/objfilter.c
@@ -46,7 +46,7 @@
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,
diff --git a/py/objfloat.c b/py/objfloat.c
index fdb8250..83b9826 100644
--- a/py/objfloat.c
+++ b/py/objfloat.c
@@ -65,7 +65,7 @@
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,
diff --git a/py/objfun.c b/py/objfun.c
index 72c23a9..56ea692 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -90,7 +90,7 @@
const mp_obj_type_t fun_native_type = {
{ &mp_const_type },
- "function",
+ .name = MP_QSTR_function,
.call = fun_native_call,
};
@@ -160,7 +160,7 @@
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 const mp_obj_type_t fun_asm_type = {
{ &mp_const_type },
- "function",
+ .name = MP_QSTR_function,
.call = fun_asm_call,
};
diff --git a/py/objgenerator.c b/py/objgenerator.c
index dff4ade..4e7d3a1 100644
--- a/py/objgenerator.c
+++ b/py/objgenerator.c
@@ -39,7 +39,7 @@
const mp_obj_type_t gen_wrap_type = {
{ &mp_const_type },
- "generator",
+ .name = MP_QSTR_generator,
.call = gen_wrap_call,
};
@@ -121,7 +121,7 @@
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,
diff --git a/py/objgetitemiter.c b/py/objgetitemiter.c
index 0b8b439..28b118a 100644
--- a/py/objgetitemiter.c
+++ b/py/objgetitemiter.c
@@ -38,7 +38,7 @@
STATIC const mp_obj_type_t it_type = {
{ &mp_const_type },
- "iterator",
+ .name = MP_QSTR_iterator,
.iternext = it_iternext
};
diff --git a/py/objint.c b/py/objint.c
index 51d3b7e..1ae3ceb 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -99,7 +99,7 @@
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,
diff --git a/py/objlist.c b/py/objlist.c
index 5516a08..844f9cc 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -347,7 +347,7 @@
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 @@
STATIC const mp_obj_type_t list_it_type = {
{ &mp_const_type },
- "list_iterator",
+ .name = MP_QSTR_iterator,
.iternext = list_it_iternext,
};
diff --git a/py/objmap.c b/py/objmap.c
index f7508b2..012f0aa 100644
--- a/py/objmap.c
+++ b/py/objmap.c
@@ -52,7 +52,7 @@
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,
diff --git a/py/objmodule.c b/py/objmodule.c
index 259f119..14a2491 100644
--- a/py/objmodule.c
+++ b/py/objmodule.c
@@ -39,7 +39,7 @@
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,
diff --git a/py/objnone.c b/py/objnone.c
index 3104787..73f2601 100644
--- a/py/objnone.c
+++ b/py/objnone.c
@@ -25,7 +25,7 @@
const mp_obj_type_t none_type = {
{ &mp_const_type },
- "NoneType",
+ .name = MP_QSTR_NoneType,
.print = none_print,
.unary_op = none_unary_op,
};
diff --git a/py/objrange.c b/py/objrange.c
index 38796a6..a526ebc 100644
--- a/py/objrange.c
+++ b/py/objrange.c
@@ -25,7 +25,7 @@
STATIC const mp_obj_type_t range_type = {
{ &mp_const_type} ,
- "range",
+ .name = MP_QSTR_range,
.getiter = range_getiter,
};
@@ -63,7 +63,7 @@
STATIC const mp_obj_type_t range_it_type = {
{ &mp_const_type },
- "range_iterator",
+ .name = MP_QSTR_iterator,
.iternext = range_it_iternext,
};
diff --git a/py/objset.c b/py/objset.c
index 3cb1929..580b9de 100644
--- a/py/objset.c
+++ b/py/objset.c
@@ -73,7 +73,7 @@
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 @@
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,
diff --git a/py/objslice.c b/py/objslice.c
index b62c4e0..66a3c7a 100644
--- a/py/objslice.c
+++ b/py/objslice.c
@@ -23,7 +23,7 @@
const mp_obj_type_t ellipsis_type = {
{ &mp_const_type },
- "ellipsis",
+ .name = MP_QSTR_Ellipsis,
.print = ellipsis_print,
};
@@ -50,7 +50,7 @@
const mp_obj_type_t slice_type = {
{ &mp_const_type },
- "slice",
+ .name = MP_QSTR_slice,
.print = slice_print,
};
diff --git a/py/objstr.c b/py/objstr.c
index 7089b54..6ccd239 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -508,7 +508,7 @@
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 @@
// 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 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 const mp_obj_type_t bytes_it_type = {
{ &mp_const_type },
- "bytes_iterator",
+ .name = MP_QSTR_iterator,
.iternext = bytes_it_iternext,
};
diff --git a/py/objtuple.c b/py/objtuple.c
index f30b9a1..de49ce7 100644
--- a/py/objtuple.c
+++ b/py/objtuple.c
@@ -175,7 +175,7 @@
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 const mp_obj_type_t tuple_it_type = {
{ &mp_const_type },
- "tuple_iterator",
+ .name = MP_QSTR_iterator,
.iternext = tuple_it_iternext,
};
diff --git a/py/objtype.c b/py/objtype.c
index 5b364e6..a159214 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -257,7 +257,7 @@
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 @@
// 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 @@
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 @@
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 @@
.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 @@
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 @@
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
};
diff --git a/py/objzip.c b/py/objzip.c
index 5e5d35d..8f1bfe1 100644
--- a/py/objzip.c
+++ b/py/objzip.c
@@ -52,7 +52,7 @@
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,
diff --git a/py/qstrdefs.h b/py/qstrdefs.h
index 680c4bc..ac106f9 100644
--- a/py/qstrdefs.h
+++ b/py/qstrdefs.h
@@ -44,6 +44,8 @@
Q(ValueError)
Q(OverflowError)
+Q(NoneType)
+
Q(abs)
Q(all)
Q(any)
@@ -101,6 +103,15 @@
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>)
diff --git a/stm/Makefile b/stm/Makefile
index 7229f86..5048af3 100644
--- a/stm/Makefile
+++ b/stm/Makefile
@@ -18,7 +18,7 @@
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)
diff --git a/stm/adc.c b/stm/adc.c
index 51d3e9f..89f137a 100644
--- a/stm/adc.c
+++ b/stm/adc.c
@@ -333,7 +333,7 @@
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_obj_type_t adc_type = {
{ &mp_const_type },
- "ADC",
+ .name = MP_QSTR_ADC,
.print = adc_print,
.methods = adc_methods,
};
diff --git a/stm/file.c b/stm/file.c
index 36658e7..f50d377 100644
--- a/stm/file.c
+++ b/stm/file.c
@@ -61,7 +61,7 @@
static const mp_obj_type_t file_obj_type = {
{ &mp_const_type },
- "File",
+ .name = MP_QSTR_File,
.print = file_obj_print,
.methods = file_methods,
};
diff --git a/stm/i2c.c b/stm/i2c.c
index 1dfd74a..f355878 100644
--- a/stm/i2c.c
+++ b/stm/i2c.c
@@ -336,7 +336,7 @@
static const mp_obj_type_t i2c_obj_type = {
{ &mp_const_type },
- "I2C",
+ .name = MP_QSTR_I2C,
.print = i2c_obj_print,
.methods = i2c_methods,
};
diff --git a/stm/lcd.c b/stm/lcd.c
index 48d5a81..fb12cd4 100644
--- a/stm/lcd.c
+++ b/stm/lcd.c
@@ -287,7 +287,7 @@
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));
diff --git a/stm/led.c b/stm/led.c
index c517c3f..3a7d8a7 100644
--- a/stm/led.c
+++ b/stm/led.c
@@ -149,7 +149,7 @@
static const mp_obj_type_t led_obj_type = {
{ &mp_const_type },
- "Led",
+ .name = MP_QSTR_Led,
.print = led_obj_print,
.methods = led_methods,
};
diff --git a/stm/qstrdefsport.h b/stm/qstrdefsport.h
index 4fbcb1e..162e659 100644
--- a/stm/qstrdefsport.h
+++ b/stm/qstrdefsport.h
@@ -21,9 +21,12 @@
Q(time)
Q(rand)
Q(Led)
+Q(LCD)
Q(Servo)
+Q(SDcard)
Q(I2C)
Q(gpio)
Q(Usart)
Q(ADC)
Q(open)
+Q(File)
diff --git a/stm/sdcard.c b/stm/sdcard.c
index d0ec45a..c98bab4 100644
--- a/stm/sdcard.c
+++ b/stm/sdcard.c
@@ -203,7 +203,7 @@
static const mp_obj_type_t sdcard_type = {
{ &mp_const_type },
- "SDcard",
+ .name = MP_QSTR_SDcard,
.methods = sdcard_methods,
};
diff --git a/stm/servo.c b/stm/servo.c
index 31d6528..4b69eef 100644
--- a/stm/servo.c
+++ b/stm/servo.c
@@ -145,7 +145,7 @@
static const mp_obj_type_t servo_obj_type = {
{ &mp_const_type },
- "Servo",
+ .name = MP_QSTR_Servo,
.print = servo_obj_print,
.methods = servo_methods,
};
diff --git a/stm/usart.c b/stm/usart.c
index 306284d..e24211a 100644
--- a/stm/usart.c
+++ b/stm/usart.c
@@ -243,7 +243,7 @@
static const mp_obj_type_t usart_obj_type = {
{ &mp_const_type },
- "Usart",
+ .name = MP_QSTR_Usart,
.print = usart_obj_print,
.methods = usart_methods,
};
diff --git a/teensy/led.c b/teensy/led.c
index f16ba83..49ba46b 100644
--- a/teensy/led.c
+++ b/teensy/led.c
@@ -71,7 +71,7 @@
static const mp_obj_type_t led_obj_type = {
{ &mp_const_type },
- "Led",
+ .name = MP_QSTR_Led,
.print = led_obj_print,
.methods = led_methods,
};
diff --git a/teensy/servo.c b/teensy/servo.c
index da720c8..c3a2b28 100644
--- a/teensy/servo.c
+++ b/teensy/servo.c
@@ -190,7 +190,7 @@
static const mp_obj_type_t servo_obj_type = {
{ &mp_const_type },
- "Servo",
+ .name = MP_QSTR_Servo,
.print = servo_obj_print,
.methods = servo_methods,
};
diff --git a/unix/file.c b/unix/file.c
index 21dd764..4e8fba5 100644
--- a/unix/file.c
+++ b/unix/file.c
@@ -116,7 +116,7 @@
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,
diff --git a/unix/main.c b/unix/main.c
index 716c7b1..6aafe94 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -195,7 +195,7 @@
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 @@
// 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));
diff --git a/unix/qstrdefsport.h b/unix/qstrdefsport.h
index 9f28c60..42c88b4 100644
--- a/unix/qstrdefsport.h
+++ b/unix/qstrdefsport.h
@@ -1,5 +1,7 @@
// qstrs specific to this port
+Q(Test)
+
Q(argv)
Q(open)
Q(stdin)
@@ -13,3 +15,5 @@
Q(gethostbyname)
Q(getaddrinfo)
Q(microsocket)
+
+Q(io.FileIO)
diff --git a/unix/socket.c b/unix/socket.c
index 4b160e0..25c4bfc 100644
--- a/unix/socket.c
+++ b/unix/socket.c
@@ -238,7 +238,7 @@
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,
diff --git a/windows/qstrdefsport.h b/windows/qstrdefsport.h
index 3c69a1c..a8b4313 100644
--- a/windows/qstrdefsport.h
+++ b/windows/qstrdefsport.h
@@ -4,4 +4,6 @@
Q(open)
Q(stdin)
Q(stdout)
-Q(stderr)
\ No newline at end of file
+Q(stderr)
+
+Q(io.FileIO)