| 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 the system to generate | 6 """This module provides shared functionality for the system to generate |
| 7 dart:html APIs from the IDL database.""" | 7 dart:html APIs from the IDL database.""" |
| 8 | 8 |
| 9 from generator import AnalyzeOperation, ConstantOutputOrder, \ | 9 from generator import AnalyzeOperation, ConstantOutputOrder, \ |
| 10 DartDomNameOfAttribute, FindMatchingAttribute, IsDartCollectionType, \ | 10 DartDomNameOfAttribute, FindMatchingAttribute, IsDartCollectionType, \ |
| 11 IsPureInterface, TypeOrNothing | 11 IsPureInterface, TypeOrNothing |
| 12 | 12 |
| 13 # Types that are accessible cross-frame in a limited fashion. | 13 # Types that are accessible cross-frame in a limited fashion. |
| 14 # In these cases, the base type (e.g., WindowBase) provides restricted access | 14 # In these cases, the base type (e.g., WindowBase) provides restricted access |
| 15 # while the subtype (e.g., Window) provides full access to the | 15 # while the subtype (e.g., Window) provides full access to the |
| 16 # corresponding objects if there are from the same frame. | 16 # corresponding objects if there are from the same frame. |
| 17 _secure_base_types = { | 17 _secure_base_types = { |
| 18 'Window': 'WindowBase', | 18 'Window': 'WindowBase', |
| 19 'Location': 'LocationBase', | 19 'Location': 'LocationBase', |
| 20 'History': 'HistoryBase', | 20 'History': 'HistoryBase', |
| 21 } | 21 } |
| 22 | 22 |
| 23 |
| 23 class HtmlDartGenerator(object): | 24 class HtmlDartGenerator(object): |
| 24 def __init__(self, interface, options): | 25 def __init__(self, interface, options): |
| 25 self._database = options.database | 26 self._database = options.database |
| 26 self._interface = interface | 27 self._interface = interface |
| 27 self._type_registry = options.type_registry | 28 self._type_registry = options.type_registry |
| 28 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) | 29 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) |
| 29 self._renamer = options.renamer | 30 self._renamer = options.renamer |
| 30 | 31 |
| 32 def EmitSupportCheck(self): |
| 33 if self.HasSupportCheck(): |
| 34 support_check = self.GetSupportCheck() |
| 35 self._members_emitter.Emit('\n' |
| 36 ' /**\n' |
| 37 ' * Checks if this type is supported on the current platform\n' |
| 38 ' */\n' |
| 39 ' static bool get supported => $SUPPORT_CHECK;\n', |
| 40 SUPPORT_CHECK=support_check) |
| 41 |
| 31 def EmitAttributeDocumentation(self, attribute): | 42 def EmitAttributeDocumentation(self, attribute): |
| 32 """ Emits the MDN dartdoc comment for an attribute. | 43 """ Emits the MDN dartdoc comment for an attribute. |
| 33 """ | 44 """ |
| 34 dom_name = DartDomNameOfAttribute(attribute) | 45 dom_name = DartDomNameOfAttribute(attribute) |
| 35 self._members_emitter.Emit('\n /// @domName $DOMINTERFACE.$DOMNAME;' | 46 self._members_emitter.Emit('\n /// @domName $DOMINTERFACE.$DOMNAME;' |
| 36 ' @docsEditable true', | 47 ' @docsEditable true', |
| 37 DOMINTERFACE=attribute.doc_js_interface_name, | 48 DOMINTERFACE=attribute.doc_js_interface_name, |
| 38 DOMNAME=dom_name) | 49 DOMNAME=dom_name) |
| 39 | 50 |
| 40 def EmitOperationDocumentation(self, operation): | 51 def EmitOperationDocumentation(self, operation): |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 walk(interface.parents) | 362 walk(interface.parents) |
| 352 else: | 363 else: |
| 353 walk(interface.parents[1:]) | 364 walk(interface.parents[1:]) |
| 354 return result | 365 return result |
| 355 | 366 |
| 356 def _DartType(self, type_name): | 367 def _DartType(self, type_name): |
| 357 return self._type_registry.DartType(type_name) | 368 return self._type_registry.DartType(type_name) |
| 358 | 369 |
| 359 def _IsPrivate(self, name): | 370 def _IsPrivate(self, name): |
| 360 return name.startswith('_') | 371 return name.startswith('_') |
| OLD | NEW |