aboutsummaryrefslogtreecommitdiff
path: root/py/objrange.c
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2020-02-27 15:36:53 +1100
committerDamien George <damien.p.george@gmail.com>2020-02-28 10:33:03 +1100
commit69661f3343bedf86e514337cff63d96cc42f8859 (patch)
treeaf5dfb380ffdb75dda84828f63cf9d840d992f0f /py/objrange.c
parent3f39d18c2b884d32f0443e2e8114ff9d7a14d718 (diff)
all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
Diffstat (limited to 'py/objrange.c')
-rw-r--r--py/objrange.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/py/objrange.c b/py/objrange.c
index 6c3097abd..9727d4864 100644
--- a/py/objrange.c
+++ b/py/objrange.c
@@ -59,7 +59,7 @@ STATIC const mp_obj_type_t range_it_type = {
STATIC mp_obj_t mp_obj_new_range_iterator(mp_int_t cur, mp_int_t stop, mp_int_t step, mp_obj_iter_buf_t *iter_buf) {
assert(sizeof(mp_obj_range_it_t) <= sizeof(mp_obj_iter_buf_t));
- mp_obj_range_it_t *o = (mp_obj_range_it_t*)iter_buf;
+ mp_obj_range_it_t *o = (mp_obj_range_it_t *)iter_buf;
o->base.type = &range_it_type;
o->cur = cur;
o->stop = stop;
@@ -132,9 +132,12 @@ STATIC mp_obj_t range_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
mp_int_t len = range_len(self);
switch (op) {
- case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len > 0);
- case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(len);
- default: return MP_OBJ_NULL; // op not supported
+ case MP_UNARY_OP_BOOL:
+ return mp_obj_new_bool(len > 0);
+ case MP_UNARY_OP_LEN:
+ return MP_OBJ_NEW_SMALL_INT(len);
+ default:
+ return MP_OBJ_NULL; // op not supported
}
}
@@ -152,7 +155,7 @@ STATIC mp_obj_t range_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs
&& (lhs_len == 0
|| (lhs->start == rhs->start
&& (lhs_len == 1 || lhs->step == rhs->step)))
- );
+ );
}
#endif
@@ -161,7 +164,7 @@ STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
// load
mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
mp_int_t len = range_len(self);
-#if MICROPY_PY_BUILTINS_SLICE
+ #if MICROPY_PY_BUILTINS_SLICE
if (mp_obj_is_type(index, &mp_type_slice)) {
mp_bound_slice_t slice;
mp_seq_get_fast_slice_indexes(len, index, &slice);
@@ -176,7 +179,7 @@ STATIC mp_obj_t range_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
}
return MP_OBJ_FROM_PTR(o);
}
-#endif
+ #endif
size_t index_val = mp_get_index(self->base.type, len, index, false);
return MP_OBJ_NEW_SMALL_INT(self->start + index_val * self->step);
} else {
@@ -218,7 +221,7 @@ const mp_obj_type_t mp_type_range = {
#endif
.subscr = range_subscr,
.getiter = range_getiter,
-#if MICROPY_PY_BUILTINS_RANGE_ATTRS
+ #if MICROPY_PY_BUILTINS_RANGE_ATTRS
.attr = range_attr,
-#endif
+ #endif
};