Re: [PATCH spice-server v3] style: Update style to include some C++ element

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> 
> > On 8 Feb 2018, at 15:16, Lukáš Hrázký <lhrazky@xxxxxxxxxx> wrote:
> > 
> > On Thu, 2018-02-08 at 14:03 +0000, Frediano Ziglio wrote:
> >> This style is used by other SPICE projects like spice-streaming-agent.
> >> See discussion "Coding style and naming conventions for C++" at
> >> https://lists.freedesktop.org/archives/spice-devel/2018-January/041562.html.
> >> 
> >> Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
> >> ---
> >> docs/spice_style.txt | 52
> >> ++++++++++++++++++++++++++++++++++++++++++++++++++++
> >> 1 file changed, 52 insertions(+)
> >> 
> >> Changes in v3:
> >> - fix commit message grammar.
> >> 
> >> Changes in v2:
> >> - more details for namespace usages;
> >> - specify C++ dialect;
> >> - fix class indentation.
> >> diff --git a/docs/spice_style.txt b/docs/spice_style.txt
> >> index f5d13642..29c1756f 100644
> >> --- a/docs/spice_style.txt
> >> +++ b/docs/spice_style.txt
> >> @@ -380,3 +380,55 @@ Also in source (no header) files you must include
> >> `config.h` at the beginning so
> >> 
> >> #include "spice_server.h"
> >> ----
> >> +
> >> +C++
> >> +---
> >> +C\++ follows C style if not specified otherwise.
> > 
> > Sorry, one more grammar improvement:
> > "C\++ style follows the C style"
> > 
> >> +The C+\+11 dialect is assumed by default. No attempts will be made to
> >> +restrict the code to older variants of C+\+.
> >> +For compatibility reasons don't use more recent C++ dialects.
> 
> I notice you have C++, C\++ and C+\+ within a few lines from one another. Not
> sure why. I thought you needed to escape + only if at the beginning of a
> line.
> 

I though too... but for some reasons code kept doing weird stuff, looks
like the ++ is also some kind of code block quotation so something like

test ++code whatever++ end

is formatting the "code whatever" using monospace fonts.

But if you quote any of the + in the single "C++" (header) for
some reasons the backslash is taken verbatim!

> 
> >> +
> >> +Method names
> >> +~~~~~~~~~~~~
> >> +
> >> +Method names should use lower case and separate words with
> >> +underscores.
> >> +
> >> +
> >> +Namespaces
> >> +~~~~~~~~~~
> >> +
> >> +Namespaces should use lower case and separate words with underscores.
> >> +Namespace blocks should not increase indentation.
> >> +Namespaces can be nested. Namespace closing brackets for nested
> >> +namespaces can be placed together on the same line, but for
> >> +readability reasons the closure should specify the namespace with a
> >> +comment.
> >> +
> >> +[source,cpp]
> >> +----
> >> +namespace spice {
> >> +namespace streaming_agent {
> >> +
> >> +class ClassInsideNamespace {
> >> +...
> >> +};
> >> +
> >> +}} // namespace spice::streaming_agent
> >> +----
> >> +
> >> +The `using namespace` construct should never be used in headers. It
> >> should
> >> +be used sparingly in source files, and only within the body of short
> >> +functions.
> >> +
> >> +Preferred alternatives to `using namespace` include:
> >> +
> >> +* using declarations
> >> ++
> >> +[source,cpp]
> >> +using spice::streaming_agent::some_class;
> >> ++
> >> +* namespace aliases
> >> ++
> >> +[source,cpp]
> >> +namespace ssa = spice::streaming_agent;
> > 
> > Let's get it in, further improvements welcome.
> > 
> > Acked-by: Lukáš Hrázký <lhrazky@xxxxxxxxxx>

Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]