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

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: Fixing merged classes in dartium not compiling under dartc. 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
« no previous file with comments | « sdk/lib/html/scripts/generator.py ('k') | sdk/lib/html/scripts/htmleventgenerator.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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."""
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)
67
68 def DeclareAttribute(self, attribute, type_name, html_name, read_only):
69 # Declares an attribute but does not include the code to invoke it.
70 self.EmitAttributeDocumentation(attribute)
71 if read_only:
72 template = '\n $TYPE get $NAME;\n'
73 else:
74 template = '\n $TYPE $NAME;\n'
75
76 self._members_emitter.Emit(template,
77 NAME=html_name,
78 TYPE=type_name)
79
80 def DeclareOperation(self, operation, type_name, html_name):
81 # Declares an operation but does not include the code to invoke it.
82 self.EmitOperationDocumentation(operation)
83 self._members_emitter.Emit(
84 '\n'
85 ' $TYPE $NAME($PARAMS);\n',
86 TYPE=type_name,
87 NAME=html_name,
88 PARAMS=operation.ParametersDeclaration(self._DartType))
OLDNEW
« no previous file with comments | « sdk/lib/html/scripts/generator.py ('k') | sdk/lib/html/scripts/htmleventgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698