Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 namespace blink { | 5 namespace blink { |
| 6 | 6 |
| 7 class C { | 7 class C { |
| 8 public: | 8 public: |
| 9 // Make sure initializers are updated to use the new names. | 9 // Make sure initializers are updated to use the new names. |
| 10 C() : m_flagField(~0), m_fieldMentioningHTTPAndHTTPS(1) {} | 10 C() : m_flagField(~0), m_fieldMentioningHTTPAndHTTPS(1) {} |
| 11 | 11 |
| 12 int method() { | 12 int method() { |
| 13 // Test that references to fields are updated correctly. | 13 // Test that references to fields are updated correctly. |
| 14 return instanceCount + m_flagField + m_fieldMentioningHTTPAndHTTPS; | 14 return instanceCount + m_flagField + m_fieldMentioningHTTPAndHTTPS; |
| 15 } | 15 } |
| 16 | 16 |
| 17 private: | |
| 18 // The m_ prefix, if any, should be removed. | 17 // The m_ prefix, if any, should be removed. |
|
danakj
2016/01/06 22:09:40
The comment is weird now, it really applies to the
dcheng
2016/01/08 01:41:11
I've added a comment on each one to make this clea
| |
| 19 static int instanceCount; | 18 static int instanceCount; |
| 19 | |
| 20 private: | |
| 20 const int m_flagField; | 21 const int m_flagField; |
| 21 // Statics should be named with s_, but make sure s_ and m_ are both correctly | 22 // Statics should be named with s_, but make sure s_ and m_ are both correctly |
| 22 // stripped. | 23 // stripped. |
| 23 static int s_staticCount; | 24 static int s_staticCount; |
| 24 static int m_staticCountWithBadName; | 25 static int m_staticCountWithBadName; |
| 25 // Make sure that acronyms don't confuse the underscore inserter. | 26 // Make sure that acronyms don't confuse the underscore inserter. |
| 26 int m_fieldMentioningHTTPAndHTTPS; | 27 int m_fieldMentioningHTTPAndHTTPS; |
| 27 // Already Google style, should not change. | 28 // Already Google style, should not change. |
| 28 int already_google_style_; | 29 int already_google_style_; |
| 29 }; | 30 }; |
| 30 | 31 |
| 31 int C::instanceCount = 0; | 32 int C::instanceCount = 0; |
| 32 | 33 |
| 33 // Structs are like classes, but don't use a `_` suffix for members. | 34 // Structs are like classes, but don't use a `_` suffix for members. |
| 34 struct S { | 35 struct S { |
| 35 int m_integerField; | 36 int m_integerField; |
| 36 int google_style_already; | 37 int google_style_already; |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 // Unions also use struct-style naming. | 40 // Unions also use struct-style naming. |
| 40 union U { | 41 union U { |
| 41 char fourChars[4]; | 42 char fourChars[4]; |
| 42 short twoShorts[2]; | 43 short twoShorts[2]; |
| 43 int one_hopefully_four_byte_int; | 44 int one_hopefully_four_byte_int; |
| 44 }; | 45 }; |
| 45 | 46 |
| 46 } // namespace blink | 47 } // namespace blink |
| 48 | |
| 49 void F() { | |
| 50 // Test that references to a static field are correctly rewritten. | |
| 51 blink::C::instanceCount++; | |
| 52 } | |
| OLD | NEW |