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