Skip to content

Formatting#369

Open
hazelwiss wants to merge 24 commits intoskylersaleh:devfrom
hazelwiss:formatting
Open

Formatting#369
hazelwiss wants to merge 24 commits intoskylersaleh:devfrom
hazelwiss:formatting

Conversation

@hazelwiss
Copy link
Copy Markdown
Contributor

Added a formatting script to format the project, and crated a clang-format script using the LLVM formatting style. If we want another style it is a simple fix!

Comment thread src/main.c Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Includes should not be moved past defines.

Comment thread src/main.c Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to make it not break aligned numbers like this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right I will try to see if I can make it do that

Comment thread src/main.c Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • and / should not be wrapped in spaces (but + and - should be wrapped in spaces) to improve readability.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uhm ok sounds like a good idea

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang format does unfortunately not seem to support this (?)
is this a deal breaker? It seems to want to have spaces between most operators.

Comment thread src/main.c Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't auto word wrap long lines.

Comment thread src/main.c Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. if/while should not have spaces between "("
  2. if statements without {} should always be on the same line as their statement (it prevents bugs)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we always want {} to create a new line?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, leave it up to the programmer to put the new lines if they want it.

Comment thread src/main.c Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no space between ) and {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't seem to be an option sadly

Comment thread src/main.c Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where did this extra semicolon come from?

Comment thread src/main.c Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you configure the formatting to not touch the location of * in variable names?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dunno but I will try

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No sadly, it does not seem like it, but we can tell it to put pointers to the left, right or in the middle. Maybe I simply missed it in the docs because it does feel like it should be an option but it is not.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it still format them even if you don't have a PointerAlignment field?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can look into it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope it defaults to right alignment if I do that.

Comment thread src/main.c Outdated
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to not break up these case labels and the returns onto separate lines.
They are laid out like this to allow block edits.

Comment thread src/gba_bios.h
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't format this file

Comment thread src/nds_rom_database.h
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't format this file

Comment thread src/lcd_shaders.h
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't format this file

Comment thread src/main.c Outdated
"Toggle Full Screen"
};
const static char *se_keybind_names[SE_NUM_KEYBINDS] = {
"A",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should only be 2 spaces

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want a tab width of 2 spaces?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix that

Comment thread src/main.c
// Utilize a watchdog channel to detect if the audio context has encountered an error
// and restart it if a problem occurred.
int audio_watchdog_timer;
int audio_watchdog_triggered;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spacing here is a bit long

Copy link
Copy Markdown
Contributor Author

@hazelwiss hazelwiss Dec 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spacing is long in order to have alignment, we could add newlines between the lines to alleviate that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

things like this may happen a bit everywhere though so declarations are aligned, it is sadly impossible as far as I can see to give it a sort of threshold.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants