Update 'Coding Style'

Patrick Vogler 2023-06-22 13:50:24 +00:00
parent 476b54c903
commit d0ed94577c

@ -18,6 +18,7 @@ This document discusses practices and style for programmers working on the BigWh
- [The Single Most Important Rule](#the-single-most-important-rule)
- [Formatting](#formatting)
- [Indentation](#indentation)
- [Line Continuation](#line-continuation)
- [Braces](#braces)
- [Whitespace](#whitespace)
- [Functions](#functions)
@ -259,11 +260,8 @@ Do eliminate trailing whitespace on any line, preferably as a separate patch or
The following general rules should be followed when defining a function in BigWhoop:
* Function name must be lowercase, optionally separated with underscore _ character
* Functions private to a translation unit need to be declared before they are called
* All private functions of a translation unit must appear before the public functions in their respective block, which is identified by the block header 'private functions':
* All public functions must appear in their respective block, identified by the `public functions` block header, following the `private functions` block:
* All private functions of a translation unit must appear before the public functions in their respective block, which is identified by the block header `private functions`:
* All public functions of a translation unit must appear in their respective block, identified by the `public functions` block header:
Functions should be declared by placing the returned value on a separate line from the function name:
```c
@ -297,6 +295,23 @@ initialize_subband (field,
l);
```
For header files, the function prototypes must be vertically aligned in six columns and separated by the function delimiter:
```c
uchar bwc_open_file (bwc_field *const field,
char const *const filename,
char const *const mode);
//==========|==========================|======================|======|=======|====================
uchar bwc_load_file (bwc_field *const field,
char const *const filename);
//==========|==========================|======================|======|=======|====================
uchar bwc_compress (bwc_field *const field,
char *const rate_control);
//==========|==========================|======================|======|=======|====================
uchar bwc_decompress (bwc_field *const field,
uint8 const layer);
```
Each column is marked by the function delimiter with a `|` with each element in the column right aligned to the column seperator. The delimiter must precede every function prototype except the first.
```c
prec_control->numCodeblocks_a = (uint64) (prec_control->numCbX