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

Side by Side Diff: lib/dom/scripts/systemfrog.py

Issue 9959048: Remove unused typed array factory constructors. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 8 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 | « lib/dom/scripts/generator.py ('k') | lib/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 systems to generate 6 """This module provides shared functionality for the systems to generate
7 frog binding from the IDL database.""" 7 frog binding from the IDL database."""
8 8
9 import os 9 import os
10 from generator import * 10 from generator import *
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 self._members_emitter = self._dart_code.Emit( 121 self._members_emitter = self._dart_code.Emit(
122 self._template, 122 self._template,
123 #class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC { 123 #class $CLASSNAME$EXTENDS$IMPLEMENTS$NATIVESPEC {
124 #$!MEMBERS 124 #$!MEMBERS
125 #} 125 #}
126 CLASSNAME=self._class_name, 126 CLASSNAME=self._class_name,
127 EXTENDS=extends, 127 EXTENDS=extends,
128 IMPLEMENTS=' implements ' + ', '.join(implements), 128 IMPLEMENTS=' implements ' + ', '.join(implements),
129 NATIVESPEC=' native "' + native_spec + '"') 129 NATIVESPEC=' native "' + native_spec + '"')
130 130
131 element_type = MaybeTypedArrayElementType(interface)
132 if element_type:
133 self.AddTypedArrayConstructors(element_type)
134
135 # Emit a factory provider class for the constructor. 131 # Emit a factory provider class for the constructor.
136 constructor_info = AnalyzeConstructor(interface) 132 constructor_info = AnalyzeConstructor(interface)
137 if constructor_info: 133 if constructor_info:
138 self._EmitFactoryProvider(interface_name, constructor_info) 134 self._EmitFactoryProvider(interface_name, constructor_info)
139 135
140 136
141 def FinishInterface(self): 137 def FinishInterface(self):
142 """.""" 138 """."""
143 pass 139 pass
144 140
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 ' }\n', 334 ' }\n',
339 TYPE=self._NarrowInputType(element_type)) 335 TYPE=self._NarrowInputType(element_type))
340 336
341 # TODO(sra): Use separate mixins for mutable implementations of List<T>. 337 # TODO(sra): Use separate mixins for mutable implementations of List<T>.
342 # TODO(sra): Use separate mixins for typed array implementations of List<T>. 338 # TODO(sra): Use separate mixins for typed array implementations of List<T>.
343 template_file = 'immutable_list_mixin.darttemplate' 339 template_file = 'immutable_list_mixin.darttemplate'
344 template = self._system._templates.Load(template_file) 340 template = self._system._templates.Load(template_file)
345 self._members_emitter.Emit(template, E=DartType(element_type)) 341 self._members_emitter.Emit(template, E=DartType(element_type))
346 342
347 343
348 def AddTypedArrayConstructors(self, element_type):
349 self._members_emitter.Emit(
350 '\n'
351 ' factory $CTOR(int length) => _construct_$CTOR(length);\n'
352 '\n'
353 ' factory $CTOR.fromList(List<$TYPE> list) => _construct_$CTOR(list);\n '
354 '\n'
355 ' factory $CTOR.fromBuffer(ArrayBuffer buffer) => _construct_$CTOR(buff er);\n'
356 '\n'
357 ' static _construct_$CTOR(arg) native \'return new $CTOR(arg);\';\n',
358 CTOR=self._interface.id,
359 TYPE=DartType(element_type))
360
361
362 def AddOperation(self, info): 344 def AddOperation(self, info):
363 """ 345 """
364 Arguments: 346 Arguments:
365 info: An OperationInfo object. 347 info: An OperationInfo object.
366 """ 348 """
367 # TODO(vsm): Handle overloads. 349 # TODO(vsm): Handle overloads.
368 params = info.ParametersImplementationDeclaration( 350 params = info.ParametersImplementationDeclaration(
369 lambda type_name: self._NarrowInputType(type_name)) 351 lambda type_name: self._NarrowInputType(type_name))
370 352
353 native_string = ''
354 if info.declared_name != info.name:
355 native_string = " '%s'" % info.declared_name
356
371 native_body = dom_frog_native_bodies.get( 357 native_body = dom_frog_native_bodies.get(
372 self._interface.id + '.' + info.name, '') 358 self._interface.id + '.' + info.name, '')
373 if native_body: 359 if native_body:
374 native_body = " '''" + native_body + "'''" 360 native_string = " '''" + native_body + "'''"
375 361
376 self._members_emitter.Emit( 362 self._members_emitter.Emit(
377 '\n' 363 '\n'
378 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n', 364 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n',
379 TYPE=self._NarrowOutputType(info.type_name), 365 TYPE=self._NarrowOutputType(info.type_name),
380 NAME=info.name, 366 NAME=info.name,
381 PARAMS=params, 367 PARAMS=params,
382 NATIVESTRING=native_body) 368 NATIVESTRING=native_string)
OLDNEW
« no previous file with comments | « lib/dom/scripts/generator.py ('k') | lib/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698