Skip to content

Commit 3d65101

Browse files
committed
py: Clean up formatting of union definitions.
Signed-off-by: Damien George <[email protected]>
1 parent 7c8ec85 commit 3d65101

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

py/binary.c

+13-9
Original file line numberDiff line numberDiff line change
@@ -241,13 +241,15 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte *p_base, byte *
241241
return mp_obj_new_str(s_val, strlen(s_val));
242242
#if MICROPY_PY_BUILTINS_FLOAT
243243
} else if (val_type == 'f') {
244-
union { uint32_t i;
245-
float f;
244+
union {
245+
uint32_t i;
246+
float f;
246247
} fpu = {val};
247248
return mp_obj_new_float_from_f(fpu.f);
248249
} else if (val_type == 'd') {
249-
union { uint64_t i;
250-
double f;
250+
union {
251+
uint64_t i;
252+
double f;
251253
} fpu = {val};
252254
return mp_obj_new_float_from_d(fpu.f);
253255
#endif
@@ -308,17 +310,19 @@ void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte *p
308310
break;
309311
#if MICROPY_PY_BUILTINS_FLOAT
310312
case 'f': {
311-
union { uint32_t i;
312-
float f;
313+
union {
314+
uint32_t i;
315+
float f;
313316
} fp_sp;
314317
fp_sp.f = mp_obj_get_float_to_f(val_in);
315318
val = fp_sp.i;
316319
break;
317320
}
318321
case 'd': {
319-
union { uint64_t i64;
320-
uint32_t i32[2];
321-
double f;
322+
union {
323+
uint64_t i64;
324+
uint32_t i32[2];
325+
double f;
322326
} fp_dp;
323327
fp_dp.f = mp_obj_get_float_to_d(val_in);
324328
if (MP_BYTES_PER_OBJ_WORD == 8) {

py/obj.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,11 @@ static inline bool mp_obj_is_obj(mp_const_obj_t o) {
283283
#define MP_OBJ_FROM_PTR(p) ((mp_obj_t)((uintptr_t)(p)))
284284

285285
// rom object storage needs special handling to widen 32-bit pointer to 64-bits
286-
typedef union _mp_rom_obj_t { uint64_t u64;
287-
struct { const void *lo, *hi;
288-
} u32;
286+
typedef union _mp_rom_obj_t {
287+
uint64_t u64;
288+
struct {
289+
const void *lo, *hi;
290+
} u32;
289291
} mp_rom_obj_t;
290292
#define MP_ROM_INT(i) {MP_OBJ_NEW_SMALL_INT(i)}
291293
#define MP_ROM_QSTR(q) {MP_OBJ_NEW_QSTR(q)}

0 commit comments

Comments
 (0)