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

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

Issue 23549025: Clean up JSON Schema Compiler. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 3 months 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
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 from code import Code 5 from code import Code
6 from model import PropertyType, Type 6 from model import PropertyType
7 import cpp_util 7 import cpp_util
8 import schema_util 8 import schema_util
9 9
10 class HGenerator(object): 10 class HGenerator(object):
11 def __init__(self, type_generator, cpp_namespace): 11 def __init__(self, type_generator, cpp_namespace):
12 self._type_generator = type_generator 12 self._type_generator = type_generator
13 self._cpp_namespace = cpp_namespace 13 self._cpp_namespace = cpp_namespace
14 14
15 def Generate(self, namespace): 15 def Generate(self, namespace):
16 return _Generator(namespace, 16 return _Generator(namespace,
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 .Eblock('} // namespace %s' % event_namespace) 296 .Eblock('} // namespace %s' % event_namespace)
297 ) 297 )
298 return c 298 return c
299 299
300 def _GenerateFunction(self, function): 300 def _GenerateFunction(self, function):
301 """Generates the namespaces and structs for a function. 301 """Generates the namespaces and structs for a function.
302 """ 302 """
303 c = Code() 303 c = Code()
304 # TODO(kalman): Use function.unix_name not Classname here. 304 # TODO(kalman): Use function.unix_name not Classname here.
305 function_namespace = cpp_util.Classname(function.name) 305 function_namespace = cpp_util.Classname(function.name)
306 """Windows has a #define for SendMessage, so to avoid any issues, we need 306 # Windows has a #define for SendMessage, so to avoid any issues, we need
307 to not use the name. 307 # to not use the name.
308 """
309 if function_namespace == 'SendMessage': 308 if function_namespace == 'SendMessage':
310 function_namespace = 'PassMessage' 309 function_namespace = 'PassMessage'
311 (c.Append('namespace %s {' % function_namespace) 310 (c.Append('namespace %s {' % function_namespace)
312 .Append() 311 .Append()
313 .Cblock(self._GenerateFunctionParams(function)) 312 .Cblock(self._GenerateFunctionParams(function))
314 ) 313 )
315 if function.callback: 314 if function.callback:
316 c.Cblock(self._GenerateFunctionResults(function.callback)) 315 c.Cblock(self._GenerateFunctionResults(function.callback))
317 c.Append('} // namespace %s' % function_namespace) 316 c.Append('} // namespace %s' % function_namespace)
318 return c 317 return c
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 .Append('} // namespace Results') 387 .Append('} // namespace Results')
389 ) 388 )
390 return c 389 return c
391 390
392 def _GenerateParams(self, params): 391 def _GenerateParams(self, params):
393 """Builds the parameter list for a function, given an array of parameters. 392 """Builds the parameter list for a function, given an array of parameters.
394 """ 393 """
395 if self._generate_error_messages: 394 if self._generate_error_messages:
396 params += ('base::string16* error = NULL',) 395 params += ('base::string16* error = NULL',)
397 return ', '.join(str(p) for p in params) 396 return ', '.join(str(p) for p in params)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698