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

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

Issue 22295002: Base infrastructure for Networking Private API on Windows and Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use crypto_verify_mock for browser_test. Created 7 years, 1 month 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
« no previous file with comments | « ipc/ipc_message_start.h ('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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 def _GetPlatformIfdefs(self, model_object): 72 def _GetPlatformIfdefs(self, model_object):
73 """Generates the "defined" conditional for an #if check if |model_object| 73 """Generates the "defined" conditional for an #if check if |model_object|
74 has platform restrictions. Returns None if there are no restrictions. 74 has platform restrictions. Returns None if there are no restrictions.
75 """ 75 """
76 if model_object.platforms is None: 76 if model_object.platforms is None:
77 return None 77 return None
78 ifdefs = [] 78 ifdefs = []
79 for platform in model_object.platforms: 79 for platform in model_object.platforms:
80 if platform == Platforms.CHROMEOS: 80 if platform == Platforms.CHROMEOS:
81 ifdefs.append('defined(OS_CHROMEOS)') 81 ifdefs.append('defined(OS_CHROMEOS)')
82 elif platform == Platforms.LINUX:
83 ifdefs.append('defined(OS_LINUX)')
84 elif platform == Platforms.MAC:
85 ifdefs.append('defined(OS_MACOSX)')
86 elif platform == Platforms.WIN:
87 ifdefs.append('defined(OS_WIN)')
82 else: 88 else:
83 raise ValueError("Unsupported platform ifdef: %s" % platform.name) 89 raise ValueError("Unsupported platform ifdef: %s" % platform.name)
84 return ' and '.join(ifdefs) 90 return ' || '.join(ifdefs)
85 91
86 def _GenerateRegisterFunctions(self, namespace_name, function): 92 def _GenerateRegisterFunctions(self, namespace_name, function):
87 c = code.Code() 93 c = code.Code()
88 function_ifdefs = self._GetPlatformIfdefs(function) 94 function_ifdefs = self._GetPlatformIfdefs(function)
89 if function_ifdefs is not None: 95 if function_ifdefs is not None:
90 c.Append("#if %s" % function_ifdefs, indent_level=0) 96 c.Append("#if %s" % function_ifdefs, indent_level=0)
91 97
92 function_name = JsFunctionNameToClassName(namespace_name, function.name) 98 function_name = JsFunctionNameToClassName(namespace_name, function.name)
93 c.Append("registry->RegisterFunction<%sFunction>();" % ( 99 c.Append("registry->RegisterFunction<%sFunction>();" % (
94 function_name)) 100 function_name))
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 c.Eblock('}') 294 c.Eblock('}')
289 c.Append() 295 c.Append()
290 c.Append('// static') 296 c.Append('// static')
291 c.Sblock('bool GeneratedSchemas::IsGenerated(std::string name) {') 297 c.Sblock('bool GeneratedSchemas::IsGenerated(std::string name) {')
292 c.Append('return g_lazy_instance.Get().schemas.count(name) > 0;') 298 c.Append('return g_lazy_instance.Get().schemas.count(name) > 0;')
293 c.Eblock('}') 299 c.Eblock('}')
294 c.Append() 300 c.Append()
295 c.Concat(cpp_util.CloseNamespace(self._bundle._cpp_namespace)) 301 c.Concat(cpp_util.CloseNamespace(self._bundle._cpp_namespace))
296 c.Append() 302 c.Append()
297 return c 303 return c
OLDNEW
« no previous file with comments | « ipc/ipc_message_start.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698