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

Side by Side Diff: lib/html/scripts/dartdomgenerator.py

Issue 10986048: Get rid of System classes for backend generators. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: . Created 8 years, 2 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 | « no previous file | lib/html/scripts/dartgenerator.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) 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 is the entry point to create Dart APIs from the IDL database.""" 6 """This is the entry point to create Dart APIs from the IDL database."""
7 7
8 import dartgenerator 8 import dartgenerator
9 import database 9 import database
10 import logging.config 10 import logging.config
11 import multiemitter 11 import multiemitter
12 import optparse 12 import optparse
13 import os 13 import os
14 import shutil 14 import shutil
15 import subprocess 15 import subprocess
16 import sys 16 import sys
17 from generator import TypeRegistry 17 from generator import TypeRegistry
18 from htmlrenamer import HtmlRenamer 18 from htmlrenamer import HtmlRenamer
19 from systembase import GeneratorOptions 19 from systembase import GeneratorOptions
20 from systemdart2js import Dart2JSSystem 20 from systemdart2js import Dart2JSSystem
21 from systemhtml import DartLibraryEmitter, HtmlInterfacesSystem,\ 21 from systemhtml import DartLibraryEmitter, HtmlInterfacesSystem,\
22 HtmlDart2JSSystem 22 Dart2JSBackend
23 from systeminterface import InterfacesSystem 23 from systeminterface import InterfacesSystem
24 from systemnative import CPPLibraryEmitter, NativeImplementationSystem 24 from systemnative import CPPLibraryEmitter, DartiumBackend
25 from templateloader import TemplateLoader 25 from templateloader import TemplateLoader
26 26
27 _logger = logging.getLogger('dartdomgenerator') 27 _logger = logging.getLogger('dartdomgenerator')
28 28
29 _webkit_renames = { 29 _webkit_renames = {
30 # W3C -> WebKit name conversion 30 # W3C -> WebKit name conversion
31 # TODO(vsm): Maybe Store these renames in the IDLs. 31 # TODO(vsm): Maybe Store these renames in the IDLs.
32 'ApplicationCache': 'DOMApplicationCache', 32 'ApplicationCache': 'DOMApplicationCache',
33 'BarProp': 'BarInfo', 33 'BarProp': 'BarInfo',
34 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext', 34 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext',
(...skipping 28 matching lines...) Expand all
63 exclude_suppressed = ['WebKit', 'Dart']) 63 exclude_suppressed = ['WebKit', 'Dart'])
64 generator.RenameTypes(webkit_database, _webkit_renames, True) 64 generator.RenameTypes(webkit_database, _webkit_renames, True)
65 generator.FixEventTargets(webkit_database) 65 generator.FixEventTargets(webkit_database)
66 generator.AddMissingArguments(webkit_database) 66 generator.AddMissingArguments(webkit_database)
67 67
68 emitters = multiemitter.MultiEmitter() 68 emitters = multiemitter.MultiEmitter()
69 renamer = HtmlRenamer(webkit_database) 69 renamer = HtmlRenamer(webkit_database)
70 type_registry = TypeRegistry(webkit_database, renamer) 70 type_registry = TypeRegistry(webkit_database, renamer)
71 71
72 def RunGenerator(dart_library_template, dart_output_dir, dart_library_path, 72 def RunGenerator(dart_library_template, dart_output_dir, dart_library_path,
73 backend): 73 template_loader, backend_factory):
74 template_loader = TemplateLoader(
75 template_dir, ['html/interface', 'html/impl', 'html', ''], {})
76 options = GeneratorOptions( 74 options = GeneratorOptions(
77 template_loader, webkit_database, type_registry, renamer) 75 template_loader, webkit_database, type_registry, renamer)
78 dart_library_emitter = DartLibraryEmitter( 76 dart_library_emitter = DartLibraryEmitter(
79 emitters, dart_library_template, dart_output_dir) 77 emitters, dart_library_template, dart_output_dir)
80 html_system = HtmlInterfacesSystem(options, dart_library_emitter, backend) 78 html_system = HtmlInterfacesSystem(
79 options, dart_library_emitter, backend_factory)
81 generator.Generate( 80 generator.Generate(
82 webkit_database, html_system, common_database, _webkit_renames) 81 webkit_database, html_system, common_database, _webkit_renames)
83 dart_library_emitter.EmitLibrary(dart_library_path, auxiliary_dir) 82 dart_library_emitter.EmitLibrary(dart_library_path, auxiliary_dir)
84 83
85 if dart2js_output_dir: 84 if dart2js_output_dir:
85 template_paths = ['html/dart2js', 'html/impl', 'html/interface', '']
86 template_loader = TemplateLoader(template_dir, 86 template_loader = TemplateLoader(template_dir,
87 ['html/dart2js', 'html/impl', 'html', ''], 87 template_paths,
88 {'DARTIUM': False, 'DART2JS': True}) 88 {'DARTIUM': False, 'DART2JS': True})
89 backend_options = GeneratorOptions( 89 backend_options = GeneratorOptions(
90 template_loader, webkit_database, type_registry, renamer) 90 template_loader, webkit_database, type_registry, renamer)
91 backend = HtmlDart2JSSystem(backend_options) 91 backend_factory = lambda interface:\
92 Dart2JSBackend(interface, backend_options)
92 93
93 dart_library_template = template_loader.Load('html_dart2js.darttemplate') 94 dart_library_template = template_loader.Load('html_dart2js.darttemplate')
94 dart_output_dir = os.path.join(dart2js_output_dir, 'dart') 95 dart_output_dir = os.path.join(dart2js_output_dir, 'dart')
95 dart_library_path = os.path.join(dart2js_output_dir, 'html_dart2js.dart') 96 dart_library_path = os.path.join(dart2js_output_dir, 'html_dart2js.dart')
96 97
97 RunGenerator( 98 RunGenerator(dart_library_template, dart_output_dir, dart_library_path,
98 dart_library_template, dart_output_dir, dart_library_path, backend) 99 template_loader, backend_factory)
99 100
100 if dartium_output_dir: 101 if dartium_output_dir:
102 template_paths = ['html/dartium', 'html/impl', 'html/interface', '']
101 template_loader = TemplateLoader(template_dir, 103 template_loader = TemplateLoader(template_dir,
102 ['html/dartium', 'html/impl', ''], 104 template_paths,
103 {'DARTIUM': True, 'DART2JS': False}) 105 {'DARTIUM': True, 'DART2JS': False})
104 backend_options = GeneratorOptions( 106 backend_options = GeneratorOptions(
105 template_loader, webkit_database, type_registry, renamer) 107 template_loader, webkit_database, type_registry, renamer)
106 cpp_output_dir = os.path.join(dartium_output_dir, 'cpp') 108 cpp_output_dir = os.path.join(dartium_output_dir, 'cpp')
107 cpp_library_emitter = CPPLibraryEmitter(emitters, cpp_output_dir) 109 cpp_library_emitter = CPPLibraryEmitter(emitters, cpp_output_dir)
108 backend = NativeImplementationSystem(backend_options, cpp_library_emitter) 110 backend_factory = lambda interface:\
111 DartiumBackend(interface, cpp_library_emitter, backend_options)
109 112
110 dart_library_template = template_loader.Load('html_dartium.darttemplate') 113 dart_library_template = template_loader.Load('html_dartium.darttemplate')
111 dart_output_dir = os.path.join(dartium_output_dir, 'dart') 114 dart_output_dir = os.path.join(dartium_output_dir, 'dart')
112 dart_library_path = os.path.join(dartium_output_dir, 'html_dartium.dart') 115 dart_library_path = os.path.join(dartium_output_dir, 'html_dartium.dart')
113 116
114 RunGenerator( 117 RunGenerator(dart_library_template, dart_output_dir, dart_library_path,
115 dart_library_template, dart_output_dir, dart_library_path, backend) 118 template_loader, backend_factory)
116 cpp_library_emitter.EmitDerivedSources( 119 cpp_library_emitter.EmitDerivedSources(
117 template_loader.Load('cpp_derived_sources.template'), 120 template_loader.Load('cpp_derived_sources.template'),
118 dartium_output_dir) 121 dartium_output_dir)
119 cpp_library_emitter.EmitResolver( 122 cpp_library_emitter.EmitResolver(
120 template_loader.Load('cpp_resolver.template'), dartium_output_dir) 123 template_loader.Load('cpp_resolver.template'), dartium_output_dir)
121 124
122 _logger.info('Flush...') 125 _logger.info('Flush...')
123 emitters.Flush() 126 emitters.Flush()
124 127
125 def GenerateSingleFile(library_path, output_dir): 128 def GenerateSingleFile(library_path, output_dir):
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 _logger.info('Copy html_dart2js to dart2js/') 171 _logger.info('Copy html_dart2js to dart2js/')
169 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'), 172 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'),
170 '../dart2js') 173 '../dart2js')
171 if 'htmldartium' in systems: 174 if 'htmldartium' in systems:
172 _logger.info('Copy html_dartium to dartium/') 175 _logger.info('Copy html_dartium to dartium/')
173 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'), 176 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'),
174 '../dartium') 177 '../dartium')
175 178
176 if __name__ == '__main__': 179 if __name__ == '__main__':
177 sys.exit(main()) 180 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | lib/html/scripts/dartgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698