Add gc.enable, gc.disable; remove pyb.gc.

This commit is contained in:
Damien George 2014-05-08 23:04:49 +01:00
parent d6cbbc51ab
commit 8c1c7488b2
4 changed files with 16 additions and 3 deletions

View File

@ -43,9 +43,23 @@ STATIC mp_obj_t py_gc_collect(void) {
}
MP_DEFINE_CONST_FUN_OBJ_0(gc_collect_obj, py_gc_collect);
STATIC mp_obj_t gc_disable(void) {
gc_lock();
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(gc_disable_obj, gc_disable);
STATIC mp_obj_t gc_enable(void) {
gc_unlock();
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_0(gc_enable_obj, gc_enable);
STATIC const mp_map_elem_t mp_module_gc_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_gc) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_collect), (mp_obj_t)&gc_collect_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_disable), (mp_obj_t)&gc_disable_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_enable), (mp_obj_t)&gc_enable_obj },
};
STATIC const mp_obj_dict_t mp_module_gc_globals = {

View File

@ -352,6 +352,8 @@ Q(getvalue)
#if MICROPY_ENABLE_MOD_GC
Q(gc)
Q(collect)
Q(disable)
Q(enable)
#endif
#if MICROPY_ENABLE_PROPERTY

View File

@ -39,5 +39,3 @@ extern uint32_t _estack;
extern uint32_t _ram_end;
void gc_collect(void);
MP_DECLARE_CONST_FUN_OBJ(gc_collect_obj);

View File

@ -305,7 +305,6 @@ STATIC const mp_map_elem_t pyb_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_info), (mp_obj_t)&pyb_info_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_unique_id), (mp_obj_t)&pyb_unique_id_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_freq), (mp_obj_t)&pyb_freq_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_gc), (mp_obj_t)&gc_collect_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_repl_info), (mp_obj_t)&pyb_set_repl_info_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_wfi), (mp_obj_t)&pyb_wfi_obj },