| 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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 Args: | 158 Args: |
| 159 system: The NativeImplementationSystem. | 159 system: The NativeImplementationSystem. |
| 160 interface: an IDLInterface instance. It is assumed that all types have | 160 interface: an IDLInterface instance. It is assumed that all types have |
| 161 been converted to Dart types (e.g. int, String), unless they are in | 161 been converted to Dart types (e.g. int, String), unless they are in |
| 162 the same package as the interface. | 162 the same package as the interface. |
| 163 """ | 163 """ |
| 164 super(NativeImplementationGenerator, self).__init__( | 164 super(NativeImplementationGenerator, self).__init__( |
| 165 system._database, interface) | 165 system._database, interface) |
| 166 self._system = system | 166 self._system = system |
| 167 self._current_secondary_parent = None | 167 self._current_secondary_parent = None |
| 168 self._html_interface_name = system._type_registry.InterfaceName(self._interf
ace.id) | 168 self._html_interface_name = system._renamer.RenameInterface(self._interface) |
| 169 | 169 |
| 170 def HasImplementation(self): | 170 def HasImplementation(self): |
| 171 return not IsPureInterface(self._interface.id) | 171 return not IsPureInterface(self._interface.id) |
| 172 | 172 |
| 173 def ImplementationClassName(self): | 173 def ImplementationClassName(self): |
| 174 return self._ImplClassName(self._interface.id) | 174 return self._ImplClassName(self._interface.id) |
| 175 | 175 |
| 176 def FilePathForDartImplementation(self): | 176 def FilePathForDartImplementation(self): |
| 177 return os.path.join(self._system._output_dir, 'dart', | 177 return os.path.join(self._system._output_dir, 'dart', |
| 178 '%sImplementation.dart' % self._interface.id) | 178 '%sImplementation.dart' % self._interface.id) |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 ' return DartDOMWrapper::toDart<Dart$(INTERFACE)>(value);\n' | 411 ' return DartDOMWrapper::toDart<Dart$(INTERFACE)>(value);\n' |
| 412 ' }\n', | 412 ' }\n', |
| 413 INTERFACE=self._interface.id) | 413 INTERFACE=self._interface.id) |
| 414 | 414 |
| 415 webcore_includes = _GenerateCPPIncludes(self._interface_type_info.webcore_in
cludes()) | 415 webcore_includes = _GenerateCPPIncludes(self._interface_type_info.webcore_in
cludes()) |
| 416 | 416 |
| 417 is_node_test = lambda interface: interface.id == 'Node' | 417 is_node_test = lambda interface: interface.id == 'Node' |
| 418 is_active_test = lambda interface: 'ActiveDOMObject' in interface.ext_attrs | 418 is_active_test = lambda interface: 'ActiveDOMObject' in interface.ext_attrs |
| 419 is_event_target_test = lambda interface: 'EventTarget' in interface.ext_attr
s | 419 is_event_target_test = lambda interface: 'EventTarget' in interface.ext_attr
s |
| 420 def TypeCheckHelper(test): | 420 def TypeCheckHelper(test): |
| 421 return 'true' if _FindInHierarchy(self._database, self._interface, test) e
lse 'false' | 421 return 'true' if any(map(test, self._database.Hierarchy(self._interface)))
else 'false' |
| 422 | 422 |
| 423 self._cpp_header_emitter.Emit( | 423 self._cpp_header_emitter.Emit( |
| 424 self._system._templates.Load('cpp_header.template'), | 424 self._system._templates.Load('cpp_header.template'), |
| 425 INTERFACE=self._interface.id, | 425 INTERFACE=self._interface.id, |
| 426 WEBCORE_INCLUDES=webcore_includes, | 426 WEBCORE_INCLUDES=webcore_includes, |
| 427 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(), | 427 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(), |
| 428 DECLARATIONS=self._cpp_declarations_emitter.Fragments(), | 428 DECLARATIONS=self._cpp_declarations_emitter.Fragments(), |
| 429 IS_NODE=TypeCheckHelper(is_node_test), | 429 IS_NODE=TypeCheckHelper(is_node_test), |
| 430 IS_ACTIVE=TypeCheckHelper(is_active_test), | 430 IS_ACTIVE=TypeCheckHelper(is_active_test), |
| 431 IS_EVENT_TARGET=TypeCheckHelper(is_event_target_test), | 431 IS_EVENT_TARGET=TypeCheckHelper(is_event_target_test), |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 943 | 943 |
| 944 def _IsArgumentOptionalInWebCore(argument): | 944 def _IsArgumentOptionalInWebCore(argument): |
| 945 return IsOptional(argument) and not 'Callback' in argument.ext_attrs | 945 return IsOptional(argument) and not 'Callback' in argument.ext_attrs |
| 946 | 946 |
| 947 def _ToWebKitName(name): | 947 def _ToWebKitName(name): |
| 948 name = name[0].lower() + name[1:] | 948 name = name[0].lower() + name[1:] |
| 949 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), | 949 name = re.sub(r'^(hTML|uRL|jS|xML|xSLT)', lambda s: s.group(1).lower(), |
| 950 name) | 950 name) |
| 951 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, | 951 return re.sub(r'^(create|exclusive)', lambda s: 'is' + s.group(1).capitalize()
, |
| 952 name) | 952 name) |
| OLD | NEW |