Skip to content

Instantly share code, notes, and snippets.

@srl295
Created March 2, 2022 20:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save srl295/401f1eb9bac8fdf64b7825548ce37864 to your computer and use it in GitHub Desktop.
Save srl295/401f1eb9bac8fdf64b7825548ce37864 to your computer and use it in GitHub Desktop.
Diff to keyman style guide
diff --git a/Keyman-Code-Style-Guide.md b/Keyman-Code-Style-Guide.md
index e04cd78..e9978f3 100644
--- a/Keyman-Code-Style-Guide.md
+++ b/Keyman-Code-Style-Guide.md
@@ -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:
Don’t 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment