| 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 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 import emitter | 9 import emitter |
| 10 from generator import AnalyzeOperation, ConstantOutputOrder, \ | 10 from generator import AnalyzeOperation, ConstantOutputOrder, \ |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 def AddAttribute(self, attribute, declare_only=False): | 140 def AddAttribute(self, attribute, declare_only=False): |
| 141 """ Adds an attribute to the generated class. | 141 """ Adds an attribute to the generated class. |
| 142 Arguments: | 142 Arguments: |
| 143 attribute - The attribute which is to be added. | 143 attribute - The attribute which is to be added. |
| 144 declare_only- True if the attribute should be declared as an abstract | 144 declare_only- True if the attribute should be declared as an abstract |
| 145 member and not include invocation code. | 145 member and not include invocation code. |
| 146 """ | 146 """ |
| 147 dom_name = DartDomNameOfAttribute(attribute) | 147 dom_name = DartDomNameOfAttribute(attribute) |
| 148 attr_name = self._renamer.RenameMember( | 148 attr_name = self._renamer.RenameMember( |
| 149 self._interface.id, attribute, dom_name, 'get:') | 149 self._interface.id, attribute, dom_name, 'get:') |
| 150 if not attr_name or self._IsPrivate(attr_name): | 150 if not attr_name: |
| 151 return | 151 return |
| 152 | 152 |
| 153 html_setter_name = self._renamer.RenameMember( | 153 html_setter_name = self._renamer.RenameMember( |
| 154 self._interface.id, attribute, dom_name, 'set:') | 154 self._interface.id, attribute, dom_name, 'set:') |
| 155 read_only = (attribute.is_read_only or 'Replaceable' in attribute.ext_attrs | 155 read_only = (attribute.is_read_only or 'Replaceable' in attribute.ext_attrs |
| 156 or not html_setter_name) | 156 or not html_setter_name) |
| 157 | 157 |
| 158 # We don't yet handle inconsistent renames of the getter and setter yet. | 158 # We don't yet handle inconsistent renames of the getter and setter yet. |
| 159 assert(not html_setter_name or attr_name == html_setter_name) | 159 assert(not html_setter_name or attr_name == html_setter_name) |
| 160 | 160 |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 590 if interface.parents: | 590 if interface.parents: |
| 591 parent = interface.parents[0] | 591 parent = interface.parents[0] |
| 592 if IsPureInterface(parent.type.id): | 592 if IsPureInterface(parent.type.id): |
| 593 walk(interface.parents) | 593 walk(interface.parents) |
| 594 else: | 594 else: |
| 595 walk(interface.parents[1:]) | 595 walk(interface.parents[1:]) |
| 596 return result | 596 return result |
| 597 | 597 |
| 598 def _DartType(self, type_name): | 598 def _DartType(self, type_name): |
| 599 return self._type_registry.DartType(type_name) | 599 return self._type_registry.DartType(type_name) |
| 600 | |
| 601 def _IsPrivate(self, name): | |
| 602 return name.startswith('_') | |
| OLD | NEW |