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

Side by Side Diff: client/dom/scripts/dartgenerator.py

Issue 9231021: Several fixes needed to reuse JS DOM interfaces in dartium. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 11 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) 2011, the Dart project authors. Please see the AUTHORS file 2 # Copyright (c) 2011, 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 generates Dart APIs from the IDL database.""" 6 """This module generates Dart APIs from the IDL database."""
7 7
8 import emitter 8 import emitter
9 import idlnode 9 import idlnode
10 import logging 10 import logging
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 def _IsDartListType(type): 186 def _IsDartListType(type):
187 return type == 'List' or type.startswith('List<') 187 return type == 'List' or type.startswith('List<')
188 188
189 def _IsDartCollectionType(type): 189 def _IsDartCollectionType(type):
190 return _IsDartListType(type) 190 return _IsDartListType(type)
191 191
192 192
193 class DartGenerator(object): 193 class DartGenerator(object):
194 """Utilities to generate Dart APIs and corresponding JavaScript.""" 194 """Utilities to generate Dart APIs and corresponding JavaScript."""
195 195
196 def __init__(self, auxiliary_dir, base_package): 196 def __init__(self, auxiliary_dir, template_dir, base_package):
197 """Constructor for the DartGenerator. 197 """Constructor for the DartGenerator.
198 198
199 Args: 199 Args:
200 auxiliary_dir -- location of auxiliary handwritten classes 200 auxiliary_dir -- location of auxiliary handwritten classes
201 template_dir -- location of template files
201 base_package -- the base package name for the generated code. 202 base_package -- the base package name for the generated code.
202 """ 203 """
203 self._auxiliary_dir = auxiliary_dir 204 self._auxiliary_dir = auxiliary_dir
205 self._template_dir = template_dir
204 self._base_package = base_package 206 self._base_package = base_package
205 self._auxiliary_files = {} 207 self._auxiliary_files = {}
206 self._dart_templates_re = re.compile(r'[\w.:]+<([\w\.<>:]+)>') 208 self._dart_templates_re = re.compile(r'[\w.:]+<([\w\.<>:]+)>')
207 209
208 self._emitters = None # set later 210 self._emitters = None # set later
209 211
210 212
211 def _StripModules(self, type_name): 213 def _StripModules(self, type_name):
212 return type_name.split('::')[-1] 214 return type_name.split('::')[-1]
213 215
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 lib_template -- template file in this directory for generated lib file. 419 lib_template -- template file in this directory for generated lib file.
418 """ 420 """
419 421
420 self._emitters = multiemitter.MultiEmitter() 422 self._emitters = multiemitter.MultiEmitter()
421 self._database = database 423 self._database = database
422 self._output_dir = output_dir 424 self._output_dir = output_dir
423 425
424 self._ComputeInheritanceClosure() 426 self._ComputeInheritanceClosure()
425 427
426 interface_system = WrappingInterfacesSystem( 428 interface_system = WrappingInterfacesSystem(
427 TemplateLoader('../templates', ['dom/interface', 'dom', '']), 429 TemplateLoader(self._template_dir, ['dom/interface', 'dom', '']),
428 self._database, self._emitters, self._output_dir) 430 self._database, self._emitters, self._output_dir)
429 431
430 wrapping_system = WrappingImplementationSystem( 432 wrapping_system = WrappingImplementationSystem(
431 TemplateLoader('../templates', ['dom/wrapping', 'dom', '']), 433 TemplateLoader(self._template_dir, ['dom/wrapping', 'dom', '']),
432 self._database, self._emitters, self._output_dir) 434 self._database, self._emitters, self._output_dir)
433 435
434 # Makes interface files available for listing in the library for the 436 # Makes interface files available for listing in the library for the
435 # wrapping implementation. 437 # wrapping implementation.
436 wrapping_system._interface_system = interface_system 438 wrapping_system._interface_system = interface_system
437 439
438 frog_system = FrogSystem( 440 frog_system = FrogSystem(
439 TemplateLoader('../templates', ['dom/frog', 'dom', '']), 441 TemplateLoader(self._template_dir, ['dom/frog', 'dom', '']),
440 self._database, self._emitters, self._output_dir) 442 self._database, self._emitters, self._output_dir)
441 443
442 self._systems = [interface_system, 444 self._systems = [interface_system,
443 wrapping_system, 445 wrapping_system,
444 frog_system] 446 frog_system]
445 447
446 # Render all interfaces into Dart and save them in files. 448 # Render all interfaces into Dart and save them in files.
447 for interface in database.GetInterfaces(): 449 for interface in database.GetInterfaces():
448 450
449 super_interface = None 451 super_interface = None
(...skipping 1562 matching lines...) Expand 10 before | Expand all | Expand 10 after
2012 Arguments: 2014 Arguments:
2013 info: An OperationInfo object. 2015 info: An OperationInfo object.
2014 """ 2016 """
2015 # TODO(vsm): Handle overloads. 2017 # TODO(vsm): Handle overloads.
2016 self._members_emitter.Emit( 2018 self._members_emitter.Emit(
2017 '\n' 2019 '\n'
2018 ' $TYPE $NAME($ARGS) native;\n', 2020 ' $TYPE $NAME($ARGS) native;\n',
2019 TYPE=info.type_name, 2021 TYPE=info.type_name,
2020 NAME=info.name, 2022 NAME=info.name,
2021 ARGS=info.arg_implementation_declaration) 2023 ARGS=info.arg_implementation_declaration)
OLDNEW
« client/dom/idl/dart/dart.idl ('K') | « client/dom/scripts/dartdomgenerator.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698