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
6022d9d4
Commit
6022d9d4
authored
Mar 26, 2014
by
Damien George
Browse files
py: Improved builtin dir.
parent
9b196cdd
Changes
1
Hide whitespace changes
Inline
Side-by-side
py/builtin.c
View file @
6022d9d4
...
...
@@ -157,11 +157,18 @@ STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
map
=
rt_locals_get
();
}
else
{
// n_args == 1
// make a list of names in the given object
mp_obj_type_t
*
type
=
mp_obj_get_type
(
args
[
0
]);
if
(
type
==
&
mp_type_module
)
{
if
(
MP_OBJ_IS_TYPE
(
args
[
0
],
&
mp_type_module
))
{
map
=
mp_obj_module_get_globals
(
args
[
0
]);
}
else
if
(
type
->
locals_dict
!=
MP_OBJ_NULL
&&
MP_OBJ_IS_TYPE
(
type
->
locals_dict
,
&
dict_type
))
{
map
=
mp_obj_dict_get_map
(
type
->
locals_dict
);
}
else
{
mp_obj_type_t
*
type
;
if
(
MP_OBJ_IS_TYPE
(
args
[
0
],
&
mp_type_type
))
{
type
=
args
[
0
];
}
else
{
type
=
mp_obj_get_type
(
args
[
0
]);
}
if
(
type
->
locals_dict
!=
MP_OBJ_NULL
&&
MP_OBJ_IS_TYPE
(
type
->
locals_dict
,
&
dict_type
))
{
map
=
mp_obj_dict_get_map
(
type
->
locals_dict
);
}
}
}
...
...
Write
Preview
Markdown
is supported
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