Re: [webkit-dev] using namespace style guideline

2009-11-16 Thread Darin Adler
On Nov 15, 2009, at 9:57 PM, Chris Jerdonek wrote:

 In particular, the following file uses using namespace WTF::Unicode five 
 times, but within the bodies of various template definitions:
 
 http://trac.webkit.org/browser/trunk/WebCore/platform/text/BidiResolver.h
 
 (see line 304, for example)
 
 Is this also not okay?

This is fine.

If the using namespace is scoped to a particular function, then it’s not the 
same thing we’re talking about.

 The following is another example.  The using statement for this one appears 
 at the beginning, outside of any definitions, but the file seems to be 
 central:
 
 http://trac.webkit.org/browser/trunk/JavaScriptGlue/JSUtils.h
 
 It uses using namespace JSC.

JavaScriptGlue does not follow the WebKit coding style — there’s no need to 
look at files inside the JavaScriptGlue directory when considering matters of 
style.

 My second question is whether the guideline above should apply, for the same 
 reason, to all using statements within header files -- and not just to 
 using namespace statements.  Statements of the form using WTF::... would 
 be exceptions.  You've already discussed those here:
 
 https://lists.webkit.org/pipermail/webkit-dev/2009-November/010453.html
 
 I checked, and there are only about 40 files in all of WebKit that wouldn't 
 currently be following this -- slightly less than half of which are in JSC.

Probably. We’d have to discuss specific examples to be sure.

-- Darin

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] using namespace style guideline

2009-11-15 Thread Chris Jerdonek
On Tue, Nov 10, 2009 at 8:30 PM, Darin Adler da...@apple.com wrote:

 No using namespace statements are permitted in header files. The guidelines 
 are talking about non-header files. We should clarify that.

Thanks for your later reply explaining the history behind the using
WTF::... statements.  It sounds reasonable.

I have a couple more questions related to the rule above though.  (For
everyone else's benefit, this rule now appears on the web site).

I found there to be seven files in WebKit that don't follow this rule,
and I wanted to double-check whether there should be any exceptions to
it.

In particular, the following file uses using namespace WTF::Unicode
five times, but within the bodies of various template definitions:

http://trac.webkit.org/browser/trunk/WebCore/platform/text/BidiResolver.h

(see line 304, for example)

Is this also not okay?

The following is another example.  The using statement for this one
appears at the beginning, outside of any definitions, but the file
seems to be central:

http://trac.webkit.org/browser/trunk/JavaScriptGlue/JSUtils.h

It uses using namespace JSC.

My second question is whether the guideline above should apply, for
the same reason, to all using statements within header files -- and
not just to using namespace statements.  Statements of the form
using WTF::... would be exceptions.  You've already discussed those
here:

https://lists.webkit.org/pipermail/webkit-dev/2009-November/010453.html

I checked, and there are only about 40 files in all of WebKit that
wouldn't currently be following this -- slightly less than half of
which are in JSC.

--Chris
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] using namespace style guideline

2009-11-12 Thread Darin Adler
On Nov 11, 2009, at 6:56 PM, Chris Jerdonek wrote:

 What is the current thinking on all of the using WTF::... statements at the 
 end of many header files in JSC?  For example, what was the original reason 
 behind including those, and is there any chance that they will be taken out 
 at a later date (or has that already been ruled out)? I searched a bit and 
 didn't come across any discussion of this.

WTF uses namespacing differently than most libraries. We’re using it to 
disambiguate at link time, but not compile  time.Having the symbols in a 
namespace at link time still has a substantial benefit, so it’s good to put 
things in a WTF namespace instead of just putting them outside any namespace.

Maciej Stachowiak devised this scheme for WTF, and I think on balance it’s 
probably a good way to do things although I would probably not have chosen it 
myself, and would have used the more conventional scheme. Maciej and I and a 
few others at Apple discussed this a bit a few years back, but nobody on any 
WebKit mailing list ever raised the issue before.

Since WTF is for use inside WebKit itself, I think we can stick with this 
approach unless we run into a substantial, concrete problem with it.

I don’t think things would be better if we did this in the conventional way and 
either had to utter WTF::RefPtr and WTF::Vector in WebCore and JavaScriptCore 
header files, or every client of RefPtr had to include a certain header file 
with a using WTF::RefPtr in the WebCore or JavaScriptCore namespace. 
Similarly if many .cpp files had to have using namespace WTF.

For a while I was adding using namespace WTF to .cpp files because I did not 
understand our WTF namespacing approach.

-- Darin

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] using namespace style guideline

2009-11-11 Thread Chris Jerdonek
On Tue, Nov 10, 2009 at 8:30 PM, Darin Adler da...@apple.com wrote:

 No using namespace statements are permitted in header files. The guidelines 
 are talking about non-header files. We should clarify that.

Thanks for the clarification.  I will go ahead and try adding that.

This is a good segue into another question I have.

What is the current thinking on all of the using WTF::... statements
at the end of many header files in JSC?  For example, what was the
original reason behind including those, and is there any chance that
they will be taken out at a later date (or has that already been ruled
out)?  I searched a bit and didn't come across any discussion of this.

--Chris
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] using namespace style guideline

2009-11-10 Thread Chris Jerdonek
Hi, I have a question about the last of the WebKit Coding Style Guidelines:

http://webkit.org/coding/coding-style.html

It's the second of these two:

1. Any using namespace statements for a nested namespace whose
parent namespace is also defined in a file must be declared within
that namespace definition.

2. Any other using namespace statements must be declared before the
first namespace definition in the file.

Unlike most or all of the other rules, this one can affect
compilation.  So I was wondering what the rule is for.

For example, say I want to write the following in an existing header
file to avoid having to fully qualify several identifiers in the WTF
namespace:

namespace MyNewNameSpace {

using namespace WTF;

// code

}

Following rule 2 and putting the using statement outside the namespace
can cause compilation errors elsewhere in the project (due to
ambiguous overloads for bringing the WTF namespace into files already
including the above).  This actually happened to me while doing some
minor refactoring.

If I want to keep the using namespace statement, it seems like the
style guideline would require me to do an unknown amount of
refactoring outside the file.

Let me know your thoughts.

Thanks,
--Chris
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] using namespace style guideline

2009-11-10 Thread Darin Adler
On Nov 10, 2009, at 7:41 PM, Chris Jerdonek wrote:

 Hi, I have a question about the last of the WebKit Coding Style Guidelines:
 
 http://webkit.org/coding/coding-style.html
 
 It's the second of these two:
 
 1. Any using namespace statements for a nested namespace whose parent 
 namespace is also defined in a file must be declared within that namespace 
 definition.
 
 2. Any other using namespace statements must be declared before the first 
 namespace definition in the file.

No using namespace statements are permitted in header files. The guidelines 
are talking about non-header files. We should clarify that.

-- Darin

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev