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 * |
11 from systembase import * | 11 from systembase import * |
12 | 12 |
13 # Members (getters, setters, and methods) to suppress. These are | |
14 # either removed or custom implemented. | |
15 _overridden_members = set([ | |
sra1
2012/02/24 03:38:30
Call this _dom_frog_omitted_members.
With everyone
vsm
2012/02/26 01:52:10
Done, though we should consider making some of thi
| |
16 # Replace with custom. | |
17 'HTMLIFrameElement.get:contentWindow', | |
18 | |
19 # Remove. | |
20 'HTMLIFrameElement.get:contentDocument', | |
21 'DOMWindow.get:frameElement', | |
22 ]) | |
23 | |
13 class FrogSystem(System): | 24 class FrogSystem(System): |
14 | 25 |
15 def __init__(self, templates, database, emitters, output_dir): | 26 def __init__(self, templates, database, emitters, output_dir): |
16 super(FrogSystem, self).__init__( | 27 super(FrogSystem, self).__init__( |
17 templates, database, emitters, output_dir) | 28 templates, database, emitters, output_dir) |
18 self._dart_frog_file_paths = [] | 29 self._dart_frog_file_paths = [] |
19 | 30 |
20 def InterfaceGenerator(self, | 31 def InterfaceGenerator(self, |
21 interface, | 32 interface, |
22 common_prefix, | 33 common_prefix, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 # Since we are currently generating native classes without interfaces, | 165 # Since we are currently generating native classes without interfaces, |
155 # generate the constants as part of the class. This will need to go away | 166 # generate the constants as part of the class. This will need to go away |
156 # if we revert back to generating interfaces. | 167 # if we revert back to generating interfaces. |
157 self._members_emitter.Emit('\n static final $TYPE $NAME = $VALUE;\n', | 168 self._members_emitter.Emit('\n static final $TYPE $NAME = $VALUE;\n', |
158 NAME=constant.id, | 169 NAME=constant.id, |
159 TYPE=constant.type.id, | 170 TYPE=constant.type.id, |
160 VALUE=constant.value) | 171 VALUE=constant.value) |
161 | 172 |
162 pass | 173 pass |
163 | 174 |
175 def OverrideMember(self, member): | |
176 return self._interface.id + '.' + member in _overridden_members | |
177 | |
164 def AddAttribute(self, getter, setter): | 178 def AddAttribute(self, getter, setter): |
179 if getter and self.OverrideMember('get:' + getter.id): | |
180 getter = None | |
181 if setter and self.OverrideMember('set:' + setter.id): | |
182 setter = None | |
183 if not getter and not setter: | |
184 return | |
185 | |
165 output_type = getter and self._NarrowOutputType(getter.type.id) | 186 output_type = getter and self._NarrowOutputType(getter.type.id) |
166 input_type = setter and self._NarrowInputType(setter.type.id) | 187 input_type = setter and self._NarrowInputType(setter.type.id) |
167 | 188 |
168 # If the (getter, setter) pair is shadowing, we can't generate a shadowing | 189 # If the (getter, setter) pair is shadowing, we can't generate a shadowing |
169 # field (Issue 1633). | 190 # field (Issue 1633). |
170 (super_getter, super_getter_interface) = self._FindShadowedAttribute(getter) | 191 (super_getter, super_getter_interface) = self._FindShadowedAttribute(getter) |
171 (super_setter, super_setter_interface) = self._FindShadowedAttribute(setter) | 192 (super_setter, super_setter_interface) = self._FindShadowedAttribute(setter) |
172 if super_getter or super_setter: | 193 if super_getter or super_setter: |
173 if getter and not setter and super_getter and not super_setter: | 194 if getter and not setter and super_getter and not super_setter: |
174 if getter.type.id == super_getter.type.id: | 195 if getter.type.id == super_getter.type.id: |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
323 if native_body: | 344 if native_body: |
324 native_body = " '''" + native_body + "'''" | 345 native_body = " '''" + native_body + "'''" |
325 | 346 |
326 self._members_emitter.Emit( | 347 self._members_emitter.Emit( |
327 '\n' | 348 '\n' |
328 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n', | 349 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n', |
329 TYPE=self._NarrowOutputType(info.type_name), | 350 TYPE=self._NarrowOutputType(info.type_name), |
330 NAME=info.name, | 351 NAME=info.name, |
331 PARAMS=params, | 352 PARAMS=params, |
332 NATIVESTRING=native_body) | 353 NATIVESTRING=native_body) |
OLD | NEW |