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

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

Issue 10541029: Do not merge IDL interfaces in dartdomgenerator. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments. Created 8 years, 6 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/dartgenerator.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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 (super_setter, super_setter_interface) = self._FindShadowedAttribute(setter) 216 (super_setter, super_setter_interface) = self._FindShadowedAttribute(setter)
217 if super_getter or super_setter: 217 if super_getter or super_setter:
218 if getter and not setter and super_getter and not super_setter: 218 if getter and not setter and super_getter and not super_setter:
219 if DartType(getter.type.id) == DartType(super_getter.type.id): 219 if DartType(getter.type.id) == DartType(super_getter.type.id):
220 # Compatible getter, use the superclass property. This works because 220 # Compatible getter, use the superclass property. This works because
221 # JavaScript will do its own dynamic dispatch. 221 # JavaScript will do its own dynamic dispatch.
222 self._members_emitter.Emit( 222 self._members_emitter.Emit(
223 '\n' 223 '\n'
224 ' // Use implementation from $SUPER.\n' 224 ' // Use implementation from $SUPER.\n'
225 ' // final $TYPE $NAME;\n', 225 ' // final $TYPE $NAME;\n',
226 SUPER=super_getter_interface.id, 226 SUPER=super_getter_interface,
227 NAME=DartDomNameOfAttribute(getter), 227 NAME=DartDomNameOfAttribute(getter),
228 TYPE=output_type) 228 TYPE=output_type)
229 return 229 return
230 230
231 self._members_emitter.Emit('\n // Shadowing definition.') 231 self._members_emitter.Emit('\n // Shadowing definition.')
232 self._AddAttributeUsingProperties(getter, setter) 232 self._AddAttributeUsingProperties(getter, setter)
233 return 233 return
234 234
235 # Can't generate field if attribute has different name in JS and Dart. 235 # Can't generate field if attribute has different name in JS and Dart.
236 if self._AttributeChangesName(getter or setter): 236 if self._AttributeChangesName(getter or setter):
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 270
271 def _AddSetter(self, attr): 271 def _AddSetter(self, attr):
272 # TODO(sra): Remove native body when Issue 829 fixed. 272 # TODO(sra): Remove native body when Issue 829 fixed.
273 self._members_emitter.Emit( 273 self._members_emitter.Emit(
274 ' void set $NAME($(OPT_TYPE)value)' 274 ' void set $NAME($(OPT_TYPE)value)'
275 ' native "this.$NATIVE_NAME = value;";\n', 275 ' native "this.$NATIVE_NAME = value;";\n',
276 NAME=DartDomNameOfAttribute(attr), 276 NAME=DartDomNameOfAttribute(attr),
277 NATIVE_NAME=attr.id, 277 NATIVE_NAME=attr.id,
278 OPT_TYPE=TypeOrNothing(self._NarrowInputType(attr.type.id))) 278 OPT_TYPE=TypeOrNothing(self._NarrowInputType(attr.type.id)))
279 279
280 def _FindShadowedAttribute(self, attr): 280 def _FindShadowedAttribute(self, attr, merged_interfaces={}):
281 """Returns (attribute, superinterface) or (None, None).""" 281 """Returns (attribute, superinterface) or (None, None)."""
282 def FindInParent(interface): 282 def FindInParent(interface):
283 """Returns matching attribute in parent, or None.""" 283 """Returns matching attribute in parent, or None."""
284 if interface.parents: 284 if interface.parents:
285 parent = interface.parents[0] 285 parent = interface.parents[0]
286 if IsDartCollectionType(parent.type.id): 286 if IsDartCollectionType(parent.type.id):
287 return (None, None) 287 return (None, None)
288 if IsPureInterface(parent.type.id): 288 if IsPureInterface(parent.type.id):
289 return (None, None) 289 return (None, None)
290 if self._system._database.HasInterface(parent.type.id): 290 if self._system._database.HasInterface(parent.type.id):
291 parent_interface = self._system._database.GetInterface(parent.type.id) 291 interfaces_to_search_in = []
292 attr2 = FindMatchingAttribute(parent_interface, attr) 292 if parent.type.id in merged_interfaces:
293 if attr2: 293 # IDL parent was merged into another interface, which became a
294 return (attr2, parent_interface) 294 # parent interface in Dart.
295 return FindInParent(parent_interface) 295 interfaces_to_search_in.append(parent.type.id)
296 parent_interface_name = merged_interfaces[parent.type.id]
297 else:
298 parent_interface_name = parent.type.id
299
300 for interface_name in merged_interfaces:
301 if merged_interfaces[interface_name] == parent_interface_name:
302 # IDL parent has another interface that was merged into it.
303 interfaces_to_search_in.append(interface_name)
304
305 interfaces_to_search_in.append(parent_interface_name)
306 for interface_name in interfaces_to_search_in:
307 interface = self._system._database.GetInterface(interface_name)
308 attr2 = FindMatchingAttribute(interface, attr)
309 if attr2:
310 return (attr2, parent_interface_name)
311
312 return FindInParent(
313 self._system._database.GetInterface(parent_interface_name))
296 return (None, None) 314 return (None, None)
297 315
298 return FindInParent(self._interface) if attr else (None, None) 316 return FindInParent(self._interface) if attr else (None, None)
299 317
300 318
301 def AddSecondaryAttribute(self, interface, getter, setter): 319 def AddSecondaryAttribute(self, interface, getter, setter):
302 self._SecondaryContext(interface) 320 self._SecondaryContext(interface)
303 self.AddAttribute(getter, setter) 321 self.AddAttribute(getter, setter)
304 322
305 def AddSecondaryOperation(self, interface, info): 323 def AddSecondaryOperation(self, interface, info):
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 if native_body: 390 if native_body:
373 native_string = " '''" + native_body + "'''" 391 native_string = " '''" + native_body + "'''"
374 392
375 self._members_emitter.Emit( 393 self._members_emitter.Emit(
376 '\n' 394 '\n'
377 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n', 395 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n',
378 TYPE=self._NarrowOutputType(info.type_name), 396 TYPE=self._NarrowOutputType(info.type_name),
379 NAME=info.name, 397 NAME=info.name,
380 PARAMS=params, 398 PARAMS=params,
381 NATIVESTRING=native_string) 399 NATIVESTRING=native_string)
OLDNEW
« no previous file with comments | « lib/dom/scripts/dartgenerator.py ('k') | lib/dom/scripts/systemhtml.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698