Commit dea6afc6 authored by Mael Cravero's avatar Mael Cravero Committed by Pierre Brandone
Browse files

instructions: file_conventions: update section

* source/instructions/coding_style/file_conventions.rst: Here.
parent 8df12188
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
File Conventions File Conventions
---------------- ----------------
There are some strict conventions to obey wrt the files and their There are some strict conventions to obey regarding the files and their
contents. contents.
Rule: One class :code:`LikeThis` per files :code:`like-this.*` Rule: One class :code:`LikeThis` per files :code:`like-this.*`
...@@ -18,7 +18,7 @@ Rule: :code:`*.hh`: Declarations ...@@ -18,7 +18,7 @@ Rule: :code:`*.hh`: Declarations
The :code:`*.hh` should contain only declarations, i.e., prototypes, The :code:`*.hh` should contain only declarations, i.e., prototypes,
:code:`extern` for variables etc. Inlined short methods are accepted :code:`extern` for variables etc. Inlined short methods are accepted
when there are few of them, otherwise, create an :code:`*.hxx` file. The when there are few of them, otherwise, create an :code:`*.hxx` file. The
documentation should be here too. documentation should be here in the :code:`*.hh` too.
There is no good reason for huge objects to be defined here. There is no good reason for huge objects to be defined here.
...@@ -45,6 +45,12 @@ Rule: :code:`*.hh`: Declarations ...@@ -45,6 +45,12 @@ Rule: :code:`*.hh`: Declarations
Actually, if you merely need to declare the existence Actually, if you merely need to declare the existence
of streams, you might want to include :code:`iosfwd`. of streams, you might want to include :code:`iosfwd`.
Relevant C++ Core Guidelines:
- :cppcgl:`sf2-a-h-file-may-not-contain-object-definitions-or-non-inline-function-definitions`
- :cppcgl:`sf4-include-h-files-before-other-declarations-in-a-file`
- :cppcgl:`sf10-avoid-dependencies-on-implicitly-included-names`
- :cppcgl:`sf11-header-files-should-be-self-contained`
Rule: :code:`*.hxx`: Inlined definitions Rule: :code:`*.hxx`: Inlined definitions
Some definitions should be loaded in different places: templates, inline Some definitions should be loaded in different places: templates, inline
functions etc. Declare and document them in the :code:`*.hh` file, and functions etc. Declare and document them in the :code:`*.hh` file, and
...@@ -52,6 +58,8 @@ Rule: :code:`*.hxx`: Inlined definitions ...@@ -52,6 +58,8 @@ Rule: :code:`*.hxx`: Inlined definitions
*last* includes the :code:`*.hxx` file, conversely :code:`*.hxx` *last* includes the :code:`*.hxx` file, conversely :code:`*.hxx`
*first* includes :code:`*.hh`. Read below. *first* includes :code:`*.hh`. Read below.
Relevant C++ Core Guidelines:
- :cppcgl:`f5-if-a-function-is-very-small-and-time-critical-declare-it-inline`
Rule: :code:`*.cc`: Definitions of functions and variables Rule: :code:`*.cc`: Definitions of functions and variables
Big objects should be defined in the :code:`*.cc` file corresponding to Big objects should be defined in the :code:`*.cc` file corresponding to
...@@ -68,8 +76,7 @@ Rule: :code:`*.cc`: Definitions of functions and variables ...@@ -68,8 +76,7 @@ Rule: :code:`*.cc`: Definitions of functions and variables
.. code-block:: c++ .. code-block:: c++
void void LetExp::accept(Visitor& v)
LetExp::accept(Visitor& v)
{ {
v(*this); v(*this);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment