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

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

Issue 10107010: Map IDBAny and IDBKey to Dynamic (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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 if super_getter or super_setter: 209 if super_getter or super_setter:
210 if getter and not setter and super_getter and not super_setter: 210 if getter and not setter and super_getter and not super_setter:
211 if DartType(getter.type.id) == DartType(super_getter.type.id): 211 if DartType(getter.type.id) == DartType(super_getter.type.id):
212 # Compatible getter, use the superclass property. This works because 212 # Compatible getter, use the superclass property. This works because
213 # JavaScript will do its own dynamic dispatch. 213 # JavaScript will do its own dynamic dispatch.
214 self._members_emitter.Emit( 214 self._members_emitter.Emit(
215 '\n' 215 '\n'
216 ' // Use implementation from $SUPER.\n' 216 ' // Use implementation from $SUPER.\n'
217 ' // final $TYPE $NAME;\n', 217 ' // final $TYPE $NAME;\n',
218 SUPER=super_getter_interface.id, 218 SUPER=super_getter_interface.id,
219 NAME=DartDomNameOfAttribute(getter), TYPE=output_type) 219 NAME=DartDomNameOfAttribute(getter),
220 TYPE=output_type)
220 return 221 return
221 222
222 self._members_emitter.Emit('\n // Shadowing definition.') 223 self._members_emitter.Emit('\n // Shadowing definition.')
223 self._AddAttributeUsingProperties(getter, setter) 224 self._AddAttributeUsingProperties(getter, setter)
224 return 225 return
225 226
226 # Can't generate field if attribute has different name in JS and Dart. 227 # Can't generate field if attribute has different name in JS and Dart.
227 if self._AttributeChangesName(getter or setter): 228 if self._AttributeChangesName(getter or setter):
228 self._AddAttributeUsingProperties(getter, setter) 229 self._AddAttributeUsingProperties(getter, setter)
229 return 230 return
230 231
231 if getter and setter and input_type == output_type: 232 if getter and setter and input_type == output_type:
232 self._members_emitter.Emit( 233 self._members_emitter.Emit(
233 '\n $TYPE $NAME;\n', 234 '\n $TYPE $NAME;\n',
234 NAME=DartDomNameOfAttribute(getter), TYPE=output_type) 235 NAME=DartDomNameOfAttribute(getter),
236 TYPE=TypeOrVar(output_type))
235 return 237 return
236 if getter and not setter: 238 if getter and not setter:
237 self._members_emitter.Emit( 239 self._members_emitter.Emit(
238 '\n final $TYPE $NAME;\n', 240 '\n final $OPT_TYPE$NAME;\n',
239 NAME=DartDomNameOfAttribute(getter), TYPE=output_type) 241 NAME=DartDomNameOfAttribute(getter),
242 OPT_TYPE=TypeOrNothing(output_type))
240 return 243 return
241 self._AddAttributeUsingProperties(getter, setter) 244 self._AddAttributeUsingProperties(getter, setter)
242 245
243 def _AttributeChangesName(self, attr): 246 def _AttributeChangesName(self, attr):
244 return attr.id != DartDomNameOfAttribute(attr) 247 return attr.id != DartDomNameOfAttribute(attr)
245 248
246 def _AddAttributeUsingProperties(self, getter, setter): 249 def _AddAttributeUsingProperties(self, getter, setter):
247 if getter: 250 if getter:
248 self._AddGetter(getter) 251 self._AddGetter(getter)
249 if setter: 252 if setter:
250 self._AddSetter(setter) 253 self._AddSetter(setter)
251 254
252 def _AddGetter(self, attr): 255 def _AddGetter(self, attr):
253 # TODO(sra): Remove native body when Issue 829 fixed. 256 # TODO(sra): Remove native body when Issue 829 fixed.
254 self._members_emitter.Emit( 257 self._members_emitter.Emit(
255 '\n $TYPE get $NAME() native "return this.$NATIVE_NAME;";\n', 258 '\n $(OPT_TYPE)get $NAME() native "return this.$NATIVE_NAME;";\n',
256 NAME=DartDomNameOfAttribute(attr), 259 NAME=DartDomNameOfAttribute(attr),
257 NATIVE_NAME=attr.id, 260 NATIVE_NAME=attr.id,
258 TYPE=self._NarrowOutputType(attr.type.id)) 261 OPT_TYPE=TypeOrNothing(self._NarrowOutputType(attr.type.id)))
259 262
260 def _AddSetter(self, attr): 263 def _AddSetter(self, attr):
261 # TODO(sra): Remove native body when Issue 829 fixed. 264 # TODO(sra): Remove native body when Issue 829 fixed.
262 self._members_emitter.Emit( 265 self._members_emitter.Emit(
263 ' void set $NAME($TYPE value) native "this.$NATIVE_NAME = value;";\n', 266 ' void set $NAME($(OPT_TYPE)value)'
267 ' native "this.$NATIVE_NAME = value;";\n',
264 NAME=DartDomNameOfAttribute(attr), 268 NAME=DartDomNameOfAttribute(attr),
265 NATIVE_NAME=attr.id, 269 NATIVE_NAME=attr.id,
266 TYPE=self._NarrowInputType(attr.type.id)) 270 OPT_TYPE=TypeOrNothing(self._NarrowInputType(attr.type.id)))
267 271
268 def _FindShadowedAttribute(self, attr): 272 def _FindShadowedAttribute(self, attr):
269 """Returns (attribute, superinterface) or (None, None).""" 273 """Returns (attribute, superinterface) or (None, None)."""
270 def FindInParent(interface): 274 def FindInParent(interface):
271 """Returns matching attribute in parent, or None.""" 275 """Returns matching attribute in parent, or None."""
272 if interface.parents: 276 if interface.parents:
273 parent = interface.parents[0] 277 parent = interface.parents[0]
274 if IsDartCollectionType(parent.type.id): 278 if IsDartCollectionType(parent.type.id):
275 return (None, None) 279 return (None, None)
276 if self._system._database.HasInterface(parent.type.id): 280 if self._system._database.HasInterface(parent.type.id):
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 if native_body: 363 if native_body:
360 native_string = " '''" + native_body + "'''" 364 native_string = " '''" + native_body + "'''"
361 365
362 self._members_emitter.Emit( 366 self._members_emitter.Emit(
363 '\n' 367 '\n'
364 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n', 368 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n',
365 TYPE=self._NarrowOutputType(info.type_name), 369 TYPE=self._NarrowOutputType(info.type_name),
366 NAME=info.name, 370 NAME=info.name,
367 PARAMS=params, 371 PARAMS=params,
368 NATIVESTRING=native_string) 372 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