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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 factory_provider = '_' + interface_name + 'FactoryProvider' | 155 factory_provider = '_' + interface_name + 'FactoryProvider' |
| 156 emitter = self._system._ImplFileEmitter(factory_provider) | 156 emitter = self._system._ImplFileEmitter(factory_provider) |
| 157 emitter.Emit( | 157 emitter.Emit( |
| 158 template, | 158 template, |
| 159 FACTORYPROVIDER=factory_provider, | 159 FACTORYPROVIDER=factory_provider, |
| 160 CONSTRUCTOR=interface_name, | 160 CONSTRUCTOR=interface_name, |
| 161 PARAMETERS=constructor_info.ParametersImplementationDeclaration(), | 161 PARAMETERS=constructor_info.ParametersImplementationDeclaration(), |
| 162 NAMEDCONSTRUCTOR=constructor_info.name or interface_name, | 162 NAMEDCONSTRUCTOR=constructor_info.name or interface_name, |
| 163 ARGUMENTS=constructor_info.ParametersAsArgumentList()) | 163 ARGUMENTS=constructor_info.ParametersAsArgumentList()) |
| 164 | 164 |
| 165 def _NarrowToImplementationType(self, type_name): | 165 def _ShouldNarrowToImplementationType(self, type_name): |
|
Anton Muhin
2012/06/07 11:43:47
maybe pass a renamer here instead of doing if and
podivilov
2012/06/08 18:03:25
It might be a good idea, but there too many call s
| |
| 166 # TODO(sra): Move into the 'system' and cache the result. | 166 # TODO(sra): Move into the 'system' and cache the result. |
| 167 if type_name == 'EventListener': | 167 if type_name == 'EventListener': |
| 168 # Callbacks are typedef functions so don't have a class. | 168 # Callbacks are typedef functions so don't have a class. |
| 169 return type_name | 169 return False |
| 170 if self._system._database.HasInterface(type_name): | 170 if self._system._database.HasInterface(type_name): |
| 171 interface = self._system._database.GetInterface(type_name) | 171 interface = self._system._database.GetInterface(type_name) |
| 172 if RecognizeCallback(interface): | 172 if RecognizeCallback(interface): |
| 173 # Callbacks are typedef functions so don't have a class. | 173 # Callbacks are typedef functions so don't have a class. |
| 174 return type_name | 174 return False |
| 175 elif type_name == 'MediaQueryListListener': | 175 elif type_name == 'MediaQueryListListener': |
| 176 # Somewhat like a callback. See Issue 3338. | 176 # Somewhat like a callback. See Issue 3338. |
| 177 return type_name | 177 return False |
| 178 else: | 178 else: |
| 179 return self._ImplClassName(type_name) | 179 return True |
| 180 return False | |
| 181 | |
| 182 def _NarrowToImplementationType(self, type_name): | |
| 183 if self._ShouldNarrowToImplementationType(type_name): | |
| 184 return self._ImplClassName(type_name) | |
| 180 return type_name | 185 return type_name |
| 181 | 186 |
| 182 def _NarrowInputType(self, type_name): | 187 def _NarrowInputType(self, type_name): |
| 183 return self._NarrowToImplementationType(DartType(type_name)) | 188 return self._NarrowToImplementationType(DartType(type_name)) |
| 184 | 189 |
| 185 def _NarrowOutputType(self, type_name): | 190 def _NarrowOutputType(self, type_name): |
| 186 return self._NarrowToImplementationType(DartType(type_name)) | 191 return self._NarrowToImplementationType(DartType(type_name)) |
| 187 | 192 |
| 188 def AddConstant(self, constant): | 193 def AddConstant(self, constant): |
| 189 # Since we are currently generating native classes without interfaces, | 194 # Since we are currently generating native classes without interfaces, |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 372 if native_body: | 377 if native_body: |
| 373 native_string = " '''" + native_body + "'''" | 378 native_string = " '''" + native_body + "'''" |
| 374 | 379 |
| 375 self._members_emitter.Emit( | 380 self._members_emitter.Emit( |
| 376 '\n' | 381 '\n' |
| 377 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n', | 382 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n', |
| 378 TYPE=self._NarrowOutputType(info.type_name), | 383 TYPE=self._NarrowOutputType(info.type_name), |
| 379 NAME=info.name, | 384 NAME=info.name, |
| 380 PARAMS=params, | 385 PARAMS=params, |
| 381 NATIVESTRING=native_string) | 386 NATIVESTRING=native_string) |
| OLD | NEW |