| 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 |
| 11 from generator import * | 11 from generator import * |
| 12 from htmldartgenerator import * | 12 from htmldartgenerator import * |
| 13 from systemhtml import js_support_checks |
| 13 | 14 |
| 14 class DartiumBackend(HtmlDartGenerator): | 15 class DartiumBackend(HtmlDartGenerator): |
| 15 """Generates Dart implementation for one DOM IDL interface.""" | 16 """Generates Dart implementation for one DOM IDL interface.""" |
| 16 | 17 |
| 17 def __init__(self, interface, cpp_library_emitter, options): | 18 def __init__(self, interface, cpp_library_emitter, options): |
| 18 super(DartiumBackend, self).__init__(interface, options) | 19 super(DartiumBackend, self).__init__(interface, options) |
| 19 | 20 |
| 20 self._interface = interface | 21 self._interface = interface |
| 21 self._cpp_library_emitter = cpp_library_emitter | 22 self._cpp_library_emitter = cpp_library_emitter |
| 22 self._database = options.database | 23 self._database = options.database |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 function_expression = '%s::%s' % (self._interface_type_info.native_type(), c
reate_function) | 194 function_expression = '%s::%s' % (self._interface_type_info.native_type(), c
reate_function) |
| 194 self._GenerateNativeCallback( | 195 self._GenerateNativeCallback( |
| 195 'constructorCallback', | 196 'constructorCallback', |
| 196 False, | 197 False, |
| 197 function_expression, | 198 function_expression, |
| 198 self._interface, | 199 self._interface, |
| 199 constructor_info.idl_args, | 200 constructor_info.idl_args, |
| 200 self._interface.id, | 201 self._interface.id, |
| 201 'ConstructorRaisesException' in ext_attrs) | 202 'ConstructorRaisesException' in ext_attrs) |
| 202 | 203 |
| 204 def HasSupportCheck(self): |
| 205 # Need to omit a support check if it is conditional in JS. |
| 206 return self._interface.doc_js_name in js_support_checks |
| 207 |
| 208 def GetSupportCheck(self): |
| 209 # Assume that everything is supported on Dartium. |
| 210 return 'true' |
| 211 |
| 203 def FinishInterface(self): | 212 def FinishInterface(self): |
| 204 self._GenerateCPPHeader() | 213 self._GenerateCPPHeader() |
| 205 | 214 |
| 206 self._cpp_impl_emitter.Emit( | 215 self._cpp_impl_emitter.Emit( |
| 207 self._template_loader.Load('cpp_implementation.template'), | 216 self._template_loader.Load('cpp_implementation.template'), |
| 208 INTERFACE=self._interface.id, | 217 INTERFACE=self._interface.id, |
| 209 INCLUDES=self._GenerateCPPIncludes(self._cpp_impl_includes), | 218 INCLUDES=self._GenerateCPPIncludes(self._cpp_impl_includes), |
| 210 CALLBACKS=self._cpp_definitions_emitter.Fragments(), | 219 CALLBACKS=self._cpp_definitions_emitter.Fragments(), |
| 211 RESOLVER=self._cpp_resolver_emitter.Fragments(), | 220 RESOLVER=self._cpp_resolver_emitter.Fragments(), |
| 212 DART_IMPLEMENTATION_CLASS=self._interface_type_info.implementation_name(
), | 221 DART_IMPLEMENTATION_CLASS=self._interface_type_info.implementation_name(
), |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 LIBRARY_NAME=library_name) | 914 LIBRARY_NAME=library_name) |
| 906 | 915 |
| 907 headers = self._library_headers[library_name] | 916 headers = self._library_headers[library_name] |
| 908 for header_file in headers: | 917 for header_file in headers: |
| 909 path = os.path.relpath(header_file, output_dir) | 918 path = os.path.relpath(header_file, output_dir) |
| 910 includes_emitter.Emit('#include "$PATH"\n', PATH=path) | 919 includes_emitter.Emit('#include "$PATH"\n', PATH=path) |
| 911 body_emitter.Emit( | 920 body_emitter.Emit( |
| 912 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' | 921 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' |
| 913 ' return func;\n', | 922 ' return func;\n', |
| 914 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) | 923 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) |
| OLD | NEW |