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

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

Issue 10698108: Stop passing HtmlSystemShared around and move html renaming to IDLTypeInfo. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 5 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
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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 emitter.Emit( 148 emitter.Emit(
149 template, 149 template,
150 FACTORYPROVIDER=factory_provider, 150 FACTORYPROVIDER=factory_provider,
151 CONSTRUCTOR=interface_name, 151 CONSTRUCTOR=interface_name,
152 PARAMETERS=constructor_info.ParametersImplementationDeclaration(), 152 PARAMETERS=constructor_info.ParametersImplementationDeclaration(),
153 NAMEDCONSTRUCTOR=constructor_info.name or interface_name, 153 NAMEDCONSTRUCTOR=constructor_info.name or interface_name,
154 ARGUMENTS=constructor_info.ParametersAsArgumentList()) 154 ARGUMENTS=constructor_info.ParametersAsArgumentList())
155 155
156 def _ShouldNarrowToImplementationType(self, type_name): 156 def _ShouldNarrowToImplementationType(self, type_name):
157 # TODO(sra): Move into the 'system' and cache the result. 157 # TODO(sra): Move into the 'system' and cache the result.
158 if type_name == 'EventListener': 158 do_not_narrow = ['DOMStringList', 'DOMStringMap', 'EventListener',
159 # Callbacks are typedef functions so don't have a class. 159 'IDBAny', 'IDBKey', 'MediaQueryListListener']
160 if type_name in do_not_narrow:
160 return False 161 return False
161 if self._system._database.HasInterface(type_name): 162 if self._system._database.HasInterface(type_name):
162 interface = self._system._database.GetInterface(type_name) 163 interface = self._system._database.GetInterface(type_name)
163 if RecognizeCallback(interface): 164 if RecognizeCallback(interface):
164 # Callbacks are typedef functions so don't have a class. 165 # Callbacks are typedef functions so don't have a class.
165 return False 166 return False
166 elif type_name == 'MediaQueryListListener': 167 return True
167 # Somewhat like a callback. See Issue 3338.
168 return False
169 else:
170 return True
171 return False 168 return False
172 169
173 def _NarrowToImplementationType(self, type_name): 170 def _NarrowToImplementationType(self, type_name):
174 if self._ShouldNarrowToImplementationType(type_name): 171 if self._ShouldNarrowToImplementationType(type_name):
175 return self._ImplClassName(type_name) 172 return self._ImplClassName(DartType(type_name))
176 return type_name 173 return DartType(type_name)
177 174
178 def _NarrowInputType(self, type_name): 175 def _NarrowInputType(self, type_name):
179 return self._NarrowToImplementationType(DartType(type_name)) 176 return self._NarrowToImplementationType(type_name)
180 177
181 def _NarrowOutputType(self, type_name): 178 def _NarrowOutputType(self, type_name):
182 return self._NarrowToImplementationType(DartType(type_name)) 179 return self._NarrowToImplementationType(type_name)
183 180
184 def AddConstant(self, constant): 181 def AddConstant(self, constant):
185 # Since we are currently generating native classes without interfaces, 182 # Since we are currently generating native classes without interfaces,
186 # generate the constants as part of the class. This will need to go away 183 # generate the constants as part of the class. This will need to go away
187 # if we revert back to generating interfaces. 184 # if we revert back to generating interfaces.
188 self._members_emitter.Emit('\n static final $TYPE $NAME = $VALUE;\n', 185 self._members_emitter.Emit('\n static final $TYPE $NAME = $VALUE;\n',
189 NAME=constant.id, 186 NAME=constant.id,
190 TYPE=DartType(constant.type.id), 187 TYPE=DartType(constant.type.id),
191 VALUE=constant.value) 188 VALUE=constant.value)
192 189
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 if native_body: 385 if native_body:
389 native_string = " '''" + native_body + "'''" 386 native_string = " '''" + native_body + "'''"
390 387
391 self._members_emitter.Emit( 388 self._members_emitter.Emit(
392 '\n' 389 '\n'
393 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n', 390 ' $TYPE $NAME($PARAMS) native$NATIVESTRING;\n',
394 TYPE=self._NarrowOutputType(info.type_name), 391 TYPE=self._NarrowOutputType(info.type_name),
395 NAME=info.name, 392 NAME=info.name,
396 PARAMS=params, 393 PARAMS=params,
397 NATIVESTRING=native_string) 394 NATIVESTRING=native_string)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698