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://heycam.github.io/webidl/#idl-types |
42 'DOMString', | 42 'DOMString', |
| 43 'ByteString', |
43 'Date', | 44 'Date', |
44 # http://www.w3.org/TR/WebIDL/#es-type-mapping | 45 # http://heycam.github.io/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', |
| 67 'Date': 'Date', |
66 } | 68 } |
67 | 69 |
68 | 70 |
69 ################################################################################ | 71 ################################################################################ |
70 # Inheritance | 72 # Inheritance |
71 ################################################################################ | 73 ################################################################################ |
72 | 74 |
73 ancestors = defaultdict(list) # interface_name -> ancestors | 75 ancestors = defaultdict(list) # interface_name -> ancestors |
74 | 76 |
75 def inherits_interface(interface_name, ancestor_name): | 77 def inherits_interface(interface_name, ancestor_name): |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 309 |
308 @property | 310 @property |
309 def name(self): | 311 def name(self): |
310 return 'Or'.join(member_type.name for member_type in self.member_types) | 312 return 'Or'.join(member_type.name for member_type in self.member_types) |
311 | 313 |
312 def resolve_typedefs(self, typedefs): | 314 def resolve_typedefs(self, typedefs): |
313 self.member_types = [ | 315 self.member_types = [ |
314 typedefs.get(member_type, member_type) | 316 typedefs.get(member_type, member_type) |
315 for member_type in self.member_types] | 317 for member_type in self.member_types] |
316 return self | 318 return self |
OLD | NEW |