Skip to content

Commit 1b586f3

Browse files
committed
py: Rename MP_BOOL() to mp_obj_new_bool() for consistency in naming.
1 parent 53ca6ae commit 1b586f3

26 files changed

+57
-61
lines changed

cc3200/mods/modnetwork.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ STATIC mp_obj_t network_server_running(mp_uint_t n_args, const mp_obj_t *args) {
5454
return mp_const_none;
5555
} else {
5656
// get
57-
return MP_BOOL(servers_are_enabled());
57+
return mp_obj_new_bool(servers_are_enabled());
5858
}
5959
}
6060
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(network_server_running_obj, 0, 1, network_server_running);

py/modbuiltins.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
534534
// in nlr_push and handle exception.
535535
mp_load_method_maybe(object_in, MP_OBJ_QSTR_VALUE(attr_in), dest);
536536

537-
return MP_BOOL(dest[0] != MP_OBJ_NULL);
537+
return mp_obj_new_bool(dest[0] != MP_OBJ_NULL);
538538
}
539539
MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_hasattr_obj, mp_builtin_hasattr);
540540

py/modgc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ STATIC mp_obj_t gc_enable(void) {
6363
MP_DEFINE_CONST_FUN_OBJ_0(gc_enable_obj, gc_enable);
6464

6565
STATIC mp_obj_t gc_isenabled(void) {
66-
return MP_BOOL(MP_STATE_MEM(gc_auto_collect_enabled));
66+
return mp_obj_new_bool(MP_STATE_MEM(gc_auto_collect_enabled));
6767
}
6868
MP_DEFINE_CONST_FUN_OBJ_0(gc_isenabled_obj, gc_isenabled);
6969

py/modmath.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_## py_name ## _obj, mp_math_ ## py_name);
4646

4747
#define MATH_FUN_1_TO_BOOL(py_name, c_name) \
48-
STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return MP_BOOL(c_name(mp_obj_get_float(x_obj))); } \
48+
STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_bool(c_name(mp_obj_get_float(x_obj))); } \
4949
STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name);
5050

5151
#define MATH_FUN_1_TO_INT(py_name, c_name) \

py/nativeglue.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ mp_obj_t mp_convert_native_to_obj(mp_uint_t val, mp_uint_t type) {
6767
DEBUG_printf("mp_convert_native_to_obj(" UINT_FMT ", " UINT_FMT ")\n", val, type);
6868
switch (type & 3) {
6969
case MP_NATIVE_TYPE_OBJ: return (mp_obj_t)val;
70-
case MP_NATIVE_TYPE_BOOL: return MP_BOOL(val);
70+
case MP_NATIVE_TYPE_BOOL: return mp_obj_new_bool(val);
7171
case MP_NATIVE_TYPE_INT: return mp_obj_new_int(val);
7272
case MP_NATIVE_TYPE_UINT: return mp_obj_new_int_from_uint(val);
7373
default: assert(0); return mp_const_none;

py/obj.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ extern const struct _mp_obj_exception_t mp_const_GeneratorExit_obj;
459459

460460
mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict);
461461
mp_obj_t mp_obj_new_none(void);
462-
mp_obj_t mp_obj_new_bool(bool value);
462+
static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? mp_const_true : mp_const_false; }
463463
mp_obj_t mp_obj_new_cell(mp_obj_t obj);
464464
mp_obj_t mp_obj_new_int(mp_int_t value);
465465
mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value);
@@ -528,10 +528,6 @@ mp_obj_t mp_obj_len_maybe(mp_obj_t o_in); // may return MP_OBJ_NULL
528528
mp_obj_t mp_obj_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t val);
529529
mp_obj_t mp_generic_unary_op(mp_uint_t op, mp_obj_t o_in);
530530

531-
// bool
532-
// TODO make lower case when it has proven itself
533-
static inline mp_obj_t MP_BOOL(mp_int_t x) { return x ? mp_const_true : mp_const_false; }
534-
535531
// cell
536532
mp_obj_t mp_obj_cell_get(mp_obj_t self_in);
537533
void mp_obj_cell_set(mp_obj_t self_in, mp_obj_t obj);

py/objarray.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ STATIC mp_obj_t memoryview_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_
246246
STATIC mp_obj_t array_unary_op(mp_uint_t op, mp_obj_t o_in) {
247247
mp_obj_array_t *o = o_in;
248248
switch (op) {
249-
case MP_UNARY_OP_BOOL: return MP_BOOL(o->len != 0);
249+
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->len != 0);
250250
case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(o->len);
251251
default: return MP_OBJ_NULL; // op not supported
252252
}
@@ -290,7 +290,7 @@ STATIC mp_obj_t array_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in)
290290
if (!mp_get_buffer(rhs_in, &rhs_bufinfo, MP_BUFFER_READ)) {
291291
return mp_const_false;
292292
}
293-
return MP_BOOL(mp_seq_cmp_bytes(op, lhs_bufinfo.buf, lhs_bufinfo.len, rhs_bufinfo.buf, rhs_bufinfo.len));
293+
return mp_obj_new_bool(mp_seq_cmp_bytes(op, lhs_bufinfo.buf, lhs_bufinfo.len, rhs_bufinfo.buf, rhs_bufinfo.len));
294294
}
295295

296296
default:

py/objcomplex.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ STATIC mp_obj_t complex_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n
116116
STATIC mp_obj_t complex_unary_op(mp_uint_t op, mp_obj_t o_in) {
117117
mp_obj_complex_t *o = o_in;
118118
switch (op) {
119-
case MP_UNARY_OP_BOOL: return MP_BOOL(o->real != 0 || o->imag != 0);
119+
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->real != 0 || o->imag != 0);
120120
case MP_UNARY_OP_POSITIVE: return o_in;
121121
case MP_UNARY_OP_NEGATIVE: return mp_obj_new_complex(-o->real, -o->imag);
122122
default: return MP_OBJ_NULL; // op not supported
@@ -240,7 +240,7 @@ mp_obj_t mp_obj_complex_binary_op(mp_uint_t op, mp_float_t lhs_real, mp_float_t
240240
break;
241241
}
242242

243-
case MP_BINARY_OP_EQUAL: return MP_BOOL(lhs_real == rhs_real && lhs_imag == rhs_imag);
243+
case MP_BINARY_OP_EQUAL: return mp_obj_new_bool(lhs_real == rhs_real && lhs_imag == rhs_imag);
244244

245245
default:
246246
return MP_OBJ_NULL; // op not supported

py/objdict.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ STATIC mp_obj_t dict_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_kw
103103
STATIC mp_obj_t dict_unary_op(mp_uint_t op, mp_obj_t self_in) {
104104
mp_obj_dict_t *self = MP_OBJ_CAST(self_in);
105105
switch (op) {
106-
case MP_UNARY_OP_BOOL: return MP_BOOL(self->map.used != 0);
106+
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->map.used != 0);
107107
case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->map.used);
108108
default: return MP_OBJ_NULL; // op not supported
109109
}
@@ -114,7 +114,7 @@ STATIC mp_obj_t dict_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in) {
114114
switch (op) {
115115
case MP_BINARY_OP_IN: {
116116
mp_map_elem_t *elem = mp_map_lookup(&o->map, rhs_in, MP_MAP_LOOKUP);
117-
return MP_BOOL(elem != NULL);
117+
return mp_obj_new_bool(elem != NULL);
118118
}
119119
case MP_BINARY_OP_EQUAL: {
120120
#if MICROPY_PY_COLLECTIONS_ORDEREDDICT

py/objfloat.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ STATIC mp_obj_t float_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
8585
STATIC mp_obj_t float_unary_op(mp_uint_t op, mp_obj_t o_in) {
8686
mp_obj_float_t *o = o_in;
8787
switch (op) {
88-
case MP_UNARY_OP_BOOL: return MP_BOOL(o->value != 0);
88+
case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->value != 0);
8989
case MP_UNARY_OP_POSITIVE: return o_in;
9090
case MP_UNARY_OP_NEGATIVE: return mp_obj_new_float(-o->value);
9191
default: return MP_OBJ_NULL; // op not supported
@@ -216,11 +216,11 @@ mp_obj_t mp_obj_float_binary_op(mp_uint_t op, mp_float_t lhs_val, mp_obj_t rhs_i
216216
};
217217
return mp_obj_new_tuple(2, tuple);
218218
}
219-
case MP_BINARY_OP_LESS: return MP_BOOL(lhs_val < rhs_val);
220-
case MP_BINARY_OP_MORE: return MP_BOOL(lhs_val > rhs_val);
221-
case MP_BINARY_OP_EQUAL: return MP_BOOL(lhs_val == rhs_val);
222-
case MP_BINARY_OP_LESS_EQUAL: return MP_BOOL(lhs_val <= rhs_val);
223-
case MP_BINARY_OP_MORE_EQUAL: return MP_BOOL(lhs_val >= rhs_val);
219+
case MP_BINARY_OP_LESS: return mp_obj_new_bool(lhs_val < rhs_val);
220+
case MP_BINARY_OP_MORE: return mp_obj_new_bool(lhs_val > rhs_val);
221+
case MP_BINARY_OP_EQUAL: return mp_obj_new_bool(lhs_val == rhs_val);
222+
case MP_BINARY_OP_LESS_EQUAL: return mp_obj_new_bool(lhs_val <= rhs_val);
223+
case MP_BINARY_OP_MORE_EQUAL: return mp_obj_new_bool(lhs_val >= rhs_val);
224224

225225
default:
226226
return MP_OBJ_NULL; // op not supported

0 commit comments

Comments
 (0)