diff options
author | Damien George <damien.p.george@gmail.com> | 2014-12-09 16:19:48 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2014-12-09 16:19:48 +0000 |
commit | 78d702c300ae9f175e6f47f805a37cdfe5b81898 (patch) | |
tree | 034b42ea789dc38c629a2f0dd8a48001a32cd838 /py/builtin.h | |
parent | e6e8ad8ab238cd596a3eedf8f4dd635e2e84f46e (diff) |
py: Allow builtins to be overridden.
This patch adds a configuration option (MICROPY_CAN_OVERRIDE_BUILTINS)
which, when enabled, allows to override all names within the builtins
module. A builtins override dict is created the first time the user
assigns to a name in the builtins model, and then that dict is searched
first on subsequent lookups. Note that this implementation doesn't
allow deleting of names.
This patch also does some refactoring of builtins code, creating the
modbuiltins.c file.
Addresses issue #959.
Diffstat (limited to 'py/builtin.h')
-rw-r--r-- | py/builtin.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/py/builtin.h b/py/builtin.h index a63752c5f..115d05991 100644 --- a/py/builtin.h +++ b/py/builtin.h @@ -73,6 +73,7 @@ MP_DECLARE_CONST_FUN_OBJ(mp_op_setitem_obj); MP_DECLARE_CONST_FUN_OBJ(mp_op_delitem_obj); extern const mp_obj_module_t mp_module___main__; +extern const mp_obj_module_t mp_module_builtins; extern const mp_obj_module_t mp_module_array; extern const mp_obj_module_t mp_module_collections; extern const mp_obj_module_t mp_module_io; @@ -83,6 +84,9 @@ extern const mp_obj_module_t mp_module_struct; extern const mp_obj_module_t mp_module_sys; extern const mp_obj_module_t mp_module_gc; +extern const mp_obj_dict_t mp_module_builtins_globals; +extern mp_obj_dict_t *mp_module_builtins_override_dict; + struct _dummy_t; extern struct _dummy_t mp_sys_stdin_obj; extern struct _dummy_t mp_sys_stdout_obj; |