aboutsummaryrefslogtreecommitdiff
path: root/py/builtinevex.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2015-11-27 17:01:44 +0000
committerDamien George <damien.p.george@gmail.com>2015-11-29 14:25:35 +0000
commit999cedb90ff0827cdb9dfe0e4faa6ebc1739d271 (patch)
tree897eb07b82f1893cfd413b9ef7f625cd996f859d /py/builtinevex.c
parentcbf7674025814797f5c537d6d1c195efe58ccaaf (diff)
py: Wrap all obj-ptr conversions in MP_OBJ_TO_PTR/MP_OBJ_FROM_PTR.
This allows the mp_obj_t type to be configured to something other than a pointer-sized primitive type. This patch also includes additional changes to allow the code to compile when sizeof(mp_uint_t) != sizeof(void*), such as using size_t instead of mp_uint_t, and various casts.
Diffstat (limited to 'py/builtinevex.c')
-rw-r--r--py/builtinevex.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/py/builtinevex.c b/py/builtinevex.c
index 4cafc5ecf..c14869e35 100644
--- a/py/builtinevex.c
+++ b/py/builtinevex.c
@@ -44,7 +44,7 @@ STATIC const mp_obj_type_t mp_type_code = {
.name = MP_QSTR_code,
};
-STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_t globals, mp_obj_t locals) {
+STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_dict_t *globals, mp_obj_dict_t *locals) {
// save context and set new context
mp_obj_dict_t *old_globals = mp_globals_get();
mp_obj_dict_t *old_locals = mp_locals_get();
@@ -54,7 +54,7 @@ STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_t globals, mp_obj_t loc
// a bit of a hack: fun_bc will re-set globals, so need to make sure it's
// the correct one
if (MP_OBJ_IS_TYPE(self->module_fun, &mp_type_fun_bc)) {
- mp_obj_fun_bc_t *fun_bc = self->module_fun;
+ mp_obj_fun_bc_t *fun_bc = MP_OBJ_TO_PTR(self->module_fun);
fun_bc->globals = globals;
}
@@ -70,7 +70,7 @@ STATIC mp_obj_t code_execute(mp_obj_code_t *self, mp_obj_t globals, mp_obj_t loc
// exception; restore context and re-raise same exception
mp_globals_set(old_globals);
mp_locals_set(old_locals);
- nlr_raise(nlr.ret_val);
+ nlr_jump(nlr.ret_val);
}
}
@@ -101,7 +101,7 @@ STATIC mp_obj_t mp_builtin_compile(mp_uint_t n_args, const mp_obj_t *args) {
mp_obj_code_t *code = m_new_obj(mp_obj_code_t);
code->base.type = &mp_type_code;
code->module_fun = mp_parse_compile_execute(lex, parse_input_kind, NULL, NULL);
- return code;
+ return MP_OBJ_FROM_PTR(code);
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_compile_obj, 3, 6, mp_builtin_compile);
@@ -112,9 +112,9 @@ STATIC mp_obj_t eval_exec_helper(mp_uint_t n_args, const mp_obj_t *args, mp_pars
mp_obj_dict_t *globals = mp_globals_get();
mp_obj_dict_t *locals = mp_locals_get();
if (n_args > 1) {
- globals = args[1];
+ globals = MP_OBJ_TO_PTR(args[1]);
if (n_args > 2) {
- locals = args[2];
+ locals = MP_OBJ_TO_PTR(args[2]);
} else {
locals = globals;
}
@@ -122,7 +122,7 @@ STATIC mp_obj_t eval_exec_helper(mp_uint_t n_args, const mp_obj_t *args, mp_pars
#if MICROPY_PY_BUILTINS_COMPILE
if (MP_OBJ_IS_TYPE(args[0], &mp_type_code)) {
- return code_execute(args[0], globals, locals);
+ return code_execute(MP_OBJ_TO_PTR(args[0]), globals, locals);
}
#endif