Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: tools/json_schema_compiler/cpp_bundle_generator.py

Issue 54323003: Base infrastructure for Networking Private API on Windows and Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync up to r236620 Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« components/wifi.gypi ('K') | « components/wifi/wifi_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 def _GetPlatformIfdefs(self, model_object): 77 def _GetPlatformIfdefs(self, model_object):
78 """Generates the "defined" conditional for an #if check if |model_object| 78 """Generates the "defined" conditional for an #if check if |model_object|
79 has platform restrictions. Returns None if there are no restrictions. 79 has platform restrictions. Returns None if there are no restrictions.
80 """ 80 """
81 if model_object.platforms is None: 81 if model_object.platforms is None:
82 return None 82 return None
83 ifdefs = [] 83 ifdefs = []
84 for platform in model_object.platforms: 84 for platform in model_object.platforms:
85 if platform == Platforms.CHROMEOS: 85 if platform == Platforms.CHROMEOS:
86 ifdefs.append('defined(OS_CHROMEOS)') 86 ifdefs.append('defined(OS_CHROMEOS)')
87 elif platform == Platforms.LINUX:
88 ifdefs.append('defined(OS_LINUX)')
89 elif platform == Platforms.MAC:
90 ifdefs.append('defined(OS_MACOSX)')
91 elif platform == Platforms.WIN:
92 ifdefs.append('defined(OS_WIN)')
87 else: 93 else:
88 raise ValueError("Unsupported platform ifdef: %s" % platform.name) 94 raise ValueError("Unsupported platform ifdef: %s" % platform.name)
89 return ' and '.join(ifdefs) 95 return ' || '.join(ifdefs)
90 96
91 def _GenerateRegisterFunctions(self, namespace_name, function): 97 def _GenerateRegisterFunctions(self, namespace_name, function):
92 c = code.Code() 98 c = code.Code()
93 function_ifdefs = self._GetPlatformIfdefs(function) 99 function_ifdefs = self._GetPlatformIfdefs(function)
94 if function_ifdefs is not None: 100 if function_ifdefs is not None:
95 c.Append("#if %s" % function_ifdefs, indent_level=0) 101 c.Append("#if %s" % function_ifdefs, indent_level=0)
96 102
97 function_name = JsFunctionNameToClassName(namespace_name, function.name) 103 function_name = JsFunctionNameToClassName(namespace_name, function.name)
98 c.Append("registry->RegisterFunction<%sFunction>();" % ( 104 c.Append("registry->RegisterFunction<%sFunction>();" % (
99 function_name)) 105 function_name))
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 c.Eblock('}') 299 c.Eblock('}')
294 c.Append() 300 c.Append()
295 c.Append('// static') 301 c.Append('// static')
296 c.Sblock('bool GeneratedSchemas::IsGenerated(std::string name) {') 302 c.Sblock('bool GeneratedSchemas::IsGenerated(std::string name) {')
297 c.Append('return g_lazy_instance.Get().schemas.count(name) > 0;') 303 c.Append('return g_lazy_instance.Get().schemas.count(name) > 0;')
298 c.Eblock('}') 304 c.Eblock('}')
299 c.Append() 305 c.Append()
300 c.Concat(cpp_util.CloseNamespace(self._bundle._cpp_namespace)) 306 c.Concat(cpp_util.CloseNamespace(self._bundle._cpp_namespace))
301 c.Append() 307 c.Append()
302 return c 308 return c
OLDNEW
« components/wifi.gypi ('K') | « components/wifi/wifi_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698