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

Side by Side Diff: sdk/lib/html/scripts/htmldartgenerator.py

Issue 11365019: Merging dart:html interfaces and implementations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merging with latest. Created 8 years, 1 month 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
OLDNEW
(Empty)
1 #!/usr/bin/python
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
4 # BSD-style license that can be found in the LICENSE file.
5
6 """This module provides shared functionality for the system to generate
7 Dart:html APIs from the IDL database."""
Anton Muhin 2012/11/06 12:28:43 nit: dart:html
blois 2012/11/06 22:11:44 Done.
8
9 from generator import DartDomNameOfAttribute
10
11 class HtmlDartGenerator(object):
12 def __init__(self, interface, options):
13 self._interface = interface
14
15 def EmitAttributeDocumentation(self, attribute):
16 dom_name = DartDomNameOfAttribute(attribute)
17 self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME */',
18 DOMINTERFACE=attribute.doc_js_interface_name,
19 DOMNAME=dom_name)
20
21 def EmitOperationDocumentation(self, operation):
22 self._members_emitter.Emit('\n /** @domName $DOMINTERFACE.$DOMNAME */',
23 DOMINTERFACE=operation.overloads[0].doc_js_interface_name,
24 DOMNAME=operation.name)
25
26 def AdditionalImplementedInterfaces(self):
27 # TODO: Include all implemented interfaces, including other Lists.
28 implements = []
29 if self._interface_type_info.is_typed_array():
30 element_type = self._interface_type_info.list_item_type()
31 implements.append('List<%s>' % self._DartType(element_type))
32 if self._interface_type_info.list_item_type():
33 item_type_info = self._type_registry.TypeInfo(
34 self._interface_type_info.list_item_type())
35 implements.append('List<%s>' % item_type_info.dart_type())
36 return implements
37
38 def AddConstructors(self, constructors, factory_provider, class_name,
39 base_class):
40 for constructor_info in constructors:
41 self._AddConstructor(constructor_info, factory_provider)
42
43 typed_array_type = None
44 for interface in self._database.Hierarchy(self._interface):
45 type_info = self._type_registry.TypeInfo(interface.id)
46 if type_info.is_typed_array():
47 typed_array_type = type_info.list_item_type()
48 break
49 if typed_array_type:
50 self._members_emitter.Emit(
51 '\n'
52 ' factory $CTOR(int length) =>\n'
53 ' $FACTORY.create$(CTOR)(length);\n'
54 '\n'
55 ' factory $CTOR.fromList(List<$TYPE> list) =>\n'
56 ' $FACTORY.create$(CTOR)_fromList(list);\n'
57 '\n'
58 ' factory $CTOR.fromBuffer(ArrayBuffer buffer, [int byteOffset, int l ength]) => \n'
59 ' $FACTORY.create$(CTOR)_fromBuffer(buffer, byteOffset, length);\n' ,
60 CTOR=self._interface.id,
61 TYPE=self._DartType(typed_array_type),
62 FACTORY=factory_provider)
63
64 def _AddConstructor(self, constructor_info, factory_provider):
65 constructor_info.GenerateFactoryInvocation(
66 self._DartType, self._members_emitter, factory_provider)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698