| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 super(NativeImplementationGenerator, self).__init__( | 183 super(NativeImplementationGenerator, self).__init__( |
| 184 system._database, interface) | 184 system._database, interface) |
| 185 self._system = system | 185 self._system = system |
| 186 self._current_secondary_parent = None | 186 self._current_secondary_parent = None |
| 187 self._html_system = self._system._html_system | 187 self._html_system = self._system._html_system |
| 188 self._html_renames = self._html_system._html_renames | 188 self._html_renames = self._html_system._html_renames |
| 189 | 189 |
| 190 def HasImplementation(self): | 190 def HasImplementation(self): |
| 191 return not IsPureInterface(self._interface.id) | 191 return not IsPureInterface(self._interface.id) |
| 192 | 192 |
| 193 def ImplementationClassName(self): |
| 194 return self._ImplClassName(self._interface.id) |
| 195 |
| 193 def FilePathForDartImplementation(self): | 196 def FilePathForDartImplementation(self): |
| 194 return os.path.join(self._system._output_dir, 'dart', | 197 return os.path.join(self._system._output_dir, 'dart', |
| 195 '%sImplementation.dart' % self._interface.id) | 198 '%sImplementation.dart' % self._interface.id) |
| 196 | 199 |
| 197 def SetImplementationEmitter(self, implementation_emitter): | 200 def SetImplementationEmitter(self, implementation_emitter): |
| 198 self._dart_impl_emitter = implementation_emitter | 201 self._dart_impl_emitter = implementation_emitter |
| 199 | 202 |
| 200 def StartInterface(self): | 203 def StartInterface(self): |
| 201 # Create emitters for c++ implementation. | 204 # Create emitters for c++ implementation. |
| 202 if self.HasImplementation(): | 205 if self.HasImplementation(): |
| (...skipping 12 matching lines...) Expand all Loading... |
| 215 self._cpp_declarations_emitter = emitter.Emitter() | 218 self._cpp_declarations_emitter = emitter.Emitter() |
| 216 self._cpp_impl_includes = set() | 219 self._cpp_impl_includes = set() |
| 217 self._cpp_definitions_emitter = emitter.Emitter() | 220 self._cpp_definitions_emitter = emitter.Emitter() |
| 218 self._cpp_resolver_emitter = emitter.Emitter() | 221 self._cpp_resolver_emitter = emitter.Emitter() |
| 219 | 222 |
| 220 self._GenerateConstructors() | 223 self._GenerateConstructors() |
| 221 self._GenerateEvents() | 224 self._GenerateEvents() |
| 222 | 225 |
| 223 def _GenerateConstructors(self): | 226 def _GenerateConstructors(self): |
| 224 html_interface_name = self._HTMLInterfaceName(self._interface.id) | 227 html_interface_name = self._HTMLInterfaceName(self._interface.id) |
| 225 infos = HtmlElementConstructorInfos(html_interface_name) | |
| 226 if infos: | |
| 227 self._EmitHtmlElementFactoryConstructors(infos, html_interface_name) | |
| 228 | 228 |
| 229 if not self._IsConstructable(): | 229 if not self._IsConstructable(): |
| 230 return | 230 return |
| 231 | 231 |
| 232 # TODO(antonm): currently we don't have information about number of argument
s expected by | 232 # TODO(antonm): currently we don't have information about number of argument
s expected by |
| 233 # the constructor, so name only dispatch. | 233 # the constructor, so name only dispatch. |
| 234 self._cpp_resolver_emitter.Emit( | 234 self._cpp_resolver_emitter.Emit( |
| 235 ' if (name == "$(INTERFACE_NAME)_constructor_Callback")\n' | 235 ' if (name == "$(INTERFACE_NAME)_constructor_Callback")\n' |
| 236 ' return Dart$(INTERFACE_NAME)Internal::constructorCallback;\n', | 236 ' return Dart$(INTERFACE_NAME)Internal::constructorCallback;\n', |
| 237 INTERFACE_NAME=self._interface.id) | 237 INTERFACE_NAME=self._interface.id) |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 ' goto fail;\n' | 315 ' goto fail;\n' |
| 316 ' }', | 316 ' }', |
| 317 FEATURE=_ToWebKitName(ext_attrs['synthesizedV8EnabledAtRuntime'])) | 317 FEATURE=_ToWebKitName(ext_attrs['synthesizedV8EnabledAtRuntime'])) |
| 318 | 318 |
| 319 self._GenerateNativeCallback(callback_name='constructorCallback', | 319 self._GenerateNativeCallback(callback_name='constructorCallback', |
| 320 parameter_definitions=parameter_definitions_emitter.Fragments(), | 320 parameter_definitions=parameter_definitions_emitter.Fragments(), |
| 321 needs_receiver=False, invocation=invocation, | 321 needs_receiver=False, invocation=invocation, |
| 322 raises_exceptions=raises_exceptions, | 322 raises_exceptions=raises_exceptions, |
| 323 runtime_check=runtime_check) | 323 runtime_check=runtime_check) |
| 324 | 324 |
| 325 def _EmitHtmlElementFactoryConstructors(self, infos, html_interface_name): | |
| 326 EmitHtmlElementFactoryConstructors( | |
| 327 self._system._EmitterForFactoryProviderBody( | |
| 328 infos[0].factory_provider_name), | |
| 329 infos, | |
| 330 html_interface_name, | |
| 331 html_interface_name) | |
| 332 | |
| 333 def _GenerateEvents(self): | 325 def _GenerateEvents(self): |
| 334 if self._interface.id == 'DocumentFragment': | 326 if self._interface.id == 'DocumentFragment': |
| 335 # Interface DocumentFragment extends Element in dart:html but this fact | 327 # Interface DocumentFragment extends Element in dart:html but this fact |
| 336 # is not reflected in idls. | 328 # is not reflected in idls. |
| 337 self._EmitEventGetter('_ElementEventsImpl') | 329 self._EmitEventGetter('_ElementEventsImpl') |
| 338 return | 330 return |
| 339 | 331 |
| 340 events_attributes = [attr for attr in self._interface.attributes | 332 events_attributes = [attr for attr in self._interface.attributes |
| 341 if attr.type.id == 'EventListener'] | 333 if attr.type.id == 'EventListener'] |
| 342 if not 'EventTarget' in self._interface.ext_attrs and not events_attributes: | 334 if not 'EventTarget' in self._interface.ext_attrs and not events_attributes: |
| (...skipping 734 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1077 | 1069 |
| 1078 def _IsArgumentOptionalInWebCore(argument): | 1070 def _IsArgumentOptionalInWebCore(argument): |
| 1079 return IsOptional(argument) and not 'Callback' in argument.ext_attrs | 1071 return IsOptional(argument) and not 'Callback' in argument.ext_attrs |
| 1080 | 1072 |
| 1081 def _ToWebKitName(name): | 1073 def _ToWebKitName(name): |
| 1082 name = name[0].lower() + name[1:] | 1074 name = name[0].lower() + name[1:] |
| 1083 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), | 1075 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), |
| 1084 name) | 1076 name) |
| 1085 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, | 1077 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, |
| 1086 name) | 1078 name) |
| OLD | NEW |