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 Property, PropertyType, Type | 10 from model import Property, PropertyType, Type |
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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 c.Append('namespace %s {' % component) | 108 c.Append('namespace %s {' % component) |
105 return c | 109 return c |
106 | 110 |
107 def CloseNamespace(namespace): | 111 def CloseNamespace(namespace): |
108 """Get closing root namespace declarations. | 112 """Get closing root namespace declarations. |
109 """ | 113 """ |
110 c = Code() | 114 c = Code() |
111 for component in reversed(namespace.split('::')): | 115 for component in reversed(namespace.split('::')): |
112 c.Append('} // namespace %s' % component) | 116 c.Append('} // namespace %s' % component) |
113 return c | 117 return c |
118 | |
119 def RemoveFeatureDuplicates(feature_list): | |
120 """Return a "set" of features where any feature with the same name is tossed. | |
not at google - send to devlin
2013/09/12 16:20:43
this method returns a list not a set.
dhnishi (use Chromium)
2013/09/13 17:36:42
Done.
| |
121 """ | |
122 feature_set = set() | |
123 return [feature for feature in feature_list if feature.name not in | |
124 feature_set and not feature_set.add(feature.name)] | |
OLD | NEW |