| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2012, 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 module provides shared functionality for the systems to generate | 6 """This module provides shared functionality for the systems to generate |
| 7 native binding from the IDL database.""" | 7 native binding from the IDL database.""" |
| 8 | 8 |
| 9 import emitter | 9 import emitter |
| 10 import os | 10 import os |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 # FIXME(leafp) This should really go elsewhere. I think the right thing | 224 # FIXME(leafp) This should really go elsewhere. I think the right thing |
| 225 # to do is to add support in the DartLibraries objects in systemhtml | 225 # to do is to add support in the DartLibraries objects in systemhtml |
| 226 # for emitting top level code in libraries. This can then just be a | 226 # for emitting top level code in libraries. This can then just be a |
| 227 # normal use of that kind of object | 227 # normal use of that kind of object |
| 228 def GetNativeLibraryEmitter(emitters, template_loader, | 228 def GetNativeLibraryEmitter(emitters, template_loader, |
| 229 dartium_output_dir, dart_output_dir, | 229 dartium_output_dir, dart_output_dir, |
| 230 auxiliary_dir): | 230 auxiliary_dir): |
| 231 def massage_path(path): | 231 def massage_path(path): |
| 232 # The most robust way to emit path separators is to use / always. | 232 # The most robust way to emit path separators is to use / always. |
| 233 return path.replace('\\', '/') | 233 return path.replace('\\', '/') |
| 234 template = template_loader.Load('blink_dartium.darttemplate') | 234 template = template_loader.Load('_blink_dartium.darttemplate') |
| 235 dart_path = os.path.join(dartium_output_dir, 'blink_dartium.dart') | 235 dart_path = os.path.join(dartium_output_dir, '_blink_dartium.dart') |
| 236 library_emitter = emitters.FileEmitter(dart_path) | 236 library_emitter = emitters.FileEmitter(dart_path) |
| 237 auxiliary_dir = os.path.relpath(auxiliary_dir, dartium_output_dir) | 237 auxiliary_dir = os.path.relpath(auxiliary_dir, dartium_output_dir) |
| 238 emitter = \ | 238 emitter = \ |
| 239 library_emitter.Emit(template, | 239 library_emitter.Emit(template, |
| 240 AUXILIARY_DIR=massage_path(auxiliary_dir)) | 240 AUXILIARY_DIR=massage_path(auxiliary_dir)) |
| 241 return emitter | 241 return emitter |
| 242 | 242 |
| 243 class DartiumBackend(HtmlDartGenerator): | 243 class DartiumBackend(HtmlDartGenerator): |
| 244 """Generates Dart implementation for one DOM IDL interface.""" | 244 """Generates Dart implementation for one DOM IDL interface.""" |
| 245 | 245 |
| 246 def __init__(self, interface, native_library_emitter, | 246 def __init__(self, interface, native_library_emitter, |
| 247 cpp_library_emitter, options, dart_use_blink): | 247 cpp_library_emitter, options, dart_use_blink): |
| 248 super(DartiumBackend, self).__init__(interface, options) | 248 super(DartiumBackend, self).__init__(interface, options) |
| 249 | 249 |
| 250 self._interface = interface | 250 self._interface = interface |
| 251 self._cpp_library_emitter = cpp_library_emitter | 251 self._cpp_library_emitter = cpp_library_emitter |
| 252 self._native_library_emitter = native_library_emitter | 252 self._native_library_emitter = native_library_emitter |
| 253 self._database = options.database | 253 self._database = options.database |
| 254 self._template_loader = options.templates | 254 self._template_loader = options.templates |
| 255 self._type_registry = options.type_registry | 255 self._type_registry = options.type_registry |
| 256 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) | 256 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) |
| 257 self._metadata = options.metadata | 257 self._metadata = options.metadata |
| 258 self._native_library_name = "blink" | 258 self._native_library_name = "_blink" |
| 259 # This goes away after the Chrome 35 roll (or whenever we commit to the | 259 # This goes away after the Chrome 35 roll (or whenever we commit to the |
| 260 # dart:blink refactor) | 260 # dart:blink refactor) |
| 261 self._dart_use_blink = dart_use_blink | 261 self._dart_use_blink = dart_use_blink |
| 262 # These get initialized by StartInterface | 262 # These get initialized by StartInterface |
| 263 self._cpp_header_emitter = None | 263 self._cpp_header_emitter = None |
| 264 self._cpp_impl_emitter = None | 264 self._cpp_impl_emitter = None |
| 265 self._members_emitter = None | 265 self._members_emitter = None |
| 266 self._cpp_declarations_emitter = None | 266 self._cpp_declarations_emitter = None |
| 267 self._cpp_impl_includes = None | 267 self._cpp_impl_includes = None |
| 268 self._cpp_definitions_emitter = None | 268 self._cpp_definitions_emitter = None |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 def ImplementationTemplate(self): | 388 def ImplementationTemplate(self): |
| 389 template = None | 389 template = None |
| 390 interface_name = self._interface.doc_js_name | 390 interface_name = self._interface.doc_js_name |
| 391 if interface_name == self._interface.id or not self._database.HasInterface(i
nterface_name): | 391 if interface_name == self._interface.id or not self._database.HasInterface(i
nterface_name): |
| 392 template_file = 'impl_%s.darttemplate' % interface_name | 392 template_file = 'impl_%s.darttemplate' % interface_name |
| 393 template = self._template_loader.TryLoad(template_file) | 393 template = self._template_loader.TryLoad(template_file) |
| 394 if not template: | 394 if not template: |
| 395 template = self._template_loader.Load('dart_implementation.darttemplate') | 395 template = self._template_loader.Load('dart_implementation.darttemplate') |
| 396 return template | 396 return template |
| 397 | 397 |
| 398 def _NativeImplementationTemplate(self): | |
| 399 template = None | |
| 400 interface_name = self._interface.doc_js_name | |
| 401 if (interface_name == self._interface.id or | |
| 402 not self._database.HasInterface(interface_name)): | |
| 403 template_file = 'impl_blink_%s.darttemplate' % interface_name | |
| 404 template = self._template_loader.TryLoad(template_file) | |
| 405 if not template: | |
| 406 template = \ | |
| 407 self._template_loader.Load('dart_blink_implementation.darttemplate') | |
| 408 return template | |
| 409 | |
| 410 def RootClassName(self): | 398 def RootClassName(self): |
| 411 return 'NativeFieldWrapperClass2' | 399 return 'NativeFieldWrapperClass2' |
| 412 | 400 |
| 413 def NativeSpec(self): | 401 def NativeSpec(self): |
| 414 return '' | 402 return '' |
| 415 | 403 |
| 416 def StartInterface(self, members_emitter): | 404 def StartInterface(self, members_emitter): |
| 417 # Create emitters for c++ implementation. | 405 # Create emitters for c++ implementation. |
| 418 if not IsPureInterface(self._interface.id) and \ | 406 if not IsPureInterface(self._interface.id) and \ |
| 419 not IsCustomType(self._interface.id): | 407 not IsCustomType(self._interface.id): |
| (...skipping 1336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1756 e.Emit("};\n"); | 1744 e.Emit("};\n"); |
| 1757 e.Emit('\n'); | 1745 e.Emit('\n'); |
| 1758 e.Emit('} // namespace WebCore\n'); | 1746 e.Emit('} // namespace WebCore\n'); |
| 1759 | 1747 |
| 1760 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1748 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 1761 return ( | 1749 return ( |
| 1762 interface.id.endswith('Event') and | 1750 interface.id.endswith('Event') and |
| 1763 operation.id.startswith('init') and | 1751 operation.id.startswith('init') and |
| 1764 argument.ext_attrs.get('Default') == 'Undefined' and | 1752 argument.ext_attrs.get('Default') == 'Undefined' and |
| 1765 argument.type.id == 'DOMString') | 1753 argument.type.id == 'DOMString') |
| OLD | NEW |