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, \ |
(...skipping 14 matching lines...) Expand all Loading... |
25 self._database = options.database | 25 self._database = options.database |
26 self._interface = interface | 26 self._interface = interface |
27 self._type_registry = options.type_registry | 27 self._type_registry = options.type_registry |
28 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) | 28 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) |
29 self._renamer = options.renamer | 29 self._renamer = options.renamer |
30 | 30 |
31 def EmitAttributeDocumentation(self, attribute): | 31 def EmitAttributeDocumentation(self, attribute): |
32 """ Emits the MDN dartdoc comment for an attribute. | 32 """ Emits the MDN dartdoc comment for an attribute. |
33 """ | 33 """ |
34 dom_name = DartDomNameOfAttribute(attribute) | 34 dom_name = DartDomNameOfAttribute(attribute) |
35 self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME;' | 35 self._members_emitter.Emit('\n /// @domName $DOMINTERFACE.$DOMNAME;' |
36 ' @docsEditable true */', | 36 ' @docsEditable true', |
37 DOMINTERFACE=attribute.doc_js_interface_name, | 37 DOMINTERFACE=attribute.doc_js_interface_name, |
38 DOMNAME=dom_name) | 38 DOMNAME=dom_name) |
39 | 39 |
40 def EmitOperationDocumentation(self, operation): | 40 def EmitOperationDocumentation(self, operation): |
41 """ Emits the MDN dartdoc comment for an operation. | 41 """ Emits the MDN dartdoc comment for an operation. |
42 """ | 42 """ |
43 self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME;' | 43 self._members_emitter.Emit('\n /// @domName $DOMINTERFACE.$DOMNAME;' |
44 ' @docsEditable true */', | 44 ' @docsEditable true', |
45 DOMINTERFACE=operation.overloads[0].doc_js_interface_name, | 45 DOMINTERFACE=operation.overloads[0].doc_js_interface_name, |
46 DOMNAME=operation.name) | 46 DOMNAME=operation.name) |
47 | 47 |
48 def EmitEventGetter(self, events_class_name): | 48 def EmitEventGetter(self, events_class_name): |
49 self._members_emitter.Emit( | 49 self._members_emitter.Emit( |
50 '\n /**' | 50 '\n /// @domName EventTarget.addEventListener, ' |
51 '\n * @domName EventTarget.addEventListener, ' | |
52 'EventTarget.removeEventListener, EventTarget.dispatchEvent;' | 51 'EventTarget.removeEventListener, EventTarget.dispatchEvent;' |
53 ' @docsEditable true' | 52 ' @docsEditable true' |
54 '\n */' | |
55 '\n $TYPE get on =>\n new $TYPE(this);\n', | 53 '\n $TYPE get on =>\n new $TYPE(this);\n', |
56 TYPE=events_class_name) | 54 TYPE=events_class_name) |
57 | 55 |
58 def AddMembers(self, interface, declare_only=False): | 56 def AddMembers(self, interface, declare_only=False): |
59 for const in sorted(interface.constants, ConstantOutputOrder): | 57 for const in sorted(interface.constants, ConstantOutputOrder): |
60 self.AddConstant(const) | 58 self.AddConstant(const) |
61 | 59 |
62 for attr in sorted(interface.attributes, ConstantOutputOrder): | 60 for attr in sorted(interface.attributes, ConstantOutputOrder): |
63 if attr.type.id != 'EventListener': | 61 if attr.type.id != 'EventListener': |
64 self.AddAttribute(attr, declare_only) | 62 self.AddAttribute(attr, declare_only) |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 walk(interface.parents) | 302 walk(interface.parents) |
305 else: | 303 else: |
306 walk(interface.parents[1:]) | 304 walk(interface.parents[1:]) |
307 return result | 305 return result |
308 | 306 |
309 def _DartType(self, type_name): | 307 def _DartType(self, type_name): |
310 return self._type_registry.DartType(type_name) | 308 return self._type_registry.DartType(type_name) |
311 | 309 |
312 def _IsPrivate(self, name): | 310 def _IsPrivate(self, name): |
313 return name.startswith('_') | 311 return name.startswith('_') |
OLD | NEW |