Changes between Version 41 and Version 42 of Coding_Conventions


Ignore:
Timestamp:
Jun 19, 2019, 12:29:19 AM (5 years ago)
Author:
Nescio
Comment:

JSON

Legend:

Unmodified
Added
Removed
Modified
  • Coding_Conventions

    v41 v42  
    1212Our code is currently not entirely consistent in places, but the following guidelines attempt to describe the most common style and are what we should converge towards. (Obviously we always want clean, readable, adequately-documented code - lots of articles and books already talk about how to do that - so here we're mostly describing minor details.)
    1313
     14
    1415== Common ==
    1516
    1617- Use the US variant of English when choosing variable names. For example, use 'color' instead of 'colour'.
    1718
     19
    1820== C++ ==
     21
    1922=== Creating new files ===
    2023 * All source files (.cpp, .h) must start with the following GPL license header, before any other content:
     
    7780 * All source files must have the `svn:eol-style` property set to `native`
    7881
     82
    7983=== Formatting ===
    8084 * Use tabs for indentation, not spaces.
     
    138142}}}
    139143
     144
    140145=== Error reporting ===
    141146See [wiki:Logging] for more info.
     
    150155
    151156 * The engine should try to cope gracefully with `LOGERROR` cases, e.g. abort loading the current file; it should never crash in those cases.
     157
    152158
    153159=== Documentation ===
     
    180186 * Don't need to bother documenting every line of code or every member function or every member variable; only when it'll add to a competent reader's understanding of the program.
    181187
     188
    182189=== Strings ===
    183190 * Use `CStr` instead of `std::string`. Use `CStrW` instead of `std::wstring`. (These are subclasses of `std::[w]string` with various extra methods added for convenience.)
     
    205212std::wstring cppWStr = str.wc_str(); // Don't use c_str() because it breaks OS X build
    206213}}}
     214
    207215
    208216=== Preprocessor instructions ===
     
    243251}}}
    244252
     253
    245254=== Misc ===
    246255 * In header files, avoid `#include` and use forward declarations wherever possible.
     
    333342}}}
    334343
     344
    335345== !JavaScript ==
    336346 * Use the same basic formatting as described above for C++.
     
    396406}}}
    397407
     408
     409== JSON==
     410* basically follow the JS formatting conventions
     411* when on the same line, insert spaces after {, [, and : and before ] and }; e.g. `{ "foo": "bar" }` and `[ "baz" ]`
     412* use tabs for indentation, not spaces
     413
     414
    398415== XML ==
    399416 * All XML files should start with
     
    406423
    407424 * Indent using whatever the similar existing XML files use. (Usually two spaces; sometimes four spaces, or tabs, etc.)
     425
    408426
    409427== GLSL ==