proposed update to style guide

Steven R. Loomis 2022-03-02 14:52:14 -06:00
parent 3214032d34
commit 3feae99e76

@ -285,19 +285,27 @@ The "rules" in this section may not apply to other programming languages used in
### Platform Code
Windows™ is the original platform on which Keyman was written. Therefore there is legacy code style, conventions, and language extensions that are not consistent with common coding style as we move towards integrating common code across multiple platforms. Windows, Linux, MacOS platform code will inevitably have code that uses extensions etc needed to integrate with native platforms, breaking the guidelines for the common C++ code.
### C++ Level
As of 25-Feb-2022 the toolchain supports C11 and C14++.
### Datatypes
Use C or C99 types and calling convention for any API boundary, it has the broadest language FFI support. Within module implementation more complex data types are permitted.
#### Standard Library
Use of the C++ Standard Template Library, where possible, is preferred over home-grown or additional
library data types.
### Exceptions:
Dont use exceptions.
### Preprocessor Macros
It is not a hard no, but prefer inline functions, enums, and const variables.
It is not a hard no, but prefer inline functions, enums, and const variables to macros.
Macros are used for including libraries for example KMN_API in keyboardprocessor_bits.h
### Template Metaprograming
@ -306,13 +314,14 @@ Templates are permitted but should be used in private implementation detail and
### Namespace
The Keyman Common Core uses the namespace `km_kbp`
The Keyman Common Core uses the namespace `km::kbp`
The KMX keyboard processor is nested with in that name space using `kmx` that is `km::kbp::kmx`
Other keyboard processor implementatoins can follow the same pattern for examlple LDML can use `km::kbp::ldml`
### Proprietary Language Extentions
Proprietary Language Extensions are not permited in the core cross-platform code. For platform integration componets of Keyman it maybe required to use extensions it which case that is acceptable
[Proprietary Language Extensions](https://docs.microsoft.com/en-us/cpp/build/reference/microsoft-extensions-to-c-and-cpp?view=msvc-170) are not permited in the core cross-platform code. For platform integration components of Keyman it maybe required to use extensions, in which case that is acceptable
### Naming
@ -324,9 +333,10 @@ Follow the convention of the project you are adding a file to. Otherwise, filena
#### Type Names
Use snake case.
```
```c
std::string my_string;
````
```
#### Constants
All upper case.
@ -352,7 +362,8 @@ Use snake_case??
Header files shall contain include guards to avoid including the same header multiple times.
For example
```
```c
#ifndef CLASSNAME_H
#define CLASSNAME_H