Commit d99e9083 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

modsys, unix: Add sys.exit(), should be implemented by a port.

parent d80e2476
......@@ -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 },
......
......@@ -329,6 +329,7 @@ Q(utf-8)
Q(argv)
Q(byteorder)
Q(big)
Q(exit)
Q(little)
Q(stdin)
Q(stdout)
......
......@@ -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) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment