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

Side by Side Diff: tools/dom/scripts/systemhtml.py

Issue 12543014: Reapply Futureification. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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
« no previous file with comments | « tools/dom/scripts/monitored.py ('k') | tools/dom/scripts/systemnative.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 import monitored 10 import monitored
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 self._library_name = self._renamer.GetLibraryName(self._interface) 414 self._library_name = self._renamer.GetLibraryName(self._interface)
415 415
416 def Generate(self): 416 def Generate(self):
417 if 'Callback' in self._interface.ext_attrs: 417 if 'Callback' in self._interface.ext_attrs:
418 self.GenerateCallback() 418 self.GenerateCallback()
419 else: 419 else:
420 self.GenerateInterface() 420 self.GenerateInterface()
421 421
422 def GenerateCallback(self): 422 def GenerateCallback(self):
423 """Generates a typedef for the callback interface.""" 423 """Generates a typedef for the callback interface."""
424 handlers = [operation for operation in self._interface.operations 424 info = GetCallbackInfo(self._interface)
425 if operation.id == 'handleEvent']
426 info = AnalyzeOperation(self._interface, handlers)
427 code = self._library_emitter.FileEmitter(self._interface.id, 425 code = self._library_emitter.FileEmitter(self._interface.id,
428 self._library_name) 426 self._library_name)
429 code.Emit(self._template_loader.Load('callback.darttemplate')) 427 code.Emit(self._template_loader.Load('callback.darttemplate'))
430 428
431 typedef_name = self._renamer.RenameInterface(self._interface) 429 typedef_name = self._renamer.RenameInterface(self._interface)
432 code.Emit('typedef void $NAME($PARAMS);\n', 430 code.Emit('typedef void $NAME($PARAMS);\n',
433 LIBRARYNAME='dart.dom.%s' % self._library_name, 431 LIBRARYNAME='dart.dom.%s' % self._library_name,
434 NAME=typedef_name, 432 NAME=typedef_name,
435 PARAMS=info.ParametersDeclaration(self._DartType)) 433 PARAMS=info.ParametersDeclaration(self._DartType))
436 self._backend.GenerateCallback(info) 434 self._backend.GenerateCallback(info)
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 def EmitOperation(self, info, html_name): 851 def EmitOperation(self, info, html_name):
854 """ 852 """
855 Arguments: 853 Arguments:
856 info: An OperationInfo object. 854 info: An OperationInfo object.
857 """ 855 """
858 if self._HasCustomImplementation(info.name): 856 if self._HasCustomImplementation(info.name):
859 return 857 return
860 858
861 if IsPureInterface(self._interface.id): 859 if IsPureInterface(self._interface.id):
862 self._AddInterfaceOperation(info, html_name) 860 self._AddInterfaceOperation(info, html_name)
861 elif info.callback_args:
862 self._AddFutureifiedOperation(info, html_name)
863 elif any(self._OperationRequiresConversions(op) for op in info.overloads): 863 elif any(self._OperationRequiresConversions(op) for op in info.overloads):
864 # Any conversions needed? 864 # Any conversions needed?
865 self._AddOperationWithConversions(info, html_name) 865 self._AddOperationWithConversions(info, html_name)
866 else: 866 else:
867 self._AddDirectNativeOperation(info, html_name) 867 self._AddDirectNativeOperation(info, html_name)
868 868
869 def _AddDirectNativeOperation(self, info, html_name): 869 def _AddDirectNativeOperation(self, info, html_name):
870 self._members_emitter.Emit( 870 self._members_emitter.Emit(
871 '\n' 871 '\n'
872 ' $RENAME$ANNOTATIONS$MODIFIERS$TYPE $NAME($PARAMS) native;\n', 872 ' $RENAME$ANNOTATIONS$MODIFIERS$TYPE $NAME($PARAMS) native;\n',
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 for library_name in libraries: 1135 for library_name in libraries:
1136 self._libraries[library_name] = DartLibrary( 1136 self._libraries[library_name] = DartLibrary(
1137 library_name, template_loader, library_type, output_dir) 1137 library_name, template_loader, library_type, output_dir)
1138 1138
1139 def AddFile(self, basename, library_name, path): 1139 def AddFile(self, basename, library_name, path):
1140 self._libraries[library_name].AddFile(path) 1140 self._libraries[library_name].AddFile(path)
1141 1141
1142 def Emit(self, emitter, auxiliary_dir): 1142 def Emit(self, emitter, auxiliary_dir):
1143 for lib in self._libraries.values(): 1143 for lib in self._libraries.values():
1144 lib.Emit(emitter, auxiliary_dir) 1144 lib.Emit(emitter, auxiliary_dir)
OLDNEW
« no previous file with comments | « tools/dom/scripts/monitored.py ('k') | tools/dom/scripts/systemnative.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698