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 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 """Appends a space to |var| if it ends with a >, so that it can be compiled | 103 """Appends a space to |var| if it ends with a >, so that it can be compiled |
104 within generic types. | 104 within generic types. |
105 """ | 105 """ |
106 return ('%s ' % var) if var.endswith('>') else var | 106 return ('%s ' % var) if var.endswith('>') else var |
107 | 107 |
108 | 108 |
109 def OpenNamespace(namespace): | 109 def OpenNamespace(namespace): |
110 """Get opening root namespace declarations. | 110 """Get opening root namespace declarations. |
111 """ | 111 """ |
112 c = Code() | 112 c = Code() |
113 if namespace == '': | |
not at google - send to devlin
2014/01/23 18:26:47
ok, add a comment then.
# In lieu of GYP supporti
| |
114 return c | |
113 for component in namespace.split('::'): | 115 for component in namespace.split('::'): |
114 c.Append('namespace %s {' % component) | 116 c.Append('namespace %s {' % component) |
115 return c | 117 return c |
116 | 118 |
117 | 119 |
118 def CloseNamespace(namespace): | 120 def CloseNamespace(namespace): |
119 """Get closing root namespace declarations. | 121 """Get closing root namespace declarations. |
120 """ | 122 """ |
121 c = Code() | 123 c = Code() |
124 if namespace == '': | |
125 return c | |
122 for component in reversed(namespace.split('::')): | 126 for component in reversed(namespace.split('::')): |
123 c.Append('} // namespace %s' % component) | 127 c.Append('} // namespace %s' % component) |
124 return c | 128 return c |
125 | 129 |
126 | 130 |
127 def ConstantName(feature_name): | 131 def ConstantName(feature_name): |
128 """Returns a kName for a feature's name. | 132 """Returns a kName for a feature's name. |
129 """ | 133 """ |
130 return ('k' + ''.join(word[0].upper() + word[1:] | 134 return ('k' + ''.join(word[0].upper() + word[1:] |
131 for word in feature_name.replace('.', ' ').split())) | 135 for word in feature_name.replace('.', ' ').split())) |
132 | 136 |
133 | 137 |
134 def CamelCase(unix_name): | 138 def CamelCase(unix_name): |
135 return ''.join(word.capitalize() for word in unix_name.split('_')) | 139 return ''.join(word.capitalize() for word in unix_name.split('_')) |
136 | 140 |
137 | 141 |
138 def ClassName(filepath): | 142 def ClassName(filepath): |
139 return CamelCase(os.path.split(filepath)[1]) | 143 return CamelCase(os.path.split(filepath)[1]) |
OLD | NEW |