Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 # http://www.w3.org/TR/WebIDL/#dfn-numeric-type | 31 # http://www.w3.org/TR/WebIDL/#dfn-numeric-type |
| 32 'float', | 32 'float', |
| 33 'unrestricted float', | 33 'unrestricted float', |
| 34 'double', | 34 'double', |
| 35 'unrestricted double', | 35 'unrestricted double', |
| 36 ])) | 36 ])) |
| 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://www.w3.org/TR/WebIDL/#idl-types | 41 # http://www.w3.org/TR/WebIDL/#idl-types |
|
Nils Barth (inactive)
2014/06/02 03:20:16
Could you update this link to the ED?
(Otherwise w
jsbell
2014/06/03 23:22:36
Done.
| |
| 42 'DOMString', | 42 'DOMString', |
| 43 'ByteString', | |
| 43 'Date', | 44 'Date', |
| 44 # http://www.w3.org/TR/WebIDL/#es-type-mapping | 45 # http://www.w3.org/TR/WebIDL/#es-type-mapping |
| 45 'void', | 46 'void', |
| 46 ])) | 47 ])) |
| 47 TYPE_NAMES = { | 48 TYPE_NAMES = { |
| 48 # http://heycam.github.io/webidl/#dfn-type-name | 49 # http://heycam.github.io/webidl/#dfn-type-name |
| 49 'any': 'Any', | 50 'any': 'Any', |
| 50 'boolean': 'Boolean', | 51 'boolean': 'Boolean', |
| 51 'byte': 'Byte', | 52 'byte': 'Byte', |
| 52 'octet': 'Octet', | 53 'octet': 'Octet', |
| 53 'short': 'Short', | 54 'short': 'Short', |
| 54 'unsigned short': 'UnsignedShort', | 55 'unsigned short': 'UnsignedShort', |
| 55 'long': 'Long', | 56 'long': 'Long', |
| 56 'unsigned long': 'UnsignedLong', | 57 'unsigned long': 'UnsignedLong', |
| 57 'long long': 'LongLong', | 58 'long long': 'LongLong', |
| 58 'unsigned long long': 'UnsignedLongLong', | 59 'unsigned long long': 'UnsignedLongLong', |
| 59 'float': 'Float', | 60 'float': 'Float', |
| 60 'unrestricted float': 'UnrestrictedFloat', | 61 'unrestricted float': 'UnrestrictedFloat', |
| 61 'double': 'Double', | 62 'double': 'Double', |
| 62 'unrestricted double': 'UnrestrictedDouble', | 63 'unrestricted double': 'UnrestrictedDouble', |
| 63 'DOMString': 'String', | 64 'DOMString': 'String', |
| 64 'ByteString': 'ByteString', | 65 'ByteString': 'ByteString', |
| 65 'object': 'Object', | 66 'object': 'Object', |
| 66 } | 67 } |
|
Nils Barth (inactive)
2014/06/02 03:20:16
Could you add
'Date': 'Date',
here?
jsbell
2014/06/03 23:22:36
Done.
| |
| 67 | 68 |
| 68 | 69 |
| 69 ################################################################################ | 70 ################################################################################ |
| 70 # Inheritance | 71 # Inheritance |
| 71 ################################################################################ | 72 ################################################################################ |
| 72 | 73 |
| 73 ancestors = defaultdict(list) # interface_name -> ancestors | 74 ancestors = defaultdict(list) # interface_name -> ancestors |
| 74 | 75 |
| 75 def inherits_interface(interface_name, ancestor_name): | 76 def inherits_interface(interface_name, ancestor_name): |
| 76 return (interface_name == ancestor_name or | 77 return (interface_name == ancestor_name or |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 307 | 308 |
| 308 @property | 309 @property |
| 309 def name(self): | 310 def name(self): |
| 310 return 'Or'.join(member_type.name for member_type in self.member_types) | 311 return 'Or'.join(member_type.name for member_type in self.member_types) |
| 311 | 312 |
| 312 def resolve_typedefs(self, typedefs): | 313 def resolve_typedefs(self, typedefs): |
| 313 self.member_types = [ | 314 self.member_types = [ |
| 314 typedefs.get(member_type, member_type) | 315 typedefs.get(member_type, member_type) |
| 315 for member_type in self.member_types] | 316 for member_type in self.member_types] |
| 316 return self | 317 return self |
| OLD | NEW |