OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 import os.path | 5 import os.path |
6 | 6 |
7 from code import Code | 7 from code import Code |
8 import cpp_util | 8 import cpp_util |
9 | 9 |
10 | 10 |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 def Generate(self): | 26 def Generate(self): |
27 """Generates a Code object for features. | 27 """Generates a Code object for features. |
28 """ | 28 """ |
29 c = Code() | 29 c = Code() |
30 (c.Append(cpp_util.CHROMIUM_LICENSE) | 30 (c.Append(cpp_util.CHROMIUM_LICENSE) |
31 .Append() | 31 .Append() |
32 .Append(cpp_util.GENERATED_FEATURE_MESSAGE % self._source_file) | 32 .Append(cpp_util.GENERATED_FEATURE_MESSAGE % self._source_file) |
33 .Append() | 33 .Append() |
34 ) | 34 ) |
35 ifndef_name = cpp_util.GenerateIfndefName(self._source_file_filename, | 35 |
36 self._class_name) | 36 # Hack: for the purpose of gyp the header file will always be the source |
| 37 # file with its file extension replaced by '.h'. Assume so. |
| 38 output_file = os.path.splitext(self._namespace.source_file)[0] + '.h' |
| 39 ifndef_name = cpp_util.GenerateIfndefName(output_file) |
| 40 |
37 (c.Append('#ifndef %s' % ifndef_name) | 41 (c.Append('#ifndef %s' % ifndef_name) |
38 .Append('#define %s' % ifndef_name) | 42 .Append('#define %s' % ifndef_name) |
39 .Append() | 43 .Append() |
40 ) | 44 ) |
41 | 45 |
42 (c.Append('#include <map>') | 46 (c.Append('#include <map>') |
43 .Append('#include <string>') | 47 .Append('#include <string>') |
44 .Append() | 48 .Append() |
45 .Concat(cpp_util.OpenNamespace(self._namespace)) | 49 .Concat(cpp_util.OpenNamespace(self._namespace)) |
46 .Append() | 50 .Append() |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 c = Code() | 90 c = Code() |
87 | 91 |
88 (c.Sblock() | 92 (c.Sblock() |
89 .Append('kUnknown,') | 93 .Append('kUnknown,') |
90 ) | 94 ) |
91 for feature in self._feature_defs: | 95 for feature in self._feature_defs: |
92 c.Append('%s,' % cpp_util.ConstantName(feature.name)) | 96 c.Append('%s,' % cpp_util.ConstantName(feature.name)) |
93 c.Append('kEnumBoundary') | 97 c.Append('kEnumBoundary') |
94 | 98 |
95 return c | 99 return c |
OLD | NEW |