| 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 // Simple global constants. | 7 // Simple global constants. |
| 8 const char helloWorldConstant[] = "Hello world!"; | 8 const char helloWorldConstant[] = "Hello world!"; |
| 9 // Make sure a one-character constant doesn't get mangled. | 9 // Make sure a one-character constant doesn't get mangled. |
| 10 const float e = 2.718281828; | 10 const float e = 2.718281828; |
| 11 // Some constants start with a capital letter already. |
| 12 const int SpeedOfLightInMetresPerSecond = 299792458; |
| 11 | 13 |
| 12 // Already Chrome style, so shouldn't change. | 14 // Already Chrome style, so shouldn't change. |
| 13 const float kPi = 3.141592654; | 15 const float kPi = 3.141592654; |
| 14 | 16 |
| 15 class C { | 17 class C { |
| 16 public: | 18 public: |
| 17 // Static class constants. | 19 // Static class constants. |
| 18 static const int usefulConstant = 8; | 20 static const int usefulConstant = 8; |
| 19 // Note: s_ prefix should not be retained. | 21 // Note: s_ prefix should not be retained. |
| 20 static const int s_staticConstant = 9; | 22 static const int s_staticConstant = 9; |
| 21 // Note: m_ prefix should not be retained even though the proper prefix is s_. | 23 // Note: m_ prefix should not be retained even though the proper prefix is s_. |
| 22 static const int m_superNumber = 42; | 24 static const int m_superNumber = 42; |
| 23 | 25 |
| 24 // Not a constant even though it has static storage duration. | 26 // Not a constant even though it has static storage duration. |
| 25 static const char* m_currentEvent; | 27 static const char* m_currentEvent; |
| 26 }; | 28 }; |
| 27 | 29 |
| 28 void F() { | 30 void F() { |
| 29 // Constant in function body. | 31 // Constant in function body. |
| 30 static const char staticString[] = "abc"; | 32 static const char staticString[] = "abc"; |
| 31 // Constant-style naming, since it's initialized with a literal. | 33 // Constant-style naming, since it's initialized with a literal. |
| 32 const char* const nonStaticStringConstant = "def"; | 34 const char* const nonStaticStringConstant = "def"; |
| 33 // Not constant-style naming, since it's not initialized with a literal. | 35 // Not constant-style naming, since it's not initialized with a literal. |
| 34 const char* const nonStaticStringUnconstant = nonStaticStringConstant; | 36 const char* const nonStaticStringUnconstant = nonStaticStringConstant; |
| 35 } | 37 } |
| 36 | 38 |
| 37 } // namespace blink | 39 } // namespace blink |
| OLD | NEW |