@ -270,35 +270,35 @@ static inline bool mp_obj_is_integer(mp_const_obj_t o) { return MP_OBJ_IS_INT(o)
// These macros are used to declare and define constant function objects
// You can put "static" in front of the definitions to make them local
# define MP_DECLARE_CONST_FUN_OBJ_0(obj_name) extern const mp_obj_fun_builtin_t obj_name
# define MP_DECLARE_CONST_FUN_OBJ_1(obj_name) extern const mp_obj_fun_builtin_t obj_name
# define MP_DECLARE_CONST_FUN_OBJ_2(obj_name) extern const mp_obj_fun_builtin_t obj_name
# define MP_DECLARE_CONST_FUN_OBJ_3(obj_name) extern const mp_obj_fun_builtin_t obj_name
# define MP_DECLARE_CONST_FUN_OBJ_VAR(obj_name) extern const mp_obj_fun_builtin_t obj_name
# define MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(obj_name) extern const mp_obj_fun_builtin_t obj_name
# define MP_DECLARE_CONST_FUN_OBJ_KW(obj_name) extern const mp_obj_fun_builtin_t obj_name
# define MP_DECLARE_CONST_FUN_OBJ_0(obj_name) extern const mp_obj_fun_builtin_fixed_ t obj_name
# define MP_DECLARE_CONST_FUN_OBJ_1(obj_name) extern const mp_obj_fun_builtin_fixed_ t obj_name
# define MP_DECLARE_CONST_FUN_OBJ_2(obj_name) extern const mp_obj_fun_builtin_fixed_ t obj_name
# define MP_DECLARE_CONST_FUN_OBJ_3(obj_name) extern const mp_obj_fun_builtin_fixed_ t obj_name
# define MP_DECLARE_CONST_FUN_OBJ_VAR(obj_name) extern const mp_obj_fun_builtin_var_ t obj_name
# define MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(obj_name) extern const mp_obj_fun_builtin_var_ t obj_name
# define MP_DECLARE_CONST_FUN_OBJ_KW(obj_name) extern const mp_obj_fun_builtin_var_ t obj_name
# define MP_DEFINE_CONST_FUN_OBJ_0(obj_name, fun_name) \
const mp_obj_fun_builtin_t obj_name = \
{ { & mp_type_fun_builtin } , false , 0 , 0 , . fun . _0 = fun_name }
const mp_obj_fun_builtin_fixed_ t obj_name = \
{ { & mp_type_fun_builtin_0 } , . fun . _0 = fun_name }
# define MP_DEFINE_CONST_FUN_OBJ_1(obj_name, fun_name) \
const mp_obj_fun_builtin_t obj_name = \
{ { & mp_type_fun_builtin } , false , 1 , 1 , . fun . _1 = fun_name }
const mp_obj_fun_builtin_fixed_ t obj_name = \
{ { & mp_type_fun_builtin_1 } , . fun . _1 = fun_name }
# define MP_DEFINE_CONST_FUN_OBJ_2(obj_name, fun_name) \
const mp_obj_fun_builtin_t obj_name = \
{ { & mp_type_fun_builtin } , false , 2 , 2 , . fun . _2 = fun_name }
const mp_obj_fun_builtin_fixed_ t obj_name = \
{ { & mp_type_fun_builtin_2 } , . fun . _2 = fun_name }
# define MP_DEFINE_CONST_FUN_OBJ_3(obj_name, fun_name) \
const mp_obj_fun_builtin_t obj_name = \
{ { & mp_type_fun_builtin } , false , 3 , 3 , . fun . _3 = fun_name }
const mp_obj_fun_builtin_fixed_ t obj_name = \
{ { & mp_type_fun_builtin_3 } , . fun . _3 = fun_name }
# define MP_DEFINE_CONST_FUN_OBJ_VAR(obj_name, n_args_min, fun_name) \
const mp_obj_fun_builtin_t obj_name = \
{ { & mp_type_fun_builtin } , false , n_args_min , MP_OBJ_FUN_ARGS_MAX , . fun . var = fun_name }
const mp_obj_fun_builtin_var_ t obj_name = \
{ { & mp_type_fun_builtin_var } , false , n_args_min , MP_OBJ_FUN_ARGS_MAX , . fun . var = fun_name }
# define MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(obj_name, n_args_min, n_args_max, fun_name) \
const mp_obj_fun_builtin_t obj_name = \
{ { & mp_type_fun_builtin } , false , n_args_min , n_args_max , . fun . var = fun_name }
const mp_obj_fun_builtin_var_ t obj_name = \
{ { & mp_type_fun_builtin_var } , false , n_args_min , n_args_max , . fun . var = fun_name }
# define MP_DEFINE_CONST_FUN_OBJ_KW(obj_name, n_args_min, fun_name) \
const mp_obj_fun_builtin_t obj_name = \
{ { & mp_type_fun_builtin } , true , n_args_min , MP_OBJ_FUN_ARGS_MAX , . fun . kw = fun_name }
const mp_obj_fun_builtin_var_ t obj_name = \
{ { & mp_type_fun_builtin_var } , true , n_args_min , MP_OBJ_FUN_ARGS_MAX , . fun . kw = fun_name }
// These macros are used to define constant map/dict objects
// You can put "static" in front of the definition to make it local
@ -536,7 +536,11 @@ extern const mp_obj_type_t mp_type_zip;
extern const mp_obj_type_t mp_type_array ;
extern const mp_obj_type_t mp_type_super ;
extern const mp_obj_type_t mp_type_gen_instance ;
extern const mp_obj_type_t mp_type_fun_builtin ;
extern const mp_obj_type_t mp_type_fun_builtin_0 ;
extern const mp_obj_type_t mp_type_fun_builtin_1 ;
extern const mp_obj_type_t mp_type_fun_builtin_2 ;
extern const mp_obj_type_t mp_type_fun_builtin_3 ;
extern const mp_obj_type_t mp_type_fun_builtin_var ;
extern const mp_obj_type_t mp_type_fun_bc ;
extern const mp_obj_type_t mp_type_module ;
extern const mp_obj_type_t mp_type_staticmethod ;
@ -746,21 +750,28 @@ void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item);
void mp_obj_slice_get ( mp_obj_t self_in , mp_obj_t * start , mp_obj_t * stop , mp_obj_t * step ) ;
// functions
# define MP_OBJ_FUN_ARGS_MAX (0xffff) // to set maximum value in n_args_max below
typedef struct _mp_obj_fun_builtin_t { // use this to make const objects that go in ROM
typedef struct _mp_obj_fun_builtin_fixed_ t {
mp_obj_base_t base ;
bool is_kw : 1 ;
mp_uint_t n_args_min : 15 ; // inclusive
mp_uint_t n_args_max : 16 ; // inclusive
union {
mp_fun_0_t _0 ;
mp_fun_1_t _1 ;
mp_fun_2_t _2 ;
mp_fun_3_t _3 ;
} fun ;
} mp_obj_fun_builtin_fixed_t ;
# define MP_OBJ_FUN_ARGS_MAX (0xffff) // to set maximum value in n_args_max below
typedef struct _mp_obj_fun_builtin_var_t {
mp_obj_base_t base ;
bool is_kw : 1 ;
mp_uint_t n_args_min : 15 ; // inclusive
mp_uint_t n_args_max : 16 ; // inclusive
union {
mp_fun_var_t var ;
mp_fun_kw_t kw ;
} fun ;
} mp_obj_fun_builtin_t ;
} mp_obj_fun_builtin_var_ t ;
qstr mp_obj_fun_get_name ( mp_const_obj_t fun ) ;
qstr mp_obj_code_get_name ( const byte * code_info ) ;