Mark Cogan | 6a8e4878 | 2017-08-17 10:06:24 | [diff] [blame] | 1 | ## All files are Objective-C++ |
| 2 | |
| 3 | Chrome back-end code is all C++ and we want to leverage many C++ features, such |
| 4 | as stack-based classes and namespaces. As a result, all front-end Bling files |
| 5 | should be .mm files, as we expect eventually they will contain C++ code or |
| 6 | language features. |
| 7 | |
Mark Cogan | 6a8e4878 | 2017-08-17 10:06:24 | [diff] [blame] | 8 | ## Use ObjCCast<T> and ObjcCCastStrict<T> |
| 9 | |
| 10 | As the C++ style guide tells you, we never use C casts and prefer |
| 11 | `static_cast<T>` and `dynamic_cast<T>`. However, for Objective-C casts we have |
Avi Drissman | eac566b0 | 2023-08-18 02:56:21 | [diff] [blame] | 12 | two specific casts: `base::apple::ObjCCast<T>arg` is similar to `dynamic_cast<T>`, |
Mark Cogan | 6a8e4878 | 2017-08-17 10:06:24 | [diff] [blame] | 13 | and `ObjcCCastStrict` `DCHECKs` against that class. |
| 14 | |
| 15 | ## Blocks |
| 16 | |
| 17 | We follow Google style for blocks, except that historically we have used 2-space |
| 18 | indentation for blocks that are parameters, rather than 4. You may continue to |
| 19 | use this style when it is consistent with the surrounding code. |
| 20 | |
| 21 | ## NOTIMPLEMENTED and NOTREACHED logging macros |
| 22 | |
| 23 | `NOTREACHED`: This function should not be called. If it is, we have a problem |
| 24 | somewhere else. |
| 25 | `NOTIMPLEMENTED`: This isn't implemented because we don't use it yet. If it's |
| 26 | called, then we need to figure out what it should do. |
| 27 | |
Solomon Kinard | 57aa4ef | 2023-03-22 15:18:24 | [diff] [blame] | 28 | When something is called but doesn't need an implementation, just add a comment |
| 29 | indicating this instead of using a logging macro. |
Mark Cogan | 6a8e4878 | 2017-08-17 10:06:24 | [diff] [blame] | 30 | |
| 31 | ## TODO comments |
| 32 | |
| 33 | Sometimes we include TODO comments in code. Generally we follow |
| 34 | [C++ style](https://google.github.io/styleguide/cppguide.html#TODO_Comments), |
| 35 | but here are some more specific practices we've agreed upon as a team: |
| 36 | |
| 37 | * **Every TODO must have a bug** |
| 38 | * Bug should be labeled with **Hotlist-TODO-iOS** |
| 39 | * Always list bug in parentheses following "TODO" |
| 40 | * `// TODO(crbug.com/######): Something that needs doing.` |
| 41 | * Do NOT include http:// |
| 42 | * Optionally include a username for reference |
| 43 | * Optionally include expiration date (make sure it's documented in the bug!) |