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 json | 6 import json |
7 import os.path | 7 import os.path |
8 import re | 8 import re |
9 import sys | 9 import sys |
10 | 10 |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 if self.typeref == 'DOMString': | 183 if self.typeref == 'DOMString': |
184 properties['type'] = 'string' | 184 properties['type'] = 'string' |
185 elif self.typeref == 'boolean': | 185 elif self.typeref == 'boolean': |
186 properties['type'] = 'boolean' | 186 properties['type'] = 'boolean' |
187 elif self.typeref == 'double': | 187 elif self.typeref == 'double': |
188 properties['type'] = 'number' | 188 properties['type'] = 'number' |
189 elif self.typeref == 'long': | 189 elif self.typeref == 'long': |
190 properties['type'] = 'integer' | 190 properties['type'] = 'integer' |
191 elif self.typeref == 'any': | 191 elif self.typeref == 'any': |
192 properties['type'] = 'any' | 192 properties['type'] = 'any' |
193 elif self.typeref == 'ArrayBuffer' or self.typeref == 'object': | 193 elif self.typeref == 'object': |
194 properties['type'] = 'object' | 194 properties['type'] = 'object' |
195 if 'additionalProperties' not in properties: | 195 if 'additionalProperties' not in properties: |
196 properties['additionalProperties'] = {} | 196 properties['additionalProperties'] = {} |
197 properties['additionalProperties']['type'] = 'any' | 197 properties['additionalProperties']['type'] = 'any' |
198 instance_of = self.parent.GetProperty('instanceOf') | 198 instance_of = self.parent.GetProperty('instanceOf') |
199 if self.typeref == 'ArrayBuffer': | 199 if instance_of: |
200 properties['isInstanceOf'] = 'ArrayBuffer' | |
201 elif instance_of: | |
202 properties['isInstanceOf'] = instance_of | 200 properties['isInstanceOf'] = instance_of |
| 201 elif self.typeref == 'ArrayBuffer': |
| 202 properties['type'] = 'binary' |
| 203 properties['isInstanceOf'] = 'ArrayBuffer' |
203 elif self.typeref is None: | 204 elif self.typeref is None: |
204 properties['type'] = 'function' | 205 properties['type'] = 'function' |
205 else: | 206 else: |
206 if self.typeref in callbacks: | 207 if self.typeref in callbacks: |
207 properties.update(callbacks[self.typeref]) | 208 properties.update(callbacks[self.typeref]) |
208 else: | 209 else: |
209 properties['$ref'] = self.typeref | 210 properties['$ref'] = self.typeref |
210 | 211 |
211 return result | 212 return result |
212 | 213 |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 ''' | 305 ''' |
305 Dump a json serialization of parse result for the IDL files whose names | 306 Dump a json serialization of parse result for the IDL files whose names |
306 were passed in on the command line. | 307 were passed in on the command line. |
307 ''' | 308 ''' |
308 for filename in sys.argv[1:]: | 309 for filename in sys.argv[1:]: |
309 schema = Load(filename) | 310 schema = Load(filename) |
310 print json.dumps(schema, indent=2) | 311 print json.dumps(schema, indent=2) |
311 | 312 |
312 if __name__ == '__main__': | 313 if __name__ == '__main__': |
313 Main() | 314 Main() |
OLD | NEW |