Re: #include sorting: case-sensitive or -insensitive?
Any reason not to adopt SpiderMonkey's check_spidermonkey_style.py? It deals almost exclusively with header and include related things, and not indent levels, line lengths, or other things that gecko style disagrees with. https://dxr.mozilla.org/mozilla-central/source/config/check_spidermonkey_style.py """ ## This script checks various aspects of SpiderMonkey code style. The current checks are as# follows.## We check the following things in headers.## - No cyclic dependencies.## - No normal header should #include a inlines.h/-inl.h file.## - #ifndef wrappers should have the right form. (XXX: not yet implemented)# - Every header file should have one.# - The guard name used should be appropriate for the filename.## We check the following things in all files.## - #includes should have full paths, e.g. "jit/Ion.h", not "Ion.h".## - #includes should use the appropriate form for system headers (<...>) and# local headers ("...").## - #includes should be ordered correctly.# - Each one should be in the correct section.# - Alphabetical order should be used within sections.# - Sections should be in the right order.# Note that the presence of #if/#endif blocks complicates things, to the# point that it's not always clear where a conditionally-compiled #include# statement should go, even to a human. Therefore, we check the #include# statements within each #if/#endif block (including nested ones) in# isolation, but don't try to do any order checking between such blocks.# """ On Mon, Mar 28, 2016 at 3:54 PM, Cameron McCormackwrote: > David Keeler: > > The style guidelines at > > > https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style > > indicate that #includes are to be sorted. It does not say whether or not > > to consider case when doing so (and if so, which case goes first?). That > > is, should it be: > > > > #include "Foo.h" > > #include "bar.h" > > > > or > > > > #include "bar.h" > > #include "Foo.h" > > If you are preparing to make some changes to the Coding style document > around #include order, can you also please prescribe (a) where system- > includes get placed, e.g. > > #include "aaa.h" > #include > #include "ccc.h" > #include > > or > > #include > #include > #include "aaa.h" > #include "ccc.h" > > and (b) how includes with paths are sorted, e.g. > > #include "aaa.h" > #include "bbb/bbb.h" > #include "bbb/ccc/ddd.h" > #include "bbb/eee/fff.h" > #include "bbb/ggg.h" > #include "ccc.h" > > or > > #include "bbb/ccc/ddd.h" > #include "bbb/eee/fff.h" > #include "bbb/bbb.h" > #include "bbb/ggg.h" > #include "aaa.h" > #include "ccc.h" > > or some other order that makes sense. > > -- > Cameron McCormack ≝ http://mcc.id.au/ > ___ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform > ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: #include sorting: case-sensitive or -insensitive?
a) It's explained in the style docs: 1. The main header: Foo.h in Foo.cpp 2. Standard library includes: #include 3. Mozilla includes: #include "mozilla/dom/Element.h" Thus you'd want the second b) I'm assuming it includes the path. That's what I've seen most of the code do too and it means that once you've split it out in the 3 section you can use ':sort -i' or similar on each section. On Mon, Mar 28, 2016 at 6:54 PM, Cameron McCormackwrote: > David Keeler: > > The style guidelines at > > > https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style > > indicate that #includes are to be sorted. It does not say whether or not > > to consider case when doing so (and if so, which case goes first?). That > > is, should it be: > > > > #include "Foo.h" > > #include "bar.h" > > > > or > > > > #include "bar.h" > > #include "Foo.h" > > If you are preparing to make some changes to the Coding style document > around #include order, can you also please prescribe (a) where system- > includes get placed, e.g. > > #include "aaa.h" > #include > #include "ccc.h" > #include > > or > > #include > #include > #include "aaa.h" > #include "ccc.h" > > and (b) how includes with paths are sorted, e.g. > > #include "aaa.h" > #include "bbb/bbb.h" > #include "bbb/ccc/ddd.h" > #include "bbb/eee/fff.h" > #include "bbb/ggg.h" > #include "ccc.h" > > or > > #include "bbb/ccc/ddd.h" > #include "bbb/eee/fff.h" > #include "bbb/bbb.h" > #include "bbb/ggg.h" > #include "aaa.h" > #include "ccc.h" > > or some other order that makes sense. > > -- > Cameron McCormack ≝ http://mcc.id.au/ > ___ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform > ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: #include sorting: case-sensitive or -insensitive?
David Keeler: > The style guidelines at > https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style > indicate that #includes are to be sorted. It does not say whether or not > to consider case when doing so (and if so, which case goes first?). That > is, should it be: > > #include "Foo.h" > #include "bar.h" > > or > > #include "bar.h" > #include "Foo.h" If you are preparing to make some changes to the Coding style document around #include order, can you also please prescribe (a) where system- includes get placed, e.g. #include "aaa.h" #include #include "ccc.h" #include or #include #include #include "aaa.h" #include "ccc.h" and (b) how includes with paths are sorted, e.g. #include "aaa.h" #include "bbb/bbb.h" #include "bbb/ccc/ddd.h" #include "bbb/eee/fff.h" #include "bbb/ggg.h" #include "ccc.h" or #include "bbb/ccc/ddd.h" #include "bbb/eee/fff.h" #include "bbb/bbb.h" #include "bbb/ggg.h" #include "aaa.h" #include "ccc.h" or some other order that makes sense. -- Cameron McCormack ≝ http://mcc.id.au/ ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: #include sorting: case-sensitive or -insensitive?
On Mon, Mar 28, 2016 at 3:31 PM, Masatoshi Kimurawrote: > On 2016/03/29 7:18, Jared Wein wrote: > > We need to be careful with shuffling around #includes as there can be > > ordering dependencies that are not obvious at a glance. > > Especially, #include "Foo.h" should be put first in Foo.cpp regardless > of the alphabetical order to avoid introducing such dependencies. > (If Foo.h requires other headers, Foo.h should include them.) > The guideline should say about that. It already does: 1. The main header: Foo.h in Foo.cpp 2. Standard library includes: #include 3. Mozilla includes: #include "mozilla/dom/Element.h -Ekr > ___ dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform > ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: #include sorting: case-sensitive or -insensitive?
On 2016/03/29 7:18, Jared Wein wrote: > We need to be careful with shuffling around #includes as there can be > ordering dependencies that are not obvious at a glance. Especially, #include "Foo.h" should be put first in Foo.cpp regardless of the alphabetical order to avoid introducing such dependencies. (If Foo.h requires other headers, Foo.h should include them.) The guideline should say about that. ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: #include sorting: case-sensitive or -insensitive?
We need to be careful with shuffling around #includes as there can be ordering dependencies that are not obvious at a glance. Further, I don't think this is something worthwhile until we have a script that enforces said ordering. Thanks, Jared On Mon, Mar 28, 2016 at 5:20 PM, Nicholas Alexanderwrote: > On Mon, Mar 28, 2016 at 1:28 PM, David Keeler wrote: > > > (Everyone, start your bikesheds.) > > > > The style guidelines at > > > > > https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style > > indicate that #includes are to be sorted. It does not say whether or not > > to consider case when doing so (and if so, which case goes first?). That > > is, should it be: > > > > #include "Foo.h" > > #include "bar.h" > > > > or > > > > #include "bar.h" > > #include "Foo.h" > > > > Based on the "Java practices" section of that document, I'm assuming > > it's the former, but that's just an assumption and in either case it > > would be nice to document the accepted style for C/C++. > > > > Not a comprehensive argument, but could we do what moz.build does for file > names? I believe that is case insensitive, and foo.h sorts before foox.h. > > Nick > ___ > dev-platform mailing list > dev-platform@lists.mozilla.org > https://lists.mozilla.org/listinfo/dev-platform > ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
Re: #include sorting: case-sensitive or -insensitive?
On Mon, Mar 28, 2016 at 1:28 PM, David Keelerwrote: > (Everyone, start your bikesheds.) > > The style guidelines at > > https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style > indicate that #includes are to be sorted. It does not say whether or not > to consider case when doing so (and if so, which case goes first?). That > is, should it be: > > #include "Foo.h" > #include "bar.h" > > or > > #include "bar.h" > #include "Foo.h" > > Based on the "Java practices" section of that document, I'm assuming > it's the former, but that's just an assumption and in either case it > would be nice to document the accepted style for C/C++. > Not a comprehensive argument, but could we do what moz.build does for file names? I believe that is case insensitive, and foo.h sorts before foox.h. Nick ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform
#include sorting: case-sensitive or -insensitive?
(Everyone, start your bikesheds.) The style guidelines at https://developer.mozilla.org/en-US/docs/Mozilla/Developer_guide/Coding_Style indicate that #includes are to be sorted. It does not say whether or not to consider case when doing so (and if so, which case goes first?). That is, should it be: #include "Foo.h" #include "bar.h" or #include "bar.h" #include "Foo.h" Based on the "Java practices" section of that document, I'm assuming it's the former, but that's just an assumption and in either case it would be nice to document the accepted style for C/C++. Cheers, David signature.asc Description: OpenPGP digital signature ___ dev-platform mailing list dev-platform@lists.mozilla.org https://lists.mozilla.org/listinfo/dev-platform