New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply uncrustify to format all code (v1) #5691
Conversation
This looks amazing. Minor preference to use inline comments (the equivalent of I think there are a few things set to |
Pretty good yes. I've used uncrustify in the past and mainly remember it took like an hour to get through all configuration :) Wrt codeformat.py: I think in the end it needs to be changed to not require the current working directory to be correct i.e. use full absoluta paths instead of relative so that it's easier to invoke from anywhere. And if arguments are passed they should be treated as paths to files to format (also checked agains list of files to exclude, if that's kept). That makes it easier to integrate in text editors etc so you can just format the file you're currently working on. |
Yes that needs to be fixed.
That also needs to be fixed, to put everything on its own line. Uncrustify respects a lot of existing format style so it may be that the code needs to be fixed by hand to put things on one line, then uncrustify will keep it that way.
Agreed (and this goes regardless of which formatter we pick). |
@tannewt what do you think about using uncrustify as a C formatter? Big benefit is that it can handle indenting #if's as we currently use them. And I don't see any show-stoppers to using it. |
Looks good to me! |
We can always refine it later or move to clang-format/clang-tidy if there is something we want later. |
There doesn't appear to be a way to get this exactly right, but
help. You get If we consider changing the casting format to
is what you need here.
|
16781d4
to
fbf4901
Compare
Ok, I force-pushed this with some fixes and changes. INDENT-OFF is now used to turn off formatting in specific places, and newlines are always added after the case label in a switch. Some outstanding items:
typedef uint64_t mp_obj_t;
typedef uint64_t mp_const_obj_t;
#else
-typedef void *mp_obj_t;
-typedef const void *mp_const_obj_t;
+typedef void*mp_obj_t;
+typedef const void*mp_const_obj_t;
#endif
struct _mp_obj_base_t {
- const mp_obj_type_t *type MICROPY_OBJ_BASE_ALIGNMENT;
+ const mp_obj_type_t*type MICROPY_OBJ_BASE_ALIGNMENT;
};
typedef struct _mp_obj_base_t mp_obj_base_t;
#define DECODE_CODESTATE_SIZE(bytecode, n_state_out_var, state_size_out_var) \
{ \
- const uint8_t *ip = bytecode; \
+ const uint8_t*ip = bytecode; \
size_t n_exc_stack, scope_flags, n_pos_args, n_kwonly_args, n_def_args; \
MP_BC_PRELUDE_SIG_DECODE_INTO(ip, n_state_out_var, n_exc_stack, scope_flags, n_pos_ar
\
/* state size in bytes */ \
- state_size_out_var = n_state_out_var * sizeof(mp_obj_t) \
- + n_exc_stack * sizeof(mp_exc_stack_t); \
+ state_size_out_var = n_state_out_var*sizeof(mp_obj_t) \
+ + n_exc_stack*sizeof(mp_exc_stack_t); \
} |
6c0950b
to
a3cb139
Compare
Force pushed changes to include mpy-cross in the formatting, and fix the above issues (by changing all casts to have a space before the pointer star). |
For code formatting consistency.
To improve formatting consistency.
a3cb139
to
cdf03dc
Compare
Closed in favour of #5700. |
Fix PIDs to match official espressif list
Per discussion in #4223 here's an attempt to format the code using the uncrustify tool; see https://github.com/uncrustify/uncrustify
Uncrustify is highly configurable, and seems to support indenting preprocessor directives quite well. It can also add braces
{}
for single-line if-else statements (which is enabled in the settings here).It's not perfect but is pretty good. There's still a bit of room left to optimise the settings.