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
d99e9083
Commit
d99e9083
authored
May 10, 2014
by
Paul Sokolovsky
Browse files
modsys, unix: Add sys.exit(), should be implemented by a port.
parent
d80e2476
Changes
3
Hide whitespace changes
Inline
Side-by-side
py/modsys.c
View file @
d99e9083
...
...
@@ -36,6 +36,8 @@
#if MICROPY_ENABLE_MOD_SYS
MP_DECLARE_CONST_FUN_OBJ
(
mp_sys_exit_obj
);
// These should be implemented by ports, specific types don't matter,
// only addresses.
struct
_dummy_t
;
...
...
@@ -53,6 +55,9 @@ STATIC const MP_DEFINE_STR_OBJ(version_obj, "3.4.0");
STATIC
const
mp_map_elem_t
mp_module_sys_globals_table
[]
=
{
{
MP_OBJ_NEW_QSTR
(
MP_QSTR___name__
),
MP_OBJ_NEW_QSTR
(
MP_QSTR_sys
)
},
// Should be implemented by port
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_exit
),
(
mp_obj_t
)
&
mp_sys_exit_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_path
),
(
mp_obj_t
)
&
mp_sys_path_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_argv
),
(
mp_obj_t
)
&
mp_sys_argv_obj
},
{
MP_OBJ_NEW_QSTR
(
MP_QSTR_version
),
(
mp_obj_t
)
&
version_obj
},
...
...
py/qstrdefs.h
View file @
d99e9083
...
...
@@ -329,6 +329,7 @@ Q(utf-8)
Q
(
argv
)
Q
(
byteorder
)
Q
(
big
)
Q
(
exit
)
Q
(
little
)
Q
(
stdin
)
Q
(
stdout
)
...
...
unix/main.c
View file @
d99e9083
...
...
@@ -371,6 +371,15 @@ int main(int argc, char **argv) {
return
0
;
}
STATIC
mp_obj_t
mp_sys_exit
(
uint
n_args
,
const
mp_obj_t
*
args
)
{
int
rc
=
0
;
if
(
n_args
>
0
)
{
rc
=
mp_obj_get_int
(
args
[
0
]);
}
exit
(
rc
);
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN
(
mp_sys_exit_obj
,
0
,
1
,
mp_sys_exit
);
uint
mp_import_stat
(
const
char
*
path
)
{
struct
stat
st
;
if
(
stat
(
path
,
&
st
)
==
0
)
{
...
...
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