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

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

Issue 1982193002: Add enum class support to json_schema_compiler (idl files) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: I accidentally a patchset dependency Created 4 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
« no previous file with comments | « tools/json_schema_compiler/h_generator.py ('k') | tools/json_schema_compiler/model.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 pprint 9 import pprint
10 import re 10 import re
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 raise ValueError('Did not process %s %s' % (child.cls, child)) 353 raise ValueError('Did not process %s %s' % (child.cls, child))
354 enum.append(enum_value) 354 enum.append(enum_value)
355 elif node.cls == 'Comment': 355 elif node.cls == 'Comment':
356 self.description = ProcessComment(node.GetName())[0] 356 self.description = ProcessComment(node.GetName())[0]
357 else: 357 else:
358 sys.exit('Did not process %s %s' % (node.cls, node)) 358 sys.exit('Did not process %s %s' % (node.cls, node))
359 result = {'id' : self.node.GetName(), 359 result = {'id' : self.node.GetName(),
360 'description': self.description, 360 'description': self.description,
361 'type': 'string', 361 'type': 'string',
362 'enum': enum} 362 'enum': enum}
363 # TODO(tapted): Drop enum_class when it is the default.
364 # See http://crbug.com/612382.
363 for property_name in ('cpp_enum_prefix_override', 'inline_doc', 365 for property_name in ('cpp_enum_prefix_override', 'inline_doc',
364 'noinline_doc', 'nodefine', 'nodoc',): 366 'noinline_doc', 'nodefine', 'nodoc', 'enum_class',):
365 if self.node.GetProperty(property_name): 367 if self.node.GetProperty(property_name):
366 result[property_name] = self.node.GetProperty(property_name) 368 result[property_name] = self.node.GetProperty(property_name)
367 if self.node.GetProperty('deprecated'): 369 if self.node.GetProperty('deprecated'):
368 result['deprecated'] = self.node.GetProperty('deprecated') 370 result['deprecated'] = self.node.GetProperty('deprecated')
369 return result 371 return result
370 372
371 373
372 class Namespace(object): 374 class Namespace(object):
373 ''' 375 '''
374 Given an IDLNode representing an IDL namespace, converts into a Python 376 Given an IDLNode representing an IDL namespace, converts into a Python
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 print json.dumps(schema, indent=2) 553 print json.dumps(schema, indent=2)
552 else: 554 else:
553 contents = sys.stdin.read() 555 contents = sys.stdin.read()
554 idl = idl_parser.IDLParser().ParseData(contents, '<stdin>') 556 idl = idl_parser.IDLParser().ParseData(contents, '<stdin>')
555 schema = IDLSchema(idl).process() 557 schema = IDLSchema(idl).process()
556 print json.dumps(schema, indent=2) 558 print json.dumps(schema, indent=2)
557 559
558 560
559 if __name__ == '__main__': 561 if __name__ == '__main__':
560 Main() 562 Main()
OLDNEW
« no previous file with comments | « tools/json_schema_compiler/h_generator.py ('k') | tools/json_schema_compiler/model.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698