all: Fix #if inside MP_DEFINE_CONST_OBJ_TYPE for msvc.
Changes: MP_DEFINE_CONST_OBJ_TYPE( ... #if FOO ... #endif ... ); to: MP_DEFINE_CONST_OBJ_TYPE( ... FOO_TYPE_ATTR ... ); Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
This commit is contained in:
parent
662b9761b3
commit
b7d6ee9b75
@ -502,15 +502,19 @@ STATIC const mp_vfs_proto_t MP_VFS_LFSx(proto) = {
|
||||
.import_stat = MP_VFS_LFSx(import_stat),
|
||||
};
|
||||
|
||||
#if LFS_BUILD_VERSION == 1
|
||||
#define VFS_LFSx_QSTR MP_QSTR_VfsLfs1
|
||||
#else
|
||||
#define VFS_LFSx_QSTR MP_QSTR_VfsLfs2
|
||||
#endif
|
||||
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
MP_TYPE_VFS_LFSx,
|
||||
#if LFS_BUILD_VERSION == 1
|
||||
MP_QSTR_VfsLfs1,
|
||||
#else
|
||||
MP_QSTR_VfsLfs2,
|
||||
#endif
|
||||
VFS_LFSx_QSTR,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_VFS_LFSx(make_new),
|
||||
protocol, &MP_VFS_LFSx(proto),
|
||||
locals_dict, (mp_obj_dict_t *)&MP_VFS_LFSx(locals_dict)
|
||||
);
|
||||
|
||||
#undef VFS_LFSx_QSTR
|
||||
|
@ -603,6 +603,18 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_BUILTINS_MEMORYVIEW
|
||||
#if MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
|
||||
#define MEMORYVIEW_TYPE_ATTR attr, memoryview_attr,
|
||||
#else
|
||||
#define MEMORYVIEW_TYPE_ATTR
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_BUILTINS_BYTES_HEX
|
||||
#define MEMORYVIEW_TYPE_LOCALS_DICT locals_dict, (mp_obj_dict_t *)&mp_obj_memoryview_locals_dict,
|
||||
#else
|
||||
#define MEMORYVIEW_TYPE_LOCALS_DICT
|
||||
#endif
|
||||
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
mp_type_memoryview,
|
||||
MP_QSTR_memoryview,
|
||||
@ -611,16 +623,12 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
getiter, array_iterator_new,
|
||||
unary_op, array_unary_op,
|
||||
binary_op, array_binary_op,
|
||||
#if MICROPY_PY_BUILTINS_MEMORYVIEW_ITEMSIZE
|
||||
attr, memoryview_attr,
|
||||
#endif
|
||||
#if MICROPY_PY_BUILTINS_BYTES_HEX
|
||||
locals_dict, (mp_obj_dict_t *)&mp_obj_memoryview_locals_dict,
|
||||
#endif
|
||||
.subscr = array_subscr,
|
||||
.buffer = array_get_buffer,
|
||||
MEMORYVIEW_TYPE_LOCALS_DICT
|
||||
MEMORYVIEW_TYPE_ATTR
|
||||
subscr, array_subscr,
|
||||
buffer, array_get_buffer
|
||||
);
|
||||
#endif
|
||||
#endif // MICROPY_PY_BUILTINS_MEMORYVIEW
|
||||
|
||||
/* unused
|
||||
size_t mp_obj_array_len(mp_obj_t self_in) {
|
||||
|
@ -95,18 +95,26 @@ STATIC void bound_meth_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
|
||||
#define BOUND_METH_TYPE_PRINT print, bound_meth_print,
|
||||
#else
|
||||
#define BOUND_METH_TYPE_PRINT
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_FUNCTION_ATTRS
|
||||
#define BOUND_METH_TYPE_ATTR attr, bound_meth_attr,
|
||||
#else
|
||||
#define BOUND_METH_TYPE_ATTR
|
||||
#endif
|
||||
|
||||
STATIC MP_DEFINE_CONST_OBJ_TYPE(
|
||||
mp_type_bound_meth,
|
||||
MP_QSTR_bound_method,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
|
||||
print, bound_meth_print,
|
||||
#endif
|
||||
BOUND_METH_TYPE_PRINT
|
||||
BOUND_METH_TYPE_ATTR
|
||||
call, bound_meth_call
|
||||
#if MICROPY_PY_FUNCTION_ATTRS
|
||||
, attr, bound_meth_attr
|
||||
#endif
|
||||
);
|
||||
|
||||
mp_obj_t mp_obj_new_bound_meth(mp_obj_t meth, mp_obj_t self) {
|
||||
|
10
py/objcell.c
10
py/objcell.c
@ -40,12 +40,16 @@ STATIC void cell_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t k
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
|
||||
#define CELL_TYPE_PRINT , print, cell_print
|
||||
#else
|
||||
#define CELL_TYPE_PRINT
|
||||
#endif
|
||||
|
||||
STATIC MP_DEFINE_CONST_OBJ_TYPE(
|
||||
// cell representation is just value in < >
|
||||
mp_type_cell, MP_QSTR_, MP_TYPE_FLAG_NONE, MP_TYPE_NULL_MAKE_NEW
|
||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
|
||||
, print, cell_print
|
||||
#endif
|
||||
CELL_TYPE_PRINT
|
||||
);
|
||||
|
||||
mp_obj_t mp_obj_new_cell(mp_obj_t obj) {
|
||||
|
@ -84,6 +84,15 @@ STATIC void mp_obj_closure_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
mp_obj_closure_t *o = MP_OBJ_TO_PTR(self_in);
|
||||
mp_load_method_maybe(o->fun, attr, dest);
|
||||
}
|
||||
#define CLOSURE_TYPE_ATTR attr, mp_obj_closure_attr,
|
||||
#else
|
||||
#define CLOSURE_TYPE_ATTR
|
||||
#endif
|
||||
|
||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
|
||||
#define CLOSURE_TYPE_PRINT print, closure_print,
|
||||
#else
|
||||
#define CLOSURE_TYPE_PRINT
|
||||
#endif
|
||||
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
@ -91,12 +100,8 @@ MP_DEFINE_CONST_OBJ_TYPE(
|
||||
MP_QSTR_closure,
|
||||
MP_TYPE_FLAG_BINDS_SELF,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
|
||||
print, closure_print,
|
||||
#endif
|
||||
#if MICROPY_PY_FUNCTION_ATTRS
|
||||
attr, mp_obj_closure_attr,
|
||||
#endif
|
||||
CLOSURE_TYPE_ATTR
|
||||
CLOSURE_TYPE_PRINT
|
||||
call, closure_call
|
||||
);
|
||||
|
||||
|
39
py/objfun.c
39
py/objfun.c
@ -352,19 +352,27 @@ void mp_obj_fun_bc_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
#define FUN_BC_TYPE_PRINT print, fun_bc_print,
|
||||
#else
|
||||
#define FUN_BC_TYPE_PRINT
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_FUNCTION_ATTRS
|
||||
#define FUN_BC_TYPE_ATTR attr, mp_obj_fun_bc_attr,
|
||||
#else
|
||||
#define FUN_BC_TYPE_ATTR
|
||||
#endif
|
||||
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
mp_type_fun_bc,
|
||||
MP_QSTR_function,
|
||||
MP_TYPE_FLAG_BINDS_SELF,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
print, fun_bc_print,
|
||||
#endif
|
||||
FUN_BC_TYPE_PRINT
|
||||
FUN_BC_TYPE_ATTR
|
||||
call, fun_bc_call,
|
||||
unary_op, mp_generic_unary_op
|
||||
#if MICROPY_PY_FUNCTION_ATTRS
|
||||
, attr, mp_obj_fun_bc_attr
|
||||
#endif
|
||||
);
|
||||
|
||||
mp_obj_t mp_obj_new_fun_bc(const mp_obj_t *def_args, const byte *code, const mp_module_context_t *context, struct _mp_raw_code_t *const *child_table) {
|
||||
@ -408,17 +416,24 @@ STATIC mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, co
|
||||
return fun(self_in, n_args, n_kw, args);
|
||||
}
|
||||
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
#define FUN_BC_TYPE_PRINT print, fun_bc_print,
|
||||
#else
|
||||
#define FUN_BC_TYPE_PRINT
|
||||
#endif
|
||||
#if MICROPY_PY_FUNCTION_ATTRS
|
||||
#define FUN_BC_TYPE_ATTR attr, mp_obj_fun_bc_attr,
|
||||
#else
|
||||
#define FUN_BC_TYPE_ATTR
|
||||
#endif
|
||||
|
||||
STATIC MP_DEFINE_CONST_OBJ_TYPE(
|
||||
mp_type_fun_native,
|
||||
MP_QSTR_function,
|
||||
MP_TYPE_FLAG_BINDS_SELF,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
print, fun_bc_print,
|
||||
#endif
|
||||
#if MICROPY_PY_FUNCTION_ATTRS
|
||||
attr, mp_obj_fun_bc_attr,
|
||||
#endif
|
||||
FUN_BC_TYPE_PRINT
|
||||
FUN_BC_TYPE_ATTR
|
||||
call, fun_native_call,
|
||||
unary_op, mp_generic_unary_op
|
||||
);
|
||||
|
@ -70,16 +70,20 @@ STATIC mp_obj_t gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_kw, cons
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
#if MICROPY_PY_FUNCTION_ATTRS
|
||||
#define GEN_WRAP_TYPE_ATTR attr, mp_obj_fun_bc_attr,
|
||||
#else
|
||||
#define GEN_WRAP_TYPE_ATTR
|
||||
#endif
|
||||
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
mp_type_gen_wrap,
|
||||
MP_QSTR_generator,
|
||||
MP_TYPE_FLAG_BINDS_SELF,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
GEN_WRAP_TYPE_ATTR
|
||||
call, gen_wrap_call,
|
||||
unary_op, mp_generic_unary_op
|
||||
#if MICROPY_PY_FUNCTION_ATTRS
|
||||
, attr, mp_obj_fun_bc_attr
|
||||
#endif
|
||||
);
|
||||
|
||||
/******************************************************************************/
|
||||
@ -132,16 +136,20 @@ STATIC mp_obj_t native_gen_wrap_call(mp_obj_t self_in, size_t n_args, size_t n_k
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
#if MICROPY_PY_FUNCTION_ATTRS
|
||||
#define NATIVE_GEN_WRAP_TYPE_ATTR attr, mp_obj_fun_bc_attr,
|
||||
#else
|
||||
#define NATIVE_GEN_WRAP_TYPE_ATTR
|
||||
#endif
|
||||
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
mp_type_native_gen_wrap,
|
||||
MP_QSTR_generator,
|
||||
MP_TYPE_FLAG_BINDS_SELF,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
call, native_gen_wrap_call,
|
||||
NATIVE_GEN_WRAP_TYPE_ATTR
|
||||
unary_op, mp_generic_unary_op
|
||||
#if MICROPY_PY_FUNCTION_ATTRS
|
||||
, attr, mp_obj_fun_bc_attr
|
||||
#endif
|
||||
);
|
||||
|
||||
#endif // MICROPY_EMIT_NATIVE
|
||||
|
@ -111,12 +111,16 @@ STATIC const mp_rom_map_elem_t object_locals_dict_table[] = {
|
||||
STATIC MP_DEFINE_CONST_DICT(object_locals_dict, object_locals_dict_table);
|
||||
#endif
|
||||
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
#define OBJECT_TYPE_LOCALS_DICT , locals_dict, (mp_obj_dict_t *)&object_locals_dict
|
||||
#else
|
||||
#define OBJECT_TYPE_LOCALS_DICT
|
||||
#endif
|
||||
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
mp_type_object,
|
||||
MP_QSTR_object,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
object_make_new
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
, locals_dict, (mp_obj_dict_t *)&object_locals_dict
|
||||
#endif
|
||||
OBJECT_TYPE_LOCALS_DICT
|
||||
);
|
||||
|
@ -210,19 +210,27 @@ STATIC void range_attr(mp_obj_t o_in, qstr attr, mp_obj_t *dest) {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_BUILTINS_RANGE_BINOP
|
||||
#define RANGE_TYPE_BINOP binary_op, range_binary_op,
|
||||
#else
|
||||
#define RANGE_TYPE_BINOP
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_BUILTINS_RANGE_ATTRS
|
||||
#define RANGE_TYPE_ATTR attr, range_attr,
|
||||
#else
|
||||
#define RANGE_TYPE_ATTR
|
||||
#endif
|
||||
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
mp_type_range,
|
||||
MP_QSTR_range,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
range_make_new,
|
||||
RANGE_TYPE_BINOP
|
||||
RANGE_TYPE_ATTR
|
||||
print, range_print,
|
||||
unary_op, range_unary_op,
|
||||
#if MICROPY_PY_BUILTINS_RANGE_BINOP
|
||||
binary_op, range_binary_op,
|
||||
#endif
|
||||
subscr, range_subscr,
|
||||
getiter, range_getiter
|
||||
#if MICROPY_PY_BUILTINS_RANGE_ATTRS
|
||||
, attr, range_attr
|
||||
#endif
|
||||
);
|
||||
|
@ -92,17 +92,21 @@ STATIC const mp_rom_map_elem_t slice_locals_dict_table[] = {
|
||||
STATIC MP_DEFINE_CONST_DICT(slice_locals_dict, slice_locals_dict_table);
|
||||
#endif
|
||||
|
||||
#if MICROPY_PY_BUILTINS_SLICE_ATTRS
|
||||
#define SLICE_TYPE_ATTR_OR_LOCALS_DICT attr, slice_attr,
|
||||
#elif MICROPY_PY_BUILTINS_SLICE_INDICES
|
||||
#define SLICE_TYPE_ATTR_OR_LOCALS_DICT locals_dict, (mp_obj_dict_t *)&slice_locals_dict,
|
||||
#else
|
||||
#define SLICE_TYPE_ATTR_OR_LOCALS_DICT
|
||||
#endif
|
||||
|
||||
MP_DEFINE_CONST_OBJ_TYPE(
|
||||
mp_type_slice,
|
||||
MP_QSTR_slice,
|
||||
MP_TYPE_FLAG_NONE,
|
||||
MP_TYPE_NULL_MAKE_NEW,
|
||||
SLICE_TYPE_ATTR_OR_LOCALS_DICT
|
||||
print, slice_print
|
||||
#if MICROPY_PY_BUILTINS_SLICE_ATTRS
|
||||
, attr, slice_attr
|
||||
#elif MICROPY_PY_BUILTINS_SLICE_INDICES
|
||||
, locals_dict, (mp_obj_dict_t *)&slice_locals_dict
|
||||
#endif
|
||||
);
|
||||
|
||||
mp_obj_t mp_obj_new_slice(mp_obj_t ostart, mp_obj_t ostop, mp_obj_t ostep) {
|
||||
|
Loading…
Reference in New Issue
Block a user