124 lines
3 KiB
Markdown
124 lines
3 KiB
Markdown
# Contributing to SynthXEX
|
|
|
|
## Bug reports
|
|
Please direct any bug reports to either the [main repository](https://git.aidenisik.scot/FreeChainXenon/SynthXEX/issues), or the [GitHub mirror](https://github.com/FreeChainXenon/SynthXEX/issues).
|
|
|
|
## Patches
|
|
To contribute code, first ensure you have read and adhered to the [code style](#code-style) section.
|
|
|
|
There are two ways to contribute code patches:
|
|
|
|
- Pull requests, which you can submit either to the [main repository](https://git.aidenisik.scot/FreeChainXenon/SynthXEX/pulls), or the [GitHub mirror](https://github.com/FreeChainXenon/SynthXEX/pulls).
|
|
|
|
- Patch files, generated by Git, can be sent to \<aidenisik+git@member.fsf.org\>, which I will review and possibly merge.
|
|
|
|
## Code Style
|
|
|
|
If you are using [AStyle](https://astyle.sourceforge.net/), the following command will format the code correctly (run from the project root):
|
|
```
|
|
astyle --style=allman --add-braces --break-blocks --indent-labels --indent-switches --unpad-paren --align-pointer=name --pad-oper --indent-preproc-block --add-one-line-braces --squeeze-ws --squeeze-lines=1 --recursive "./src/*.c" "./src/*.h"
|
|
```
|
|
|
|
The code style used in SynthXEX is the [Allman/BSD style as specified by AStyle](https://astyle.sourceforge.net/astyle.html#_style=allman), with the following extra specifications:
|
|
|
|
- C++-style comments are used, rather than multiline/C89-style comments, e.g:
|
|
```
|
|
// This is a comment
|
|
// This is another comment
|
|
// This is yet another comment
|
|
```
|
|
|
|
- All conditional statements utilise curly brackets, even when there is only one line within them, e.g:
|
|
```
|
|
if(condition)
|
|
{
|
|
printf("Hello!\n");
|
|
}
|
|
```
|
|
|
|
- It is acceptable to have the curly brackets on the same line as the code if it is short, e.g:
|
|
```
|
|
if(condition) { printf("Hello!\n"); }
|
|
|
|
if(condition)
|
|
{ printf("Hello!\n"); }
|
|
```
|
|
|
|
- All brackets immediately succeed/precede the name/keyword they correspond to with no spaces, e.g:
|
|
```
|
|
foo(bar);
|
|
(float)(a + b);
|
|
```
|
|
|
|
- All code blocks have one empty line between the start/end and any other code, e.g.:
|
|
```
|
|
int a = 1;
|
|
|
|
if(a == 2)
|
|
{
|
|
printf("Hi!\n");
|
|
}
|
|
|
|
int b = 2;
|
|
```
|
|
|
|
- Labels are always 1 indentation level below the current level, e.g:
|
|
```
|
|
if(1)
|
|
{
|
|
if(2)
|
|
{
|
|
int a = 1;
|
|
label1:
|
|
int b = 2;
|
|
}
|
|
}
|
|
```
|
|
|
|
- Case statements are always 1 indentation level above their corresponding switch, e.g.:
|
|
```
|
|
switch(val)
|
|
{
|
|
case 1:
|
|
printf("1\n");
|
|
break;
|
|
|
|
default:
|
|
printf("0\n");
|
|
break;
|
|
}
|
|
```
|
|
|
|
- Pointer operators are always attached to variables, e.g:
|
|
```
|
|
char *string = NULL;
|
|
int a = 0;
|
|
setA(&a);
|
|
```
|
|
|
|
- Operators are always padded to be one space away from their operands, e.g:
|
|
```
|
|
int a = 1 + 2;
|
|
```
|
|
|
|
- Commas in function calls, etc, always have one space after them, e.g:
|
|
```
|
|
myFunc(1, 2);
|
|
```
|
|
|
|
- Preprocessor macros outside functions are indented, just like regular code, e.g:
|
|
```
|
|
#ifdef MACRO_ONE
|
|
#define MACRO 1
|
|
#else
|
|
#define MACRO 0
|
|
#endif
|
|
```
|
|
|
|
- There should never be more than one blank line between code, e.g:
|
|
```
|
|
int a;
|
|
int b;
|
|
|
|
int c;
|
|
```
|