| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 """IDL type handling. | 4 """IDL type handling. |
| 5 | 5 |
| 6 Classes: | 6 Classes: |
| 7 IdlType | 7 IdlType |
| 8 IdlUnionType | 8 IdlUnionType |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 # http://www.w3.org/TR/WebIDL/#dfn-primitive-type | 37 # http://www.w3.org/TR/WebIDL/#dfn-primitive-type |
| 38 PRIMITIVE_TYPES = (frozenset(['boolean']) | NUMERIC_TYPES) | 38 PRIMITIVE_TYPES = (frozenset(['boolean']) | NUMERIC_TYPES) |
| 39 BASIC_TYPES = (PRIMITIVE_TYPES | frozenset([ | 39 BASIC_TYPES = (PRIMITIVE_TYPES | frozenset([ |
| 40 # Built-in, non-composite, non-object data types | 40 # Built-in, non-composite, non-object data types |
| 41 # http://heycam.github.io/webidl/#idl-types | 41 # http://heycam.github.io/webidl/#idl-types |
| 42 'DOMString', | 42 'DOMString', |
| 43 'ByteString', | 43 'ByteString', |
| 44 'Date', | 44 'Date', |
| 45 # http://heycam.github.io/webidl/#es-type-mapping | 45 # http://heycam.github.io/webidl/#es-type-mapping |
| 46 'void', | 46 'void', |
| 47 # http://encoding.spec.whatwg.org/#type-scalarvaluestring |
| 48 'ScalarValueString', |
| 47 ])) | 49 ])) |
| 48 TYPE_NAMES = { | 50 TYPE_NAMES = { |
| 49 # http://heycam.github.io/webidl/#dfn-type-name | 51 # http://heycam.github.io/webidl/#dfn-type-name |
| 50 'any': 'Any', | 52 'any': 'Any', |
| 51 'boolean': 'Boolean', | 53 'boolean': 'Boolean', |
| 52 'byte': 'Byte', | 54 'byte': 'Byte', |
| 53 'octet': 'Octet', | 55 'octet': 'Octet', |
| 54 'short': 'Short', | 56 'short': 'Short', |
| 55 'unsigned short': 'UnsignedShort', | 57 'unsigned short': 'UnsignedShort', |
| 56 'long': 'Long', | 58 'long': 'Long', |
| 57 'unsigned long': 'UnsignedLong', | 59 'unsigned long': 'UnsignedLong', |
| 58 'long long': 'LongLong', | 60 'long long': 'LongLong', |
| 59 'unsigned long long': 'UnsignedLongLong', | 61 'unsigned long long': 'UnsignedLongLong', |
| 60 'float': 'Float', | 62 'float': 'Float', |
| 61 'unrestricted float': 'UnrestrictedFloat', | 63 'unrestricted float': 'UnrestrictedFloat', |
| 62 'double': 'Double', | 64 'double': 'Double', |
| 63 'unrestricted double': 'UnrestrictedDouble', | 65 'unrestricted double': 'UnrestrictedDouble', |
| 64 'DOMString': 'String', | 66 'DOMString': 'String', |
| 65 'ByteString': 'ByteString', | 67 'ByteString': 'ByteString', |
| 68 'ScalarValueString': 'ScalarValueString', |
| 66 'object': 'Object', | 69 'object': 'Object', |
| 67 'Date': 'Date', | 70 'Date': 'Date', |
| 68 } | 71 } |
| 69 | 72 |
| 70 | 73 |
| 71 ################################################################################ | 74 ################################################################################ |
| 72 # Inheritance | 75 # Inheritance |
| 73 ################################################################################ | 76 ################################################################################ |
| 74 | 77 |
| 75 ancestors = defaultdict(list) # interface_name -> ancestors | 78 ancestors = defaultdict(list) # interface_name -> ancestors |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 | 312 |
| 310 @property | 313 @property |
| 311 def name(self): | 314 def name(self): |
| 312 return 'Or'.join(member_type.name for member_type in self.member_types) | 315 return 'Or'.join(member_type.name for member_type in self.member_types) |
| 313 | 316 |
| 314 def resolve_typedefs(self, typedefs): | 317 def resolve_typedefs(self, typedefs): |
| 315 self.member_types = [ | 318 self.member_types = [ |
| 316 typedefs.get(member_type, member_type) | 319 typedefs.get(member_type, member_type) |
| 317 for member_type in self.member_types] | 320 for member_type in self.member_types] |
| 318 return self | 321 return self |
| OLD | NEW |