Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(402)

Side by Side Diff: tools/dom/scripts/htmldartgenerator.py

Issue 11887006: Changed @domName annotation in comment to full fledge @DomName annotation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/dom/scripts/generator.py ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, FindCommonAnnotations
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 }
(...skipping 11 matching lines...) Expand all
33 if self.HasSupportCheck(): 33 if self.HasSupportCheck():
34 support_check = self.GetSupportCheck() 34 support_check = self.GetSupportCheck()
35 self._members_emitter.Emit('\n' 35 self._members_emitter.Emit('\n'
36 ' /// Checks if this type is supported on the current platform.\n' 36 ' /// Checks if this type is supported on the current platform.\n'
37 ' static bool get supported => $SUPPORT_CHECK;\n', 37 ' static bool get supported => $SUPPORT_CHECK;\n',
38 SUPPORT_CHECK=support_check) 38 SUPPORT_CHECK=support_check)
39 39
40 def EmitAttributeDocumentation(self, attribute): 40 def EmitAttributeDocumentation(self, attribute):
41 """ Emits the MDN dartdoc comment for an attribute. 41 """ Emits the MDN dartdoc comment for an attribute.
42 """ 42 """
43
43 dom_name = DartDomNameOfAttribute(attribute) 44 dom_name = DartDomNameOfAttribute(attribute)
44 self._members_emitter.Emit('\n /// @domName $DOMINTERFACE.$DOMNAME;' 45
45 ' @docsEditable true', 46 annotations = FindCommonAnnotations(dom_name)
47 annotations_str = ''
48 if annotations:
49 annotations_str = '\n' + '\n'.join(annotations)
50 self._members_emitter.Emit('\n /// @docsEditable true',
46 DOMINTERFACE=attribute.doc_js_interface_name, 51 DOMINTERFACE=attribute.doc_js_interface_name,
47 DOMNAME=dom_name) 52 ANNOTATIONS=annotations)
48 53
49 def EmitOperationDocumentation(self, operation): 54 def EmitOperationDocumentation(self, operation):
50 """ Emits the MDN dartdoc comment for an operation. 55 """ Emits the MDN dartdoc comment for an operation.
51 """ 56 """
52 self._members_emitter.Emit('\n /// @domName $DOMINTERFACE.$DOMNAME;' 57
53 ' @docsEditable true', 58 annotations = FindCommonAnnotations(operation.name)
59 annotations_str = ''
60 if annotations:
61 annotations_str = '\n' + '\n'.join(annotations)
62 self._members_emitter.Emit('\n /// @docsEditable true',
54 DOMINTERFACE=operation.overloads[0].doc_js_interface_name, 63 DOMINTERFACE=operation.overloads[0].doc_js_interface_name,
55 DOMNAME=operation.name) 64 ANNOTATIONS=annotations)
56 65
57 def EmitEventGetter(self, events_class_name): 66 def EmitEventGetter(self, events_class_name):
58 self._members_emitter.Emit( 67 self._members_emitter.Emit(
59 '\n /// @domName EventTarget.addEventListener, ' 68 "\n /// @docsEditable true"
60 'EventTarget.removeEventListener, EventTarget.dispatchEvent;' 69 "\n @DomName('EventTarget.addEventListener, "
61 ' @docsEditable true' 70 "EventTarget.removeEventListener, EventTarget.dispatchEvent')"
62 '\n $TYPE get on =>\n new $TYPE(this);\n', 71 "\n $TYPE get on =>\n new $TYPE(this);\n",
63 TYPE=events_class_name) 72 TYPE=events_class_name)
64 73
65 def AddMembers(self, interface, declare_only=False): 74 def AddMembers(self, interface, declare_only=False):
66 for const in sorted(interface.constants, ConstantOutputOrder): 75 for const in sorted(interface.constants, ConstantOutputOrder):
67 self.AddConstant(const) 76 self.AddConstant(const)
68 77
69 for attr in sorted(interface.attributes, ConstantOutputOrder): 78 for attr in sorted(interface.attributes, ConstantOutputOrder):
70 if attr.type.id != 'EventListener': 79 if attr.type.id != 'EventListener':
71 self.AddAttribute(attr, declare_only) 80 self.AddAttribute(attr, declare_only)
72 81
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 '\n' 295 '\n'
287 ' factory $CTOR.fromBuffer(ArrayBuffer buffer, ' 296 ' factory $CTOR.fromBuffer(ArrayBuffer buffer, '
288 '[int byteOffset, int length]) => \n' 297 '[int byteOffset, int length]) => \n'
289 ' $FACTORY.create$(CTOR)_fromBuffer(buffer, byteOffset, length);\n' , 298 ' $FACTORY.create$(CTOR)_fromBuffer(buffer, byteOffset, length);\n' ,
290 CTOR=self._interface.id, 299 CTOR=self._interface.id,
291 TYPE=self._DartType(typed_array_type), 300 TYPE=self._DartType(typed_array_type),
292 FACTORY=factory_name) 301 FACTORY=factory_name)
293 302
294 def _AddConstructor(self, 303 def _AddConstructor(self,
295 constructor_info, factory_name, factory_constructor_name): 304 constructor_info, factory_name, factory_constructor_name):
296 self._members_emitter.Emit('\n ///@docsEditable true'); 305 self._members_emitter.Emit('\n /// @docsEditable true');
297 306
298 if not factory_constructor_name: 307 if not factory_constructor_name:
299 factory_constructor_name = '_create' 308 factory_constructor_name = '_create'
300 factory_parameters = constructor_info.ParametersAsArgumentList() 309 factory_parameters = constructor_info.ParametersAsArgumentList()
301 has_factory_provider = True 310 has_factory_provider = True
302 else: 311 else:
303 factory_parameters = ', '.join(constructor_info.factory_parameters) 312 factory_parameters = ', '.join(constructor_info.factory_parameters)
304 has_factory_provider = False 313 has_factory_provider = False
305 314
306 has_optional = any(param_info.is_optional 315 has_optional = any(param_info.is_optional
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 walk(interface.parents) 471 walk(interface.parents)
463 else: 472 else:
464 walk(interface.parents[1:]) 473 walk(interface.parents[1:])
465 return result 474 return result
466 475
467 def _DartType(self, type_name): 476 def _DartType(self, type_name):
468 return self._type_registry.DartType(type_name) 477 return self._type_registry.DartType(type_name)
469 478
470 def _IsPrivate(self, name): 479 def _IsPrivate(self, name):
471 return name.startswith('_') 480 return name.startswith('_')
OLDNEW
« no previous file with comments | « tools/dom/scripts/generator.py ('k') | tools/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698