| 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 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 html_renames['WebKit' + subclass] = subclass | 63 html_renames['WebKit' + subclass] = subclass |
| 64 | 64 |
| 65 # TODO(jacobr): we almost want to add this commented out line back. | 65 # TODO(jacobr): we almost want to add this commented out line back. |
| 66 # html_renames['HTMLCollection'] = 'ElementList' | 66 # html_renames['HTMLCollection'] = 'ElementList' |
| 67 # html_renames['NodeList'] = 'ElementList' | 67 # html_renames['NodeList'] = 'ElementList' |
| 68 # html_renames['HTMLOptionsCollection'] = 'ElementList' | 68 # html_renames['HTMLOptionsCollection'] = 'ElementList' |
| 69 html_renames['DOMWindow'] = 'Window' | 69 html_renames['DOMWindow'] = 'Window' |
| 70 | 70 |
| 71 return html_renames | 71 return html_renames |
| 72 | 72 |
| 73 def GenerateDOM(systems, generate_html_systems, output_dir, use_database_cache): | 73 def GenerateDOM(systems, generate_html_systems, output_dir, |
| 74 database_dir, use_database_cache): |
| 74 current_dir = os.path.dirname(__file__) | 75 current_dir = os.path.dirname(__file__) |
| 75 | 76 |
| 76 generator = dartgenerator.DartGenerator( | 77 generator = dartgenerator.DartGenerator( |
| 77 auxiliary_dir=os.path.join(current_dir, '..', 'src'), | 78 auxiliary_dir=os.path.join(current_dir, '..', 'src'), |
| 78 template_dir=os.path.join(current_dir, '..', 'templates'), | 79 template_dir=os.path.join(current_dir, '..', 'templates'), |
| 79 base_package='') | 80 base_package='') |
| 80 generator.LoadAuxiliary() | 81 generator.LoadAuxiliary() |
| 81 | 82 |
| 82 common_database = database.Database( | 83 common_database = database.Database(database_dir) |
| 83 os.path.join(current_dir, '..', 'database')) | |
| 84 if use_database_cache: | 84 if use_database_cache: |
| 85 common_database.LoadFromCache() | 85 common_database.LoadFromCache() |
| 86 else: | 86 else: |
| 87 common_database.Load() | 87 common_database.Load() |
| 88 # Remove these types since they are mapped directly to dart. | 88 # Remove these types since they are mapped directly to dart. |
| 89 common_database.DeleteInterface('DOMStringMap') | 89 common_database.DeleteInterface('DOMStringMap') |
| 90 common_database.DeleteInterface('DOMStringList') | 90 common_database.DeleteInterface('DOMStringList') |
| 91 | 91 |
| 92 generator.RenameTypes(common_database, { | 92 generator.RenameTypes(common_database, { |
| 93 # W3C -> Dart renames | 93 # W3C -> Dart renames |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 help='''Use the cached database from the previous run to | 171 help='''Use the cached database from the previous run to |
| 172 improve startup performance''') | 172 improve startup performance''') |
| 173 (options, args) = parser.parse_args() | 173 (options, args) = parser.parse_args() |
| 174 | 174 |
| 175 current_dir = os.path.dirname(__file__) | 175 current_dir = os.path.dirname(__file__) |
| 176 systems = options.systems.split(',') | 176 systems = options.systems.split(',') |
| 177 html_system_names = ['htmldartium', 'htmlfrog'] | 177 html_system_names = ['htmldartium', 'htmlfrog'] |
| 178 html_systems = [s for s in systems if s in html_system_names] | 178 html_systems = [s for s in systems if s in html_system_names] |
| 179 dom_systems = [s for s in systems if s not in html_system_names] | 179 dom_systems = [s for s in systems if s not in html_system_names] |
| 180 | 180 |
| 181 database_dir = os.path.join(current_dir, '..', 'database') |
| 181 use_database_cache = options.use_database_cache | 182 use_database_cache = options.use_database_cache |
| 182 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) | 183 logging.config.fileConfig(os.path.join(current_dir, 'logging.conf')) |
| 183 | 184 |
| 184 if dom_systems: | 185 if dom_systems: |
| 185 output_dir = options.output_dir or os.path.join(current_dir, | 186 output_dir = options.output_dir or os.path.join(current_dir, |
| 186 '../generated') | 187 '../generated') |
| 187 GenerateDOM(dom_systems, False, output_dir, use_database_cache) | 188 GenerateDOM(dom_systems, False, output_dir, |
| 189 database_dir, use_database_cache) |
| 188 | 190 |
| 189 if html_systems: | 191 if html_systems: |
| 190 output_dir = options.output_dir or os.path.join(current_dir, | 192 output_dir = options.output_dir or os.path.join(current_dir, |
| 191 '../../html/generated') | 193 '../../html/generated') |
| 192 GenerateDOM(html_systems, True, output_dir, use_database_cache or dom_system
s) | 194 GenerateDOM(html_systems, True, output_dir, |
| 195 database_dir, use_database_cache or dom_systems) |
| 193 | 196 |
| 194 if __name__ == '__main__': | 197 if __name__ == '__main__': |
| 195 sys.exit(main()) | 198 sys.exit(main()) |
| OLD | NEW |