| OLD | NEW |
| 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 systembase import GeneratorContext | 18 from systembase import GeneratorContext |
| 19 from systemfrog import FrogSystem | 19 from systemfrog import FrogSystem |
| 20 from systemhtml import HtmlInterfacesSystem, HtmlFrogSystem | 20 from systemhtml import HtmlInterfacesSystem, HtmlFrogSystem, HtmlSystemShared |
| 21 from systeminterface import InterfacesSystem | 21 from systeminterface import InterfacesSystem |
| 22 from systemnative import NativeImplementationSystem | 22 from systemnative import NativeImplementationSystem |
| 23 from templateloader import TemplateLoader | 23 from templateloader import TemplateLoader |
| 24 | 24 |
| 25 _logger = logging.getLogger('dartdomgenerator') | 25 _logger = logging.getLogger('dartdomgenerator') |
| 26 | 26 |
| 27 _webkit_renames = { | 27 _webkit_renames = { |
| 28 # W3C -> WebKit name conversion | 28 # W3C -> WebKit name conversion |
| 29 # TODO(vsm): Maybe Store these renames in the IDLs. | 29 # TODO(vsm): Maybe Store these renames in the IDLs. |
| 30 'ApplicationCache': 'DOMApplicationCache', | 30 'ApplicationCache': 'DOMApplicationCache', |
| (...skipping 24 matching lines...) Expand all Loading... |
| 55 webkit_database = common_database.Clone() | 55 webkit_database = common_database.Clone() |
| 56 | 56 |
| 57 # Generate Dart interfaces for the WebKit DOM. | 57 # Generate Dart interfaces for the WebKit DOM. |
| 58 generator.FilterInterfaces(database = webkit_database, | 58 generator.FilterInterfaces(database = webkit_database, |
| 59 or_annotations = ['WebKit', 'Dart'], | 59 or_annotations = ['WebKit', 'Dart'], |
| 60 exclude_displaced = ['WebKit'], | 60 exclude_displaced = ['WebKit'], |
| 61 exclude_suppressed = ['WebKit', 'Dart']) | 61 exclude_suppressed = ['WebKit', 'Dart']) |
| 62 generator.RenameTypes(webkit_database, _webkit_renames, True) | 62 generator.RenameTypes(webkit_database, _webkit_renames, True) |
| 63 generator.FixEventTargets(webkit_database) | 63 generator.FixEventTargets(webkit_database) |
| 64 | 64 |
| 65 def CreateGeneratorContext(template_paths, conditions, output_dir): | 65 def CreateGeneratorContext(template_paths, conditions, type_registry, |
| 66 output_dir): |
| 66 return GeneratorContext( | 67 return GeneratorContext( |
| 67 TemplateLoader(template_dir, template_paths, conditions), | 68 TemplateLoader(template_dir, template_paths, conditions), |
| 68 webkit_database, emitters, TypeRegistry(), output_dir) | 69 webkit_database, emitters, type_registry, output_dir) |
| 69 | 70 |
| 70 def Generate(system): | 71 def Generate(system): |
| 71 generator.Generate(webkit_database, system, | 72 generator.Generate(webkit_database, system, |
| 72 super_database=common_database, | 73 super_database=common_database, |
| 73 webkit_renames=_webkit_renames) | 74 webkit_renames=_webkit_renames) |
| 74 | 75 |
| 75 emitters = multiemitter.MultiEmitter() | 76 emitters = multiemitter.MultiEmitter() |
| 76 | 77 |
| 77 for system_name in system_names: | 78 for system_name in system_names: |
| 78 if system_name in ['htmlfrog', 'htmldartium']: | 79 if system_name in ['htmlfrog', 'htmldartium']: |
| 80 renames = HtmlSystemShared.MakeHtmlRenames(webkit_database) |
| 81 type_registry = TypeRegistry(renames) |
| 79 if system_name == 'htmlfrog': | 82 if system_name == 'htmlfrog': |
| 80 context = CreateGeneratorContext( | 83 context = CreateGeneratorContext( |
| 81 ['html/frog', 'html/impl', 'html', ''], | 84 ['html/frog', 'html/impl', 'html', ''], |
| 82 {'DARTIUM': False, 'FROG': True}, | 85 {'DARTIUM': False, 'FROG': True}, |
| 86 type_registry, |
| 83 html_output_dir) | 87 html_output_dir) |
| 84 backend = HtmlFrogSystem(context) | 88 backend = HtmlFrogSystem(context) |
| 85 else: | 89 else: |
| 86 context = CreateGeneratorContext( | 90 context = CreateGeneratorContext( |
| 87 ['dom/native', 'html/dartium', 'html/impl', ''], | 91 ['dom/native', 'html/dartium', 'html/impl', ''], |
| 88 {'DARTIUM': True, 'FROG': False}, | 92 {'DARTIUM': True, 'FROG': False}, |
| 93 type_registry, |
| 89 html_output_dir) | 94 html_output_dir) |
| 90 backend = NativeImplementationSystem(context, auxiliary_dir) | 95 backend = NativeImplementationSystem(context, auxiliary_dir) |
| 91 context = CreateGeneratorContext( | 96 context = CreateGeneratorContext( |
| 92 ['html/interface', 'html/impl', 'html', ''], {}, html_output_dir) | 97 ['html/interface', 'html/impl', 'html', ''], {}, type_registry, |
| 98 html_output_dir) |
| 93 html_system = HtmlInterfacesSystem(context, backend) | 99 html_system = HtmlInterfacesSystem(context, backend) |
| 94 Generate(html_system) | 100 Generate(html_system) |
| 95 else: | 101 else: |
| 102 type_registry = TypeRegistry({}) |
| 96 context = CreateGeneratorContext( | 103 context = CreateGeneratorContext( |
| 97 ['dom/interface', 'dom', ''], {}, dom_output_dir) | 104 ['dom/interface', 'dom', ''], {}, type_registry, dom_output_dir) |
| 98 interface_system = InterfacesSystem(context) | 105 interface_system = InterfacesSystem(context) |
| 99 if system_name == 'dummy': | 106 if system_name == 'dummy': |
| 100 context = CreateGeneratorContext( | 107 context = CreateGeneratorContext( |
| 101 ['dom/dummy', 'dom', ''], {}, dom_output_dir) | 108 ['dom/dummy', 'dom', ''], {}, type_registry, dom_output_dir) |
| 102 implementation_system = dartgenerator.DummyImplementationSystem( | 109 implementation_system = dartgenerator.DummyImplementationSystem( |
| 103 context) | 110 context) |
| 104 elif system_name == 'frog': | 111 elif system_name == 'frog': |
| 105 context = CreateGeneratorContext( | 112 context = CreateGeneratorContext( |
| 106 ['dom/frog', 'dom', ''], {}, dom_output_dir) | 113 ['dom/frog', 'dom', ''], {}, type_registry, dom_output_dir) |
| 107 implementation_system = FrogSystem(context) | 114 implementation_system = FrogSystem(context) |
| 108 else: | 115 else: |
| 109 raise Exception('Unsupported system_name %s' % system_name) | 116 raise Exception('Unsupported system_name %s' % system_name) |
| 110 | 117 |
| 111 # Makes interface files available for listing in the library for the | 118 # Makes interface files available for listing in the library for the |
| 112 # implementation system. | 119 # implementation system. |
| 113 implementation_system._interface_system = interface_system | 120 implementation_system._interface_system = interface_system |
| 114 Generate(interface_system) | 121 Generate(interface_system) |
| 115 Generate(implementation_system) | 122 Generate(implementation_system) |
| 116 | 123 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 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, |
| 171 '../generated') | 178 '../generated') |
| 172 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, |
| 173 '../../html/generated') | 180 '../../html/generated') |
| 174 Generate(systems, database_dir, options.use_database_cache, | 181 Generate(systems, database_dir, options.use_database_cache, |
| 175 dom_output_dir, html_output_dir) | 182 dom_output_dir, html_output_dir) |
| 176 GenerateSingleFile(systems) | 183 GenerateSingleFile(systems) |
| 177 | 184 |
| 178 if __name__ == '__main__': | 185 if __name__ == '__main__': |
| 179 sys.exit(main()) | 186 sys.exit(main()) |
| OLD | NEW |