From a71c83a1d1aeca1d81d7c673929f8e836dec131e Mon Sep 17 00:00:00 2001 From: Damien George Date: Sat, 15 Feb 2014 11:34:50 +0000 Subject: 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. --- unix/file.c | 2 +- unix/main.c | 4 ++-- unix/qstrdefsport.h | 4 ++++ unix/socket.c | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) (limited to 'unix') diff --git a/unix/file.c b/unix/file.c index 21dd76474..4e8fba54c 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 716c7b114..6aafe94dd 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 9f28c607e..42c88b469 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 4b160e0bc..25c4bfcb4 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, -- cgit v1.2.3