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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 # track the necessary info. | 164 # track the necessary info. |
165 _url_utils = ['hash', 'host', 'hostname', 'origin', | 165 _url_utils = ['hash', 'host', 'hostname', 'origin', |
166 'password', 'pathname', 'port', 'protocol', | 166 'password', 'pathname', 'port', 'protocol', |
167 'search', 'username'] | 167 'search', 'username'] |
168 _cpp_static_call_map = { | 168 _cpp_static_call_map = { |
169 'DOMURL': _url_utils + ['href', 'toString'], | 169 'DOMURL': _url_utils + ['href', 'toString'], |
170 'HTMLAnchorElement': _url_utils, | 170 'HTMLAnchorElement': _url_utils, |
171 'HTMLAreaElement': _url_utils, | 171 'HTMLAreaElement': _url_utils, |
172 } | 172 } |
173 | 173 |
| 174 # This goes away after the Chrome 35 roll (or whenever we commit to the |
| 175 # dart:blink refactor) |
| 176 dart_use_blink = False |
| 177 |
174 def _GetCPPPartialNames(interface): | 178 def _GetCPPPartialNames(interface): |
175 interface_name = interface.ext_attrs.get('ImplementedAs', interface.id) | 179 interface_name = interface.ext_attrs.get('ImplementedAs', interface.id) |
176 if not _cpp_partial_map: | 180 if not _cpp_partial_map: |
177 for (type, member) in _cpp_callback_map.keys(): | 181 for (type, member) in _cpp_callback_map.keys(): |
178 if type not in _cpp_partial_map: | 182 if type not in _cpp_partial_map: |
179 _cpp_partial_map[type] = set([]) | 183 _cpp_partial_map[type] = set([]) |
180 | 184 |
181 name_with_path = _cpp_callback_map[(type, member)] | 185 name_with_path = _cpp_callback_map[(type, member)] |
182 if name_with_path in _cpp_import_map: | 186 if name_with_path in _cpp_import_map: |
183 name_with_path = _cpp_import_map[name_with_path] | 187 name_with_path = _cpp_import_map[name_with_path] |
(...skipping 21 matching lines...) Expand all Loading... |
205 | 209 |
206 cpp_tuple = (interface_name, callback_name) | 210 cpp_tuple = (interface_name, callback_name) |
207 if cpp_tuple in _cpp_callback_map: | 211 if cpp_tuple in _cpp_callback_map: |
208 cpp_type_name = _cpp_callback_map[cpp_tuple] | 212 cpp_type_name = _cpp_callback_map[cpp_tuple] |
209 elif (interface_name, cpp_name) in _cpp_overloaded_callback_map: | 213 elif (interface_name, cpp_name) in _cpp_overloaded_callback_map: |
210 cpp_type_name = _cpp_overloaded_callback_map[(interface_name, cpp_name)] | 214 cpp_type_name = _cpp_overloaded_callback_map[(interface_name, cpp_name)] |
211 else: | 215 else: |
212 cpp_type_name = interface_name | 216 cpp_type_name = interface_name |
213 return cpp_type_name | 217 return cpp_type_name |
214 | 218 |
| 219 def DeriveQualifiedName(library_name, name): |
| 220 return library_name + "." + name |
| 221 |
| 222 def DeriveNativeName(interface_name, name, suffix): |
| 223 fields = ["Native", interface_name, name] |
| 224 if suffix != "": |
| 225 fields.append(suffix) |
| 226 return "_".join(fields) |
| 227 |
| 228 # FIXME(leafp) This should really go elsewhere. I think the right thing |
| 229 # to do is to add support in the DartLibraries objects in systemhtml |
| 230 # for emitting top level code in libraries. This can then just be a |
| 231 # normal use of that kind of object |
| 232 def GetNativeLibraryEmitter(emitters, template_loader, |
| 233 dartium_output_dir, dart_output_dir, |
| 234 auxiliary_dir): |
| 235 def massage_path(path): |
| 236 # The most robust way to emit path separators is to use / always. |
| 237 return path.replace('\\', '/') |
| 238 template = template_loader.Load('blink_dartium.darttemplate') |
| 239 dart_path = os.path.join(dartium_output_dir, 'blink_dartium.dart') |
| 240 library_emitter = emitters.FileEmitter(dart_path) |
| 241 auxiliary_dir = os.path.relpath(auxiliary_dir, dartium_output_dir) |
| 242 emitter = \ |
| 243 library_emitter.Emit(template, |
| 244 AUXILIARY_DIR=massage_path(auxiliary_dir)) |
| 245 return emitter |
| 246 |
215 class DartiumBackend(HtmlDartGenerator): | 247 class DartiumBackend(HtmlDartGenerator): |
216 """Generates Dart implementation for one DOM IDL interface.""" | 248 """Generates Dart implementation for one DOM IDL interface.""" |
217 | 249 |
218 def __init__(self, interface, cpp_library_emitter, options): | 250 def __init__(self, interface, native_library_emitter, |
| 251 cpp_library_emitter, options): |
219 super(DartiumBackend, self).__init__(interface, options) | 252 super(DartiumBackend, self).__init__(interface, options) |
220 | 253 |
221 self._interface = interface | 254 self._interface = interface |
222 self._cpp_library_emitter = cpp_library_emitter | 255 self._cpp_library_emitter = cpp_library_emitter |
| 256 self._native_library_emitter = native_library_emitter |
223 self._database = options.database | 257 self._database = options.database |
224 self._template_loader = options.templates | 258 self._template_loader = options.templates |
225 self._type_registry = options.type_registry | 259 self._type_registry = options.type_registry |
226 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) | 260 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) |
227 self._metadata = options.metadata | 261 self._metadata = options.metadata |
| 262 self._native_library_name = "blink" |
| 263 # These get initialized by StartInterface |
| 264 self._cpp_header_emitter = None |
| 265 self._cpp_impl_emitter = None |
| 266 self._members_emitter = None |
| 267 self._cpp_declarations_emitter = None |
| 268 self._cpp_impl_includes = None |
| 269 self._cpp_definitions_emitter = None |
| 270 self._cpp_resolver_emitter = None |
228 | 271 |
229 def ImplementsMergedMembers(self): | 272 def ImplementsMergedMembers(self): |
230 # We could not add merged functions to implementation class because | 273 # We could not add merged functions to implementation class because |
231 # underlying c++ object doesn't implement them. Merged functions are | 274 # underlying c++ object doesn't implement them. Merged functions are |
232 # generated on merged interface implementation instead. | 275 # generated on merged interface implementation instead. |
233 return False | 276 return False |
234 | 277 |
235 def CustomJSMembers(self): | 278 def CustomJSMembers(self): |
236 return {} | 279 return {} |
237 | 280 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 def ImplementationTemplate(self): | 389 def ImplementationTemplate(self): |
347 template = None | 390 template = None |
348 interface_name = self._interface.doc_js_name | 391 interface_name = self._interface.doc_js_name |
349 if interface_name == self._interface.id or not self._database.HasInterface(i
nterface_name): | 392 if interface_name == self._interface.id or not self._database.HasInterface(i
nterface_name): |
350 template_file = 'impl_%s.darttemplate' % interface_name | 393 template_file = 'impl_%s.darttemplate' % interface_name |
351 template = self._template_loader.TryLoad(template_file) | 394 template = self._template_loader.TryLoad(template_file) |
352 if not template: | 395 if not template: |
353 template = self._template_loader.Load('dart_implementation.darttemplate') | 396 template = self._template_loader.Load('dart_implementation.darttemplate') |
354 return template | 397 return template |
355 | 398 |
| 399 def _NativeImplementationTemplate(self): |
| 400 template = None |
| 401 interface_name = self._interface.doc_js_name |
| 402 if (interface_name == self._interface.id or |
| 403 not self._database.HasInterface(interface_name)): |
| 404 template_file = 'impl_blink_%s.darttemplate' % interface_name |
| 405 template = self._template_loader.TryLoad(template_file) |
| 406 if not template: |
| 407 template = \ |
| 408 self._template_loader.Load('dart_blink_implementation.darttemplate') |
| 409 return template |
| 410 |
356 def RootClassName(self): | 411 def RootClassName(self): |
357 return 'NativeFieldWrapperClass2' | 412 return 'NativeFieldWrapperClass2' |
358 | 413 |
359 def NativeSpec(self): | 414 def NativeSpec(self): |
360 return '' | 415 return '' |
361 | 416 |
362 def StartInterface(self, members_emitter): | 417 def StartInterface(self, members_emitter): |
363 # Create emitters for c++ implementation. | 418 # Create emitters for c++ implementation. |
364 if not IsPureInterface(self._interface.id) and not IsCustomType(self._interf
ace.id): | 419 if not IsPureInterface(self._interface.id) and \ |
| 420 not IsCustomType(self._interface.id): |
365 self._cpp_header_emitter = self._cpp_library_emitter.CreateHeaderEmitter( | 421 self._cpp_header_emitter = self._cpp_library_emitter.CreateHeaderEmitter( |
366 self._interface.id, | 422 self._interface.id, |
367 self._renamer.GetLibraryName(self._interface)) | 423 self._renamer.GetLibraryName(self._interface)) |
368 self._cpp_impl_emitter = self._cpp_library_emitter.CreateSourceEmitter(sel
f._interface.id) | 424 self._cpp_impl_emitter = \ |
| 425 self._cpp_library_emitter.CreateSourceEmitter(self._interface.id) |
369 else: | 426 else: |
370 self._cpp_header_emitter = emitter.Emitter() | 427 self._cpp_header_emitter = emitter.Emitter() |
371 self._cpp_impl_emitter = emitter.Emitter() | 428 self._cpp_impl_emitter = emitter.Emitter() |
372 | 429 |
373 self._interface_type_info = self._TypeInfo(self._interface.id) | 430 self._interface_type_info = self._TypeInfo(self._interface.id) |
374 self._members_emitter = members_emitter | 431 self._members_emitter = members_emitter |
| 432 |
375 self._cpp_declarations_emitter = emitter.Emitter() | 433 self._cpp_declarations_emitter = emitter.Emitter() |
376 | 434 |
377 self._cpp_impl_includes = set(['"' + partial + '.h"' | 435 self._cpp_impl_includes = \ |
378 for partial in _GetCPPPartialNames(self._inte
rface)]) | 436 set(['"' + partial + '.h"' |
| 437 for partial in _GetCPPPartialNames(self._interface)]) |
379 | 438 |
380 # This is a hack to work around a strange C++ compile error that we weren't | 439 # This is a hack to work around a strange C++ compile error that we weren't |
381 # able to track down the true cause of. | 440 # able to track down the true cause of. |
382 if self._interface.id == 'Timing': | 441 if self._interface.id == 'Timing': |
383 self._cpp_impl_includes.add('"core/animation/TimedItem.h"') | 442 self._cpp_impl_includes.add('"core/animation/TimedItem.h"') |
384 | 443 |
385 self._cpp_definitions_emitter = emitter.Emitter() | 444 self._cpp_definitions_emitter = emitter.Emitter() |
386 self._cpp_resolver_emitter = emitter.Emitter() | 445 self._cpp_resolver_emitter = emitter.Emitter() |
387 | 446 |
388 # We need to revisit our treatment of typed arrays, right now | 447 # We need to revisit our treatment of typed arrays, right now |
(...skipping 13 matching lines...) Expand all Loading... |
402 '}\n', | 461 '}\n', |
403 INTERFACE_NAME=self._interface.id); | 462 INTERFACE_NAME=self._interface.id); |
404 | 463 |
405 def _EmitConstructorInfrastructure(self, | 464 def _EmitConstructorInfrastructure(self, |
406 constructor_info, constructor_callback_cpp_name, factory_method_name, | 465 constructor_info, constructor_callback_cpp_name, factory_method_name, |
407 argument_count=None): | 466 argument_count=None): |
408 constructor_callback_id = self._interface.id + '_' + constructor_callback_cp
p_name | 467 constructor_callback_id = self._interface.id + '_' + constructor_callback_cp
p_name |
409 if argument_count is None: | 468 if argument_count is None: |
410 argument_count = len(constructor_info.param_infos) | 469 argument_count = len(constructor_info.param_infos) |
411 | 470 |
412 self._members_emitter.Emit( | 471 typed_formals = constructor_info.ParametersAsArgumentList(argument_count) |
413 '\n @DocsEditable()\n' | 472 parameters = constructor_info.ParametersAsStringOfVariables(argument_count) |
414 ' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) ' | 473 interface_name = self._interface_type_info.interface_name() |
| 474 |
| 475 if dart_use_blink: |
| 476 # First we emit the toplevel function |
| 477 dart_native_name = \ |
| 478 DeriveNativeName(self._interface.id, constructor_callback_cpp_name,
"") |
| 479 self._native_library_emitter.Emit( |
| 480 '\n' |
| 481 '$FACTORY_METHOD_NAME($PARAMETERS) native "$ID";\n', |
| 482 FACTORY_METHOD_NAME=dart_native_name, |
| 483 PARAMETERS=parameters, |
| 484 ID=constructor_callback_id) |
| 485 |
| 486 # Then we emit the impedance matching wrapper to call out to the |
| 487 # toplevel wrapper |
| 488 self._members_emitter.Emit( |
| 489 '\n @DocsEditable()\n' |
| 490 ' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) => ' |
| 491 '$TOPLEVEL_NAME($OUTPARAMETERS);\n', |
| 492 INTERFACE_NAME=self._interface_type_info.interface_name(), |
| 493 FACTORY_METHOD_NAME=factory_method_name, |
| 494 PARAMETERS=typed_formals, |
| 495 TOPLEVEL_NAME=DeriveQualifiedName(self._native_library_name, |
| 496 dart_native_name), |
| 497 OUTPARAMETERS=parameters) |
| 498 else: |
| 499 self._members_emitter.Emit( |
| 500 '\n @DocsEditable()\n' |
| 501 ' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) ' |
415 'native "$ID";\n', | 502 'native "$ID";\n', |
416 INTERFACE_NAME=self._interface_type_info.interface_name(), | 503 INTERFACE_NAME=self._interface_type_info.interface_name(), |
417 FACTORY_METHOD_NAME=factory_method_name, | 504 FACTORY_METHOD_NAME=factory_method_name, |
418 # TODO: add types to parameters. | 505 PARAMETERS=typed_formals, |
419 PARAMETERS=constructor_info.ParametersAsArgumentList(argument_count), | 506 ID=constructor_callback_id) |
420 ID=constructor_callback_id) | |
421 | 507 |
422 self._cpp_resolver_emitter.Emit( | 508 self._cpp_resolver_emitter.Emit( |
423 ' if (name == "$ID")\n' | 509 ' if (name == "$ID")\n' |
424 ' return Dart$(WEBKIT_INTERFACE_NAME)Internal::$CPP_CALLBACK;\n', | 510 ' return Dart$(WEBKIT_INTERFACE_NAME)Internal::$CPP_CALLBACK;\n', |
425 ID=constructor_callback_id, | 511 ID=constructor_callback_id, |
426 WEBKIT_INTERFACE_NAME=self._interface.id, | 512 WEBKIT_INTERFACE_NAME=self._interface.id, |
427 CPP_CALLBACK=constructor_callback_cpp_name) | 513 CPP_CALLBACK=constructor_callback_cpp_name) |
428 | 514 |
429 def GenerateCustomFactory(self, constructor_info): | 515 def GenerateCustomFactory(self, constructor_info): |
430 if 'CustomConstructor' not in self._interface.ext_attrs: | 516 if 'CustomConstructor' not in self._interface.ext_attrs: |
431 return False | 517 return False |
432 | 518 |
433 annotations = self._metadata.GetFormattedMetadata(self._library_name, | 519 annotations = self._metadata.GetFormattedMetadata(self._library_name, |
434 self._interface, self._interface.id, ' ') | 520 self._interface, self._interface.id, ' ') |
435 | 521 |
436 self._members_emitter.Emit( | 522 self._members_emitter.Emit( |
437 '\n $(ANNOTATIONS)factory $CTOR($PARAMS) => _create($FACTORY_PARAMS);\n
', | 523 '\n $(ANNOTATIONS)factory $CTOR($PARAMS) => _create($FACTORY_PARAMS);\n
', |
438 ANNOTATIONS=annotations, | 524 ANNOTATIONS=annotations, |
439 CTOR=constructor_info._ConstructorFullName(self._DartType), | 525 CTOR=constructor_info._ConstructorFullName(self._DartType), |
440 PARAMS=constructor_info.ParametersDeclaration(self._DartType), | 526 PARAMS=constructor_info.ParametersAsDeclaration(self._DartType), |
441 FACTORY_PARAMS= \ | 527 FACTORY_PARAMS= \ |
442 constructor_info.ParametersAsArgumentList()) | 528 constructor_info.ParametersAsArgumentList()) |
443 | 529 |
444 constructor_callback_cpp_name = 'constructorCallback' | 530 constructor_callback_cpp_name = 'constructorCallback' |
445 self._EmitConstructorInfrastructure( | 531 self._EmitConstructorInfrastructure( |
446 constructor_info, constructor_callback_cpp_name, '_create') | 532 constructor_info, constructor_callback_cpp_name, '_create') |
447 | 533 |
448 self._cpp_declarations_emitter.Emit( | 534 self._cpp_declarations_emitter.Emit( |
449 '\n' | 535 '\n' |
450 'void $CPP_CALLBACK(Dart_NativeArguments);\n', | 536 'void $CPP_CALLBACK(Dart_NativeArguments);\n', |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 | 755 |
670 def _GenerateAutoSetupScope(self, idl_name, native_suffix): | 756 def _GenerateAutoSetupScope(self, idl_name, native_suffix): |
671 return (self._interface.id, idl_name, native_suffix) not in _cpp_no_auto_sco
pe_list | 757 return (self._interface.id, idl_name, native_suffix) not in _cpp_no_auto_sco
pe_list |
672 | 758 |
673 def _AddGetter(self, attr, html_name, read_only): | 759 def _AddGetter(self, attr, html_name, read_only): |
674 # Temporary hack to force dart:scalarlist clamped array for ImageData.data. | 760 # Temporary hack to force dart:scalarlist clamped array for ImageData.data. |
675 # TODO(antonm): solve in principled way. | 761 # TODO(antonm): solve in principled way. |
676 if self._interface.id == 'ImageData' and html_name == 'data': | 762 if self._interface.id == 'ImageData' and html_name == 'data': |
677 html_name = '_data' | 763 html_name = '_data' |
678 type_info = self._TypeInfo(attr.type.id) | 764 type_info = self._TypeInfo(attr.type.id) |
679 dart_declaration = '%s get %s' % ( | 765 return_type = self.SecureOutputType(attr.type.id, False, read_only) |
680 self.SecureOutputType(attr.type.id, False, read_only), html_name) | 766 parameters = [] |
| 767 dart_declaration = '%s get %s' % (return_type, html_name) |
681 is_custom = ('Custom' in attr.ext_attrs and | 768 is_custom = ('Custom' in attr.ext_attrs and |
682 (attr.ext_attrs['Custom'] == None or | 769 (attr.ext_attrs['Custom'] == None or |
683 attr.ext_attrs['Custom'] == 'Getter')) | 770 attr.ext_attrs['Custom'] == 'Getter')) |
684 # This seems to have been replaced with Custom=Getter (see above), but | 771 # This seems to have been replaced with Custom=Getter (see above), but |
685 # check to be sure we don't see the old syntax | 772 # check to be sure we don't see the old syntax |
686 assert(not ('CustomGetter' in attr.ext_attrs)) | 773 assert(not ('CustomGetter' in attr.ext_attrs)) |
687 native_suffix = 'Getter' | 774 native_suffix = 'Getter' |
688 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) | 775 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) |
689 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, | 776 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, |
690 dart_declaration, native_suffix, is_custom, auto_scope_setup) | 777 dart_declaration, False, return_type, parameters, |
| 778 native_suffix, is_custom, auto_scope_setup) |
691 if is_custom: | 779 if is_custom: |
692 return | 780 return |
693 | 781 |
694 if 'Reflect' in attr.ext_attrs: | 782 if 'Reflect' in attr.ext_attrs: |
695 webcore_function_name = self._TypeInfo(attr.type.id).webcore_getter_name() | 783 webcore_function_name = self._TypeInfo(attr.type.id).webcore_getter_name() |
696 if 'URL' in attr.ext_attrs: | 784 if 'URL' in attr.ext_attrs: |
697 if 'NonEmpty' in attr.ext_attrs: | 785 if 'NonEmpty' in attr.ext_attrs: |
698 webcore_function_name = 'getNonEmptyURLAttribute' | 786 webcore_function_name = 'getNonEmptyURLAttribute' |
699 else: | 787 else: |
700 webcore_function_name = 'getURLAttribute' | 788 webcore_function_name = 'getURLAttribute' |
(...skipping 18 matching lines...) Expand all Loading... |
719 function_expression, | 807 function_expression, |
720 attr, | 808 attr, |
721 [], | 809 [], |
722 attr.type.id, | 810 attr.type.id, |
723 attr.type.nullable, | 811 attr.type.nullable, |
724 raises, | 812 raises, |
725 auto_scope_setup) | 813 auto_scope_setup) |
726 | 814 |
727 def _AddSetter(self, attr, html_name): | 815 def _AddSetter(self, attr, html_name): |
728 type_info = self._TypeInfo(attr.type.id) | 816 type_info = self._TypeInfo(attr.type.id) |
729 dart_declaration = 'void set %s(%s value)' % (html_name, self._DartType(attr
.type.id)) | 817 return_type = 'void' |
| 818 parameters = ['value'] |
| 819 ptype = self._DartType(attr.type.id) |
| 820 dart_declaration = 'void set %s(%s value)' % (html_name, ptype) |
730 is_custom = ('Custom' in attr.ext_attrs and | 821 is_custom = ('Custom' in attr.ext_attrs and |
731 (attr.ext_attrs['Custom'] == None or | 822 (attr.ext_attrs['Custom'] == None or |
732 attr.ext_attrs['Custom'] == 'Setter')) | 823 attr.ext_attrs['Custom'] == 'Setter')) |
733 # This seems to have been replaced with Custom=Setter (see above), but | 824 # This seems to have been replaced with Custom=Setter (see above), but |
734 # check to be sure we don't see the old syntax | 825 # check to be sure we don't see the old syntax |
735 assert(not ('CustomSetter' in attr.ext_attrs)) | 826 assert(not ('CustomSetter' in attr.ext_attrs)) |
736 assert(not ('V8CustomSetter' in attr.ext_attrs)) | 827 assert(not ('V8CustomSetter' in attr.ext_attrs)) |
737 native_suffix = 'Setter' | 828 native_suffix = 'Setter' |
738 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) | 829 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) |
739 cpp_callback_name = self._GenerateNativeBinding(attr.id, 2, | 830 cpp_callback_name = self._GenerateNativeBinding(attr.id, 2, |
740 dart_declaration, native_suffix, is_custom, auto_scope_setup) | 831 dart_declaration, False, return_type, parameters, |
| 832 native_suffix, is_custom, auto_scope_setup) |
741 if is_custom: | 833 if is_custom: |
742 return | 834 return |
743 | 835 |
744 if 'Reflect' in attr.ext_attrs: | 836 if 'Reflect' in attr.ext_attrs: |
745 webcore_function_name = self._TypeInfo(attr.type.id).webcore_setter_name() | 837 webcore_function_name = self._TypeInfo(attr.type.id).webcore_setter_name() |
746 else: | 838 else: |
747 if 'ImplementedAs' in attr.ext_attrs: | 839 if 'ImplementedAs' in attr.ext_attrs: |
748 attr_name = attr.ext_attrs['ImplementedAs'] | 840 attr_name = attr.ext_attrs['ImplementedAs'] |
749 else: | 841 else: |
750 attr_name = attr.id | 842 attr_name = attr.id |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
786 # and | 878 # and |
787 # | 879 # |
788 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; } | 880 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; } |
789 # | 881 # |
790 dart_element_type = self._DartType(element_type) | 882 dart_element_type = self._DartType(element_type) |
791 if self._HasNativeIndexGetter(): | 883 if self._HasNativeIndexGetter(): |
792 self._EmitNativeIndexGetter(dart_element_type) | 884 self._EmitNativeIndexGetter(dart_element_type) |
793 elif self._HasExplicitIndexedGetter(): | 885 elif self._HasExplicitIndexedGetter(): |
794 self._EmitExplicitIndexedGetter(dart_element_type) | 886 self._EmitExplicitIndexedGetter(dart_element_type) |
795 else: | 887 else: |
796 self._members_emitter.Emit( | 888 if dart_use_blink: |
797 '\n' | 889 dart_native_name = \ |
798 ' $TYPE operator[](int index) {\n' | 890 DeriveNativeName(self._interface.id, "NativeIndexed", "Getter") |
799 ' if (index < 0 || index >= length)\n' | 891 # First emit a toplevel function to do the native call |
800 ' throw new RangeError.range(index, 0, length);\n' | 892 # Calls to this are emitted elsewhere, |
801 ' return _nativeIndexedGetter(index);\n' | 893 self._native_library_emitter.Emit( |
802 ' }\n' | 894 '\n' |
803 ' $TYPE _nativeIndexedGetter(int index) native "$(INTERFACE)_item_Cal
lback";\n', | 895 '$(DART_NATIVE_NAME)(mthis, index) ' |
804 TYPE=self.SecureOutputType(element_type), | 896 'native "$(INTERFACE)_item_Callback";\n', |
805 INTERFACE=self._interface.id) | 897 DART_NATIVE_NAME = dart_native_name, |
| 898 INTERFACE=self._interface.id) |
| 899 |
| 900 # Emit the method which calls the toplevel function, along with |
| 901 # the [] operator. |
| 902 self._members_emitter.Emit( |
| 903 '\n' |
| 904 ' $TYPE operator[](int index) {\n' |
| 905 ' if (index < 0 || index >= length)\n' |
| 906 ' throw new RangeError.range(index, 0, length);\n' |
| 907 ' return $(DART_NATIVE_NAME)(this, index);\n' |
| 908 ' }\n\n' |
| 909 ' $TYPE _nativeIndexedGetter(int index) =>' |
| 910 ' $(DART_NATIVE_NAME)(this, index);\n', |
| 911 DART_NATIVE_NAME=DeriveQualifiedName(self._native_library_name, |
| 912 dart_native_name), |
| 913 TYPE=self.SecureOutputType(element_type), |
| 914 INTERFACE=self._interface.id) |
| 915 else: |
| 916 # Emit the method which calls the toplevel function, along with |
| 917 # the [] operator. |
| 918 self._members_emitter.Emit( |
| 919 '\n' |
| 920 ' $TYPE operator[](int index) {\n' |
| 921 ' if (index < 0 || index >= length)\n' |
| 922 ' throw new RangeError.range(index, 0, length);\n' |
| 923 ' return _nativeIndexedGetter(index);\n' |
| 924 ' }\n' |
| 925 ' $TYPE _nativeIndexedGetter(int index)' |
| 926 ' native "$(INTERFACE)_item_Callback";\n', |
| 927 TYPE=self.SecureOutputType(element_type), |
| 928 INTERFACE=self._interface.id) |
806 | 929 |
807 if self._HasNativeIndexSetter(): | 930 if self._HasNativeIndexSetter(): |
808 self._EmitNativeIndexSetter(dart_element_type) | 931 self._EmitNativeIndexSetter(dart_element_type) |
809 else: | 932 else: |
810 self._members_emitter.Emit( | 933 self._members_emitter.Emit( |
811 '\n' | 934 '\n' |
812 ' void operator[]=(int index, $TYPE value) {\n' | 935 ' void operator[]=(int index, $TYPE value) {\n' |
813 ' throw new UnsupportedError("Cannot assign element of immutable Li
st.");\n' | 936 ' throw new UnsupportedError("Cannot assign element of immutable Li
st.");\n' |
814 ' }\n', | 937 ' }\n', |
815 TYPE=dart_element_type) | 938 TYPE=dart_element_type) |
(...skipping 12 matching lines...) Expand all Loading... |
828 | 951 |
829 if self._HasNativeIndexGetter(): | 952 if self._HasNativeIndexGetter(): |
830 self._EmitNativeIndexGetter(dart_element_type) | 953 self._EmitNativeIndexGetter(dart_element_type) |
831 if self._HasNativeIndexSetter(): | 954 if self._HasNativeIndexSetter(): |
832 self._EmitNativeIndexSetter(dart_element_type) | 955 self._EmitNativeIndexSetter(dart_element_type) |
833 | 956 |
834 def _HasNativeIndexGetter(self): | 957 def _HasNativeIndexGetter(self): |
835 return 'CustomIndexedGetter' in self._interface.ext_attrs | 958 return 'CustomIndexedGetter' in self._interface.ext_attrs |
836 | 959 |
837 def _EmitNativeIndexGetter(self, element_type): | 960 def _EmitNativeIndexGetter(self, element_type): |
838 dart_declaration = '%s operator[](int index)' % \ | 961 return_type = self.SecureOutputType(element_type, True) |
839 self.SecureOutputType(element_type, True) | 962 parameters = ['index'] |
840 self._GenerateNativeBinding('numericIndexGetter', 2, dart_declaration, | 963 dart_declaration = '%s operator[](int index)' % return_type |
841 'Callback', True, False) | 964 self._GenerateNativeBinding('numericIndexGetter', 2, |
| 965 dart_declaration, False, return_type, parameters, |
| 966 'Callback', True, False) |
842 | 967 |
843 def _HasExplicitIndexedGetter(self): | 968 def _HasExplicitIndexedGetter(self): |
844 return any(op.id == 'getItem' for op in self._interface.operations) | 969 return any(op.id == 'getItem' for op in self._interface.operations) |
845 | 970 |
846 def _EmitExplicitIndexedGetter(self, dart_element_type): | 971 def _EmitExplicitIndexedGetter(self, dart_element_type): |
847 if any(op.id == 'getItem' for op in self._interface.operations): | 972 if any(op.id == 'getItem' for op in self._interface.operations): |
848 indexed_getter = 'getItem' | 973 indexed_getter = 'getItem' |
849 | 974 |
850 self._members_emitter.Emit( | 975 self._members_emitter.Emit( |
851 '\n' | 976 '\n' |
852 ' $TYPE operator[](int index) {\n' | 977 ' $TYPE operator[](int index) {\n' |
853 ' if (index < 0 || index >= length)\n' | 978 ' if (index < 0 || index >= length)\n' |
854 ' throw new RangeError.range(index, 0, length);\n' | 979 ' throw new RangeError.range(index, 0, length);\n' |
855 ' return $INDEXED_GETTER(index);\n' | 980 ' return $INDEXED_GETTER(index);\n' |
856 ' }\n', | 981 ' }\n', |
857 TYPE=dart_element_type, | 982 TYPE=dart_element_type, |
858 INDEXED_GETTER=indexed_getter) | 983 INDEXED_GETTER=indexed_getter) |
859 | 984 |
860 def _HasNativeIndexSetter(self): | 985 def _HasNativeIndexSetter(self): |
861 return 'CustomIndexedSetter' in self._interface.ext_attrs | 986 return 'CustomIndexedSetter' in self._interface.ext_attrs |
862 | 987 |
863 def _EmitNativeIndexSetter(self, element_type): | 988 def _EmitNativeIndexSetter(self, element_type): |
864 dart_declaration = 'void operator[]=(int index, %s value)' % element_type | 989 return_type = 'void' |
865 self._GenerateNativeBinding('numericIndexSetter', 3, dart_declaration, | 990 formals = ', '.join(['int index', '%s value' % element_type]) |
866 'Callback', True, False) | 991 parameters = ['index', 'value'] |
| 992 dart_declaration = 'void operator[]=(%s)' % formals |
| 993 self._GenerateNativeBinding('numericIndexSetter', 3, |
| 994 dart_declaration, False, return_type, parameters, |
| 995 'Callback', True, False) |
867 | 996 |
868 def EmitOperation(self, info, html_name): | 997 def EmitOperation(self, info, html_name): |
869 """ | 998 """ |
870 Arguments: | 999 Arguments: |
871 info: An OperationInfo object. | 1000 info: An OperationInfo object. |
872 """ | 1001 """ |
873 | 1002 return_type = self.SecureOutputType(info.type_name, False, True) |
| 1003 formals = info.ParametersAsDeclaration(self._DartType) |
| 1004 parameters = info.ParametersAsListOfVariables() |
874 dart_declaration = '%s%s %s(%s)' % ( | 1005 dart_declaration = '%s%s %s(%s)' % ( |
875 'static ' if info.IsStatic() else '', | 1006 'static ' if info.IsStatic() else '', |
876 self.SecureOutputType(info.type_name, False, True), | 1007 return_type, |
877 html_name, | 1008 html_name, |
878 info.ParametersDeclaration(self._DartType)) | 1009 formals) |
879 | 1010 |
880 operation = info.operations[0] | 1011 operation = info.operations[0] |
881 is_custom = 'Custom' in operation.ext_attrs | 1012 is_custom = 'Custom' in operation.ext_attrs |
882 has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, ar
gument) for argument in operation.arguments) | 1013 has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, ar
gument) for argument in operation.arguments) |
883 needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_option
al_arguments) | 1014 needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_option
al_arguments) |
884 | 1015 |
885 if info.callback_args: | 1016 if info.callback_args: |
886 self._AddFutureifiedOperation(info, html_name) | 1017 self._AddFutureifiedOperation(info, html_name) |
887 elif not needs_dispatcher: | 1018 elif not needs_dispatcher: |
888 # Bind directly to native implementation | 1019 # Bind directly to native implementation |
889 argument_count = (0 if info.IsStatic() else 1) + len(info.param_infos) | 1020 argument_count = (0 if info.IsStatic() else 1) + len(info.param_infos) |
890 native_suffix = 'Callback' | 1021 native_suffix = 'Callback' |
891 auto_scope_setup = self._GenerateAutoSetupScope(info.name, native_suffix) | 1022 auto_scope_setup = self._GenerateAutoSetupScope(info.name, native_suffix) |
892 cpp_callback_name = self._GenerateNativeBinding( | 1023 cpp_callback_name = self._GenerateNativeBinding( |
893 info.name, argument_count, dart_declaration, native_suffix, is_custom, | 1024 info.name, argument_count, dart_declaration, |
894 auto_scope_setup) | 1025 info.IsStatic(), return_type, parameters, |
| 1026 native_suffix, is_custom, auto_scope_setup) |
895 if not is_custom: | 1027 if not is_custom: |
896 self._GenerateOperationNativeCallback(operation, operation.arguments, cp
p_callback_name, auto_scope_setup) | 1028 self._GenerateOperationNativeCallback(operation, operation.arguments, cp
p_callback_name, auto_scope_setup) |
897 else: | 1029 else: |
898 self._GenerateDispatcher(info, info.operations, dart_declaration) | 1030 self._GenerateDispatcher(info, info.operations, dart_declaration) |
899 | 1031 |
900 def _GenerateDispatcher(self, info, operations, dart_declaration): | 1032 def _GenerateDispatcher(self, info, operations, dart_declaration): |
901 | 1033 |
902 def GenerateCall( | 1034 def GenerateCall( |
903 stmts_emitter, call_emitter, version, operation, argument_count): | 1035 stmts_emitter, call_emitter, version, operation, argument_count): |
904 overload_name = '_%s_%s' % (operation.id, version) | 1036 overload_name = '_%s_%s' % (operation.id, version) |
905 argument_list = ', '.join( | 1037 return_type = self.SecureOutputType(operation.type.id) |
906 [p.name for p in info.param_infos[:argument_count]]) | 1038 actuals = info.ParametersAsListOfVariables(argument_count) |
907 call_emitter.Emit('$NAME($ARGS)', NAME=overload_name, ARGS=argument_list) | 1039 actuals_s = ", ".join(actuals) |
908 | 1040 call_emitter.Emit('$NAME($ARGS)', NAME=overload_name, ARGS=actuals_s) |
909 dart_declaration = '%s%s %s(%s)' % ( | 1041 dart_declaration = '%s%s %s(%s)' % ( |
910 'static ' if operation.is_static else '', | 1042 'static ' if operation.is_static else '', |
911 self.SecureOutputType(operation.type.id), | 1043 return_type, |
912 overload_name, argument_list) | 1044 overload_name, actuals_s) |
913 is_custom = 'Custom' in operation.ext_attrs | 1045 is_custom = 'Custom' in operation.ext_attrs |
914 native_suffix = 'Callback' | 1046 native_suffix = 'Callback' |
915 auto_scope_setup = self._GenerateAutoSetupScope(overload_name, native_suff
ix) | 1047 auto_scope_setup = \ |
| 1048 self._GenerateAutoSetupScope(overload_name, native_suffix) |
916 cpp_callback_name = self._GenerateNativeBinding( | 1049 cpp_callback_name = self._GenerateNativeBinding( |
917 overload_name, (0 if operation.is_static else 1) + argument_count, | 1050 overload_name, (0 if operation.is_static else 1) + argument_count, |
918 dart_declaration, 'Callback', is_custom, auto_scope_setup, | 1051 dart_declaration, operation.is_static, return_type, actuals, |
919 emit_metadata=False) | 1052 'Callback', is_custom, auto_scope_setup, emit_metadata=False) |
920 if not is_custom: | 1053 if not is_custom: |
921 self._GenerateOperationNativeCallback(operation, operation.arguments[:ar
gument_count], cpp_callback_name, auto_scope_setup) | 1054 self._GenerateOperationNativeCallback(operation, |
| 1055 operation.arguments[:argument_count], cpp_callback_name, |
| 1056 auto_scope_setup) |
922 | 1057 |
923 self._GenerateDispatcherBody( | 1058 self._GenerateDispatcherBody( |
924 info, | 1059 info, |
925 operations, | 1060 operations, |
926 dart_declaration, | 1061 dart_declaration, |
927 GenerateCall, | 1062 GenerateCall, |
928 self._IsArgumentOptionalInWebCore) | 1063 self._IsArgumentOptionalInWebCore) |
929 | 1064 |
930 def SecondaryContext(self, interface): | 1065 def SecondaryContext(self, interface): |
931 pass | 1066 pass |
(...skipping 26 matching lines...) Expand all Loading... |
958 auto_scope_setup=True, | 1093 auto_scope_setup=True, |
959 generate_custom_element_scope_if_needed=False): | 1094 generate_custom_element_scope_if_needed=False): |
960 | 1095 |
961 ext_attrs = node.ext_attrs | 1096 ext_attrs = node.ext_attrs |
962 | 1097 |
963 if self._IsStatic(node.id): | 1098 if self._IsStatic(node.id): |
964 needs_receiver = True | 1099 needs_receiver = True |
965 | 1100 |
966 cpp_arguments = [] | 1101 cpp_arguments = [] |
967 runtime_check = None | 1102 runtime_check = None |
968 raises_exceptions = raises_dom_exception or arguments | 1103 raises_exceptions = raises_dom_exception or arguments or needs_receiver |
969 needs_custom_element_callbacks = False | 1104 needs_custom_element_callbacks = False |
970 | 1105 |
971 # TODO(antonm): unify with ScriptState below. | 1106 # TODO(antonm): unify with ScriptState below. |
972 requires_stack_info = (ext_attrs.get('CallWith') == 'ScriptArguments|ScriptS
tate' or | 1107 requires_stack_info = (ext_attrs.get('CallWith') == 'ScriptArguments|ScriptS
tate' or |
973 ext_attrs.get('ConstructorCallWith') == 'ScriptArgume
nts|ScriptState' or | 1108 ext_attrs.get('ConstructorCallWith') == 'ScriptArgume
nts|ScriptState' or |
974 ext_attrs.get('CallWith') == 'ScriptArguments&ScriptS
tate' or | 1109 ext_attrs.get('CallWith') == 'ScriptArguments&ScriptS
tate' or |
975 ext_attrs.get('ConstructorCallWith') == 'ScriptArgume
nts&ScriptState') | 1110 ext_attrs.get('ConstructorCallWith') == 'ScriptArgume
nts&ScriptState') |
976 if requires_stack_info: | 1111 if requires_stack_info: |
977 raises_exceptions = True | 1112 raises_exceptions = True |
978 cpp_arguments = ['&state', 'scriptArguments.release()'] | 1113 cpp_arguments = ['&state', 'scriptArguments.release()'] |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 | 1243 |
1109 body_emitter.Emit( | 1244 body_emitter.Emit( |
1110 ' DOMWindow* domWindow = DartUtilities::domWindowForCurrentIsol
ate();\n' | 1245 ' DOMWindow* domWindow = DartUtilities::domWindowForCurrentIsol
ate();\n' |
1111 ' if (!domWindow) {\n' | 1246 ' if (!domWindow) {\n' |
1112 ' exception = Dart_NewStringFromCString("Failed to fetch do
mWindow");\n' | 1247 ' exception = Dart_NewStringFromCString("Failed to fetch do
mWindow");\n' |
1113 ' goto fail;\n' | 1248 ' goto fail;\n' |
1114 ' }\n' | 1249 ' }\n' |
1115 ' Document& document = *domWindow->document();\n') | 1250 ' Document& document = *domWindow->document();\n') |
1116 | 1251 |
1117 if needs_receiver: | 1252 if needs_receiver: |
1118 body_emitter.Emit( | 1253 if dart_use_blink: |
1119 ' $WEBCORE_CLASS_NAME* receiver = DartDOMWrapper::receiver< $WE
BCORE_CLASS_NAME >(args);\n', | 1254 body_emitter.Emit( |
1120 WEBCORE_CLASS_NAME=self._interface_type_info.native_type()) | 1255 ' $WEBCORE_CLASS_NAME* receiver = ' |
| 1256 'DartDOMWrapper::receiverChecked<Dart$INTERFACE>(args, exception);\n
' |
| 1257 ' if (exception)\n' |
| 1258 ' goto fail;\n', |
| 1259 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(), |
| 1260 INTERFACE=self._interface.id) |
| 1261 else: |
| 1262 body_emitter.Emit( |
| 1263 ' $WEBCORE_CLASS_NAME* receiver = ' |
| 1264 'DartDOMWrapper::receiver< $WEBCORE_CLASS_NAME >(args);\n' |
| 1265 ' if (exception)\n' |
| 1266 ' goto fail;\n', |
| 1267 WEBCORE_CLASS_NAME=self._interface_type_info.native_type()) |
1121 | 1268 |
1122 if requires_stack_info: | 1269 if requires_stack_info: |
1123 self._cpp_impl_includes.add('"ScriptArguments.h"') | 1270 self._cpp_impl_includes.add('"ScriptArguments.h"') |
1124 body_emitter.Emit( | 1271 body_emitter.Emit( |
1125 '\n' | 1272 '\n' |
1126 ' ScriptState* currentState = DartUtilities::currentScriptState
();\n' | 1273 ' ScriptState* currentState = DartUtilities::currentScriptState
();\n' |
1127 ' if (!currentState) {\n' | 1274 ' if (!currentState) {\n' |
1128 ' exception = Dart_NewStringFromCString("Failed to retrieve
a script state");\n' | 1275 ' exception = Dart_NewStringFromCString("Failed to retrieve
a script state");\n' |
1129 ' goto fail;\n' | 1276 ' goto fail;\n' |
1130 ' }\n' | 1277 ' }\n' |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1299 value_expression, | 1446 value_expression, |
1300 auto_scope_setup, | 1447 auto_scope_setup, |
1301 self._interface.id, | 1448 self._interface.id, |
1302 ext_attrs) | 1449 ext_attrs) |
1303 set_return_value = '%s' % (return_to_dart_conversion) | 1450 set_return_value = '%s' % (return_to_dart_conversion) |
1304 invocation_emitter.Emit( | 1451 invocation_emitter.Emit( |
1305 ' $RETURN_VALUE;\n', | 1452 ' $RETURN_VALUE;\n', |
1306 RETURN_VALUE=set_return_value) | 1453 RETURN_VALUE=set_return_value) |
1307 | 1454 |
1308 def _GenerateNativeBinding(self, idl_name, argument_count, dart_declaration, | 1455 def _GenerateNativeBinding(self, idl_name, argument_count, dart_declaration, |
1309 native_suffix, is_custom, auto_scope_setup=True, emit_metadata=True): | 1456 static, return_type, parameters, native_suffix, is_custom, |
1310 | 1457 auto_scope_setup=True, emit_metadata=True): |
1311 metadata = [] | 1458 metadata = [] |
1312 if emit_metadata: | 1459 if emit_metadata: |
1313 metadata = self._metadata.GetFormattedMetadata( | 1460 metadata = self._metadata.GetFormattedMetadata( |
1314 self._renamer.GetLibraryName(self._interface), | 1461 self._renamer.GetLibraryName(self._interface), |
1315 self._interface, idl_name, ' ') | 1462 self._interface, idl_name, ' ') |
| 1463 dart_native_name = \ |
| 1464 DeriveNativeName(self._interface.id, idl_name, native_suffix) |
| 1465 native_binding = '%s_%s_%s' % (self._interface.id, idl_name, native_suffix) |
| 1466 if dart_use_blink: |
| 1467 if not static: |
| 1468 formals = ", ".join(['mthis'] + parameters) |
| 1469 actuals = ", ".join(['this'] + parameters) |
| 1470 else: |
| 1471 formals = ", ".join(parameters) |
| 1472 actuals = ", ".join(parameters) |
1316 | 1473 |
1317 native_binding = '%s_%s_%s' % (self._interface.id, idl_name, native_suffix) | 1474 self._native_library_emitter.Emit( |
1318 self._members_emitter.Emit( | 1475 '\n' |
1319 '\n' | 1476 '$DART_NAME($FORMALS) native "$NATIVE_BINDING";\n', |
1320 ' $METADATA$DART_DECLARATION native "$NATIVE_BINDING";\n', | 1477 DART_NAME=dart_native_name, |
1321 DOMINTERFACE=self._interface.id, | 1478 FORMALS=formals, |
1322 METADATA=metadata, | 1479 NATIVE_BINDING=native_binding) |
1323 DART_DECLARATION=dart_declaration, | |
1324 NATIVE_BINDING=native_binding) | |
1325 | 1480 |
| 1481 # We then emit a class method which calls out to the mangled toplevel |
| 1482 # function. Eventually this will be replaced with a call to an |
| 1483 # interceptor |
| 1484 self._members_emitter.Emit( |
| 1485 '\n' |
| 1486 ' $METADATA$DART_DECLARATION => $DART_NAME($ACTUALS);\n', |
| 1487 METADATA=metadata, |
| 1488 DART_DECLARATION=dart_declaration, |
| 1489 DART_NAME=DeriveQualifiedName(self._native_library_name, |
| 1490 dart_native_name), |
| 1491 ACTUALS=actuals) |
| 1492 else: |
| 1493 self._members_emitter.Emit( |
| 1494 '\n' |
| 1495 ' $METADATA$DART_DECLARATION native "$NATIVE_BINDING";\n', |
| 1496 METADATA=metadata, |
| 1497 DART_DECLARATION=dart_declaration, |
| 1498 NATIVE_BINDING=native_binding) |
1326 cpp_callback_name = '%s%s' % (idl_name, native_suffix) | 1499 cpp_callback_name = '%s%s' % (idl_name, native_suffix) |
1327 | 1500 |
1328 self._cpp_resolver_emitter.Emit( | 1501 self._cpp_resolver_emitter.Emit( |
1329 ' if (argumentCount == $ARGC && name == "$NATIVE_BINDING") {\n' | 1502 ' if (argumentCount == $ARGC && name == "$NATIVE_BINDING") {\n' |
1330 ' *autoSetupScope = $AUTO_SCOPE_SETUP;\n' | 1503 ' *autoSetupScope = $AUTO_SCOPE_SETUP;\n' |
1331 ' return Dart$(INTERFACE_NAME)Internal::$CPP_CALLBACK_NAME;\n' | 1504 ' return Dart$(INTERFACE_NAME)Internal::$CPP_CALLBACK_NAME;\n' |
1332 ' }\n', | 1505 ' }\n', |
1333 ARGC=argument_count, | 1506 ARGC=argument_count, |
1334 NATIVE_BINDING=native_binding, | 1507 NATIVE_BINDING=native_binding, |
1335 INTERFACE_NAME=self._interface.id, | 1508 INTERFACE_NAME=self._interface.id, |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1584 e.Emit("};\n"); | 1757 e.Emit("};\n"); |
1585 e.Emit('\n'); | 1758 e.Emit('\n'); |
1586 e.Emit('} // namespace WebCore\n'); | 1759 e.Emit('} // namespace WebCore\n'); |
1587 | 1760 |
1588 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1761 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
1589 return ( | 1762 return ( |
1590 interface.id.endswith('Event') and | 1763 interface.id.endswith('Event') and |
1591 operation.id.startswith('init') and | 1764 operation.id.startswith('init') and |
1592 argument.ext_attrs.get('Default') == 'Undefined' and | 1765 argument.ext_attrs.get('Default') == 'Undefined' and |
1593 argument.type.id == 'DOMString') | 1766 argument.type.id == 'DOMString') |
OLD | NEW |