-- Ehsan <http://ehsanakhgari.org/>
On Thu, Dec 19, 2013 at 4:32 AM, Mike Hommey <m...@glandium.org> wrote: > On Thu, Dec 19, 2013 at 01:20:41AM -0800, Andrea Marchesini wrote: > > Hi, > > > > Writing a patch for bug 949488 I had to indent this piece of code: > > > > nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); > > if (NS_WARN_IF(NS_FAILED(ssm->GetSimpleCodebasePrincipal( > > originURI, > > > getter_AddRefs(providedPrincipal))))) { > > > > It seems that our style guide does not say anything about how indent > this tricky case. > > So, talking with bholley we decided to write an email proposing > something like this: > > > > 1. if they can, all the params on the same line. max 80 chars. > > > > 2. otherwise multiple lines, aligned with the beginning of the params > list. > > > > es: obj->ThisIsALooooooooooongNameMethod(looooooooongParam1, > > loooooooooogParam2); > > > > 3. if 1 param alone goes over 80chars, it must be aligned in order to > stay in the 80chars and the rest of the params must be aligned with it. > > > > nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager(); > > if (NS_WARN_IF(NS_FAILED(ssm->GetSimpleCodebasePrincipal( > > originURI, > > > getter_AddRefs(providedPrincipal))))) { > > // 80chars > here ^ > > > > This approach is already used in dom/workers and IndexedDB. > > > https://mxr.mozilla.org/mozilla-central/source/dom/workers/RuntimeService.cpp#1647 > > > > How does it sound? > Sounds good to me! (But note that we have a terrible history of following our own style guidelines, in practice, different modules pretty much do whatever they want! ;-) > How about we just use clang-format? > http://www.irill.org/videos/euro-llvm-2013/jasper-hires.webm clang-format has a basic support for the Mozilla coding style, and we can definitely extend it to add support for this heuristic. Cheers, Ehsan _______________________________________________ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform