2014-09-17 09:37:11 +03:00
|
|
|
Buildat conventions
|
|
|
|
===================
|
2014-09-20 19:05:30 +03:00
|
|
|
C++ Coding style
|
|
|
|
----------------
|
2014-09-30 00:02:24 +03:00
|
|
|
Using the correct coding style is important. If you are asked to fix your style
|
2014-09-30 12:34:25 +03:00
|
|
|
to follow the one defined here in every detail, do it carefully.
|
2014-09-30 00:02:24 +03:00
|
|
|
|
|
|
|
If something is found to be missing from this document, such additions shall be
|
|
|
|
made.
|
2014-09-17 09:37:11 +03:00
|
|
|
|
2014-09-20 19:05:30 +03:00
|
|
|
util/codestyle.sh:
|
2014-10-06 13:36:28 +03:00
|
|
|
A code formatting script based on Uncrustify. (http://uncrustify.sourceforge.net/)
|
|
|
|
Always run before committing. It handles most whitespace issues.
|
2014-09-17 11:20:36 +03:00
|
|
|
|
|
|
|
Identifiers:
|
|
|
|
- Class and struct names are CamelCase,
|
|
|
|
- All function names are lowercase_with_underscores,
|
|
|
|
- All variable names are lowercase_with_underscores,
|
2014-09-17 13:37:34 +03:00
|
|
|
- All member variables start with m_. If the struct in question is a stupid data
|
|
|
|
container, this does not need to be followed.
|
2014-09-17 11:20:36 +03:00
|
|
|
|
|
|
|
Never use "class", always use "struct".
|
|
|
|
|
2014-09-17 11:28:15 +03:00
|
|
|
Prefer lightweight interfaces with a creation function for the default
|
|
|
|
implementation, like "struct State" and "State* createState()". The default
|
|
|
|
implementation can be called "CState" in this case, if an obviously better name
|
|
|
|
does not exist.
|
|
|
|
|
|
|
|
Use std::unique_ptr and std::shared_ptr. (core/types.h: up_<> and sp_<>)
|
|
|
|
|
2014-10-03 15:51:34 +03:00
|
|
|
Header files must have zero preprocessor conditionals, with the exception of
|
|
|
|
headers in src/ports/.
|
2014-09-20 10:04:28 +03:00
|
|
|
|
2014-09-17 13:37:34 +03:00
|
|
|
Function naming:
|
|
|
|
- Suffix _u: Unsafe, not included in public interface
|
|
|
|
|
2014-09-17 16:55:56 +03:00
|
|
|
Do not use assert(); throw anonymous exceptions instead:
|
|
|
|
- if(fail) throw Exception("Thing failed");
|
|
|
|
|
2014-09-17 20:49:30 +03:00
|
|
|
Naming:
|
|
|
|
- "type": Numeric id representing a type
|
|
|
|
- "name": A string; generally works as an identifier but not necessarily
|
|
|
|
- "id": Numeric id of an instance of something that is not a type
|
2014-10-20 09:54:08 +03:00
|
|
|
- "sub": Subscription; a means to trigger something based on something else
|
|
|
|
happening; data goes from the emitter to the subscriber
|
|
|
|
- "hook": A callback that can modify some of the source's data or behavior
|
|
|
|
before the source goes on with it
|
2014-09-17 20:49:30 +03:00
|
|
|
|
2014-09-17 23:44:42 +03:00
|
|
|
Logging:
|
|
|
|
- Use core/log.h. Only use stdout directly in case of an interactive command
|
2014-09-19 19:51:14 +03:00
|
|
|
line interface (like printing errors for command line arguments).
|
2014-09-17 23:44:42 +03:00
|
|
|
|
2014-09-20 10:42:41 +03:00
|
|
|
Ordering of #include directives:
|
|
|
|
1) The interface that the current file implements, ""
|
|
|
|
2) Internal interfaces, from core-ish to utility-ish, ""
|
|
|
|
3) Bundled libraries, <>
|
|
|
|
4) Installed libraries, <>
|
|
|
|
5) STL headers, <>
|
|
|
|
6) System headers, <>
|
|
|
|
|
2014-09-17 09:37:11 +03:00
|
|
|
Non-exception throwing and exception-throwing methods
|
|
|
|
-----------------------------------------------------
|
|
|
|
- get_x: Returns NULL or equivalent if not found
|
|
|
|
- check_x: Throws exception if not found
|
|
|
|
|
2014-09-17 11:24:54 +03:00
|
|
|
Directory structure
|
|
|
|
-------------------
|
|
|
|
├── 3rdparty << Bundled 3rd-party libraries
|
2014-09-19 19:51:14 +03:00
|
|
|
├── Build << Build files; "mkdir Build; cmake ..; make"
|
2014-09-17 11:24:54 +03:00
|
|
|
├── cache << Runtime directory used by Buildat
|
2014-09-19 10:40:10 +03:00
|
|
|
├── builtin << Built-in modules
|
|
|
|
├── client << Built-in client files
|
|
|
|
├── extensions << Built-in client extensions
|
2014-09-17 11:24:54 +03:00
|
|
|
├── src
|
|
|
|
│ ├── client << Client-specific code
|
|
|
|
│ ├── core << Core code (must be kept minimal but sufficient)
|
|
|
|
│ ├── impl << Interface implementations
|
|
|
|
│ ├── interface << Interface available to modules
|
|
|
|
│ └── server << Server-specific code
|
2014-09-30 00:02:24 +03:00
|
|
|
├── games << Games that can be run using buildat_server -m <path>
|
2014-09-17 11:24:54 +03:00
|
|
|
└── util << Miscellaneous development utilities
|
|
|
|
|
2014-09-17 09:44:09 +03:00
|
|
|
Commit messages
|
|
|
|
---------------
|
2014-09-30 00:02:24 +03:00
|
|
|
Commit messages must be formatted in the following way:
|
|
|
|
|
2014-09-17 09:44:09 +03:00
|
|
|
In present tense. Prepend a location to the message where possible. When adding
|
2014-09-17 11:20:36 +03:00
|
|
|
something, the "add" verb should be left out. Fine enough examples:
|
2014-09-30 00:02:24 +03:00
|
|
|
- client/sandbox.lua: Fix string concatenation when creating an error message
|
2014-09-17 09:44:09 +03:00
|
|
|
- interface::Server::check_module
|
|
|
|
- doc: conventions.txt, todo.txt
|
|
|
|
- Remove Module::test_add
|
|
|
|
- client, 3rdparty/c55lib: Command-line parameters
|
|
|
|
- 3rdparty/cereal
|
2014-09-30 00:02:24 +03:00
|
|
|
- client: Disable Urho3D log file
|
|
|
|
- extensions/__menu: Fix UI warnings
|
2014-09-17 09:44:09 +03:00
|
|
|
|
2014-09-24 16:42:16 +03:00
|
|
|
Urho3D
|
|
|
|
------
|
|
|
|
Urho3D's namespace should generally be aliased to be "magic".
|
|
|
|
|