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

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

Issue 10703194: Extract interfaces and members renaming logic to a new HtmlRenamer class. (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
« no previous file with comments | « no previous file | lib/dom/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 systembase import GeneratorOptions 19 from systembase import GeneratorOptions
19 from systemfrog import FrogSystem 20 from systemfrog import FrogSystem
20 from systemhtml import HtmlInterfacesSystem, HtmlFrogSystem, HtmlSystemShared 21 from systemhtml import HtmlInterfacesSystem, HtmlFrogSystem
21 from systeminterface import InterfacesSystem 22 from systeminterface import InterfacesSystem
22 from systemnative import NativeImplementationSystem 23 from systemnative import NativeImplementationSystem
23 from templateloader import TemplateLoader 24 from templateloader import TemplateLoader
24 25
25 _logger = logging.getLogger('dartdomgenerator') 26 _logger = logging.getLogger('dartdomgenerator')
26 27
27 _webkit_renames = { 28 _webkit_renames = {
28 # W3C -> WebKit name conversion 29 # W3C -> WebKit name conversion
29 # TODO(vsm): Maybe Store these renames in the IDLs. 30 # TODO(vsm): Maybe Store these renames in the IDLs.
30 'ApplicationCache': 'DOMApplicationCache', 31 'ApplicationCache': 'DOMApplicationCache',
(...skipping 24 matching lines...) Expand all
55 webkit_database = common_database.Clone() 56 webkit_database = common_database.Clone()
56 57
57 # Generate Dart interfaces for the WebKit DOM. 58 # Generate Dart interfaces for the WebKit DOM.
58 generator.FilterInterfaces(database = webkit_database, 59 generator.FilterInterfaces(database = webkit_database,
59 or_annotations = ['WebKit', 'Dart'], 60 or_annotations = ['WebKit', 'Dart'],
60 exclude_displaced = ['WebKit'], 61 exclude_displaced = ['WebKit'],
61 exclude_suppressed = ['WebKit', 'Dart']) 62 exclude_suppressed = ['WebKit', 'Dart'])
62 generator.RenameTypes(webkit_database, _webkit_renames, True) 63 generator.RenameTypes(webkit_database, _webkit_renames, True)
63 generator.FixEventTargets(webkit_database) 64 generator.FixEventTargets(webkit_database)
64 65
65 def CreateGeneratorOptions(template_paths, conditions, type_registry, 66 def CreateGeneratorOptions(template_paths, conditions, type_registry, output_d ir,
66 output_dir): 67 renamer=None):
68 template_loader = TemplateLoader(template_dir, template_paths, conditions)
67 return GeneratorOptions( 69 return GeneratorOptions(
68 TemplateLoader(template_dir, template_paths, conditions), 70 template_loader, webkit_database, emitters, type_registry, renamer,
69 webkit_database, emitters, type_registry, output_dir) 71 output_dir)
70 72
71 def Generate(system): 73 def Generate(system):
72 generator.Generate(webkit_database, system, 74 generator.Generate(webkit_database, system,
73 super_database=common_database, 75 super_database=common_database,
74 webkit_renames=_webkit_renames) 76 webkit_renames=_webkit_renames)
75 77
76 emitters = multiemitter.MultiEmitter() 78 emitters = multiemitter.MultiEmitter()
77 79
78 for system_name in system_names: 80 for system_name in system_names:
79 if system_name in ['htmlfrog', 'htmldartium']: 81 if system_name in ['htmlfrog', 'htmldartium']:
80 renames = HtmlSystemShared.MakeHtmlRenames(webkit_database) 82 renamer = HtmlRenamer(webkit_database)
81 type_registry = TypeRegistry(renames) 83 type_registry = TypeRegistry(webkit_database, renamer)
82 if system_name == 'htmlfrog': 84 if system_name == 'htmlfrog':
83 options = CreateGeneratorOptions( 85 options = CreateGeneratorOptions(
84 ['html/frog', 'html/impl', 'html', ''], 86 ['html/frog', 'html/impl', 'html', ''],
85 {'DARTIUM': False, 'FROG': True}, 87 {'DARTIUM': False, 'FROG': True},
86 type_registry, 88 type_registry, html_output_dir, renamer)
87 html_output_dir)
88 backend = HtmlFrogSystem(options) 89 backend = HtmlFrogSystem(options)
89 else: 90 else:
90 options = CreateGeneratorOptions( 91 options = CreateGeneratorOptions(
91 ['dom/native', 'html/dartium', 'html/impl', ''], 92 ['dom/native', 'html/dartium', 'html/impl', ''],
92 {'DARTIUM': True, 'FROG': False}, 93 {'DARTIUM': True, 'FROG': False},
93 type_registry, 94 type_registry, html_output_dir, renamer)
94 html_output_dir)
95 backend = NativeImplementationSystem(options, auxiliary_dir) 95 backend = NativeImplementationSystem(options, auxiliary_dir)
96 options = CreateGeneratorOptions( 96 options = CreateGeneratorOptions(
97 ['html/interface', 'html/impl', 'html', ''], {}, type_registry, 97 ['html/interface', 'html/impl', 'html', ''], {},
98 html_output_dir) 98 type_registry, html_output_dir, renamer)
99 html_system = HtmlInterfacesSystem(options, backend) 99 html_system = HtmlInterfacesSystem(options, backend)
100 Generate(html_system) 100 Generate(html_system)
101 else: 101 else:
102 type_registry = TypeRegistry({}) 102 type_registry = TypeRegistry(webkit_database)
103 options = CreateGeneratorOptions( 103 options = CreateGeneratorOptions(
104 ['dom/interface', 'dom', ''], {}, type_registry, dom_output_dir) 104 ['dom/interface', 'dom', ''], {}, type_registry, dom_output_dir)
105 interface_system = InterfacesSystem(options) 105 interface_system = InterfacesSystem(options)
106 if system_name == 'dummy': 106 if system_name == 'dummy':
107 options = CreateGeneratorOptions( 107 options = CreateGeneratorOptions(
108 ['dom/dummy', 'dom', ''], {}, type_registry, dom_output_dir) 108 ['dom/dummy', 'dom', ''], {}, type_registry, dom_output_dir)
109 implementation_system = dartgenerator.DummyImplementationSystem( 109 implementation_system = dartgenerator.DummyImplementationSystem(
110 options) 110 options)
111 elif system_name == 'frog': 111 elif system_name == 'frog':
112 options = CreateGeneratorOptions( 112 options = CreateGeneratorOptions(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 dom_output_dir = options.output_dir or os.path.join(current_dir, 177 dom_output_dir = options.output_dir or os.path.join(current_dir,
178 '../generated') 178 '../generated')
179 html_output_dir = options.output_dir or os.path.join(current_dir, 179 html_output_dir = options.output_dir or os.path.join(current_dir,
180 '../../html/generated') 180 '../../html/generated')
181 Generate(systems, database_dir, options.use_database_cache, 181 Generate(systems, database_dir, options.use_database_cache,
182 dom_output_dir, html_output_dir) 182 dom_output_dir, html_output_dir)
183 GenerateSingleFile(systems) 183 GenerateSingleFile(systems)
184 184
185 if __name__ == '__main__': 185 if __name__ == '__main__':
186 sys.exit(main()) 186 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | lib/dom/scripts/dartgenerator.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698