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

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

Issue 143473003: Generate ax enums from idl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use single quotes, add comment, rename absolute to literalvalues Created 6 years, 11 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 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 raise ValueError('Did not process %s %s' % (child.cls, child)) 300 raise ValueError('Did not process %s %s' % (child.cls, child))
301 enum.append(enum_value) 301 enum.append(enum_value)
302 elif node.cls == 'Comment': 302 elif node.cls == 'Comment':
303 self.description = ProcessComment(node.GetName())[0] 303 self.description = ProcessComment(node.GetName())[0]
304 else: 304 else:
305 sys.exit('Did not process %s %s' % (node.cls, node)) 305 sys.exit('Did not process %s %s' % (node.cls, node))
306 result = {'id' : self.node.GetName(), 306 result = {'id' : self.node.GetName(),
307 'description': self.description, 307 'description': self.description,
308 'type': 'string', 308 'type': 'string',
309 'enum': enum} 309 'enum': enum}
310 for property_name in ('inline_doc', 'noinline_doc', 'nodoc'): 310 for property_name in (
311 'inline_doc', 'noinline_doc', 'nodoc', 'literalvalues',):
311 if self.node.GetProperty(property_name): 312 if self.node.GetProperty(property_name):
312 result[property_name] = True 313 result[property_name] = True
313 return result 314 return result
314 315
315 316
316 class Namespace(object): 317 class Namespace(object):
317 ''' 318 '''
318 Given an IDLNode representing an IDL namespace, converts into a Python 319 Given an IDLNode representing an IDL namespace, converts into a Python
319 dictionary that the JSON schema compiler expects to see. 320 dictionary that the JSON schema compiler expects to see.
320 ''' 321 '''
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 Dump a json serialization of parse result for the IDL files whose names 447 Dump a json serialization of parse result for the IDL files whose names
447 were passed in on the command line. 448 were passed in on the command line.
448 ''' 449 '''
449 for filename in sys.argv[1:]: 450 for filename in sys.argv[1:]:
450 schema = Load(filename) 451 schema = Load(filename)
451 print json.dumps(schema, indent=2) 452 print json.dumps(schema, indent=2)
452 453
453 454
454 if __name__ == '__main__': 455 if __name__ == '__main__':
455 Main() 456 Main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698