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 import code | 5 import code |
6 import cpp_util | 6 import cpp_util |
7 from model import Platforms | 7 from model import Platforms |
8 from schema_util import CapitalizeFirstLetter | 8 from schema_util import CapitalizeFirstLetter |
9 from schema_util import JsFunctionNameToClassName | 9 from schema_util import JsFunctionNameToClassName |
10 | 10 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 """Generates the "defined" conditional for an #if check if |model_object| | 87 """Generates the "defined" conditional for an #if check if |model_object| |
88 has platform restrictions. Returns None if there are no restrictions. | 88 has platform restrictions. Returns None if there are no restrictions. |
89 """ | 89 """ |
90 if model_object.platforms is None: | 90 if model_object.platforms is None: |
91 return None | 91 return None |
92 ifdefs = [] | 92 ifdefs = [] |
93 for platform in model_object.platforms: | 93 for platform in model_object.platforms: |
94 if platform == Platforms.CHROMEOS: | 94 if platform == Platforms.CHROMEOS: |
95 ifdefs.append('defined(OS_CHROMEOS)') | 95 ifdefs.append('defined(OS_CHROMEOS)') |
96 elif platform == Platforms.LINUX: | 96 elif platform == Platforms.LINUX: |
97 ifdefs.append('defined(OS_LINUX)') | 97 ifdefs.append('(defined(OS_LINUX) && !defined(OS_CHROMEOS))') |
98 elif platform == Platforms.MAC: | 98 elif platform == Platforms.MAC: |
99 ifdefs.append('defined(OS_MACOSX)') | 99 ifdefs.append('defined(OS_MACOSX)') |
100 elif platform == Platforms.WIN: | 100 elif platform == Platforms.WIN: |
101 ifdefs.append('defined(OS_WIN)') | 101 ifdefs.append('defined(OS_WIN)') |
102 else: | 102 else: |
103 raise ValueError("Unsupported platform ifdef: %s" % platform.name) | 103 raise ValueError("Unsupported platform ifdef: %s" % platform.name) |
104 return ' || '.join(ifdefs) | 104 return ' || '.join(ifdefs) |
105 | 105 |
106 def _GenerateRegisterFunctions(self, namespace_name, function): | 106 def _GenerateRegisterFunctions(self, namespace_name, function): |
107 c = code.Code() | 107 c = code.Code() |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 c.Append() | 322 c.Append() |
323 c.Append('// static') | 323 c.Append('// static') |
324 c.Sblock('bool %s::IsGenerated(std::string name) {' % | 324 c.Sblock('bool %s::IsGenerated(std::string name) {' % |
325 self._bundle._GenerateBundleClass('GeneratedSchemas')) | 325 self._bundle._GenerateBundleClass('GeneratedSchemas')) |
326 c.Append('return g_lazy_instance.Get().schemas.count(name) > 0;') | 326 c.Append('return g_lazy_instance.Get().schemas.count(name) > 0;') |
327 c.Eblock('}') | 327 c.Eblock('}') |
328 c.Append() | 328 c.Append() |
329 c.Concat(cpp_util.CloseNamespace(self._bundle._cpp_namespace)) | 329 c.Concat(cpp_util.CloseNamespace(self._bundle._cpp_namespace)) |
330 c.Append() | 330 c.Append() |
331 return c | 331 return c |
OLD | NEW |