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

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

Issue 10704008: Make HtmlFrogSystem and NativeImplementationSystem the backends for HtmlInterfacesSystem and remove… (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 systemfrog import FrogSystem 17 from systemfrog import FrogSystem
18 from systemhtml import HtmlInterfacesSystem, HtmlFrogSystem, HtmlDartiumSystem 18 from systemhtml import HtmlInterfacesSystem, HtmlFrogSystem
19 from systeminterface import InterfacesSystem 19 from systeminterface import InterfacesSystem
20 from systemnative import NativeImplementationSystem 20 from systemnative import NativeImplementationSystem
21 from templateloader import TemplateLoader 21 from templateloader import TemplateLoader
22 22
23 _logger = logging.getLogger('dartdomgenerator') 23 _logger = logging.getLogger('dartdomgenerator')
24 24
25 _webkit_renames = { 25 _webkit_renames = {
26 # W3C -> WebKit name conversion 26 # W3C -> WebKit name conversion
27 # TODO(vsm): Maybe Store these renames in the IDLs. 27 # TODO(vsm): Maybe Store these renames in the IDLs.
28 'ApplicationCache': 'DOMApplicationCache', 28 'ApplicationCache': 'DOMApplicationCache',
29 'BarProp': 'BarInfo', 29 'BarProp': 'BarInfo',
30 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext', 30 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext',
31 'FormData': 'DOMFormData', 31 'FormData': 'DOMFormData',
32 'Selection': 'DOMSelection', 32 'Selection': 'DOMSelection',
33 'SharedWorkerGlobalScope': 'SharedWorkerContext', 33 'SharedWorkerGlobalScope': 'SharedWorkerContext',
34 'Window': 'DOMWindow', 34 'Window': 'DOMWindow',
35 'WorkerGlobalScope': 'WorkerContext'} 35 'WorkerGlobalScope': 'WorkerContext'}
36 36
37 def Generate(systems, database_dir, use_database_cache, dom_output_dir, 37 def Generate(system_names, database_dir, use_database_cache, dom_output_dir,
38 html_output_dir): 38 html_output_dir):
39 current_dir = os.path.dirname(__file__) 39 current_dir = os.path.dirname(__file__)
40 auxiliary_dir = os.path.join(current_dir, '..', 'src') 40 auxiliary_dir = os.path.join(current_dir, '..', 'src')
41 template_dir = os.path.join(current_dir, '..', 'templates') 41 template_dir = os.path.join(current_dir, '..', 'templates')
42 42
43 generator = dartgenerator.DartGenerator() 43 generator = dartgenerator.DartGenerator()
44 generator.LoadAuxiliary(auxiliary_dir) 44 generator.LoadAuxiliary(auxiliary_dir)
45 45
46 common_database = database.Database(database_dir) 46 common_database = database.Database(database_dir)
47 if use_database_cache: 47 if use_database_cache:
48 common_database.LoadFromCache() 48 common_database.LoadFromCache()
49 else: 49 else:
50 common_database.Load() 50 common_database.Load()
51 51
52 generator.FilterMembersWithUnidentifiedTypes(common_database) 52 generator.FilterMembersWithUnidentifiedTypes(common_database)
53 webkit_database = common_database.Clone() 53 webkit_database = common_database.Clone()
54 54
55 # Generate Dart interfaces for the WebKit DOM. 55 # Generate Dart interfaces for the WebKit DOM.
56 generator.FilterInterfaces(database = webkit_database, 56 generator.FilterInterfaces(database = webkit_database,
57 or_annotations = ['WebKit', 'Dart'], 57 or_annotations = ['WebKit', 'Dart'],
58 exclude_displaced = ['WebKit'], 58 exclude_displaced = ['WebKit'],
59 exclude_suppressed = ['WebKit', 'Dart']) 59 exclude_suppressed = ['WebKit', 'Dart'])
60 generator.RenameTypes(webkit_database, _webkit_renames, True) 60 generator.RenameTypes(webkit_database, _webkit_renames, True)
61 generator.FixEventTargets(webkit_database) 61 generator.FixEventTargets(webkit_database)
62 62
63 def Generate(system):
64 generator.Generate(webkit_database, system,
65 super_database=common_database,
66 webkit_renames=_webkit_renames)
67
63 emitters = multiemitter.MultiEmitter() 68 emitters = multiemitter.MultiEmitter()
64 69
65 for system in systems: 70 systems = []
Anton Muhin 2012/06/27 19:06:28 is it used?
podivilov 2012/06/29 10:01:52 Done.
66 if system in ['htmlfrog', 'htmldartium']: 71 for system_name in system_names:
67 72 if system_name in ['htmlfrog', 'htmldartium']:
68 output_dir = html_output_dir 73 output_dir = html_output_dir
69 interface_system = HtmlInterfacesSystem( 74 if system_name == 'htmlfrog':
75 backend = HtmlFrogSystem(
76 TemplateLoader(template_dir,
77 ['html/frog', 'html/impl', 'html', ''],
78 {'DARTIUM': False, 'FROG': True}),
79 webkit_database, emitters, output_dir)
80 else:
81 backend = NativeImplementationSystem(
82 TemplateLoader(template_dir, ['dom/native', 'html/dartium',
83 'html/impl', ''],
84 {'DARTIUM': True, 'FROG': False}),
85 webkit_database, emitters, output_dir, auxiliary_dir)
86 html_system = HtmlInterfacesSystem(
70 TemplateLoader(template_dir, ['html/interface', 'html', '']), 87 TemplateLoader(template_dir, ['html/interface', 'html', '']),
71 webkit_database, emitters, output_dir) 88 webkit_database, emitters, output_dir, backend)
89 Generate(html_system)
72 else: 90 else:
73 output_dir = dom_output_dir 91 output_dir = dom_output_dir
74 interface_system = InterfacesSystem( 92 interface_system = InterfacesSystem(
75 TemplateLoader(template_dir, ['dom/interface', 'dom', '']), 93 TemplateLoader(template_dir, ['dom/interface', 'dom', '']),
76 webkit_database, emitters, output_dir) 94 webkit_database, emitters, output_dir)
95 if system_name == 'dummy':
96 implementation_system = dartgenerator.DummyImplementationSystem(
97 TemplateLoader(template_dir, ['dom/dummy', 'dom', '']),
98 webkit_database, emitters, output_dir)
99 elif system_name == 'frog':
100 implementation_system = FrogSystem(
101 TemplateLoader(template_dir, ['dom/frog', 'dom', '']),
102 webkit_database, emitters, output_dir)
103 else:
104 raise Exception('Unsupported system_name %s' % system_name)
77 105
78 if system == 'dummy': 106 # Makes interface files available for listing in the library for the
79 implementation_system = dartgenerator.DummyImplementationSystem( 107 # implementation system.
80 TemplateLoader(template_dir, ['dom/dummy', 'dom', '']), 108 implementation_system._interface_system = interface_system
81 webkit_database, emitters, output_dir) 109 Generate(interface_system)
82 elif system == 'frog': 110 Generate(implementation_system)
83 implementation_system = FrogSystem(
84 TemplateLoader(template_dir, ['dom/frog', 'dom', '']),
85 webkit_database, emitters, output_dir)
86 elif system == 'htmlfrog':
87 implementation_system = HtmlFrogSystem(
88 TemplateLoader(template_dir,
89 ['html/frog', 'html/impl', 'html', ''],
90 {'DARTIUM': False, 'FROG': True}),
91 webkit_database, emitters, output_dir)
92 elif system == 'htmldartium':
93 # Generate native wrappers.
94 native_system = NativeImplementationSystem(
95 TemplateLoader(template_dir, ['dom/native', 'html/dartium',
96 'html/impl', ''],
97 {'DARTIUM': True, 'FROG': False}),
98 webkit_database, emitters, output_dir)
99 generator.Generate(webkit_database, native_system,
100 super_database=common_database,
101 webkit_renames=_webkit_renames)
102 dom_implementation_classes = native_system.DartImplementationFiles()
103 implementation_system = HtmlDartiumSystem(
104 TemplateLoader(template_dir,
105 ['html/dartium', 'html/impl', 'html', ''],
106 {'DARTIUM': True, 'FROG': False}),
107 webkit_database, emitters, auxiliary_dir, dom_implementation_classes,
108 output_dir)
109 else:
110 raise Exception('Unsupported system %s' % system)
111
112 # Makes interface files available for listing in the library for the
113 # implementation system.
114 implementation_system._interface_system = interface_system
115
116 for system in [interface_system, implementation_system]:
117 generator.Generate(webkit_database, system,
118 super_database=common_database,
119 webkit_renames=_webkit_renames)
120 111
121 _logger.info('Flush...') 112 _logger.info('Flush...')
122 emitters.Flush() 113 emitters.Flush()
123 114
124 def GenerateSingleFile(systems): 115 def GenerateSingleFile(systems):
125 if 'frog' in systems: 116 if 'frog' in systems:
126 _logger.info('Copy dom_frog to frog/') 117 _logger.info('Copy dom_frog to frog/')
127 subprocess.call(['cd ../generated ; ' 118 subprocess.call(['cd ../generated ; '
128 '../../../tools/copy_dart.py ../frog dom_frog.dart'], 119 '../../../tools/copy_dart.py ../frog dom_frog.dart'],
129 shell=True); 120 shell=True);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 dom_output_dir = options.output_dir or os.path.join(current_dir, 165 dom_output_dir = options.output_dir or os.path.join(current_dir,
175 '../generated') 166 '../generated')
176 html_output_dir = options.output_dir or os.path.join(current_dir, 167 html_output_dir = options.output_dir or os.path.join(current_dir,
177 '../../html/generated') 168 '../../html/generated')
178 Generate(systems, database_dir, options.use_database_cache, 169 Generate(systems, database_dir, options.use_database_cache,
179 dom_output_dir, html_output_dir) 170 dom_output_dir, html_output_dir)
180 GenerateSingleFile(systems) 171 GenerateSingleFile(systems)
181 172
182 if __name__ == '__main__': 173 if __name__ == '__main__':
183 sys.exit(main()) 174 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