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 #include "gen/thing.h" | 5 #include "gen/thing.h" |
6 | 6 |
7 namespace v8 { | 7 namespace v8 { |
8 | 8 |
9 class InterfaceOutsideOfBlink { | 9 class InterfaceOutsideOfBlink { |
10 public: | 10 public: |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 public: | 232 public: |
233 // |layoutObjectFoo| should NOT be renamed to |GetLayoutObjectFoo| (just to | 233 // |layoutObjectFoo| should NOT be renamed to |GetLayoutObjectFoo| (just to |
234 // |LayoutObjectFoo|) - see the big comment above. We use layoutObject*Foo* | 234 // |LayoutObjectFoo|) - see the big comment above. We use layoutObject*Foo* |
235 // to test inheritance-related behavior and avoid testing whether method name | 235 // to test inheritance-related behavior and avoid testing whether method name |
236 // is covered via ShouldPrefixFunctionName. | 236 // is covered via ShouldPrefixFunctionName. |
237 LayoutBoxModelObject* layoutObjectFoo() { return nullptr; } | 237 LayoutBoxModelObject* layoutObjectFoo() { return nullptr; } |
238 }; | 238 }; |
239 | 239 |
240 } // namespace get_prefix_vs_inheritance | 240 } // namespace get_prefix_vs_inheritance |
241 | 241 |
| 242 namespace blacklisting_of_method_and_function_names { |
| 243 |
| 244 class Foo { |
| 245 // Expecting |swap| method to be renamed to |Swap| - we blacklist renaming of |
| 246 // |swap| *function*, because it needs to have the same casing as std::swap, |
| 247 // so that ADL can kick-in and pull it from another namespace depending on the |
| 248 // bargument. We have a choice to rename or not rename |swap| *methods* - we |
| 249 // chose to rename to be consistent (i.e. we rename |clear| -> |Clear|) and |
| 250 // because Google C++ Styke Guide uses "Swap" in examples. |
| 251 void swap() {} |
| 252 static void swap(Foo& x, Foo& y) {} |
| 253 |
| 254 // We don't rename |begin|, so that <algorithms> and other templates that |
| 255 // expect |begin|, |end|, etc. continue to work. This is only necessary |
| 256 // for instance methods - renaming static methods and funcitons is okay. |
| 257 void begin() {} |
| 258 static void begin(int x) {} |
| 259 |
| 260 // https://crbug.com/677166: We blacklist renaming of |hash|, because it |
| 261 // collides with a struct named Hash. Blacklisting therefore should be broad |
| 262 // and should cover both instance and static methods as well as functions. |
| 263 int hash() const { return 123; } |
| 264 static int hash(const Foo& x) { return x.hash(); } |
| 265 }; |
| 266 |
| 267 void begin(int x) {} |
| 268 int hash(int x) { |
| 269 return 123 * x; |
| 270 } |
| 271 void swap(Foo& x, Foo& y) {} |
| 272 |
| 273 } // blacklisting_of_method_and_function_names |
| 274 |
242 } // namespace blink | 275 } // namespace blink |
243 | 276 |
244 namespace WTF { | 277 namespace WTF { |
245 | 278 |
246 struct StructInWTF { | 279 struct StructInWTF { |
247 // Structs in WTF should rename their methods to capitals. | 280 // Structs in WTF should rename their methods to capitals. |
248 bool function() { return true; } | 281 bool function() { return true; } |
249 }; | 282 }; |
250 | 283 |
251 } // namespace WTF | 284 } // namespace WTF |
(...skipping 19 matching lines...) Expand all Loading... |
271 static void method(); | 304 static void method(); |
272 }; | 305 }; |
273 | 306 |
274 } // namespace internal | 307 } // namespace internal |
275 | 308 |
276 } // namespace blink | 309 } // namespace blink |
277 | 310 |
278 // https://crbug.com/640688 - need to rewrite method name below. | 311 // https://crbug.com/640688 - need to rewrite method name below. |
279 void blink::ClassDeclaredInsideBlink::methodDefinedOutsideBlink() {} | 312 void blink::ClassDeclaredInsideBlink::methodDefinedOutsideBlink() {} |
280 void blink::internal::InternalClass::method() {} | 313 void blink::internal::InternalClass::method() {} |
OLD | NEW |