all: Reformat C and Python source code with tools/codeformat.py.
This is run with uncrustify 0.70.1, and black 19.10b0.
This commit is contained in:
40
py/objtype.c
40
py/objtype.c
@@ -42,7 +42,7 @@
|
||||
#endif
|
||||
|
||||
#define ENABLE_SPECIAL_ACCESSORS \
|
||||
(MICROPY_PY_DESCRIPTORS || MICROPY_PY_DELATTR_SETATTR || MICROPY_PY_BUILTINS_PROPERTY)
|
||||
(MICROPY_PY_DESCRIPTORS || MICROPY_PY_DELATTR_SETATTR || MICROPY_PY_BUILTINS_PROPERTY)
|
||||
|
||||
STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
|
||||
|
||||
@@ -63,7 +63,7 @@ STATIC int instance_count_native_bases(const mp_obj_type_t *type, const mp_obj_t
|
||||
// No parents so end search here.
|
||||
return count;
|
||||
#if MICROPY_MULTIPLE_INHERITANCE
|
||||
} else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) {
|
||||
} else if (((mp_obj_base_t *)type->parent)->type == &mp_type_tuple) {
|
||||
// Multiple parents, search through them all recursively.
|
||||
const mp_obj_tuple_t *parent_tuple = type->parent;
|
||||
const mp_obj_t *item = parent_tuple->items;
|
||||
@@ -133,7 +133,7 @@ struct class_lookup_data {
|
||||
bool is_type;
|
||||
};
|
||||
|
||||
STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_type_t *type) {
|
||||
STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_type_t *type) {
|
||||
assert(lookup->dest[0] == MP_OBJ_NULL);
|
||||
assert(lookup->dest[1] == MP_OBJ_NULL);
|
||||
for (;;) {
|
||||
@@ -143,7 +143,7 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_
|
||||
// this should not be applied to class types, as will result in extra
|
||||
// lookup either.
|
||||
if (lookup->meth_offset != 0 && mp_obj_is_native_type(type)) {
|
||||
if (*(void**)((char*)type + lookup->meth_offset) != NULL) {
|
||||
if (*(void **)((char *)type + lookup->meth_offset) != NULL) {
|
||||
DEBUG_printf("mp_obj_class_lookup: Matched special meth slot (off=%d) for %s\n",
|
||||
lookup->meth_offset, qstr_str(lookup->attr));
|
||||
lookup->dest[0] = MP_OBJ_SENTINEL;
|
||||
@@ -160,7 +160,7 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_
|
||||
if (lookup->is_type) {
|
||||
// If we look up a class method, we need to return original type for which we
|
||||
// do a lookup, not a (base) type in which we found the class method.
|
||||
const mp_obj_type_t *org_type = (const mp_obj_type_t*)lookup->obj;
|
||||
const mp_obj_type_t *org_type = (const mp_obj_type_t *)lookup->obj;
|
||||
mp_convert_member_lookup(MP_OBJ_NULL, org_type, elem->value, lookup->dest);
|
||||
} else {
|
||||
mp_obj_instance_t *obj = lookup->obj;
|
||||
@@ -173,7 +173,7 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_
|
||||
}
|
||||
mp_convert_member_lookup(obj_obj, type, elem->value, lookup->dest);
|
||||
}
|
||||
#if DEBUG_PRINT
|
||||
#if DEBUG_PRINT
|
||||
DEBUG_printf("mp_obj_class_lookup: Returning: ");
|
||||
mp_obj_print_helper(MICROPY_DEBUG_PRINTER, lookup->dest[0], PRINT_REPR);
|
||||
if (lookup->dest[1] != MP_OBJ_NULL) {
|
||||
@@ -181,7 +181,7 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_
|
||||
DEBUG_printf(" <%s @%p>", mp_obj_get_type_str(lookup->dest[1]), MP_OBJ_TO_PTR(lookup->dest[1]));
|
||||
}
|
||||
DEBUG_printf("\n");
|
||||
#endif
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -202,13 +202,13 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_
|
||||
DEBUG_printf("mp_obj_class_lookup: No more parents\n");
|
||||
return;
|
||||
#if MICROPY_MULTIPLE_INHERITANCE
|
||||
} else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) {
|
||||
} else if (((mp_obj_base_t *)type->parent)->type == &mp_type_tuple) {
|
||||
const mp_obj_tuple_t *parent_tuple = type->parent;
|
||||
const mp_obj_t *item = parent_tuple->items;
|
||||
const mp_obj_t *top = item + parent_tuple->len - 1;
|
||||
for (; item < top; ++item) {
|
||||
assert(mp_obj_is_type(*item, &mp_type_type));
|
||||
mp_obj_type_t *bt = (mp_obj_type_t*)MP_OBJ_TO_PTR(*item);
|
||||
mp_obj_type_t *bt = (mp_obj_type_t *)MP_OBJ_TO_PTR(*item);
|
||||
if (bt == &mp_type_object) {
|
||||
// Not a "real" type
|
||||
continue;
|
||||
@@ -221,7 +221,7 @@ STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_
|
||||
|
||||
// search last base (simple tail recursion elimination)
|
||||
assert(mp_obj_is_type(*item, &mp_type_type));
|
||||
type = (mp_obj_type_t*)MP_OBJ_TO_PTR(*item);
|
||||
type = (mp_obj_type_t *)MP_OBJ_TO_PTR(*item);
|
||||
#endif
|
||||
} else {
|
||||
type = type->parent;
|
||||
@@ -586,7 +586,7 @@ STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *des
|
||||
dest[0] = elem->value;
|
||||
return;
|
||||
}
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
#if MICROPY_CPYTHON_COMPAT
|
||||
if (attr == MP_QSTR___dict__) {
|
||||
// Create a new dict with a copy of the instance's map items.
|
||||
// This creates, unlike CPython, a 'read-only' __dict__: modifying
|
||||
@@ -601,7 +601,7 @@ STATIC void mp_obj_instance_load_attr(mp_obj_t self_in, qstr attr, mp_obj_t *des
|
||||
dest[0] = attr_dict;
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
struct class_lookup_data lookup = {
|
||||
.obj = self,
|
||||
.attr = attr,
|
||||
@@ -1031,7 +1031,7 @@ STATIC void type_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
}
|
||||
#endif
|
||||
struct class_lookup_data lookup = {
|
||||
.obj = (mp_obj_instance_t*)self,
|
||||
.obj = (mp_obj_instance_t *)self,
|
||||
.attr = attr,
|
||||
.meth_offset = 0,
|
||||
.dest = dest,
|
||||
@@ -1146,7 +1146,7 @@ mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict)
|
||||
// abstract base class which would translate C-level protocol to
|
||||
// Python method calls, and any subclass inheriting from it will
|
||||
// support this feature.
|
||||
o->protocol = ((mp_obj_type_t*)MP_OBJ_TO_PTR(bases_items[0]))->protocol;
|
||||
o->protocol = ((mp_obj_type_t *)MP_OBJ_TO_PTR(bases_items[0]))->protocol;
|
||||
|
||||
if (bases_len >= 2) {
|
||||
#if MICROPY_MULTIPLE_INHERITANCE
|
||||
@@ -1223,7 +1223,7 @@ STATIC mp_obj_t super_make_new(const mp_obj_type_t *type_in, size_t n_args, size
|
||||
mp_raise_TypeError(NULL);
|
||||
}
|
||||
mp_obj_super_t *o = m_new_obj(mp_obj_super_t);
|
||||
*o = (mp_obj_super_t){{type_in}, args[0], args[1]};
|
||||
*o = (mp_obj_super_t) {{type_in}, args[0], args[1]};
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
@@ -1256,7 +1256,7 @@ STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
if (type->parent == NULL) {
|
||||
// no parents, do nothing
|
||||
#if MICROPY_MULTIPLE_INHERITANCE
|
||||
} else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) {
|
||||
} else if (((mp_obj_base_t *)type->parent)->type == &mp_type_tuple) {
|
||||
const mp_obj_tuple_t *parent_tuple = type->parent;
|
||||
size_t len = parent_tuple->len;
|
||||
const mp_obj_t *items = parent_tuple->items;
|
||||
@@ -1267,7 +1267,7 @@ STATIC void super_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
|
||||
// and we don't want to lookup native methods in object.
|
||||
continue;
|
||||
}
|
||||
mp_obj_class_lookup(&lookup, (mp_obj_type_t*)MP_OBJ_TO_PTR(items[i]));
|
||||
mp_obj_class_lookup(&lookup, (mp_obj_type_t *)MP_OBJ_TO_PTR(items[i]));
|
||||
if (dest[0] != MP_OBJ_NULL) {
|
||||
break;
|
||||
}
|
||||
@@ -1330,7 +1330,7 @@ bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo) {
|
||||
// type has no parents
|
||||
return false;
|
||||
#if MICROPY_MULTIPLE_INHERITANCE
|
||||
} else if (((mp_obj_base_t*)self->parent)->type == &mp_type_tuple) {
|
||||
} else if (((mp_obj_base_t *)self->parent)->type == &mp_type_tuple) {
|
||||
// get the base objects (they should be type objects)
|
||||
const mp_obj_tuple_t *parent_tuple = self->parent;
|
||||
const mp_obj_t *item = parent_tuple->items;
|
||||
@@ -1397,7 +1397,7 @@ mp_obj_t mp_obj_cast_to_native_base(mp_obj_t self_in, mp_const_obj_t native_type
|
||||
} else if (!mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(self_type), native_type)) {
|
||||
return MP_OBJ_NULL;
|
||||
} else {
|
||||
mp_obj_instance_t *self = (mp_obj_instance_t*)MP_OBJ_TO_PTR(self_in);
|
||||
mp_obj_instance_t *self = (mp_obj_instance_t *)MP_OBJ_TO_PTR(self_in);
|
||||
return self->subobj[0];
|
||||
}
|
||||
}
|
||||
@@ -1411,7 +1411,7 @@ STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self, size_t n
|
||||
mp_arg_check_num(n_args, n_kw, 1, 1, false);
|
||||
|
||||
mp_obj_static_class_method_t *o = m_new_obj(mp_obj_static_class_method_t);
|
||||
*o = (mp_obj_static_class_method_t){{self}, args[0]};
|
||||
*o = (mp_obj_static_class_method_t) {{self}, args[0]};
|
||||
return MP_OBJ_FROM_PTR(o);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user