summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--py/makeqstrdata.py3
-rw-r--r--py/obj.c8
-rw-r--r--py/obj.h16
-rw-r--r--py/objarray.c4
-rw-r--r--py/objbool.c2
-rw-r--r--py/objboundmeth.c2
-rw-r--r--py/objcell.c2
-rw-r--r--py/objclosure.c2
-rw-r--r--py/objcomplex.c2
-rw-r--r--py/objdict.c8
-rw-r--r--py/objenumerate.c2
-rw-r--r--py/objexcept.c2
-rw-r--r--py/objfilter.c2
-rw-r--r--py/objfloat.c2
-rw-r--r--py/objfun.c6
-rw-r--r--py/objgenerator.c4
-rw-r--r--py/objgetitemiter.c2
-rw-r--r--py/objint.c2
-rw-r--r--py/objlist.c4
-rw-r--r--py/objmap.c2
-rw-r--r--py/objmodule.c2
-rw-r--r--py/objnone.c2
-rw-r--r--py/objrange.c4
-rw-r--r--py/objset.c4
-rw-r--r--py/objslice.c4
-rw-r--r--py/objstr.c8
-rw-r--r--py/objtuple.c4
-rw-r--r--py/objtype.c16
-rw-r--r--py/objzip.c2
-rw-r--r--py/qstrdefs.h11
-rw-r--r--stm/Makefile2
-rw-r--r--stm/adc.c4
-rw-r--r--stm/file.c2
-rw-r--r--stm/i2c.c2
-rw-r--r--stm/lcd.c2
-rw-r--r--stm/led.c2
-rw-r--r--stm/qstrdefsport.h3
-rw-r--r--stm/sdcard.c2
-rw-r--r--stm/servo.c2
-rw-r--r--stm/usart.c2
-rw-r--r--teensy/led.c2
-rw-r--r--teensy/servo.c2
-rw-r--r--unix/file.c2
-rw-r--r--unix/main.c4
-rw-r--r--unix/qstrdefsport.h4
-rw-r--r--unix/socket.c2
-rw-r--r--windows/qstrdefsport.h4
47 files changed, 100 insertions, 77 deletions
diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py
index c5ad708e89..f231a5d861 100644
--- a/py/makeqstrdata.py
+++ b/py/makeqstrdata.py
@@ -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
diff --git a/py/obj.c b/py/obj.c
index 4e0184a5f0..86c0edc15b 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -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)));
}
}
diff --git a/py/obj.h b/py/obj.h
index 4982d5bc23..bed119c0a2 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -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);
diff --git a/py/objarray.c b/py/objarray.c
index d1bc08b150..4a70f9f7f5 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -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,
};
diff --git a/py/objbool.c b/py/objbool.c
index fb38bdfb00..2dd019b720 100644
--- a/py/objbool.c
+++ b/py/objbool.c
@@ -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,
diff --git a/py/objboundmeth.c b/py/objboundmeth.c
index 500e61bd53..72fbc233f1 100644
--- a/py/objboundmeth.c
+++ b/py/objboundmeth.c
@@ -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,
};
diff --git a/py/objcell.c b/py/objcell.c
index 04c7f36851..ce8f360141 100644
--- a/py/objcell.c
+++ b/py/objcell.c
@@ -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) {
diff --git a/py/objclosure.c b/py/objclosure.c
index 0f4816e5fd..39e38c9d27 100644
--- a/py/objclosure.c
+++ b/py/objclosure.c
@@ -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,
};
diff --git a/py/objcomplex.c b/py/objcomplex.c
index e3dce365f5..3b5de03ed3 100644
--- a/py/objcomplex.c
+++ b/py/objcomplex.c
@@ -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,
diff --git a/py/objdict.c b/py/objdict.c
index 3f1b2087f3..15e738dff1 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -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,
diff --git a/py/objenumerate.c b/py/objenumerate.c
index e7695a16bd..2ca4dcd775 100644
--- a/py/objenumerate.c
+++ b/py/objenumerate.c
@@ -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,
diff --git a/py/objexcept.c b/py/objexcept.c
index 48d3de841e..e2c154de97 100644
--- a/py/objexcept.c
+++ b/py/objexcept.c
@@ -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,
};
diff --git a/py/objfilter.c b/py/objfilter.c
index 6d7abcf6f4..4dde7fac8c 100644
--- a/py/objfilter.c
+++ b/py/objfilter.c
@@ -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,
diff --git a/py/objfloat.c b/py/objfloat.c
index fdb8250568..83b98266e0 100644
--- a/py/objfloat.c
+++ b/py/objfloat.c
@@ -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,
diff --git a/py/objfun.c b/py/objfun.c
index 72c23a9ec2..56ea692eaf 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -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,
};
diff --git a/py/objgenerator.c b/py/objgenerator.c
index dff4ade749..4e7d3a199b 100644
--- a/py/objgenerator.c
+++ b/py/objgenerator.c
@@ -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,
diff --git a/py/objgetitemiter.c b/py/objgetitemiter.c
index 0b8b43913f..28b118a526 100644
--- a/py/objgetitemiter.c
+++ b/py/objgetitemiter.c
@@ -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
};
diff --git a/py/objint.c b/py/objint.c
index 51d3b7e1f1..1ae3cebbf7 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -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,
diff --git a/py/objlist.c b/py/objlist.c
index 5516a08f85..844f9cc81f 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -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,
};
diff --git a/py/objmap.c b/py/objmap.c
index f7508b2040..012f0aadb5 100644
--- a/py/objmap.c
+++ b/py/objmap.c
@@ -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,
diff --git a/py/objmodule.c b/py/objmodule.c
index 259f1191c9..14a2491711 100644
--- a/py/objmodule.c
+++ b/py/objmodule.c
@@ -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,
diff --git a/py/objnone.c b/py/objnone.c
index 310478734f..73f2601be4 100644
--- a/py/objnone.c
+++ b/py/objnone.c
@@ -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,
};
diff --git a/py/objrange.c b/py/objrange.c
index 38796a68ce..a526ebcec6 100644
--- a/py/objrange.c
+++ b/py/objrange.c
@@ -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,
};
diff --git a/py/objset.c b/py/objset.c
index 3cb19296f1..580b9de8e6 100644
--- a/py/objset.c
+++ b/py/objset.c
@@ -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,
diff --git a/py/objslice.c b/py/objslice.c
index b62c4e09ba..66a3c7a7a7 100644
--- a/py/objslice.c
+++ b/py/objslice.c
@@ -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,
};
diff --git a/py/objstr.c b/py/objstr.c
index 7089b54d1d..6ccd239959 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -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,
};
diff --git a/py/objtuple.c b/py/objtuple.c
index f30b9a13c7..de49ce74ef 100644
--- a/py/objtuple.c
+++ b/py/objtuple.c
@@ -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,
};
diff --git a/py/objtype.c b/py/objtype.c
index 5b364e6169..a1592140cb 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -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
};
diff --git a/py/objzip.c b/py/objzip.c
index 5e5d35df44..8f1bfe143f 100644
--- a/py/objzip.c
+++ b/py/objzip.c
@@ -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,
diff --git a/py/qstrdefs.h b/py/qstrdefs.h
index 680c4bcf73..ac106f9830 100644
--- a/py/qstrdefs.h
+++ b/py/qstrdefs.h
@@ -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>)
diff --git a/stm/Makefile b/stm/Makefile
index 7229f86e1e..5048af3824 100644
--- a/stm/Makefile
+++ b/stm/Makefile
@@ -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)
diff --git a/stm/adc.c b/stm/adc.c
index 51d3e9f91b..89f137a08c 100644
--- a/stm/adc.c
+++ b/stm/adc.c
@@ -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,
};
diff --git a/stm/file.c b/stm/file.c
index 36658e7a69..f50d3771a0 100644
--- a/stm/file.c
+++ b/stm/file.c
@@ -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,
};
diff --git a/stm/i2c.c b/stm/i2c.c
index 1dfd74a8d9..f355878f2b 100644
--- a/stm/i2c.c
+++ b/stm/i2c.c
@@ -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,
};
diff --git a/stm/lcd.c b/stm/lcd.c
index 48d5a81bb0..fb12cd4d98 100644
--- a/stm/lcd.c
+++ b/stm/lcd.c
@@ -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));
diff --git a/stm/led.c b/stm/led.c
index c517c3f6e8..3a7d8a7a7f 100644
--- a/stm/led.c
+++ b/stm/led.c
@@ -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,
};
diff --git a/stm/qstrdefsport.h b/stm/qstrdefsport.h
index 4fbcb1e5a4..162e659f36 100644
--- a/stm/qstrdefsport.h
+++ b/stm/qstrdefsport.h
@@ -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)
diff --git a/stm/sdcard.c b/stm/sdcard.c
index d0ec45a236..c98bab4d91 100644
--- a/stm/sdcard.c
+++ b/stm/sdcard.c
@@ -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,
};
diff --git a/stm/servo.c b/stm/servo.c
index 31d65283b5..4b69eefcfb 100644
--- a/stm/servo.c
+++ b/stm/servo.c
@@ -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,
};
diff --git a/stm/usart.c b/stm/usart.c
index 306284d5a9..e24211a83c 100644
--- a/stm/usart.c
+++ b/stm/usart.c
@@ -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,
};
diff --git a/teensy/led.c b/teensy/led.c
index f16ba83b39..49ba46b4d2 100644
--- a/teensy/led.c
+++ b/teensy/led.c
@@ -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,
};
diff --git a/teensy/servo.c b/teensy/servo.c
index da720c892b..c3a2b28889 100644
--- a/teensy/servo.c
+++ b/teensy/servo.c
@@ -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,
};
diff --git a/unix/file.c b/unix/file.c
index 21dd764748..4e8fba54c8 100644
--- a/unix/file.c
+++ b/unix/file.c
@@ -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,
diff --git a/unix/main.c b/unix/main.c
index 716c7b1142..6aafe94ddd 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -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));
diff --git a/unix/qstrdefsport.h b/unix/qstrdefsport.h
index 9f28c607e2..42c88b4693 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(inet_aton)
Q(gethostbyname)
Q(getaddrinfo)
Q(microsocket)
+
+Q(io.FileIO)
diff --git a/unix/socket.c b/unix/socket.c
index 4b160e0bc8..25c4bfcb46 100644
--- a/unix/socket.c
+++ b/unix/socket.c
@@ -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,
diff --git a/windows/qstrdefsport.h b/windows/qstrdefsport.h
index 3c69a1cb35..a8b4313d80 100644
--- a/windows/qstrdefsport.h
+++ b/windows/qstrdefsport.h
@@ -4,4 +4,6 @@ Q(argv)
Q(open)
Q(stdin)
Q(stdout)
-Q(stderr) \ No newline at end of file
+Q(stderr)
+
+Q(io.FileIO)