| 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 fremontcutbuilder | 10 import fremontcutbuilder |
| 11 import logging.config | 11 import logging.config |
| 12 import multiemitter | 12 import multiemitter |
| 13 import optparse | 13 import optparse |
| 14 import os | 14 import os |
| 15 import shutil | 15 import shutil |
| 16 import subprocess | 16 import subprocess |
| 17 import sys | 17 import sys |
| 18 from generator import TypeRegistry | 18 from generator import TypeRegistry |
| 19 from htmleventgenerator import HtmlEventGenerator | 19 from htmleventgenerator import HtmlEventGenerator |
| 20 from htmlrenamer import HtmlRenamer | 20 from htmlrenamer import HtmlRenamer |
| 21 from systembase import GeneratorOptions | |
| 22 from systemhtml import DartLibraryEmitter, Dart2JSBackend,\ | 21 from systemhtml import DartLibraryEmitter, Dart2JSBackend,\ |
| 23 HtmlDartInterfaceGenerator | 22 HtmlDartInterfaceGenerator |
| 24 from systemnative import CPPLibraryEmitter, DartiumBackend | 23 from systemnative import CPPLibraryEmitter, DartiumBackend |
| 25 from templateloader import TemplateLoader | 24 from templateloader import TemplateLoader |
| 26 | 25 |
| 27 _logger = logging.getLogger('dartdomgenerator') | 26 _logger = logging.getLogger('dartdomgenerator') |
| 28 | 27 |
| 29 _webkit_renames = { | 28 _webkit_renames = { |
| 30 # W3C -> WebKit name conversion | 29 # W3C -> WebKit name conversion |
| 31 # TODO(vsm): Maybe Store these renames in the IDLs. | 30 # TODO(vsm): Maybe Store these renames in the IDLs. |
| 32 'ApplicationCache': 'DOMApplicationCache', | 31 'ApplicationCache': 'DOMApplicationCache', |
| 33 'BarProp': 'BarInfo', | 32 'BarProp': 'BarInfo', |
| 34 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext', | 33 'DedicatedWorkerGlobalScope': 'DedicatedWorkerContext', |
| 35 'FormData': 'DOMFormData', | 34 'FormData': 'DOMFormData', |
| 36 'Selection': 'DOMSelection', | 35 'Selection': 'DOMSelection', |
| 37 'SharedWorkerGlobalScope': 'SharedWorkerContext', | 36 'SharedWorkerGlobalScope': 'SharedWorkerContext', |
| 38 'Window': 'DOMWindow', | 37 'Window': 'DOMWindow', |
| 39 'WorkerGlobalScope': 'WorkerContext'} | 38 'WorkerGlobalScope': 'WorkerContext'} |
| 40 | 39 |
| 40 class GeneratorOptions(object): |
| 41 def __init__(self, templates, database, type_registry, renamer): |
| 42 self.templates = templates |
| 43 self.database = database |
| 44 self.type_registry = type_registry |
| 45 self.renamer = renamer |
| 46 |
| 41 # TODO(vsm): Remove once we fix Dartium to pass in the database directly. | 47 # TODO(vsm): Remove once we fix Dartium to pass in the database directly. |
| 42 def Generate(database_dir, use_database_cache, dart2js_output_dir=None, | 48 def Generate(database_dir, use_database_cache, dart2js_output_dir=None, |
| 43 dartium_output_dir=None): | 49 dartium_output_dir=None): |
| 44 database = LoadDatabase(database_dir, use_database_cache) | 50 database = LoadDatabase(database_dir, use_database_cache) |
| 45 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir) | 51 GenerateFromDatabase(database, dart2js_output_dir, dartium_output_dir) |
| 46 | 52 |
| 47 def LoadDatabase(database_dir, use_database_cache): | 53 def LoadDatabase(database_dir, use_database_cache): |
| 48 common_database = database.Database(database_dir) | 54 common_database = database.Database(database_dir) |
| 49 if use_database_cache: | 55 if use_database_cache: |
| 50 common_database.LoadFromCache() | 56 common_database.LoadFromCache() |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 _logger.info('Copy html_dart2js to dart2js/') | 199 _logger.info('Copy html_dart2js to dart2js/') |
| 194 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'), | 200 GenerateSingleFile(os.path.join(dart2js_output_dir, 'html_dart2js.dart'), |
| 195 '../dart2js') | 201 '../dart2js') |
| 196 if 'htmldartium' in systems: | 202 if 'htmldartium' in systems: |
| 197 _logger.info('Copy html_dartium to dartium/') | 203 _logger.info('Copy html_dartium to dartium/') |
| 198 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'), | 204 GenerateSingleFile(os.path.join(dartium_output_dir, 'html_dartium.dart'), |
| 199 '../dartium') | 205 '../dartium') |
| 200 | 206 |
| 201 if __name__ == '__main__': | 207 if __name__ == '__main__': |
| 202 sys.exit(main()) | 208 sys.exit(main()) |
| OLD | NEW |