| 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 // Note: do not add any copy or move constructors to this class: doing so will | 7 // Note: do not add any copy or move constructors to this class: doing so will |
| 8 // break test coverage that we don't clobber the class name by trying to emit | 8 // break test coverage that we don't clobber the class name by trying to emit |
| 9 // replacements for synthesized functions. | 9 // replacements for synthesized functions. |
| 10 class C { | 10 class C { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 // Unions also use struct-style naming. | 57 // Unions also use struct-style naming. |
| 58 union U { | 58 union U { |
| 59 char fourChars[4]; | 59 char fourChars[4]; |
| 60 short twoShorts[2]; | 60 short twoShorts[2]; |
| 61 int one_hopefully_four_byte_int; | 61 int one_hopefully_four_byte_int; |
| 62 int m_hasPrefix; | 62 int m_hasPrefix; |
| 63 }; | 63 }; |
| 64 | 64 |
| 65 // https://crbug.com/640749#c1: Some type traits are inside blink namespace. |
| 66 struct IsGarbageCollectedMixin { |
| 67 static const bool value = true; |
| 68 }; |
| 69 |
| 65 } // namespace blink | 70 } // namespace blink |
| 66 | 71 |
| 67 namespace WTF { | 72 namespace WTF { |
| 68 | 73 |
| 69 // We don't want to capitalize fields in type traits | 74 // We don't want to capitalize fields in type traits |
| 70 // (i.e. no |value| -> |kValue| rename is undesirable below). | 75 // (i.e. no |value| -> |kValue| rename is undesirable below). |
| 71 struct TypeTrait1 { | 76 struct TypeTrait1 { |
| 72 static const bool value = true; | 77 static const bool value = true; |
| 73 }; | 78 }; |
| 74 | 79 |
| 75 // Some type traits are implemented as classes, not structs | 80 // Some type traits are implemented as classes, not structs |
| 76 // (e.g. WTF::IsGarbageCollectedType or WTF::IsAssignable). | 81 // (e.g. WTF::IsGarbageCollectedType or WTF::IsAssignable). |
| 77 template <typename T> | 82 template <typename T> |
| 78 class TypeTrait2 { | 83 class TypeTrait2 { |
| 79 public: | 84 public: |
| 80 static const bool value = false; | 85 static const bool value = false; |
| 81 }; | 86 }; |
| 82 template <> | 87 template <> |
| 83 class TypeTrait2<void> { | 88 class TypeTrait2<void> { |
| 84 public: | 89 public: |
| 85 static const bool value = false; | 90 static const bool value = false; |
| 86 }; | 91 }; |
| 87 | 92 |
| 88 }; // namespace WTF | 93 }; // namespace WTF |
| 89 | 94 |
| 90 void F() { | 95 void F() { |
| 91 // Test that references to a static field are correctly rewritten. | 96 // Test that references to a static field are correctly rewritten. |
| 92 blink::C::instanceCount++; | 97 blink::C::instanceCount++; |
| 93 // Force instantiation of a copy constructor for blink::C to make sure field | 98 // Force instantiation of a copy constructor for blink::C to make sure field |
| 94 // initializers for synthesized functions don't cause weird rewrites. | 99 // initializers for synthesized functions don't cause weird rewrites. |
| 95 blink::C c; | 100 blink::C c; |
| 96 blink::C c2 = c; | 101 blink::C c2 = c; |
| 97 | 102 |
| 98 bool b1 = WTF::TypeTrait1::value; | 103 bool b1 = WTF::TypeTrait1::value; |
| 99 bool b2 = WTF::TypeTrait2<void>::value; | 104 bool b2 = WTF::TypeTrait2<void>::value; |
| 100 } | 105 } |
| OLD | NEW |