Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
uPython-mirror
Commits
eb2fc978
Commit
eb2fc978
authored
Apr 17, 2014
by
Paul Sokolovsky
Browse files
unix modtime: Convert to static module structures.
parent
de829220
Changes
4
Hide whitespace changes
Inline
Side-by-side
unix/main.c
View file @
eb2fc978
...
...
@@ -357,9 +357,6 @@ int main(int argc, char **argv) {
#endif
microsocket_init
();
#if MICROPY_MOD_TIME
time_init
();
#endif
#if MICROPY_MOD_FFI
ffi_init
();
#endif
...
...
unix/modtime.c
View file @
eb2fc978
...
...
@@ -51,9 +51,26 @@ STATIC mp_obj_t mod_time_sleep(mp_obj_t arg) {
}
STATIC
MP_DEFINE_CONST_FUN_OBJ_1
(
mod_time_sleep_obj
,
mod_time_sleep
);
void
time_init
()
{
mp_obj_t
m
=
mp_obj_new_module
(
QSTR_FROM_STR_STATIC
(
"time"
));
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"time"
),
(
mp_obj_t
)
&
mod_time_time_obj
);
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"clock"
),
(
mp_obj_t
)
&
mod_time_clock_obj
);
mp_store_attr
(
m
,
QSTR_FROM_STR_STATIC
(
"sleep"
),
(
mp_obj_t
)
&
mod_time_sleep_obj
);
}
STATIC
const
mp_map_elem_t
mp_module_time_globals_table
[]
=
{
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___name__
),
MP_OBJ_NEW_QSTR
(
MP_QSTR_time
)
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_clock
),
(
mp_obj_t
)
&
mod_time_clock_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_sleep
),
(
mp_obj_t
)
&
mod_time_sleep_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_time
),
(
mp_obj_t
)
&
mod_time_time_obj
},
};
STATIC
const
mp_obj_dict_t
mp_module_time_globals
=
{
.
base
=
{
&
mp_type_dict
},
.
map
=
{
.
all_keys_are_qstrs
=
1
,
.
table_is_fixed_array
=
1
,
.
used
=
sizeof
(
mp_module_time_globals_table
)
/
sizeof
(
mp_map_elem_t
),
.
alloc
=
sizeof
(
mp_module_time_globals_table
)
/
sizeof
(
mp_map_elem_t
),
.
table
=
(
mp_map_elem_t
*
)
mp_module_time_globals_table
,
},
};
const
mp_obj_module_t
mp_module_time
=
{
.
base
=
{
&
mp_type_module
},
.
name
=
MP_QSTR_time
,
.
globals
=
(
mp_obj_dict_t
*
)
&
mp_module_time_globals
,
};
unix/mpconfigport.h
View file @
eb2fc978
...
...
@@ -17,6 +17,10 @@
#define MICROPY_MOD_SYS_STDFILES (1)
#define MICROPY_ENABLE_MOD_CMATH (1)
extern
const
struct
_mp_obj_module_t
mp_module_time
;
#define MICROPY_EXTRA_BUILTIN_MODULES \
{ MP_OBJ_NEW_QSTR(MP_QSTR_time), (mp_obj_t)&mp_module_time }, \
// type definitions for the specific machine
#ifdef __LP64__
...
...
unix/qstrdefsport.h
View file @
eb2fc978
...
...
@@ -30,3 +30,7 @@ Q(fficallback)
Q
(
ffivar
)
Q
(
func
)
Q
(
var
)
Q
(
time
)
Q
(
clock
)
Q
(
sleep
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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