| 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 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 cpp_type_name = _cpp_callback_map[cpp_tuple] | 368 cpp_type_name = _cpp_callback_map[cpp_tuple] |
| 369 elif (interface_name, cpp_name) in _cpp_overloaded_callback_map: | 369 elif (interface_name, cpp_name) in _cpp_overloaded_callback_map: |
| 370 cpp_type_name = _cpp_overloaded_callback_map[(interface_name, cpp_name)] | 370 cpp_type_name = _cpp_overloaded_callback_map[(interface_name, cpp_name)] |
| 371 else: | 371 else: |
| 372 cpp_type_name = interface_name | 372 cpp_type_name = interface_name |
| 373 return cpp_type_name | 373 return cpp_type_name |
| 374 | 374 |
| 375 def DeriveQualifiedName(library_name, name): | 375 def DeriveQualifiedName(library_name, name): |
| 376 return library_name + "." + name | 376 return library_name + "." + name |
| 377 | 377 |
| 378 def DeriveNativeName(interface_name, name, suffix): | 378 def DeriveBlinkClassName(name): |
| 379 fields = ["Native", interface_name, name] | 379 return "Blink" + name |
| 380 if suffix != "": | |
| 381 fields.append(suffix) | |
| 382 return "_".join(fields) | |
| 383 | 380 |
| 384 def DeriveResolverString(interface_id, operation_id, native_suffix, type_ids, da
tabase, is_custom): | 381 def DeriveResolverString(interface_id, operation_id, native_suffix, type_ids, da
tabase, is_custom): |
| 385 type_string = \ | 382 type_string = \ |
| 386 "_".join(map(lambda type_id : TypeIdToBlinkName(type_id, database), type
_ids)) | 383 "_".join(map(lambda type_id : TypeIdToBlinkName(type_id, database), type
_ids)) |
| 387 if native_suffix: | 384 if native_suffix: |
| 388 operation_id = "%s_%s" % (operation_id, native_suffix) | 385 operation_id = "%s_%s" % (operation_id, native_suffix) |
| 389 if is_custom: | 386 if is_custom: |
| 390 components = \ | 387 components = \ |
| 391 [TypeIdToBlinkName(interface_id, database), operation_id] | 388 [TypeIdToBlinkName(interface_id, database), operation_id] |
| 392 else: | 389 else: |
| (...skipping 29 matching lines...) Expand all Loading... |
| 422 super(DartiumBackend, self).__init__(interface, options, dart_use_blink) | 419 super(DartiumBackend, self).__init__(interface, options, dart_use_blink) |
| 423 | 420 |
| 424 self._interface = interface | 421 self._interface = interface |
| 425 self._cpp_library_emitter = cpp_library_emitter | 422 self._cpp_library_emitter = cpp_library_emitter |
| 426 self._native_library_emitter = native_library_emitter | 423 self._native_library_emitter = native_library_emitter |
| 427 self._database = options.database | 424 self._database = options.database |
| 428 self._template_loader = options.templates | 425 self._template_loader = options.templates |
| 429 self._type_registry = options.type_registry | 426 self._type_registry = options.type_registry |
| 430 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) | 427 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) |
| 431 self._metadata = options.metadata | 428 self._metadata = options.metadata |
| 432 self._native_library_name = "_blink" | |
| 433 # These get initialized by StartInterface | 429 # These get initialized by StartInterface |
| 434 self._cpp_header_emitter = None | 430 self._cpp_header_emitter = None |
| 435 self._cpp_impl_emitter = None | 431 self._cpp_impl_emitter = None |
| 436 self._members_emitter = None | 432 self._members_emitter = None |
| 437 self._cpp_declarations_emitter = None | 433 self._cpp_declarations_emitter = None |
| 438 self._cpp_impl_includes = None | 434 self._cpp_impl_includes = None |
| 439 self._cpp_definitions_emitter = None | 435 self._cpp_definitions_emitter = None |
| 440 self._cpp_resolver_emitter = None | 436 self._cpp_resolver_emitter = None |
| 437 self._native_class_emitter = None |
| 441 | 438 |
| 442 def ImplementsMergedMembers(self): | 439 def ImplementsMergedMembers(self): |
| 443 # We could not add merged functions to implementation class because | 440 # We could not add merged functions to implementation class because |
| 444 # underlying c++ object doesn't implement them. Merged functions are | 441 # underlying c++ object doesn't implement them. Merged functions are |
| 445 # generated on merged interface implementation instead. | 442 # generated on merged interface implementation instead. |
| 446 return False | 443 return False |
| 447 | 444 |
| 448 def CustomJSMembers(self): | 445 def CustomJSMembers(self): |
| 449 return {} | 446 return {} |
| 450 | 447 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 if interface_name == self._interface.id or not self._database.HasInterface(i
nterface_name): | 559 if interface_name == self._interface.id or not self._database.HasInterface(i
nterface_name): |
| 563 template_file = 'impl_%s.darttemplate' % interface_name | 560 template_file = 'impl_%s.darttemplate' % interface_name |
| 564 template = self._template_loader.TryLoad(template_file) | 561 template = self._template_loader.TryLoad(template_file) |
| 565 if not template: | 562 if not template: |
| 566 template = self._template_loader.Load('dart_implementation.darttemplate') | 563 template = self._template_loader.Load('dart_implementation.darttemplate') |
| 567 return template | 564 return template |
| 568 | 565 |
| 569 def RootClassName(self): | 566 def RootClassName(self): |
| 570 return 'NativeFieldWrapperClass2' | 567 return 'NativeFieldWrapperClass2' |
| 571 | 568 |
| 569 def DeriveNativeName(self, name, suffix=""): |
| 570 fields = ['$' + name] |
| 571 if suffix != "": |
| 572 fields.append(suffix) |
| 573 return "_".join(fields) |
| 574 |
| 575 def DeriveQualifiedBlinkName(self, interface_name, name): |
| 576 return DeriveQualifiedName( |
| 577 "_blink", DeriveQualifiedName(DeriveBlinkClassName(interface_name), |
| 578 name)) |
| 579 |
| 572 def NativeSpec(self): | 580 def NativeSpec(self): |
| 573 return '' | 581 return '' |
| 574 | 582 |
| 575 def StartInterface(self, members_emitter): | 583 def StartInterface(self, members_emitter): |
| 576 # Create emitters for c++ implementation. | 584 # Create emitters for c++ implementation. |
| 577 if not IsPureInterface(self._interface.id) and \ | 585 if not IsPureInterface(self._interface.id) and \ |
| 578 not IsCustomType(self._interface.id): | 586 not IsCustomType(self._interface.id): |
| 579 self._cpp_header_emitter = self._cpp_library_emitter.CreateHeaderEmitter( | 587 self._cpp_header_emitter = self._cpp_library_emitter.CreateHeaderEmitter( |
| 580 self._interface.id, | 588 self._interface.id, |
| 581 self._renamer.GetLibraryName(self._interface)) | 589 self._renamer.GetLibraryName(self._interface)) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 611 INTERFACE_NAME=self._interface.id) | 619 INTERFACE_NAME=self._interface.id) |
| 612 | 620 |
| 613 self._cpp_impl_includes.add('"DartArrayBufferViewCustom.h"'); | 621 self._cpp_impl_includes.add('"DartArrayBufferViewCustom.h"'); |
| 614 self._cpp_definitions_emitter.Emit( | 622 self._cpp_definitions_emitter.Emit( |
| 615 '\n' | 623 '\n' |
| 616 'static void constructorCallback(Dart_NativeArguments args)\n' | 624 'static void constructorCallback(Dart_NativeArguments args)\n' |
| 617 '{\n' | 625 '{\n' |
| 618 ' WebCore::DartArrayBufferViewInternal::constructWebGLArray<Dart$(INT
ERFACE_NAME)>(args);\n' | 626 ' WebCore::DartArrayBufferViewInternal::constructWebGLArray<Dart$(INT
ERFACE_NAME)>(args);\n' |
| 619 '}\n', | 627 '}\n', |
| 620 INTERFACE_NAME=self._interface.id); | 628 INTERFACE_NAME=self._interface.id); |
| 629 if self._dart_use_blink: |
| 630 self._native_class_emitter = self._native_library_emitter.Emit( |
| 631 '\n' |
| 632 'class $INTERFACE_NAME {' |
| 633 '$!METHODS' |
| 634 '}\n', |
| 635 INTERFACE_NAME=DeriveBlinkClassName(self._interface.id)) |
| 621 | 636 |
| 622 def _EmitConstructorInfrastructure(self, | 637 def _EmitConstructorInfrastructure(self, |
| 623 constructor_info, cpp_prefix, cpp_suffix, factory_method_name, | 638 constructor_info, cpp_prefix, cpp_suffix, factory_method_name, |
| 624 arguments=None, emit_to_native=False, is_custom=False): | 639 arguments=None, emit_to_native=False, is_custom=False): |
| 625 | 640 |
| 626 constructor_callback_cpp_name = cpp_prefix + cpp_suffix | 641 constructor_callback_cpp_name = cpp_prefix + cpp_suffix |
| 627 | 642 |
| 628 if arguments is None: | 643 if arguments is None: |
| 629 if self._dart_use_blink: | 644 if self._dart_use_blink: |
| 630 arguments = constructor_info.idl_args[0] | 645 arguments = constructor_info.idl_args[0] |
| (...skipping 10 matching lines...) Expand all Loading... |
| 641 if self._dart_use_blink: | 656 if self._dart_use_blink: |
| 642 type_ids = [p.type.id for p in arguments[:argument_count]] | 657 type_ids = [p.type.id for p in arguments[:argument_count]] |
| 643 constructor_callback_id = \ | 658 constructor_callback_id = \ |
| 644 DeriveResolverString(self._interface.id, cpp_suffix, None, type_ids,
self._database, is_custom) | 659 DeriveResolverString(self._interface.id, cpp_suffix, None, type_ids,
self._database, is_custom) |
| 645 else: | 660 else: |
| 646 constructor_callback_id = self._interface.id + '_' + constructor_callbac
k_cpp_name | 661 constructor_callback_id = self._interface.id + '_' + constructor_callbac
k_cpp_name |
| 647 | 662 |
| 648 if self._dart_use_blink: | 663 if self._dart_use_blink: |
| 649 # First we emit the toplevel function | 664 # First we emit the toplevel function |
| 650 dart_native_name = \ | 665 dart_native_name = \ |
| 651 DeriveNativeName(self._interface.id, constructor_callback_cpp_name,
"") | 666 self.DeriveNativeName(constructor_callback_cpp_name) |
| 652 if constructor_callback_id in _cpp_resolver_string_map: | 667 if constructor_callback_id in _cpp_resolver_string_map: |
| 653 constructor_callback_id = \ | 668 constructor_callback_id = \ |
| 654 _cpp_resolver_string_map[constructor_callback_id] | 669 _cpp_resolver_string_map[constructor_callback_id] |
| 655 self._native_library_emitter.Emit( | 670 self._native_class_emitter.Emit( |
| 656 '\n' | 671 '\n' |
| 657 '$FACTORY_METHOD_NAME($PARAMETERS) native "$ID";\n', | 672 ' static $FACTORY_METHOD_NAME($PARAMETERS) native "$ID";\n', |
| 658 FACTORY_METHOD_NAME=dart_native_name, | 673 FACTORY_METHOD_NAME=dart_native_name, |
| 659 PARAMETERS=parameters, | 674 PARAMETERS=parameters, |
| 660 ID=constructor_callback_id) | 675 ID=constructor_callback_id) |
| 661 | 676 |
| 662 # Then we emit the impedance matching wrapper to call out to the | 677 # Then we emit the impedance matching wrapper to call out to the |
| 663 # toplevel wrapper | 678 # toplevel wrapper |
| 664 if not emit_to_native: | 679 if not emit_to_native: |
| 680 toplevel_name = \ |
| 681 self.DeriveQualifiedBlinkName(self._interface.id, |
| 682 dart_native_name) |
| 665 self._members_emitter.Emit( | 683 self._members_emitter.Emit( |
| 666 '\n @DocsEditable()\n' | 684 '\n @DocsEditable()\n' |
| 667 ' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) => ' | 685 ' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) => ' |
| 668 '$TOPLEVEL_NAME($OUTPARAMETERS);\n', | 686 '$TOPLEVEL_NAME($OUTPARAMETERS);\n', |
| 669 INTERFACE_NAME=self._interface_type_info.interface_name(), | 687 INTERFACE_NAME=self._interface_type_info.interface_name(), |
| 670 FACTORY_METHOD_NAME=factory_method_name, | 688 FACTORY_METHOD_NAME=factory_method_name, |
| 671 PARAMETERS=typed_formals, | 689 PARAMETERS=typed_formals, |
| 672 TOPLEVEL_NAME=DeriveQualifiedName(self._native_library_name, | 690 TOPLEVEL_NAME=toplevel_name, |
| 673 dart_native_name), | |
| 674 OUTPARAMETERS=parameters) | 691 OUTPARAMETERS=parameters) |
| 675 else: | 692 else: |
| 676 self._members_emitter.Emit( | 693 self._members_emitter.Emit( |
| 677 '\n @DocsEditable()\n' | 694 '\n @DocsEditable()\n' |
| 678 ' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) ' | 695 ' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) ' |
| 679 'native "$ID";\n', | 696 'native "$ID";\n', |
| 680 INTERFACE_NAME=self._interface_type_info.interface_name(), | 697 INTERFACE_NAME=self._interface_type_info.interface_name(), |
| 681 FACTORY_METHOD_NAME=factory_method_name, | 698 FACTORY_METHOD_NAME=factory_method_name, |
| 682 PARAMETERS=typed_formals, | 699 PARAMETERS=typed_formals, |
| 683 ID=constructor_callback_id) | 700 ID=constructor_callback_id) |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 # | 1078 # |
| 1062 dart_element_type = self._DartType(element_type) | 1079 dart_element_type = self._DartType(element_type) |
| 1063 if self._HasNativeIndexGetter(): | 1080 if self._HasNativeIndexGetter(): |
| 1064 self._EmitNativeIndexGetter(dart_element_type) | 1081 self._EmitNativeIndexGetter(dart_element_type) |
| 1065 elif self._HasExplicitIndexedGetter(): | 1082 elif self._HasExplicitIndexedGetter(): |
| 1066 self._EmitExplicitIndexedGetter(dart_element_type) | 1083 self._EmitExplicitIndexedGetter(dart_element_type) |
| 1067 else: | 1084 else: |
| 1068 if self._dart_use_blink: | 1085 if self._dart_use_blink: |
| 1069 is_custom = any((op.id == 'item' and 'Custom' in op.ext_attrs) for op
in self._interface.operations) | 1086 is_custom = any((op.id == 'item' and 'Custom' in op.ext_attrs) for op
in self._interface.operations) |
| 1070 dart_native_name = \ | 1087 dart_native_name = \ |
| 1071 DeriveNativeName(self._interface.id, "NativeIndexed", "Getter") | 1088 self.DeriveNativeName("NativeIndexed", "Getter") |
| 1072 # First emit a toplevel function to do the native call | 1089 # First emit a toplevel function to do the native call |
| 1073 # Calls to this are emitted elsewhere, | 1090 # Calls to this are emitted elsewhere, |
| 1074 resolver_string = \ | 1091 resolver_string = \ |
| 1075 DeriveResolverString(self._interface.id, "item", "Callback", | 1092 DeriveResolverString(self._interface.id, "item", "Callback", |
| 1076 ["unsigned long"], self._database, is_custom) | 1093 ["unsigned long"], self._database, is_custom) |
| 1077 if resolver_string in _cpp_resolver_string_map: | 1094 if resolver_string in _cpp_resolver_string_map: |
| 1078 resolver_string = \ | 1095 resolver_string = \ |
| 1079 _cpp_resolver_string_map[resolver_string] | 1096 _cpp_resolver_string_map[resolver_string] |
| 1080 self._native_library_emitter.Emit( | 1097 self._native_class_emitter.Emit( |
| 1081 '\n' | 1098 '\n' |
| 1082 '$(DART_NATIVE_NAME)(mthis, index) ' | 1099 ' static $(DART_NATIVE_NAME)(mthis, index) ' |
| 1083 'native "$(RESOLVER_STRING)";\n', | 1100 'native "$(RESOLVER_STRING)";\n', |
| 1084 DART_NATIVE_NAME = dart_native_name, | 1101 DART_NATIVE_NAME = dart_native_name, |
| 1085 RESOLVER_STRING=resolver_string) | 1102 RESOLVER_STRING=resolver_string) |
| 1086 | 1103 |
| 1087 # Emit the method which calls the toplevel function, along with | 1104 # Emit the method which calls the toplevel function, along with |
| 1088 # the [] operator. | 1105 # the [] operator. |
| 1106 dart_qualified_name = \ |
| 1107 self.DeriveQualifiedBlinkName(self._interface.id, |
| 1108 dart_native_name) |
| 1089 self._members_emitter.Emit( | 1109 self._members_emitter.Emit( |
| 1090 '\n' | 1110 '\n' |
| 1091 ' $TYPE operator[](int index) {\n' | 1111 ' $TYPE operator[](int index) {\n' |
| 1092 ' if (index < 0 || index >= length)\n' | 1112 ' if (index < 0 || index >= length)\n' |
| 1093 ' throw new RangeError.range(index, 0, length);\n' | 1113 ' throw new RangeError.range(index, 0, length);\n' |
| 1094 ' return $(DART_NATIVE_NAME)(this, index);\n' | 1114 ' return $(DART_NATIVE_NAME)(this, index);\n' |
| 1095 ' }\n\n' | 1115 ' }\n\n' |
| 1096 ' $TYPE _nativeIndexedGetter(int index) =>' | 1116 ' $TYPE _nativeIndexedGetter(int index) =>' |
| 1097 ' $(DART_NATIVE_NAME)(this, index);\n', | 1117 ' $(DART_NATIVE_NAME)(this, index);\n', |
| 1098 DART_NATIVE_NAME=DeriveQualifiedName(self._native_library_name, | 1118 DART_NATIVE_NAME=dart_qualified_name, |
| 1099 dart_native_name), | |
| 1100 TYPE=self.SecureOutputType(element_type), | 1119 TYPE=self.SecureOutputType(element_type), |
| 1101 INTERFACE=self._interface.id) | 1120 INTERFACE=self._interface.id) |
| 1102 else: | 1121 else: |
| 1103 # Emit the method which calls the toplevel function, along with | 1122 # Emit the method which calls the toplevel function, along with |
| 1104 # the [] operator. | 1123 # the [] operator. |
| 1105 self._members_emitter.Emit( | 1124 self._members_emitter.Emit( |
| 1106 '\n' | 1125 '\n' |
| 1107 ' $TYPE operator[](int index) {\n' | 1126 ' $TYPE operator[](int index) {\n' |
| 1108 ' if (index < 0 || index >= length)\n' | 1127 ' if (index < 0 || index >= length)\n' |
| 1109 ' throw new RangeError.range(index, 0, length);\n' | 1128 ' throw new RangeError.range(index, 0, length);\n' |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1230 def GenerateCall( | 1249 def GenerateCall( |
| 1231 stmts_emitter, call_emitter, version, operation, argument_count): | 1250 stmts_emitter, call_emitter, version, operation, argument_count): |
| 1232 native_suffix = 'Callback' | 1251 native_suffix = 'Callback' |
| 1233 actuals = info.ParametersAsListOfVariables(argument_count) | 1252 actuals = info.ParametersAsListOfVariables(argument_count) |
| 1234 return_type = self.SecureOutputType(operation.type.id) | 1253 return_type = self.SecureOutputType(operation.type.id) |
| 1235 native_suffix = 'Callback' | 1254 native_suffix = 'Callback' |
| 1236 is_custom = 'Custom' in operation.ext_attrs | 1255 is_custom = 'Custom' in operation.ext_attrs |
| 1237 if self._dart_use_blink: | 1256 if self._dart_use_blink: |
| 1238 base_name = '_%s_%s' % (operation.id, version) | 1257 base_name = '_%s_%s' % (operation.id, version) |
| 1239 overload_name = \ | 1258 overload_name = \ |
| 1240 DeriveNativeName(self._interface.id, base_name, native_suffix) | 1259 self.DeriveNativeName(base_name, native_suffix) |
| 1241 static = True | 1260 static = True |
| 1242 if not operation.is_static: | 1261 if not operation.is_static: |
| 1243 actuals = ['mthis'] + actuals | 1262 actuals = ['mthis'] + actuals |
| 1244 actuals_s = ", ".join(actuals) | 1263 actuals_s = ", ".join(actuals) |
| 1245 dart_declaration = '%s(%s)' % ( | 1264 dart_declaration = '%s(%s)' % ( |
| 1246 base_name, actuals_s) | 1265 base_name, actuals_s) |
| 1247 type_ids = [argument.type.id | 1266 type_ids = [argument.type.id |
| 1248 for argument in operation.arguments[:argument_count]] | 1267 for argument in operation.arguments[:argument_count]] |
| 1249 resolver_string = \ | 1268 resolver_string = \ |
| 1250 DeriveResolverString(self._interface.id, operation.id, | 1269 DeriveResolverString(self._interface.id, operation.id, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1268 dart_declaration, static, return_type, actuals, | 1287 dart_declaration, static, return_type, actuals, |
| 1269 native_suffix, is_custom, auto_scope_setup, emit_metadata=False, | 1288 native_suffix, is_custom, auto_scope_setup, emit_metadata=False, |
| 1270 emit_to_native=self._dart_use_blink, resolver_string=resolver_string) | 1289 emit_to_native=self._dart_use_blink, resolver_string=resolver_string) |
| 1271 if not is_custom: | 1290 if not is_custom: |
| 1272 self._GenerateOperationNativeCallback(operation, | 1291 self._GenerateOperationNativeCallback(operation, |
| 1273 operation.arguments[:argument_count], cpp_callback_name, | 1292 operation.arguments[:argument_count], cpp_callback_name, |
| 1274 auto_scope_setup) | 1293 auto_scope_setup) |
| 1275 | 1294 |
| 1276 | 1295 |
| 1277 if self._dart_use_blink: | 1296 if self._dart_use_blink: |
| 1278 name = DeriveNativeName(self._interface.id, html_name, "") | 1297 name = self.DeriveNativeName(html_name) |
| 1279 qual_name = DeriveQualifiedName(self._native_library_name, | 1298 qual_name = self.DeriveQualifiedBlinkName(self._interface.id, |
| 1280 name) | 1299 name) |
| 1281 actuals = info.ParametersAsListOfVariables() | 1300 actuals = info.ParametersAsListOfVariables() |
| 1282 formals = info.ParametersAsListOfVariables() | 1301 formals = info.ParametersAsListOfVariables() |
| 1283 if not info.IsStatic(): | 1302 if not info.IsStatic(): |
| 1284 formals = ['mthis'] + formals | 1303 formals = ['mthis'] + formals |
| 1285 actuals = ['this'] + actuals | 1304 actuals = ['this'] + actuals |
| 1286 actuals_s = ', '.join(actuals) | 1305 actuals_s = ', '.join(actuals) |
| 1287 formals_s = ', '.join(formals) | 1306 formals_s = ', '.join(formals) |
| 1288 self._members_emitter.Emit( | 1307 self._members_emitter.Emit( |
| 1289 '\n' | 1308 '\n' |
| 1290 ' $DECLARATION => $NATIVE_NAME($ACTUALS);\n', | 1309 ' $DECLARATION => $NATIVE_NAME($ACTUALS);\n', |
| 1291 DECLARATION=dart_declaration, | 1310 DECLARATION=dart_declaration, |
| 1292 NATIVE_NAME=qual_name, | 1311 NATIVE_NAME=qual_name, |
| 1293 ACTUALS=actuals_s) | 1312 ACTUALS=actuals_s) |
| 1294 | 1313 |
| 1295 dart_declaration = \ | 1314 dart_declaration = \ |
| 1296 '// Generated overload resolver\n' \ | 1315 '// Generated overload resolver\n' \ |
| 1297 '%s(%s)' % (name, formals_s) | 1316 ' static %s(%s)' % (name, formals_s) |
| 1298 | 1317 |
| 1299 self._GenerateDispatcherBody( | 1318 self._GenerateDispatcherBody( |
| 1300 info, | 1319 info, |
| 1301 operations, | 1320 operations, |
| 1302 dart_declaration, | 1321 dart_declaration, |
| 1303 GenerateCall, | 1322 GenerateCall, |
| 1304 self._IsArgumentOptionalInWebCore) | 1323 self._IsArgumentOptionalInWebCore) |
| 1305 | 1324 |
| 1306 def SecondaryContext(self, interface): | 1325 def SecondaryContext(self, interface): |
| 1307 pass | 1326 pass |
| (...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1696 def _GenerateNativeBinding(self, idl_name, argument_count, dart_declaration, | 1715 def _GenerateNativeBinding(self, idl_name, argument_count, dart_declaration, |
| 1697 static, return_type, parameters, native_suffix, is_custom, | 1716 static, return_type, parameters, native_suffix, is_custom, |
| 1698 auto_scope_setup=True, emit_metadata=True, emit_to_native=False, | 1717 auto_scope_setup=True, emit_metadata=True, emit_to_native=False, |
| 1699 resolver_string=None): | 1718 resolver_string=None): |
| 1700 metadata = [] | 1719 metadata = [] |
| 1701 if emit_metadata: | 1720 if emit_metadata: |
| 1702 metadata = self._metadata.GetFormattedMetadata( | 1721 metadata = self._metadata.GetFormattedMetadata( |
| 1703 self._renamer.GetLibraryName(self._interface), | 1722 self._renamer.GetLibraryName(self._interface), |
| 1704 self._interface, idl_name, ' ') | 1723 self._interface, idl_name, ' ') |
| 1705 dart_native_name = \ | 1724 dart_native_name = \ |
| 1706 DeriveNativeName(self._interface.id, idl_name, native_suffix) | 1725 self.DeriveNativeName(idl_name, native_suffix) |
| 1707 | 1726 |
| 1708 if (resolver_string): | 1727 if (resolver_string): |
| 1709 native_binding = resolver_string | 1728 native_binding = resolver_string |
| 1710 else: | 1729 else: |
| 1711 native_binding_id = self._interface.id | 1730 native_binding_id = self._interface.id |
| 1712 if self._dart_use_blink: | 1731 if self._dart_use_blink: |
| 1713 native_binding_id = TypeIdToBlinkName(native_binding_id, self._databas
e) | 1732 native_binding_id = TypeIdToBlinkName(native_binding_id, self._databas
e) |
| 1714 native_binding = \ | 1733 native_binding = \ |
| 1715 '%s_%s_%s' % (native_binding_id, idl_name, native_suffix) | 1734 '%s_%s_%s' % (native_binding_id, idl_name, native_suffix) |
| 1716 | 1735 |
| 1717 if self._dart_use_blink: | 1736 if self._dart_use_blink: |
| 1718 if not static: | 1737 if not static: |
| 1719 formals = ", ".join(['mthis'] + parameters) | 1738 formals = ", ".join(['mthis'] + parameters) |
| 1720 actuals = ", ".join(['this'] + parameters) | 1739 actuals = ", ".join(['this'] + parameters) |
| 1721 else: | 1740 else: |
| 1722 formals = ", ".join(parameters) | 1741 formals = ", ".join(parameters) |
| 1723 actuals = ", ".join(parameters) | 1742 actuals = ", ".join(parameters) |
| 1724 if native_binding in _cpp_resolver_string_map: | 1743 if native_binding in _cpp_resolver_string_map: |
| 1725 native_binding = \ | 1744 native_binding = \ |
| 1726 _cpp_resolver_string_map[native_binding] | 1745 _cpp_resolver_string_map[native_binding] |
| 1727 self._native_library_emitter.Emit( | 1746 self._native_class_emitter.Emit( |
| 1728 '\n' | 1747 '\n' |
| 1729 '$DART_NAME($FORMALS) native "$NATIVE_BINDING";\n', | 1748 ' static $DART_NAME($FORMALS) native "$NATIVE_BINDING";\n', |
| 1730 DART_NAME=dart_native_name, | 1749 DART_NAME=dart_native_name, |
| 1731 FORMALS=formals, | 1750 FORMALS=formals, |
| 1732 NATIVE_BINDING=native_binding) | 1751 NATIVE_BINDING=native_binding) |
| 1733 | 1752 |
| 1734 if not emit_to_native: | 1753 if not emit_to_native: |
| 1735 caller_emitter = self._members_emitter | 1754 caller_emitter = self._members_emitter |
| 1736 full_dart_name = DeriveQualifiedName(self._native_library_name, | 1755 full_dart_name = \ |
| 1737 dart_native_name) | 1756 self.DeriveQualifiedBlinkName(self._interface.id, |
| 1757 dart_native_name) |
| 1738 caller_emitter.Emit( | 1758 caller_emitter.Emit( |
| 1739 '\n' | 1759 '\n' |
| 1740 ' $METADATA$DART_DECLARATION => $DART_NAME($ACTUALS);\n', | 1760 ' $METADATA$DART_DECLARATION => $DART_NAME($ACTUALS);\n', |
| 1741 METADATA=metadata, | 1761 METADATA=metadata, |
| 1742 DART_DECLARATION=dart_declaration, | 1762 DART_DECLARATION=dart_declaration, |
| 1743 DART_NAME=full_dart_name, | 1763 DART_NAME=full_dart_name, |
| 1744 ACTUALS=actuals) | 1764 ACTUALS=actuals) |
| 1745 else: | 1765 else: |
| 1746 self._members_emitter.Emit( | 1766 self._members_emitter.Emit( |
| 1747 '\n' | 1767 '\n' |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2010 e.Emit("};\n"); | 2030 e.Emit("};\n"); |
| 2011 e.Emit('\n'); | 2031 e.Emit('\n'); |
| 2012 e.Emit('} // namespace WebCore\n'); | 2032 e.Emit('} // namespace WebCore\n'); |
| 2013 | 2033 |
| 2014 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 2034 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 2015 return ( | 2035 return ( |
| 2016 interface.id.endswith('Event') and | 2036 interface.id.endswith('Event') and |
| 2017 operation.id.startswith('init') and | 2037 operation.id.startswith('init') and |
| 2018 argument.ext_attrs.get('Default') == 'Undefined' and | 2038 argument.ext_attrs.get('Default') == 'Undefined' and |
| 2019 argument.type.id == 'DOMString') | 2039 argument.type.id == 'DOMString') |
| OLD | NEW |