| 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 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 self._cpp_impl_includes.add('"DartArrayBufferViewCustom.h"'); | 552 self._cpp_impl_includes.add('"DartArrayBufferViewCustom.h"'); |
| 553 self._cpp_definitions_emitter.Emit( | 553 self._cpp_definitions_emitter.Emit( |
| 554 '\n' | 554 '\n' |
| 555 'static void constructorCallback(Dart_NativeArguments args)\n' | 555 'static void constructorCallback(Dart_NativeArguments args)\n' |
| 556 '{\n' | 556 '{\n' |
| 557 ' WebCore::DartArrayBufferViewInternal::constructWebGLArray<Dart$(INT
ERFACE_NAME)>(args);\n' | 557 ' WebCore::DartArrayBufferViewInternal::constructWebGLArray<Dart$(INT
ERFACE_NAME)>(args);\n' |
| 558 '}\n', | 558 '}\n', |
| 559 INTERFACE_NAME=self._interface.id); | 559 INTERFACE_NAME=self._interface.id); |
| 560 | 560 |
| 561 def _EmitConstructorInfrastructure(self, | 561 def _EmitConstructorInfrastructure(self, |
| 562 constructor_info, constructor_callback_cpp_name, factory_method_name, | 562 constructor_info, cpp_prefix, cpp_suffix, factory_method_name, |
| 563 arguments=None, emit_to_native=False): | 563 arguments=None, emit_to_native=False): |
| 564 | 564 |
| 565 constructor_callback_cpp_name = cpp_prefix + cpp_suffix |
| 566 |
| 565 if arguments is None: | 567 if arguments is None: |
| 566 argument_count = len(constructor_info.param_infos) | 568 argument_count = len(constructor_info.param_infos) |
| 567 else: | 569 else: |
| 568 argument_count = len(arguments) | 570 argument_count = len(arguments) |
| 569 | 571 |
| 570 typed_formals = constructor_info.ParametersAsArgumentList(argument_count) | 572 typed_formals = constructor_info.ParametersAsArgumentList(argument_count) |
| 571 parameters = constructor_info.ParametersAsStringOfVariables(argument_count) | 573 parameters = constructor_info.ParametersAsStringOfVariables(argument_count) |
| 572 interface_name = self._interface_type_info.interface_name() | 574 interface_name = self._interface_type_info.interface_name() |
| 573 | 575 |
| 574 if self._dart_use_blink and arguments: | 576 if self._dart_use_blink and arguments: |
| 575 type_ids = [p.type.id for p in arguments] | 577 type_ids = [p.type.id for p in arguments] |
| 576 constructor_callback_id = \ | 578 constructor_callback_id = \ |
| 577 DeriveResolverString(self._interface.id, | 579 DeriveResolverString(self._interface.id, |
| 578 constructor_callback_cpp_name, None, | 580 cpp_suffix, None, |
| 579 argument_count, type_ids) | 581 argument_count, type_ids) |
| 580 else: | 582 else: |
| 581 constructor_callback_id = self._interface.id + '_' + constructor_callbac
k_cpp_name | 583 constructor_callback_id = self._interface.id + '_' + constructor_callbac
k_cpp_name |
| 582 | 584 |
| 583 if self._dart_use_blink: | 585 if self._dart_use_blink: |
| 584 # First we emit the toplevel function | 586 # First we emit the toplevel function |
| 585 dart_native_name = \ | 587 dart_native_name = \ |
| 586 DeriveNativeName(self._interface.id, constructor_callback_cpp_name,
"") | 588 DeriveNativeName(self._interface.id, constructor_callback_cpp_name,
"") |
| 587 self._native_library_emitter.Emit( | 589 self._native_library_emitter.Emit( |
| 588 '\n' | 590 '\n' |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 self._members_emitter.Emit( | 633 self._members_emitter.Emit( |
| 632 '\n $(ANNOTATIONS)factory $CTOR($PARAMS) => _create($FACTORY_PARAMS);\n
', | 634 '\n $(ANNOTATIONS)factory $CTOR($PARAMS) => _create($FACTORY_PARAMS);\n
', |
| 633 ANNOTATIONS=annotations, | 635 ANNOTATIONS=annotations, |
| 634 CTOR=constructor_info._ConstructorFullName(self._DartType), | 636 CTOR=constructor_info._ConstructorFullName(self._DartType), |
| 635 PARAMS=constructor_info.ParametersAsDeclaration(self._DartType), | 637 PARAMS=constructor_info.ParametersAsDeclaration(self._DartType), |
| 636 FACTORY_PARAMS= \ | 638 FACTORY_PARAMS= \ |
| 637 constructor_info.ParametersAsArgumentList()) | 639 constructor_info.ParametersAsArgumentList()) |
| 638 | 640 |
| 639 constructor_callback_cpp_name = 'constructorCallback' | 641 constructor_callback_cpp_name = 'constructorCallback' |
| 640 self._EmitConstructorInfrastructure( | 642 self._EmitConstructorInfrastructure( |
| 641 constructor_info, constructor_callback_cpp_name, '_create') | 643 constructor_info, "", constructor_callback_cpp_name, '_create') |
| 642 | 644 |
| 643 self._cpp_declarations_emitter.Emit( | 645 self._cpp_declarations_emitter.Emit( |
| 644 '\n' | 646 '\n' |
| 645 'void $CPP_CALLBACK(Dart_NativeArguments);\n', | 647 'void $CPP_CALLBACK(Dart_NativeArguments);\n', |
| 646 CPP_CALLBACK=constructor_callback_cpp_name) | 648 CPP_CALLBACK=constructor_callback_cpp_name) |
| 647 | 649 |
| 648 return True | 650 return True |
| 649 | 651 |
| 650 def IsConstructorArgumentOptional(self, argument): | 652 def IsConstructorArgumentOptional(self, argument): |
| 651 return False | 653 return False |
| 652 | 654 |
| 653 def EmitStaticFactoryOverload(self, constructor_info, name, arguments): | 655 def EmitStaticFactoryOverload(self, constructor_info, name, arguments): |
| 654 if self._dart_use_blink: | 656 constructor_callback_cpp_name = name + 'constructorCallback' |
| 655 constructor_callback_cpp_name = 'constructorCallback' | |
| 656 else: | |
| 657 constructor_callback_cpp_name = name + 'constructorCallback' | |
| 658 self._EmitConstructorInfrastructure( | 657 self._EmitConstructorInfrastructure( |
| 659 constructor_info, constructor_callback_cpp_name, name, arguments, | 658 constructor_info, name, 'constructorCallback', name, arguments, |
| 660 emit_to_native=self._dart_use_blink) | 659 emit_to_native=self._dart_use_blink) |
| 661 | 660 |
| 662 ext_attrs = self._interface.ext_attrs | 661 ext_attrs = self._interface.ext_attrs |
| 663 | 662 |
| 664 create_function = 'create' | 663 create_function = 'create' |
| 665 if 'NamedConstructor' in ext_attrs: | 664 if 'NamedConstructor' in ext_attrs: |
| 666 create_function = 'createForJSConstructor' | 665 create_function = 'createForJSConstructor' |
| 667 function_expression = '%s::%s' % (self._interface_type_info.native_type(), c
reate_function) | 666 function_expression = '%s::%s' % (self._interface_type_info.native_type(), c
reate_function) |
| 668 self._GenerateNativeCallback( | 667 self._GenerateNativeCallback( |
| 669 constructor_callback_cpp_name, | 668 constructor_callback_cpp_name, |
| (...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 e.Emit("};\n"); | 1934 e.Emit("};\n"); |
| 1936 e.Emit('\n'); | 1935 e.Emit('\n'); |
| 1937 e.Emit('} // namespace WebCore\n'); | 1936 e.Emit('} // namespace WebCore\n'); |
| 1938 | 1937 |
| 1939 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1938 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 1940 return ( | 1939 return ( |
| 1941 interface.id.endswith('Event') and | 1940 interface.id.endswith('Event') and |
| 1942 operation.id.startswith('init') and | 1941 operation.id.startswith('init') and |
| 1943 argument.ext_attrs.get('Default') == 'Undefined' and | 1942 argument.ext_attrs.get('Default') == 'Undefined' and |
| 1944 argument.type.id == 'DOMString') | 1943 argument.type.id == 'DOMString') |
| OLD | NEW |