| 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 IdlTypeBase | 7 IdlTypeBase |
| 8 IdlType | 8 IdlType |
| 9 IdlUnionType | 9 IdlUnionType |
| 10 IdlArrayOrSequenceType | 10 IdlArrayOrSequenceType |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 'double', | 39 'double', |
| 40 'unrestricted double', | 40 'unrestricted double', |
| 41 ])) | 41 ])) |
| 42 # http://www.w3.org/TR/WebIDL/#dfn-primitive-type | 42 # http://www.w3.org/TR/WebIDL/#dfn-primitive-type |
| 43 PRIMITIVE_TYPES = (frozenset(['boolean']) | NUMERIC_TYPES) | 43 PRIMITIVE_TYPES = (frozenset(['boolean']) | NUMERIC_TYPES) |
| 44 BASIC_TYPES = (PRIMITIVE_TYPES | frozenset([ | 44 BASIC_TYPES = (PRIMITIVE_TYPES | frozenset([ |
| 45 # Built-in, non-composite, non-object data types | 45 # Built-in, non-composite, non-object data types |
| 46 # http://heycam.github.io/webidl/#idl-types | 46 # http://heycam.github.io/webidl/#idl-types |
| 47 'DOMString', | 47 'DOMString', |
| 48 'ByteString', | 48 'ByteString', |
| 49 'USVString', |
| 49 'Date', | 50 'Date', |
| 50 # http://heycam.github.io/webidl/#es-type-mapping | 51 # http://heycam.github.io/webidl/#idl-types |
| 51 'void', | 52 'void', |
| 52 # http://encoding.spec.whatwg.org/#type-scalarvaluestring | |
| 53 'ScalarValueString', | |
| 54 ])) | 53 ])) |
| 55 TYPE_NAMES = { | 54 TYPE_NAMES = { |
| 56 # http://heycam.github.io/webidl/#dfn-type-name | 55 # http://heycam.github.io/webidl/#dfn-type-name |
| 57 'any': 'Any', | 56 'any': 'Any', |
| 58 'boolean': 'Boolean', | 57 'boolean': 'Boolean', |
| 59 'byte': 'Byte', | 58 'byte': 'Byte', |
| 60 'octet': 'Octet', | 59 'octet': 'Octet', |
| 61 'short': 'Short', | 60 'short': 'Short', |
| 62 'unsigned short': 'UnsignedShort', | 61 'unsigned short': 'UnsignedShort', |
| 63 'long': 'Long', | 62 'long': 'Long', |
| 64 'unsigned long': 'UnsignedLong', | 63 'unsigned long': 'UnsignedLong', |
| 65 'long long': 'LongLong', | 64 'long long': 'LongLong', |
| 66 'unsigned long long': 'UnsignedLongLong', | 65 'unsigned long long': 'UnsignedLongLong', |
| 67 'float': 'Float', | 66 'float': 'Float', |
| 68 'unrestricted float': 'UnrestrictedFloat', | 67 'unrestricted float': 'UnrestrictedFloat', |
| 69 'double': 'Double', | 68 'double': 'Double', |
| 70 'unrestricted double': 'UnrestrictedDouble', | 69 'unrestricted double': 'UnrestrictedDouble', |
| 71 'DOMString': 'String', | 70 'DOMString': 'String', |
| 72 'ByteString': 'ByteString', | 71 'ByteString': 'ByteString', |
| 73 'ScalarValueString': 'ScalarValueString', | 72 'USVString': 'USVString', |
| 74 'object': 'Object', | 73 'object': 'Object', |
| 75 'Date': 'Date', | 74 'Date': 'Date', |
| 76 } | 75 } |
| 77 | 76 |
| 78 STRING_TYPES = frozenset([ | 77 STRING_TYPES = frozenset([ |
| 79 # http://heycam.github.io/webidl/#es-interface-call (step 10.11) | 78 # http://heycam.github.io/webidl/#es-interface-call (step 10.11) |
| 80 # (Interface object [[Call]] method's string types.) | 79 # (Interface object [[Call]] method's string types.) |
| 81 'String', | 80 'String', |
| 82 'ByteString', | 81 'ByteString', |
| 83 'ScalarValueString', | 82 'USVString', |
| 84 ]) | 83 ]) |
| 85 | 84 |
| 86 | 85 |
| 87 ################################################################################ | 86 ################################################################################ |
| 88 # Inheritance | 87 # Inheritance |
| 89 ################################################################################ | 88 ################################################################################ |
| 90 | 89 |
| 91 ancestors = defaultdict(list) # interface_name -> ancestors | 90 ancestors = defaultdict(list) # interface_name -> ancestors |
| 92 | 91 |
| 93 def inherits_interface(interface_name, ancestor_name): | 92 def inherits_interface(interface_name, ancestor_name): |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 def is_nullable(self): | 323 def is_nullable(self): |
| 325 return True | 324 return True |
| 326 | 325 |
| 327 @property | 326 @property |
| 328 def name(self): | 327 def name(self): |
| 329 return self.inner_type.name + 'OrNull' | 328 return self.inner_type.name + 'OrNull' |
| 330 | 329 |
| 331 def resolve_typedefs(self, typedefs): | 330 def resolve_typedefs(self, typedefs): |
| 332 self.inner_type = self.inner_type.resolve_typedefs(typedefs) | 331 self.inner_type = self.inner_type.resolve_typedefs(typedefs) |
| 333 return self | 332 return self |
| OLD | NEW |