| 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 MyIterator {}; | 7 class MyIterator {}; |
| 8 using my_iterator = char*; | 8 using my_iterator = char*; |
| 9 | 9 |
| 10 class Task { | 10 class Task { |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 int End() { return 0; } | 57 int End() { return 0; } |
| 58 void Rbegin() {} | 58 void Rbegin() {} |
| 59 int Rend() { return 0; } | 59 int Rend() { return 0; } |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 // Test that the actual method definition is also updated. | 62 // Test that the actual method definition is also updated. |
| 63 void Task::DoTheWork() { | 63 void Task::DoTheWork() { |
| 64 ReallyDoTheWork(); | 64 ReallyDoTheWork(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 template <typename T> |
| 68 class Testable { |
| 69 public: |
| 70 typedef T Testable::*UnspecifiedBoolType; |
| 71 // This method has a reference to a member in a "member context" and a |
| 72 // "non-member context" to verify both are rewritten. |
| 73 operator UnspecifiedBoolType() { return ptr_ ? &Testable::ptr_ : 0; } |
| 74 |
| 75 private: |
| 76 int ptr_; |
| 77 }; |
| 78 |
| 67 } // namespace blink | 79 } // namespace blink |
| 68 | 80 |
| 69 // Test that overrides from outside the Blink namespace are also updated. | 81 // Test that overrides from outside the Blink namespace are also updated. |
| 70 class BovineTask : public blink::Task { | 82 class BovineTask : public blink::Task { |
| 71 public: | 83 public: |
| 72 using Task::DoTheWork; | 84 using Task::DoTheWork; |
| 73 void ReallyDoTheWork() override; | 85 void ReallyDoTheWork() override; |
| 74 }; | 86 }; |
| 75 | 87 |
| 76 class SuperBovineTask : public BovineTask { | 88 class SuperBovineTask : public BovineTask { |
| 77 public: | 89 public: |
| 78 using BovineTask::ReallyDoTheWork; | 90 using BovineTask::ReallyDoTheWork; |
| 79 }; | 91 }; |
| 80 | 92 |
| 81 void BovineTask::ReallyDoTheWork() { | 93 void BovineTask::ReallyDoTheWork() { |
| 82 DoTheWork(); | 94 DoTheWork(); |
| 83 // Calls via an overridden method should also be updated. | 95 // Calls via an overridden method should also be updated. |
| 84 ReallyDoTheWork(); | 96 ReallyDoTheWork(); |
| 85 } | 97 } |
| 86 | 98 |
| 87 // Finally, test that method pointers are also updated. | 99 // Finally, test that method pointers are also updated. |
| 88 void F() { | 100 void F() { |
| 89 void (blink::Task::*p1)() = &blink::Task::DoTheWork; | 101 void (blink::Task::*p1)() = &blink::Task::DoTheWork; |
| 90 void (blink::Task::*p2)() = &BovineTask::DoTheWork; | 102 void (blink::Task::*p2)() = &BovineTask::DoTheWork; |
| 91 void (blink::Task::*p3)() = &blink::Task::ReallyDoTheWork; | 103 void (blink::Task::*p3)() = &blink::Task::ReallyDoTheWork; |
| 92 void (BovineTask::*p4)() = &BovineTask::ReallyDoTheWork; | 104 void (BovineTask::*p4)() = &BovineTask::ReallyDoTheWork; |
| 93 } | 105 } |
| 94 | 106 |
| 107 bool G() { |
| 108 // Use the Testable class to rewrite the method. |
| 109 blink::Testable<int> tt; |
| 110 return tt; |
| 111 } |
| 112 |
| 95 namespace blink { | 113 namespace blink { |
| 96 | 114 |
| 97 struct StructInBlink { | 115 struct StructInBlink { |
| 98 // Structs in blink should rename their methods to capitals. | 116 // Structs in blink should rename their methods to capitals. |
| 99 bool Function() { return true; } | 117 bool Function() { return true; } |
| 100 }; | 118 }; |
| 101 | 119 |
| 102 } // namespace blink | 120 } // namespace blink |
| 103 | 121 |
| 104 namespace WTF { | 122 namespace WTF { |
| 105 | 123 |
| 106 struct StructInWTF { | 124 struct StructInWTF { |
| 107 // Structs in WTF should rename their methods to capitals. | 125 // Structs in WTF should rename their methods to capitals. |
| 108 bool Function() { return true; } | 126 bool Function() { return true; } |
| 109 }; | 127 }; |
| 110 | 128 |
| 111 } // namespace WTF | 129 } // namespace WTF |
| 112 | 130 |
| 113 void F2() { | 131 void F2() { |
| 114 blink::StructInBlink b; | 132 blink::StructInBlink b; |
| 115 b.Function(); | 133 b.Function(); |
| 116 WTF::StructInWTF w; | 134 WTF::StructInWTF w; |
| 117 w.Function(); | 135 w.Function(); |
| 118 } | 136 } |
| OLD | NEW |