Chromium Code Reviews| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 308 properties['type'] = 'object' | 308 properties['type'] = 'object' |
| 309 if 'additionalProperties' not in properties: | 309 if 'additionalProperties' not in properties: |
| 310 properties['additionalProperties'] = OrderedDict() | 310 properties['additionalProperties'] = OrderedDict() |
| 311 properties['additionalProperties']['type'] = 'any' | 311 properties['additionalProperties']['type'] = 'any' |
| 312 instance_of = self.parent.GetProperty('instanceOf') | 312 instance_of = self.parent.GetProperty('instanceOf') |
| 313 if instance_of: | 313 if instance_of: |
| 314 properties['isInstanceOf'] = instance_of | 314 properties['isInstanceOf'] = instance_of |
| 315 elif self.typeref == 'ArrayBuffer': | 315 elif self.typeref == 'ArrayBuffer': |
| 316 properties['type'] = 'binary' | 316 properties['type'] = 'binary' |
| 317 properties['isInstanceOf'] = 'ArrayBuffer' | 317 properties['isInstanceOf'] = 'ArrayBuffer' |
| 318 elif self.typeref == 'ArrayBufferView': | |
| 319 properties['type'] = 'binary' | |
| 320 # We force the APIs to specify instanceOf since ArrayBufferView isn't an | |
|
lazyboy
2017/06/24 00:53:16
nit: also add: therefore we don't specify instance
Devlin
2017/06/24 02:05:26
Done.
| |
| 321 # instantiable type. | |
| 318 elif self.typeref == 'FileEntry': | 322 elif self.typeref == 'FileEntry': |
| 319 properties['type'] = 'object' | 323 properties['type'] = 'object' |
| 320 properties['isInstanceOf'] = 'FileEntry' | 324 properties['isInstanceOf'] = 'FileEntry' |
| 321 if 'additionalProperties' not in properties: | 325 if 'additionalProperties' not in properties: |
| 322 properties['additionalProperties'] = OrderedDict() | 326 properties['additionalProperties'] = OrderedDict() |
| 323 properties['additionalProperties']['type'] = 'any' | 327 properties['additionalProperties']['type'] = 'any' |
| 324 elif self.parent.GetPropertyLocal('Union'): | 328 elif self.parent.GetPropertyLocal('Union'): |
| 325 properties['choices'] = [Typeref(node.GetProperty('TYPEREF'), | 329 properties['choices'] = [Typeref(node.GetProperty('TYPEREF'), |
| 326 node, | 330 node, |
| 327 OrderedDict()).process(callbacks) | 331 OrderedDict()).process(callbacks) |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 print json.dumps(schema, indent=2) | 567 print json.dumps(schema, indent=2) |
| 564 else: | 568 else: |
| 565 contents = sys.stdin.read() | 569 contents = sys.stdin.read() |
| 566 idl = idl_parser.IDLParser().ParseData(contents, '<stdin>') | 570 idl = idl_parser.IDLParser().ParseData(contents, '<stdin>') |
| 567 schema = IDLSchema(idl).process() | 571 schema = IDLSchema(idl).process() |
| 568 print json.dumps(schema, indent=2) | 572 print json.dumps(schema, indent=2) |
| 569 | 573 |
| 570 | 574 |
| 571 if __name__ == '__main__': | 575 if __name__ == '__main__': |
| 572 Main() | 576 Main() |
| OLD | NEW |