Page MenuHome

BGE: Cleanup: Code style BL_Shader
ClosedPublic

Authored by Thomas Szepe (hg1) on Jul 8 2015, 9:30 PM.

Diff Detail

Repository
rB Blender

Event Timeline

Thomas Szepe (hg1) retitled this revision from to BGE: BL_Shader style cleanup.Jul 8 2015, 9:30 PM
Thomas Szepe (hg1) updated this object.
Thomas Szepe (hg1) updated this revision to Diff 4615.

This patch should show how to code style should be for the BGE in future.
Basically it follows the Blender code style Wiki. http://wiki.blender.org/index.php/Dev:Doc/Code_Style
But there some things that are not described in the Wiki. So I use this patch to show how I think it will be the best.

  1. Single line comment with // in C++ files [1294].
  2. No curly brackets in on single line if statements [1328].
  3. One line space after an if statement with return or return macro (Py_RETURN_NONE) [1286-1288].
  4. Only one line space between methods [1383 left original].
  5. No one line space after #ifdef, #else, #endif [772 left original].
  6. Colon for constructor in new line [26].
  7. Using Null instead of 0 for pointers [1254].
  8. Don't align variables, method prototype and comments [45].
  9. Variable comments on the right [45].
  10. Comment above method prototypes. Not right or below [no example].
  11. One line space above a line comment [135-136].
  12. Using Blender Doxygen style comment (/** * */) also for a single line, not /// [no example].
  13. Comment out code with // [446-452].
  14. Every code should have his own line [658-666].
  15. Remove spaces for array initialisation [1173].
  16. Don't move method argument in a new line if there is pace to put every in one line [574].
  17. No strict 120 character line break if it is only one to two letters to long [1226].
source/gameengine/Ketsji/BL_Shader.cpp
203

you can write

delete *it;
1114

listPtr = NULL

One comment, I would prefer that branches always use an explicit block. What I mean by this is I prefer

if (var) {
    do_something;
}

to

if (var)
    do_something;

It's a couple of extra characters, and it helps protect against silly errors in the future.

Thomas Szepe (hg1) marked 2 inline comments as done.Oct 19 2015, 4:42 PM

There is on open question. Should we use use curly braces for cases or should we mix it?
Because some cases are need curly braces.

case UNI_FLOAT:

or

case UNI_FLOAT:
{

}
Thomas Szepe (hg1) retitled this revision from BGE: BL_Shader style cleanup to BGE: Cleanup: style BL_Shader.Oct 21 2015, 7:13 PM
Thomas Szepe (hg1) edited edge metadata.
Thomas Szepe (hg1) updated this revision to Diff 5261.

Change my mind on point 2. Now using curly brackets also for single line if statements.
Done requested changes.

Porteries Tristan (panzergame) accepted this revision.

Nice work.

source/gameengine/Ketsji/BL_Shader.h
206

We should keep (void) ?

This revision is now accepted and ready to land.Oct 21 2015, 9:46 PM
Thomas Szepe (hg1) retitled this revision from BGE: Cleanup: style BL_Shader to BGE: Cleanup: Code style BL_Shader.Oct 25 2015, 7:39 PM
Thomas Szepe (hg1) edited edge metadata.
Thomas Szepe (hg1) updated this revision to Diff 5285.
This revision was automatically updated to reflect the committed changes.