Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 4 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,13 @@ Information and guidelines for people contributing code back to TCE.
TCE coding style
================

There used to be a huge coding style manual all TCE developers slavishly and humbly followed :P Nowadays, as there is plenty of code, the easiest way is to just match the style of the existing code.
The coding style is roughly defined by `openasip/.clang-format`. The all-important indentation style is 4 spaces, no tabs.

If in doubt, look around. Good references are the oldest pieces of code (from the times when we had stricter code review process) inside src/base. Take a look at some of the files there to get the feeling.

The basic guidelines:

* the indentations should be 4 spaces (no tabs)
* maximum of 78 characters per line

In case of emacs, you should use the stroustrup style.

Example .emacs:
Note that large parts of the codebase were written before semi-formal style checking, so you may want to run the formatter on only your changes and leave the rest of the file alone to minimize unnecessary noise in your commits. For example, you could run the below from within `openasip/` before committing:

```shell
git diff -U0 --no-color HEAD | clang-format-diff -p2 -i
Comment thread
gtkiku marked this conversation as resolved.
Outdated
```
(defun my-c-mode-common-hook ()
(c-set-style "stroustrup")
;; other customizations can go here
)
(add-hook 'c-mode-common-hook 'my-c-mode-common-hook)

(setq default-tab-width 4)
(setq-default indent-tabs-mode nil)

(add-to-list 'auto-mode-alist '("\\.icc$" . c++-mode))
```

This setups the "stroustrup" style for C/C++ code and makes emacs detect the .icc files (inline C++ definitions in TCE) as C++ files.

TCE Test Suite
Comment thread
gtkiku marked this conversation as resolved.
Outdated
==============
Expand Down
72 changes: 72 additions & 0 deletions openasip/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: false
AlignOperands: AlignAfterOperator
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowAllArgumentsOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: TopLevel
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: false
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
ColumnLimit: 78
CommentPragmas: '^ IWYU pragma:'
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IndentCaseLabels: false
IndentWidth: 4
IndentWrappedFunctionNames: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 0
PointerAlignment: Left
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
FixNamespaceComments: true
InsertNewlineAtEOF: true
KeepEmptyLines:
AtEndOfFile: false
AtStartOfBlock: true
AtStartOfFile: false
MacroBlockBegin: "^(INIT_STATE|OPERATION_WITH_STATE|OPERATION|TRIGGER)"
MacroBlockEnd: "(END_INIT_STATE|END_OPERATION_WITH_STATE|END_OPERATION|END_TRIGGER)"
AlignEscapedNewlines: Right
...

Loading