OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 """This module provides shared functionality for systems to generate | 6 """This module provides shared functionality for systems to generate |
7 Dart APIs from the IDL database.""" | 7 Dart APIs from the IDL database.""" |
8 | 8 |
9 import copy | 9 import copy |
10 import json | 10 import json |
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 | 1537 |
1538 def _TypeInfo(self, type_name): | 1538 def _TypeInfo(self, type_name): |
1539 match = re.match(r'(?:sequence<(\w+)>|(\w+)\[\])$', type_name) | 1539 match = re.match(r'(?:sequence<(\w+)>|(\w+)\[\])$', type_name) |
1540 if match: | 1540 if match: |
1541 if type_name == 'DOMString[]': | 1541 if type_name == 'DOMString[]': |
1542 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt
ring')) | 1542 return DOMStringArrayTypeInfo(TypeData('Sequence'), self.TypeInfo('DOMSt
ring')) |
1543 item_info = self.TypeInfo(match.group(1) or match.group(2)) | 1543 item_info = self.TypeInfo(match.group(1) or match.group(2)) |
1544 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info) | 1544 return SequenceIDLTypeInfo(type_name, TypeData('Sequence'), item_info) |
1545 | 1545 |
1546 if not type_name in _idl_type_registry: | 1546 if not type_name in _idl_type_registry: |
| 1547 if self._database.HasEnum(type_name): |
| 1548 return PrimitiveIDLTypeInfo( |
| 1549 type_name, |
| 1550 TypeData(clazz='Primitive', dart_type='String', native_type='String'
)) |
| 1551 |
1547 interface = self._database.GetInterface(type_name) | 1552 interface = self._database.GetInterface(type_name) |
1548 if 'Callback' in interface.ext_attrs: | 1553 if 'Callback' in interface.ext_attrs: |
1549 return CallbackIDLTypeInfo(type_name, TypeData('Callback', | 1554 return CallbackIDLTypeInfo(type_name, TypeData('Callback', |
1550 self._renamer.DartifyTypeName(type_name))) | 1555 self._renamer.DartifyTypeName(type_name))) |
1551 return InterfaceIDLTypeInfo( | 1556 return InterfaceIDLTypeInfo( |
1552 type_name, | 1557 type_name, |
1553 TypeData('Interface'), | 1558 TypeData('Interface'), |
1554 self._renamer.RenameInterface(interface), | 1559 self._renamer.RenameInterface(interface), |
1555 self) | 1560 self) |
1556 | 1561 |
1557 type_data = _idl_type_registry.get(type_name) | 1562 type_data = _idl_type_registry.get(type_name) |
1558 | 1563 |
1559 if type_data.clazz == 'Interface': | 1564 if type_data.clazz == 'Interface': |
1560 if self._database.HasInterface(type_name): | 1565 if self._database.HasInterface(type_name): |
1561 dart_interface_name = self._renamer.RenameInterface( | 1566 dart_interface_name = self._renamer.RenameInterface( |
1562 self._database.GetInterface(type_name)) | 1567 self._database.GetInterface(type_name)) |
1563 else: | 1568 else: |
1564 dart_interface_name = self._renamer.DartifyTypeName(type_name) | 1569 dart_interface_name = self._renamer.DartifyTypeName(type_name) |
1565 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name, | 1570 return InterfaceIDLTypeInfo(type_name, type_data, dart_interface_name, |
1566 self) | 1571 self) |
1567 | 1572 |
1568 if type_data.clazz == 'SVGTearOff': | 1573 if type_data.clazz == 'SVGTearOff': |
1569 dart_interface_name = self._renamer.RenameInterface( | 1574 dart_interface_name = self._renamer.RenameInterface( |
1570 self._database.GetInterface(type_name)) | 1575 self._database.GetInterface(type_name)) |
1571 return SVGTearOffIDLTypeInfo( | 1576 return SVGTearOffIDLTypeInfo( |
1572 type_name, type_data, dart_interface_name, self) | 1577 type_name, type_data, dart_interface_name, self) |
1573 | 1578 |
1574 class_name = '%sIDLTypeInfo' % type_data.clazz | 1579 class_name = '%sIDLTypeInfo' % type_data.clazz |
1575 return globals()[class_name](type_name, type_data) | 1580 return globals()[class_name](type_name, type_data) |
OLD | NEW |