Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 parent_interface = self._system._database.GetInterface(parent.type.id) |
| 292 attr2 = FindMatchingAttribute(parent_interface, attr) | 292 attr2 = FindMatchingAttribute(parent_interface, attr) |
| 293 if attr2: | 293 if attr2: |
| 294 return (attr2, parent_interface) | 294 return (attr2, parent_interface) |
| 295 if parent.type.id in merged_interfaces: | |
| 296 merged_interface = self._system._database.GetInterface( | |
| 297 merged_interfaces[parent.type.id]) | |
| 298 attr2 = FindMatchingAttribute(merged_interface, attr) | |
| 299 if attr2: | |
| 300 return (attr2, parent_interface) | |
| 295 return FindInParent(parent_interface) | 301 return FindInParent(parent_interface) |
|
sra1
2012/06/07 19:31:07
If parent_interface was merged into some other int
podivilov
2012/06/08 17:02:21
Fixed.
| |
| 296 return (None, None) | 302 return (None, None) |
| 297 | 303 |
| 298 return FindInParent(self._interface) if attr else (None, None) | 304 return FindInParent(self._interface) if attr else (None, None) |
| 299 | 305 |
| 300 | 306 |
| 301 def AddSecondaryAttribute(self, interface, getter, setter): | 307 def AddSecondaryAttribute(self, interface, getter, setter): |
| 302 self._SecondaryContext(interface) | 308 self._SecondaryContext(interface) |
| 303 self.AddAttribute(getter, setter) | 309 self.AddAttribute(getter, setter) |
| 304 | 310 |
| 305 def AddSecondaryOperation(self, interface, info): | 311 def AddSecondaryOperation(self, interface, info): |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 if native_body: | 378 if native_body: |
| 373 native_string = " '''" + native_body + "'''" | 379 native_string = " '''" + native_body + "'''" |
| 374 | 380 |
| 375 self._members_emitter.Emit( | 381 self._members_emitter.Emit( |
| 376 '\n' | 382 '\n' |
| 377 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n', | 383 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n', |
| 378 TYPE=self._NarrowOutputType(info.type_name), | 384 TYPE=self._NarrowOutputType(info.type_name), |
| 379 NAME=info.name, | 385 NAME=info.name, |
| 380 PARAMS=params, | 386 PARAMS=params, |
| 381 NATIVESTRING=native_string) | 387 NATIVESTRING=native_string) |
| OLD | NEW |