Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
93c4a6a3
Commit
93c4a6a3
authored
Sep 21, 2016
by
Damien George
Browse files
all: Remove 'name' member from mp_obj_module_t struct.
One can instead lookup __name__ in the modules dict to get the value.
parent
b0a46900
Changes
62
Hide whitespace changes
Inline
Side-by-side
py/modthread.c
View file @
93c4a6a3
...
...
@@ -294,7 +294,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_thread_globals, mp_module_thread_globals_t
const
mp_obj_module_t
mp_module_thread
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR__thread
,
.
globals
=
(
mp_obj_dict_t
*
)
&
mp_module_thread_globals
,
};
...
...
py/moduerrno.c
View file @
93c4a6a3
...
...
@@ -89,7 +89,6 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_uerrno_globals, mp_module_uerrno_globals_t
const
mp_obj_module_t
mp_module_uerrno
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_uerrno
,
.
globals
=
(
mp_obj_dict_t
*
)
&
mp_module_uerrno_globals
,
};
...
...
py/obj.h
View file @
93c4a6a3
...
...
@@ -765,7 +765,6 @@ MP_DECLARE_CONST_FUN_OBJ(mp_identity_obj);
// module
typedef
struct
_mp_obj_module_t
{
mp_obj_base_t
base
;
qstr
name
;
mp_obj_dict_t
*
globals
;
}
mp_obj_module_t
;
mp_obj_dict_t
*
mp_obj_module_get_globals
(
mp_obj_t
self_in
);
...
...
py/objmodule.c
View file @
93c4a6a3
...
...
@@ -37,17 +37,23 @@ STATIC void module_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kin
(
void
)
kind
;
mp_obj_module_t
*
self
=
MP_OBJ_TO_PTR
(
self_in
);
const
char
*
module_name
=
""
;
mp_map_elem_t
*
elem
=
mp_map_lookup
(
&
self
->
globals
->
map
,
MP_OBJ_NEW_QSTR
(
MP_QSTR___name__
),
MP_MAP_LOOKUP
);
if
(
elem
!=
NULL
)
{
module_name
=
mp_obj_str_get_str
(
elem
->
value
);
}
#if MICROPY_PY___FILE__
// If we store __file__ to imported modules then try to lookup this
// symbol to give more information about the module.
mp_map_elem_t
*
elem
=
mp_map_lookup
(
&
self
->
globals
->
map
,
MP_OBJ_NEW_QSTR
(
MP_QSTR___file__
),
MP_MAP_LOOKUP
);
elem
=
mp_map_lookup
(
&
self
->
globals
->
map
,
MP_OBJ_NEW_QSTR
(
MP_QSTR___file__
),
MP_MAP_LOOKUP
);
if
(
elem
!=
NULL
)
{
mp_printf
(
print
,
"<module '%
q
' from '%s'>"
,
self
->
name
,
mp_obj_str_get_str
(
elem
->
value
));
mp_printf
(
print
,
"<module '%
s
' from '%s'>"
,
module_
name
,
mp_obj_str_get_str
(
elem
->
value
));
return
;
}
#endif
mp_printf
(
print
,
"<module '%
q
'>"
,
self
->
name
);
mp_printf
(
print
,
"<module '%
s
'>"
,
module_
name
);
}
STATIC
void
module_attr
(
mp_obj_t
self_in
,
qstr
attr
,
mp_obj_t
*
dest
)
{
...
...
@@ -106,7 +112,6 @@ mp_obj_t mp_obj_new_module(qstr module_name) {
// create new module object
mp_obj_module_t
*
o
=
m_new_obj
(
mp_obj_module_t
);
o
->
base
.
type
=
&
mp_type_module
;
o
->
name
=
module_name
;
o
->
globals
=
MP_OBJ_TO_PTR
(
mp_obj_new_dict
(
MICROPY_MODULE_DICT_SIZE
));
// store __name__ entry in the module
...
...
py/runtime.c
View file @
93c4a6a3
...
...
@@ -55,7 +55,6 @@
const
mp_obj_module_t
mp_module___main__
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR___main__
,
.
globals
=
(
mp_obj_dict_t
*
)
&
MP_STATE_VM
(
dict_main
),
};
...
...
stmhal/modmachine.c
View file @
93c4a6a3
...
...
@@ -559,7 +559,6 @@ STATIC MP_DEFINE_CONST_DICT(machine_module_globals, machine_module_globals_table
const
mp_obj_module_t
machine_module
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_umachine
,
.
globals
=
(
mp_obj_dict_t
*
)
&
machine_module_globals
,
};
stmhal/modnetwork.c
View file @
93c4a6a3
...
...
@@ -86,6 +86,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_network_globals, mp_module_network_globals
const
mp_obj_module_t
mp_module_network
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_network
,
.
globals
=
(
mp_obj_dict_t
*
)
&
mp_module_network_globals
,
};
stmhal/modpyb.c
View file @
93c4a6a3
...
...
@@ -229,6 +229,5 @@ STATIC MP_DEFINE_CONST_DICT(pyb_module_globals, pyb_module_globals_table);
const
mp_obj_module_t
pyb_module
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_pyb
,
.
globals
=
(
mp_obj_dict_t
*
)
&
pyb_module_globals
,
};
stmhal/modstm.c
View file @
93c4a6a3
...
...
@@ -51,6 +51,5 @@ STATIC MP_DEFINE_CONST_DICT(stm_module_globals, stm_module_globals_table);
const
mp_obj_module_t
stm_module
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_stm
,
.
globals
=
(
mp_obj_dict_t
*
)
&
stm_module_globals
,
};
stmhal/moduos.c
View file @
93c4a6a3
...
...
@@ -407,6 +407,5 @@ STATIC MP_DEFINE_CONST_DICT(os_module_globals, os_module_globals_table);
const
mp_obj_module_t
mp_module_uos
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_uos
,
.
globals
=
(
mp_obj_dict_t
*
)
&
os_module_globals
,
};
stmhal/moduselect.c
View file @
93c4a6a3
...
...
@@ -307,6 +307,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_select_globals, mp_module_select_globals_t
const
mp_obj_module_t
mp_module_uselect
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_uselect
,
.
globals
=
(
mp_obj_dict_t
*
)
&
mp_module_select_globals
,
};
stmhal/modusocket.c
View file @
93c4a6a3
...
...
@@ -444,6 +444,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_usocket_globals, mp_module_usocket_globals
const
mp_obj_module_t
mp_module_usocket
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_usocket
,
.
globals
=
(
mp_obj_dict_t
*
)
&
mp_module_usocket_globals
,
};
stmhal/modutime.c
View file @
93c4a6a3
...
...
@@ -213,6 +213,5 @@ STATIC MP_DEFINE_CONST_DICT(time_module_globals, time_module_globals_table);
const
mp_obj_module_t
mp_module_utime
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_utime
,
.
globals
=
(
mp_obj_dict_t
*
)
&
time_module_globals
,
};
teensy/modpyb.c
View file @
93c4a6a3
...
...
@@ -354,6 +354,5 @@ STATIC MP_DEFINE_CONST_DICT(pyb_module_globals, pyb_module_globals_table);
const
mp_obj_module_t
pyb_module
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_pyb
,
.
globals
=
(
mp_obj_dict_t
*
)
&
pyb_module_globals
,
};
unix/modffi.c
View file @
93c4a6a3
...
...
@@ -499,6 +499,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_ffi_globals, mp_module_ffi_globals_table);
const
mp_obj_module_t
mp_module_ffi
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_ffi
,
.
globals
=
(
mp_obj_dict_t
*
)
&
mp_module_ffi_globals
,
};
unix/modjni.c
View file @
93c4a6a3
...
...
@@ -718,6 +718,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_jni_globals, mp_module_jni_globals_table);
const
mp_obj_module_t
mp_module_jni
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_jni
,
.
globals
=
(
mp_obj_dict_t
*
)
&
mp_module_jni_globals
,
};
unix/modmachine.c
View file @
93c4a6a3
...
...
@@ -91,7 +91,6 @@ STATIC MP_DEFINE_CONST_DICT(machine_module_globals, machine_module_globals_table
const
mp_obj_module_t
mp_module_machine
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_umachine
,
.
globals
=
(
mp_obj_dict_t
*
)
&
machine_module_globals
,
};
...
...
unix/modos.c
View file @
93c4a6a3
...
...
@@ -253,6 +253,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_os_globals, mp_module_os_globals_table);
const
mp_obj_module_t
mp_module_os
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_uos
,
.
globals
=
(
mp_obj_dict_t
*
)
&
mp_module_os_globals
,
};
unix/modsocket.c
View file @
93c4a6a3
...
...
@@ -586,6 +586,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_socket_globals, mp_module_socket_globals_t
const
mp_obj_module_t
mp_module_socket
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_usocket
,
.
globals
=
(
mp_obj_dict_t
*
)
&
mp_module_socket_globals
,
};
unix/modtermios.c
View file @
93c4a6a3
...
...
@@ -151,6 +151,5 @@ STATIC MP_DEFINE_CONST_DICT(mp_module_termios_globals, mp_module_termios_globals
const
mp_obj_module_t
mp_module_termios
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_termios
,
.
globals
=
(
mp_obj_dict_t
*
)
&
mp_module_termios_globals
,
};
Prev
1
2
3
4
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment