| 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 // Test that a field without a m_ prefix is correctly renamed. |
| 18 static int instanceCount; |
| 19 |
| 17 private: | 20 private: |
| 18 // The m_ prefix, if any, should be removed. | 21 // Test that a field with a m_ prefix is correctly renamed. |
| 19 static int instanceCount; | |
| 20 const int m_flagField; | 22 const int m_flagField; |
| 21 // Statics should be named with s_, but make sure s_ and m_ are both correctly | 23 // Statics should be named with s_, but make sure s_ and m_ are both correctly |
| 22 // stripped. | 24 // stripped. |
| 23 static int s_staticCount; | 25 static int s_staticCount; |
| 24 static int m_staticCountWithBadName; | 26 static int m_staticCountWithBadName; |
| 25 // Make sure that acronyms don't confuse the underscore inserter. | 27 // Make sure that acronyms don't confuse the underscore inserter. |
| 26 int m_fieldMentioningHTTPAndHTTPS; | 28 int m_fieldMentioningHTTPAndHTTPS; |
| 27 // Already Google style, should not change. | 29 // Already Google style, should not change. |
| 28 int already_google_style_; | 30 int already_google_style_; |
| 29 }; | 31 }; |
| 30 | 32 |
| 31 int C::instanceCount = 0; | 33 int C::instanceCount = 0; |
| 32 | 34 |
| 33 // Structs are like classes, but don't use a `_` suffix for members. | 35 // Structs are like classes, but don't use a `_` suffix for members. |
| 34 struct S { | 36 struct S { |
| 35 int m_integerField; | 37 int m_integerField; |
| 36 int google_style_already; | 38 int google_style_already; |
| 37 }; | 39 }; |
| 38 | 40 |
| 39 // Unions also use struct-style naming. | 41 // Unions also use struct-style naming. |
| 40 union U { | 42 union U { |
| 41 char fourChars[4]; | 43 char fourChars[4]; |
| 42 short twoShorts[2]; | 44 short twoShorts[2]; |
| 43 int one_hopefully_four_byte_int; | 45 int one_hopefully_four_byte_int; |
| 44 }; | 46 }; |
| 45 | 47 |
| 46 } // namespace blink | 48 } // namespace blink |
| 49 |
| 50 void F() { |
| 51 // Test that references to a static field are correctly rewritten. |
| 52 blink::C::instanceCount++; |
| 53 } |
| OLD | NEW |