zephyr/moduos: Convert module to use extmod version.
This also adds uos.unlink(), for all ports that use extmod/moduos.c. Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
parent
1c53d85162
commit
818be10bb5
|
@ -54,6 +54,7 @@
|
||||||
#define MICROPY_BUILD_TYPE_PAREN
|
#define MICROPY_BUILD_TYPE_PAREN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if MICROPY_PY_UOS_UNAME
|
||||||
STATIC const qstr mp_uos_uname_info_fields[] = {
|
STATIC const qstr mp_uos_uname_info_fields[] = {
|
||||||
MP_QSTR_sysname,
|
MP_QSTR_sysname,
|
||||||
MP_QSTR_nodename,
|
MP_QSTR_nodename,
|
||||||
|
@ -82,11 +83,14 @@ STATIC mp_obj_t mp_uos_uname(void) {
|
||||||
return MP_OBJ_FROM_PTR(&mp_uos_uname_info_obj);
|
return MP_OBJ_FROM_PTR(&mp_uos_uname_info_obj);
|
||||||
}
|
}
|
||||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_uos_uname_obj, mp_uos_uname);
|
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mp_uos_uname_obj, mp_uos_uname);
|
||||||
|
#endif
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
|
STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uos) },
|
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uos) },
|
||||||
|
|
||||||
|
#if MICROPY_PY_UOS_UNAME
|
||||||
{ MP_ROM_QSTR(MP_QSTR_uname), MP_ROM_PTR(&mp_uos_uname_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_uname), MP_ROM_PTR(&mp_uos_uname_obj) },
|
||||||
|
#endif
|
||||||
#if MICROPY_PY_UOS_URANDOM
|
#if MICROPY_PY_UOS_URANDOM
|
||||||
{ MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&mp_uos_urandom_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&mp_uos_urandom_obj) },
|
||||||
#endif
|
#endif
|
||||||
|
@ -101,6 +105,7 @@ STATIC const mp_rom_map_elem_t os_module_globals_table[] = {
|
||||||
{ MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&mp_vfs_rmdir_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&mp_vfs_rmdir_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&mp_vfs_stat_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&mp_vfs_stat_obj) },
|
||||||
{ MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&mp_vfs_statvfs_obj) },
|
{ MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&mp_vfs_statvfs_obj) },
|
||||||
|
{ MP_ROM_QSTR(MP_QSTR_unlink), MP_ROM_PTR(&mp_vfs_remove_obj) }, // unlink aliases to remove
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The following are MicroPython extensions.
|
// The following are MicroPython extensions.
|
||||||
|
|
|
@ -75,6 +75,7 @@
|
||||||
#define MICROPY_PY_UOS_INCLUDEFILE "ports/esp32/moduos.c"
|
#define MICROPY_PY_UOS_INCLUDEFILE "ports/esp32/moduos.c"
|
||||||
#define MICROPY_PY_OS_DUPTERM (1)
|
#define MICROPY_PY_OS_DUPTERM (1)
|
||||||
#define MICROPY_PY_UOS_DUPTERM_NOTIFY (1)
|
#define MICROPY_PY_UOS_DUPTERM_NOTIFY (1)
|
||||||
|
#define MICROPY_PY_UOS_UNAME (1)
|
||||||
#define MICROPY_PY_UOS_URANDOM (1)
|
#define MICROPY_PY_UOS_URANDOM (1)
|
||||||
#define MICROPY_PY_MACHINE (1)
|
#define MICROPY_PY_MACHINE (1)
|
||||||
#define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new
|
#define MICROPY_PY_MACHINE_PIN_MAKE_NEW mp_pin_make_new
|
||||||
|
|
|
@ -84,6 +84,7 @@
|
||||||
// Extended modules
|
// Extended modules
|
||||||
#define MICROPY_EPOCH_IS_1970 (1)
|
#define MICROPY_EPOCH_IS_1970 (1)
|
||||||
#define MICROPY_PY_UOS_INCLUDEFILE "ports/rp2/moduos.c"
|
#define MICROPY_PY_UOS_INCLUDEFILE "ports/rp2/moduos.c"
|
||||||
|
#define MICROPY_PY_UOS_UNAME (1)
|
||||||
#define MICROPY_PY_UOS_URANDOM (1)
|
#define MICROPY_PY_UOS_URANDOM (1)
|
||||||
#define MICROPY_PY_URE_MATCH_GROUPS (1)
|
#define MICROPY_PY_URE_MATCH_GROUPS (1)
|
||||||
#define MICROPY_PY_URE_MATCH_SPAN_START_END (1)
|
#define MICROPY_PY_URE_MATCH_SPAN_START_END (1)
|
||||||
|
|
|
@ -43,7 +43,6 @@ set(MICROPY_SOURCE_PORT
|
||||||
machine_uart.c
|
machine_uart.c
|
||||||
modbluetooth_zephyr.c
|
modbluetooth_zephyr.c
|
||||||
modmachine.c
|
modmachine.c
|
||||||
moduos.c
|
|
||||||
modusocket.c
|
modusocket.c
|
||||||
modutime.c
|
modutime.c
|
||||||
modzephyr.c
|
modzephyr.c
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
/*
|
|
||||||
* This file is part of the MicroPython project, http://micropython.org/
|
|
||||||
*
|
|
||||||
* The MIT License (MIT)
|
|
||||||
*
|
|
||||||
* Copyright (c) 2019 NXP
|
|
||||||
*
|
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
|
||||||
* in the Software without restriction, including without limitation the rights
|
|
||||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
* copies of the Software, and to permit persons to whom the Software is
|
|
||||||
* furnished to do so, subject to the following conditions:
|
|
||||||
*
|
|
||||||
* The above copyright notice and this permission notice shall be included in
|
|
||||||
* all copies or substantial portions of the Software.
|
|
||||||
*
|
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
||||||
* THE SOFTWARE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "py/obj.h"
|
|
||||||
|
|
||||||
#include "extmod/vfs.h"
|
|
||||||
|
|
||||||
#if MICROPY_VFS_FAT
|
|
||||||
#include "extmod/vfs_fat.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MICROPY_VFS_LFS1 || MICROPY_VFS_LFS2
|
|
||||||
#include "extmod/vfs_lfs.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MICROPY_PY_UOS_ZEPHYR
|
|
||||||
|
|
||||||
STATIC const mp_rom_map_elem_t uos_module_globals_table[] = {
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_uos) },
|
|
||||||
#if MICROPY_VFS
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_chdir), MP_ROM_PTR(&mp_vfs_chdir_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_getcwd), MP_ROM_PTR(&mp_vfs_getcwd_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_ilistdir), MP_ROM_PTR(&mp_vfs_ilistdir_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_listdir), MP_ROM_PTR(&mp_vfs_listdir_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_mkdir), MP_ROM_PTR(&mp_vfs_mkdir_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_remove), MP_ROM_PTR(&mp_vfs_remove_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_rename),MP_ROM_PTR(&mp_vfs_rename_obj)},
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_rmdir), MP_ROM_PTR(&mp_vfs_rmdir_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_stat), MP_ROM_PTR(&mp_vfs_stat_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_statvfs), MP_ROM_PTR(&mp_vfs_statvfs_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_unlink), MP_ROM_PTR(&mp_vfs_remove_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_mount), MP_ROM_PTR(&mp_vfs_mount_obj) },
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_umount), MP_ROM_PTR(&mp_vfs_umount_obj) },
|
|
||||||
#endif
|
|
||||||
#if MICROPY_VFS_FAT
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_VfsFat), MP_ROM_PTR(&mp_fat_vfs_type) },
|
|
||||||
#endif
|
|
||||||
#if MICROPY_VFS_LFS1
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_VfsLfs1), MP_ROM_PTR(&mp_type_vfs_lfs1) },
|
|
||||||
#endif
|
|
||||||
#if MICROPY_VFS_LFS2
|
|
||||||
{ MP_ROM_QSTR(MP_QSTR_VfsLfs2), MP_ROM_PTR(&mp_type_vfs_lfs2) },
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
STATIC MP_DEFINE_CONST_DICT(uos_module_globals, uos_module_globals_table);
|
|
||||||
|
|
||||||
const mp_obj_module_t mp_module_uos = {
|
|
||||||
.base = { &mp_type_module },
|
|
||||||
.globals = (mp_obj_dict_t *)&uos_module_globals,
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // MICROPY_PY_UOS_ZEPHYR
|
|
|
@ -83,7 +83,7 @@
|
||||||
#endif
|
#endif
|
||||||
#define MICROPY_PY_UBINASCII (1)
|
#define MICROPY_PY_UBINASCII (1)
|
||||||
#define MICROPY_PY_UHASHLIB (1)
|
#define MICROPY_PY_UHASHLIB (1)
|
||||||
#define MICROPY_PY_UOS_ZEPHYR (1)
|
#define MICROPY_PY_UOS (1)
|
||||||
#define MICROPY_PY_UTIME (1)
|
#define MICROPY_PY_UTIME (1)
|
||||||
#define MICROPY_PY_UTIME_MP_HAL (1)
|
#define MICROPY_PY_UTIME_MP_HAL (1)
|
||||||
#define MICROPY_PY_ZEPHYR (1)
|
#define MICROPY_PY_ZEPHYR (1)
|
||||||
|
@ -139,17 +139,10 @@ typedef long mp_off_t;
|
||||||
struct _mp_bluetooth_zephyr_root_pointers_t *bluetooth_zephyr_root_pointers;
|
struct _mp_bluetooth_zephyr_root_pointers_t *bluetooth_zephyr_root_pointers;
|
||||||
|
|
||||||
extern const struct _mp_obj_module_t mp_module_time;
|
extern const struct _mp_obj_module_t mp_module_time;
|
||||||
extern const struct _mp_obj_module_t mp_module_uos;
|
|
||||||
extern const struct _mp_obj_module_t mp_module_usocket;
|
extern const struct _mp_obj_module_t mp_module_usocket;
|
||||||
extern const struct _mp_obj_module_t mp_module_zephyr;
|
extern const struct _mp_obj_module_t mp_module_zephyr;
|
||||||
extern const struct _mp_obj_module_t mp_module_zsensor;
|
extern const struct _mp_obj_module_t mp_module_zsensor;
|
||||||
|
|
||||||
#if MICROPY_PY_UOS_ZEPHYR
|
|
||||||
#define MICROPY_PY_UOS_DEF { MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&mp_module_uos) },
|
|
||||||
#else
|
|
||||||
#define MICROPY_PY_UOS_DEF
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MICROPY_PY_USOCKET
|
#if MICROPY_PY_USOCKET
|
||||||
#define MICROPY_PY_USOCKET_DEF { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_usocket) },
|
#define MICROPY_PY_USOCKET_DEF { MP_ROM_QSTR(MP_QSTR_usocket), MP_ROM_PTR(&mp_module_usocket) },
|
||||||
#else
|
#else
|
||||||
|
@ -175,7 +168,6 @@ extern const struct _mp_obj_module_t mp_module_zsensor;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MICROPY_PORT_BUILTIN_MODULES \
|
#define MICROPY_PORT_BUILTIN_MODULES \
|
||||||
MICROPY_PY_UOS_DEF \
|
|
||||||
MICROPY_PY_USOCKET_DEF \
|
MICROPY_PY_USOCKET_DEF \
|
||||||
MICROPY_PY_UTIME_DEF \
|
MICROPY_PY_UTIME_DEF \
|
||||||
MICROPY_PY_ZEPHYR_DEF \
|
MICROPY_PY_ZEPHYR_DEF \
|
||||||
|
|
Loading…
Reference in New Issue