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

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

Issue 11299047: Add constructors for SVG elements and remove static factory providers for html (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: capitalization fix 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/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, \
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 implements = [] 175 implements = []
176 if self._interface_type_info.is_typed_array(): 176 if self._interface_type_info.is_typed_array():
177 element_type = self._interface_type_info.list_item_type() 177 element_type = self._interface_type_info.list_item_type()
178 implements.append('List<%s>' % self._DartType(element_type)) 178 implements.append('List<%s>' % self._DartType(element_type))
179 if self._interface_type_info.list_item_type(): 179 if self._interface_type_info.list_item_type():
180 item_type_info = self._type_registry.TypeInfo( 180 item_type_info = self._type_registry.TypeInfo(
181 self._interface_type_info.list_item_type()) 181 self._interface_type_info.list_item_type())
182 implements.append('List<%s>' % item_type_info.dart_type()) 182 implements.append('List<%s>' % item_type_info.dart_type())
183 return implements 183 return implements
184 184
185 def AddConstructors(self, constructors, factory_provider, class_name, 185 def AddConstructors(self, constructors, factory_name, class_name,
186 base_class): 186 base_class, factory_constructor_name=None):
187 """ Adds all of the constructors. 187 """ Adds all of the constructors.
188 Arguments: 188 Arguments:
189 constructors - List of the constructors to be added. 189 constructors - List of the constructors to be added.
190 factory_provider - Name of the factory provider for this class. 190 factory_name - Name of the factory for this class.
191 class_name - The name of this class. 191 class_name - The name of this class.
192 base_class - The name of the base class which this extends. 192 base_class - The name of the base class which this extends.
193 factory_constructor_name - The name of the constructor on the
194 factory_name to call (calls an autogenerated FactoryProvider
195 if unspecified)
193 """ 196 """
194 for constructor_info in constructors: 197 for constructor_info in constructors:
195 self._AddConstructor(constructor_info, factory_provider) 198 self._AddConstructor(constructor_info, factory_name,
199 factory_constructor_name, constructor_info.factory_parameters)
196 200
197 typed_array_type = None 201 typed_array_type = None
198 for interface in self._database.Hierarchy(self._interface): 202 for interface in self._database.Hierarchy(self._interface):
199 type_info = self._type_registry.TypeInfo(interface.id) 203 type_info = self._type_registry.TypeInfo(interface.id)
200 if type_info.is_typed_array(): 204 if type_info.is_typed_array():
201 typed_array_type = type_info.list_item_type() 205 typed_array_type = type_info.list_item_type()
202 break 206 break
203 if typed_array_type: 207 if typed_array_type:
204 self._members_emitter.Emit( 208 self._members_emitter.Emit(
205 '\n' 209 '\n'
206 ' factory $CTOR(int length) =>\n' 210 ' factory $CTOR(int length) =>\n'
207 ' $FACTORY.create$(CTOR)(length);\n' 211 ' $FACTORY.create$(CTOR)(length);\n'
208 '\n' 212 '\n'
209 ' factory $CTOR.fromList(List<$TYPE> list) =>\n' 213 ' factory $CTOR.fromList(List<$TYPE> list) =>\n'
210 ' $FACTORY.create$(CTOR)_fromList(list);\n' 214 ' $FACTORY.create$(CTOR)_fromList(list);\n'
211 '\n' 215 '\n'
212 ' factory $CTOR.fromBuffer(ArrayBuffer buffer, ' 216 ' factory $CTOR.fromBuffer(ArrayBuffer buffer, '
213 '[int byteOffset, int length]) => \n' 217 '[int byteOffset, int length]) => \n'
214 ' $FACTORY.create$(CTOR)_fromBuffer(buffer, byteOffset, length);\n' , 218 ' $FACTORY.create$(CTOR)_fromBuffer(buffer, byteOffset, length);\n' ,
215 CTOR=self._interface.id, 219 CTOR=self._interface.id,
216 TYPE=self._DartType(typed_array_type), 220 TYPE=self._DartType(typed_array_type),
217 FACTORY=factory_provider) 221 FACTORY=factory_name)
218 222
219 def _AddConstructor(self, constructor_info, factory_provider): 223 def _AddConstructor(self, constructor_info, factory_name,
220 constructor_info.GenerateFactoryInvocation( 224 factory_constructor_name, factory_constructor_params):
221 self._DartType, self._members_emitter, factory_provider) 225 constructor_info.GenerateFactoryInvocation(
226 self._DartType, self._members_emitter, factory_name,
227 factory_constructor_name=factory_constructor_name,
228 factory_parameters=factory_constructor_params)
222 229
223 def DeclareAttribute(self, attribute, type_name, attr_name, read_only): 230 def DeclareAttribute(self, attribute, type_name, attr_name, read_only):
224 """ Declares an attribute but does not include the code to invoke it. 231 """ Declares an attribute but does not include the code to invoke it.
225 """ 232 """
226 self.EmitAttributeDocumentation(attribute) 233 self.EmitAttributeDocumentation(attribute)
227 if read_only: 234 if read_only:
228 template = '\n $TYPE get $NAME;\n' 235 template = '\n $TYPE get $NAME;\n'
229 else: 236 else:
230 template = '\n $TYPE $NAME;\n' 237 template = '\n $TYPE $NAME;\n'
231 238
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 walk(interface.parents) 301 walk(interface.parents)
295 else: 302 else:
296 walk(interface.parents[1:]) 303 walk(interface.parents[1:])
297 return result 304 return result
298 305
299 def _DartType(self, type_name): 306 def _DartType(self, type_name):
300 return self._type_registry.DartType(type_name) 307 return self._type_registry.DartType(type_name)
301 308
302 def _IsPrivate(self, name): 309 def _IsPrivate(self, name):
303 return name.startswith('_') 310 return name.startswith('_')
OLDNEW
« no previous file with comments | « sdk/lib/html/scripts/generator.py ('k') | sdk/lib/html/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698