|
@ -35,6 +35,8 @@ |
|
|
|
|
|
|
|
|
#if MICROPY_PY_SYS |
|
|
#if MICROPY_PY_SYS |
|
|
|
|
|
|
|
|
|
|
|
#include "genhdr/py-version.h" |
|
|
|
|
|
|
|
|
/// \module sys - system specific functions
|
|
|
/// \module sys - system specific functions
|
|
|
|
|
|
|
|
|
// defined per port; type of these is irrelevant, just need pointer
|
|
|
// defined per port; type of these is irrelevant, just need pointer
|
|
@ -53,6 +55,34 @@ STATIC const MP_DEFINE_STR_OBJ(version_obj, "3.4.0"); |
|
|
#define I(n) MP_OBJ_NEW_SMALL_INT(n) |
|
|
#define I(n) MP_OBJ_NEW_SMALL_INT(n) |
|
|
// TODO: CPython is now at 5-element array, but save 2 els so far...
|
|
|
// TODO: CPython is now at 5-element array, but save 2 els so far...
|
|
|
STATIC const mp_obj_tuple_t mp_sys_version_info_obj = {{&mp_type_tuple}, 3, {I(3), I(4), I(0)}}; |
|
|
STATIC const mp_obj_tuple_t mp_sys_version_info_obj = {{&mp_type_tuple}, 3, {I(3), I(4), I(0)}}; |
|
|
|
|
|
|
|
|
|
|
|
// sys.implementation object
|
|
|
|
|
|
// this holds the MicroPython version
|
|
|
|
|
|
STATIC const mp_obj_tuple_t mp_sys_implementation_version_info_obj = { |
|
|
|
|
|
{&mp_type_tuple}, |
|
|
|
|
|
3, |
|
|
|
|
|
{ I(MICROPY_VERSION_MAJOR), I(MICROPY_VERSION_MINOR), I(MICROPY_VERSION_MICRO) } |
|
|
|
|
|
}; |
|
|
|
|
|
#if MICROPY_PY_ATTRTUPLE |
|
|
|
|
|
STATIC const qstr impl_fields[] = { MP_QSTR_name, MP_QSTR_version }; |
|
|
|
|
|
STATIC MP_DEFINE_ATTRTUPLE( |
|
|
|
|
|
mp_sys_implementation_obj, |
|
|
|
|
|
impl_fields, |
|
|
|
|
|
2, |
|
|
|
|
|
MP_OBJ_NEW_QSTR(MP_QSTR_micropython), |
|
|
|
|
|
(mp_obj_t)&mp_sys_implementation_version_info_obj |
|
|
|
|
|
); |
|
|
|
|
|
#else |
|
|
|
|
|
STATIC const mp_obj_tuple_t mp_sys_implementation_obj = { |
|
|
|
|
|
{&mp_type_tuple}, |
|
|
|
|
|
2, |
|
|
|
|
|
{ |
|
|
|
|
|
MP_OBJ_NEW_QSTR(MP_QSTR_micropython), |
|
|
|
|
|
(mp_obj_t)&mp_sys_implementation_version_info_obj, |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
#undef I |
|
|
#undef I |
|
|
|
|
|
|
|
|
#ifdef MICROPY_PY_SYS_PLATFORM |
|
|
#ifdef MICROPY_PY_SYS_PLATFORM |
|
@ -98,6 +128,7 @@ STATIC const mp_map_elem_t mp_module_sys_globals_table[] = { |
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_argv), (mp_obj_t)&MP_STATE_VM(mp_sys_argv_obj) }, |
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_argv), (mp_obj_t)&MP_STATE_VM(mp_sys_argv_obj) }, |
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_version), (mp_obj_t)&version_obj }, |
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_version), (mp_obj_t)&version_obj }, |
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_version_info), (mp_obj_t)&mp_sys_version_info_obj }, |
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_version_info), (mp_obj_t)&mp_sys_version_info_obj }, |
|
|
|
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_implementation), (mp_obj_t)&mp_sys_implementation_obj }, |
|
|
#ifdef MICROPY_PY_SYS_PLATFORM |
|
|
#ifdef MICROPY_PY_SYS_PLATFORM |
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_platform), (mp_obj_t)&platform_obj }, |
|
|
{ MP_OBJ_NEW_QSTR(MP_QSTR_platform), (mp_obj_t)&platform_obj }, |
|
|
#endif |
|
|
#endif |
|
|