| OLD | NEW |
| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 to see. | 175 to see. |
| 176 ''' | 176 ''' |
| 177 def __init__(self, member_node): | 177 def __init__(self, member_node): |
| 178 self.node = member_node | 178 self.node = member_node |
| 179 | 179 |
| 180 def process(self, callbacks, functions_are_properties=False): | 180 def process(self, callbacks, functions_are_properties=False): |
| 181 properties = OrderedDict() | 181 properties = OrderedDict() |
| 182 name = self.node.GetName() | 182 name = self.node.GetName() |
| 183 if self.node.GetProperty('deprecated'): | 183 if self.node.GetProperty('deprecated'): |
| 184 properties['deprecated'] = self.node.GetProperty('deprecated') | 184 properties['deprecated'] = self.node.GetProperty('deprecated') |
| 185 if self.node.GetProperty('allowAmbiguousOptionalArguments'): | 185 |
| 186 properties['allowAmbiguousOptionalArguments'] = True | 186 for property_name in ['allowAmbiguousOptionalArguments', 'forIOThread', |
| 187 for property_name in ('OPTIONAL', 'nodoc', 'nocompile', 'nodart', | 187 'nodoc', 'nocompile', 'nodart', 'nodefine']: |
| 188 'nodefine'): | |
| 189 if self.node.GetProperty(property_name): | 188 if self.node.GetProperty(property_name): |
| 190 properties[property_name.lower()] = True | 189 properties[property_name] = True |
| 190 |
| 191 if self.node.GetProperty('OPTIONAL'): |
| 192 properties['optional'] = True |
| 193 |
| 191 for option_name, sanitizer in [ | 194 for option_name, sanitizer in [ |
| 192 ('maxListeners', int), | 195 ('maxListeners', int), |
| 193 ('supportsFilters', lambda s: s == 'true'), | 196 ('supportsFilters', lambda s: s == 'true'), |
| 194 ('supportsListeners', lambda s: s == 'true'), | 197 ('supportsListeners', lambda s: s == 'true'), |
| 195 ('supportsRules', lambda s: s == 'true')]: | 198 ('supportsRules', lambda s: s == 'true')]: |
| 196 if self.node.GetProperty(option_name): | 199 if self.node.GetProperty(option_name): |
| 197 if 'options' not in properties: | 200 if 'options' not in properties: |
| 198 properties['options'] = {} | 201 properties['options'] = {} |
| 199 properties['options'][option_name] = sanitizer(self.node.GetProperty( | 202 properties['options'][option_name] = sanitizer(self.node.GetProperty( |
| 200 option_name)) | 203 option_name)) |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 print json.dumps(schema, indent=2) | 563 print json.dumps(schema, indent=2) |
| 561 else: | 564 else: |
| 562 contents = sys.stdin.read() | 565 contents = sys.stdin.read() |
| 563 idl = idl_parser.IDLParser().ParseData(contents, '<stdin>') | 566 idl = idl_parser.IDLParser().ParseData(contents, '<stdin>') |
| 564 schema = IDLSchema(idl).process() | 567 schema = IDLSchema(idl).process() |
| 565 print json.dumps(schema, indent=2) | 568 print json.dumps(schema, indent=2) |
| 566 | 569 |
| 567 | 570 |
| 568 if __name__ == '__main__': | 571 if __name__ == '__main__': |
| 569 Main() | 572 Main() |
| OLD | NEW |