core: Allow `enum` types to specify additional fields in the object

this will be used to make MathOperation enum values callable to
construct a Math object with that function
This commit is contained in:
Jeff Epler 2023-05-21 12:48:52 -05:00
parent 4ff08e02eb
commit 76101c035e
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
1 changed files with 2 additions and 1 deletions

View File

@ -50,12 +50,13 @@ typedef struct {
cp_enum_obj_print_helper(MP_QSTR_##module, print, self_in, kind); \
}
#define MAKE_ENUM_TYPE(module, type, typename) \
#define MAKE_ENUM_TYPE(module, type, typename, ...) \
const mp_obj_type_t typename##_type = { \
{ &mp_type_type }, \
.name = MP_QSTR_##type, \
.print = typename##_print, \
.locals_dict = (mp_obj_dict_t *)&typename##_locals_dict, \
##__VA_ARGS__ \
}