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

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

Issue 273323002: Convert snakecase enum names to camelcase when stringified. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Cap funciton names Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 #! /usr/bin/env python 1 #! /usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import itertools 6 import itertools
7 import json 7 import json
8 import os.path 8 import os.path
9 import re 9 import re
10 import sys 10 import sys
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 400
401 def __init__(self, idl): 401 def __init__(self, idl):
402 self.idl = idl 402 self.idl = idl
403 403
404 def process(self): 404 def process(self):
405 namespaces = [] 405 namespaces = []
406 nodoc = False 406 nodoc = False
407 internal = False 407 internal = False
408 description = None 408 description = None
409 platforms = None 409 platforms = None
410 compiler_options = None 410 compiler_options = {}
411 deprecated = None 411 deprecated = None
412 for node in self.idl: 412 for node in self.idl:
413 if node.cls == 'Namespace': 413 if node.cls == 'Namespace':
414 if not description: 414 if not description:
415 # TODO(kalman): Go back to throwing an error here. 415 # TODO(kalman): Go back to throwing an error here.
416 print('%s must have a namespace-level comment. This will ' 416 print('%s must have a namespace-level comment. This will '
417 'appear on the API summary page.' % node.GetName()) 417 'appear on the API summary page.' % node.GetName())
418 description = '' 418 description = ''
419 namespace = Namespace(node, description, nodoc, internal, 419 namespace = Namespace(node, description, nodoc, internal,
420 platforms=platforms, 420 platforms=platforms,
421 compiler_options=compiler_options, 421 compiler_options=compiler_options or None,
422 deprecated=deprecated) 422 deprecated=deprecated)
423 namespaces.append(namespace.process()) 423 namespaces.append(namespace.process())
424 nodoc = False 424 nodoc = False
425 internal = False 425 internal = False
426 platforms = None 426 platforms = None
427 compiler_options = None 427 compiler_options = None
428 elif node.cls == 'Copyright': 428 elif node.cls == 'Copyright':
429 continue 429 continue
430 elif node.cls == 'Comment': 430 elif node.cls == 'Comment':
431 description = node.GetName() 431 description = node.GetName()
432 elif node.cls == 'ExtAttribute': 432 elif node.cls == 'ExtAttribute':
433 if node.name == 'nodoc': 433 if node.name == 'nodoc':
434 nodoc = bool(node.value) 434 nodoc = bool(node.value)
435 elif node.name == 'internal': 435 elif node.name == 'internal':
436 internal = bool(node.value) 436 internal = bool(node.value)
437 elif node.name == 'platforms': 437 elif node.name == 'platforms':
438 platforms = list(node.value) 438 platforms = list(node.value)
439 elif node.name == 'implemented_in': 439 elif node.name == 'implemented_in':
440 compiler_options = {'implemented_in': node.value} 440 compiler_options = {'implemented_in': node.value}
not at google - send to devlin 2014/05/13 23:45:47 you need the [] treatment here too
David Tseng 2014/05/14 02:16:14 Done.
441 elif node.name == 'camel_case_enum_to_string':
442 compiler_options['camel_case_enum_to_string'] = node.value
441 elif node.name == 'deprecated': 443 elif node.name == 'deprecated':
442 deprecated = str(node.value) 444 deprecated = str(node.value)
443 else: 445 else:
444 continue 446 continue
445 else: 447 else:
446 sys.exit('Did not process %s %s' % (node.cls, node)) 448 sys.exit('Did not process %s %s' % (node.cls, node))
447 return namespaces 449 return namespaces
448 450
449 451
450 def Load(filename): 452 def Load(filename):
(...skipping 16 matching lines...) Expand all
467 Dump a json serialization of parse result for the IDL files whose names 469 Dump a json serialization of parse result for the IDL files whose names
468 were passed in on the command line. 470 were passed in on the command line.
469 ''' 471 '''
470 for filename in sys.argv[1:]: 472 for filename in sys.argv[1:]:
471 schema = Load(filename) 473 schema = Load(filename)
472 print json.dumps(schema, indent=2) 474 print json.dumps(schema, indent=2)
473 475
474 476
475 if __name__ == '__main__': 477 if __name__ == '__main__':
476 Main() 478 Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698