OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Utilies and constants specific to Chromium C++ code. | 5 """Utilies and constants specific to Chromium C++ code. |
6 """ | 6 """ |
7 | 7 |
8 from code import Code | 8 from code import Code |
9 from datetime import datetime | 9 from datetime import datetime |
10 from model import PropertyType | 10 from model import PropertyType |
11 import os | 11 import os |
12 import re | 12 import re |
13 | 13 |
14 CHROMIUM_LICENSE = ( | 14 CHROMIUM_LICENSE = ( |
15 """// Copyright (c) %d The Chromium Authors. All rights reserved. | 15 """// Copyright (c) %d The Chromium Authors. All rights reserved. |
16 // Use of this source code is governed by a BSD-style license that can be | 16 // Use of this source code is governed by a BSD-style license that can be |
17 // found in the LICENSE file.""" % datetime.now().year | 17 // found in the LICENSE file.""" % datetime.now().year |
18 ) | 18 ) |
19 GENERATED_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITION IN | 19 GENERATED_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITION IN |
20 // %s | 20 // %s |
21 // DO NOT EDIT. | 21 // DO NOT EDIT. |
22 """ | 22 """ |
23 GENERATED_BUNDLE_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITIONS IN | 23 GENERATED_BUNDLE_FILE_MESSAGE = """// GENERATED FROM THE API DEFINITIONS IN |
24 // %s | 24 // %s |
25 // DO NOT EDIT. | 25 // DO NOT EDIT. |
26 """ | 26 """ |
| 27 GENERATED_FEATURE_MESSAGE = """// GENERATED FROM THE FEATURE DEFINITIONS IN |
| 28 // %s |
| 29 // DO NOT EDIT. |
| 30 """ |
27 | 31 |
28 def Classname(s): | 32 def Classname(s): |
29 """Translates a namespace name or function name into something more | 33 """Translates a namespace name or function name into something more |
30 suited to C++. | 34 suited to C++. |
31 | 35 |
32 eg experimental.downloads -> Experimental_Downloads | 36 eg experimental.downloads -> Experimental_Downloads |
33 updateAll -> UpdateAll. | 37 updateAll -> UpdateAll. |
34 """ | 38 """ |
35 return '_'.join([x[0].upper() + x[1:] for x in re.split('\W', s)]) | 39 return '_'.join([x[0].upper() + x[1:] for x in re.split('\W', s)]) |
36 | 40 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 return c | 115 return c |
112 | 116 |
113 | 117 |
114 def CloseNamespace(namespace): | 118 def CloseNamespace(namespace): |
115 """Get closing root namespace declarations. | 119 """Get closing root namespace declarations. |
116 """ | 120 """ |
117 c = Code() | 121 c = Code() |
118 for component in reversed(namespace.split('::')): | 122 for component in reversed(namespace.split('::')): |
119 c.Append('} // namespace %s' % component) | 123 c.Append('} // namespace %s' % component) |
120 return c | 124 return c |
| 125 |
| 126 |
| 127 def ConstantName(feature_name): |
| 128 """Returns a kName for a feature's name. |
| 129 """ |
| 130 return ('k' + ''.join(word[0].upper() + word[1:] |
| 131 for word in feature_name.replace('.', ' ').split())) |
| 132 |
| 133 |
| 134 def CamelCase(unix_name): |
| 135 return ''.join(word.capitalize() for word in unix_name.split('_')) |
| 136 |
| 137 |
| 138 def ClassName(filepath): |
| 139 return CamelCase(os.path.split(filepath)[1]) |
OLD | NEW |