diff options
author | Damien George <damien.p.george@gmail.com> | 2017-03-23 16:36:08 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-03-23 16:36:08 +1100 |
commit | 60656eaea41df16557fbbdb51d9b8fc2cf7662a1 (patch) | |
tree | 862e226a7e29408e84dd00b1644947654741cc85 /py/obj.h | |
parent | 507119f4d80cc70cc35249f97c9b0ee22b8965f4 (diff) |
py: Define and use MP_OBJ_ITER_BUF_NSLOTS to get size of stack iter buf.
It improves readability of code and reduces the chance to make a mistake.
This patch also fixes a bug with nan-boxing builds by rounding up the
calculation of the new NSLOTS variable, giving the correct number of slots
(being 4) even if mp_obj_t is larger than the native machine size.
Diffstat (limited to 'py/obj.h')
-rw-r--r-- | py/obj.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -422,6 +422,10 @@ typedef struct _mp_obj_iter_buf_t { mp_obj_t buf[3]; } mp_obj_iter_buf_t; +// The number of slots that an mp_obj_iter_buf_t needs on the Python value stack. +// It's rounded up in case mp_obj_base_t is smaller than mp_obj_t (eg for OBJ_REPR_D). +#define MP_OBJ_ITER_BUF_NSLOTS ((sizeof(mp_obj_iter_buf_t) + sizeof(mp_obj_t) - 1) / sizeof(mp_obj_t)) + typedef void (*mp_print_fun_t)(const mp_print_t *print, mp_obj_t o, mp_print_kind_t kind); typedef mp_obj_t (*mp_make_new_fun_t)(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args); typedef mp_obj_t (*mp_call_fun_t)(mp_obj_t fun, size_t n_args, size_t n_kw, const mp_obj_t *args); |