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 _single_blink = True | |
vsm
2014/04/24 23:16:58
Can you add a comment here to indicate that this s
Leaf
2014/04/25 00:38:04
Done.
| |
175 dart_use_blink = False | |
176 | |
174 def _GetCPPPartialNames(interface): | 177 def _GetCPPPartialNames(interface): |
175 interface_name = interface.ext_attrs.get('ImplementedAs', interface.id) | 178 interface_name = interface.ext_attrs.get('ImplementedAs', interface.id) |
176 if not _cpp_partial_map: | 179 if not _cpp_partial_map: |
177 for (type, member) in _cpp_callback_map.keys(): | 180 for (type, member) in _cpp_callback_map.keys(): |
178 if type not in _cpp_partial_map: | 181 if type not in _cpp_partial_map: |
179 _cpp_partial_map[type] = set([]) | 182 _cpp_partial_map[type] = set([]) |
180 | 183 |
181 name_with_path = _cpp_callback_map[(type, member)] | 184 name_with_path = _cpp_callback_map[(type, member)] |
182 if name_with_path in _cpp_import_map: | 185 if name_with_path in _cpp_import_map: |
183 name_with_path = _cpp_import_map[name_with_path] | 186 name_with_path = _cpp_import_map[name_with_path] |
(...skipping 21 matching lines...) Expand all Loading... | |
205 | 208 |
206 cpp_tuple = (interface_name, callback_name) | 209 cpp_tuple = (interface_name, callback_name) |
207 if cpp_tuple in _cpp_callback_map: | 210 if cpp_tuple in _cpp_callback_map: |
208 cpp_type_name = _cpp_callback_map[cpp_tuple] | 211 cpp_type_name = _cpp_callback_map[cpp_tuple] |
209 elif (interface_name, cpp_name) in _cpp_overloaded_callback_map: | 212 elif (interface_name, cpp_name) in _cpp_overloaded_callback_map: |
210 cpp_type_name = _cpp_overloaded_callback_map[(interface_name, cpp_name)] | 213 cpp_type_name = _cpp_overloaded_callback_map[(interface_name, cpp_name)] |
211 else: | 214 else: |
212 cpp_type_name = interface_name | 215 cpp_type_name = interface_name |
213 return cpp_type_name | 216 return cpp_type_name |
214 | 217 |
218 def DeriveNativeLibraryName(library_name): | |
219 if _single_blink: | |
vsm
2014/04/24 23:16:58
Is this ever false now? If not, perhaps remove no
Leaf
2014/04/25 00:38:04
Done.
| |
220 return "blink" | |
221 else: | |
222 return "blink_" + library_name | |
223 | |
224 def DeriveNativeLibraryNames(): | |
225 if _single_blink: | |
226 return ["blink"] | |
227 else: | |
228 return [DeriveNativeLibraryName(l) for l in HTML_LIBRARY_NAMES] | |
229 | |
230 def DeriveQualifiedName(library_name, name): | |
231 return library_name + "." + name | |
232 | |
233 def DeriveNativeName(interface_name, name, suffix): | |
234 fields = ["Native", interface_name, name] | |
235 if suffix != "": | |
236 fields.append(suffix) | |
237 return "_".join(fields) | |
238 | |
239 def GetNativeLibraryEmitter(emitters, template_loader, | |
240 dartium_output_dir, dart_output_dir, | |
241 auxiliary_dir): | |
242 if _single_blink: | |
243 def massage_path(path): | |
244 # The most robust way to emit path separators is to use / always. | |
245 return path.replace('\\', '/') | |
246 template = template_loader.Load('blink_dartium.darttemplate') | |
247 dart_path = os.path.join(dartium_output_dir, 'blink_dartium.dart') | |
248 library_emitter = emitters.FileEmitter(dart_path) | |
249 auxiliary_dir = os.path.relpath(auxiliary_dir, dartium_output_dir) | |
250 emitter = \ | |
251 library_emitter.Emit(template, | |
252 AUXILIARY_DIR=massage_path(auxiliary_dir)) | |
253 return emitter | |
254 else: | |
255 blink_library_names = DeriveNativeLibraryNames() | |
256 blink_libraries = DartLibraries( | |
257 blink_library_names, template_loader, 'dartium', dartium_output_dir) | |
258 native_library_emitter = DartLibraryEmitter( | |
259 emitters, dart_output_dir, blink_libraries) | |
260 return native_library_emitter | |
261 | |
262 def EmitNativeLibrary(native_library_emitter, auxiliary_dir): | |
263 if not _single_blink: | |
264 native_library_emitter.EmitLibraries(auxiliary_dir) | |
265 | |
215 class DartiumBackend(HtmlDartGenerator): | 266 class DartiumBackend(HtmlDartGenerator): |
216 """Generates Dart implementation for one DOM IDL interface.""" | 267 """Generates Dart implementation for one DOM IDL interface.""" |
217 | 268 |
218 def __init__(self, interface, cpp_library_emitter, options): | 269 def __init__(self, interface, native_library_emitter, |
270 cpp_library_emitter, options): | |
219 super(DartiumBackend, self).__init__(interface, options) | 271 super(DartiumBackend, self).__init__(interface, options) |
220 | 272 |
221 self._interface = interface | 273 self._interface = interface |
222 self._cpp_library_emitter = cpp_library_emitter | 274 self._cpp_library_emitter = cpp_library_emitter |
275 self._native_library_emitter = native_library_emitter | |
223 self._database = options.database | 276 self._database = options.database |
224 self._template_loader = options.templates | 277 self._template_loader = options.templates |
225 self._type_registry = options.type_registry | 278 self._type_registry = options.type_registry |
226 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) | 279 self._interface_type_info = self._type_registry.TypeInfo(self._interface.id) |
227 self._metadata = options.metadata | 280 self._metadata = options.metadata |
281 self._native_library_name = DeriveNativeLibraryName(self._library_name) | |
282 # These get initialized by StartInterface | |
283 self._cpp_header_emitter = None | |
284 self._cpp_impl_emitter = None | |
285 self._members_emitter = None | |
286 self._cpp_declarations_emitter = None | |
287 self._cpp_impl_includes = None | |
288 self._cpp_definitions_emitter = None | |
289 self._cpp_resolver_emitter = None | |
228 | 290 |
229 def ImplementsMergedMembers(self): | 291 def ImplementsMergedMembers(self): |
230 # We could not add merged functions to implementation class because | 292 # We could not add merged functions to implementation class because |
231 # underlying c++ object doesn't implement them. Merged functions are | 293 # underlying c++ object doesn't implement them. Merged functions are |
232 # generated on merged interface implementation instead. | 294 # generated on merged interface implementation instead. |
233 return False | 295 return False |
234 | 296 |
235 def CustomJSMembers(self): | 297 def CustomJSMembers(self): |
236 return {} | 298 return {} |
237 | 299 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 def ImplementationTemplate(self): | 408 def ImplementationTemplate(self): |
347 template = None | 409 template = None |
348 interface_name = self._interface.doc_js_name | 410 interface_name = self._interface.doc_js_name |
349 if interface_name == self._interface.id or not self._database.HasInterface(i nterface_name): | 411 if interface_name == self._interface.id or not self._database.HasInterface(i nterface_name): |
350 template_file = 'impl_%s.darttemplate' % interface_name | 412 template_file = 'impl_%s.darttemplate' % interface_name |
351 template = self._template_loader.TryLoad(template_file) | 413 template = self._template_loader.TryLoad(template_file) |
352 if not template: | 414 if not template: |
353 template = self._template_loader.Load('dart_implementation.darttemplate') | 415 template = self._template_loader.Load('dart_implementation.darttemplate') |
354 return template | 416 return template |
355 | 417 |
418 def _NativeImplementationTemplate(self): | |
419 template = None | |
420 interface_name = self._interface.doc_js_name | |
421 if (interface_name == self._interface.id or | |
422 not self._database.HasInterface(interface_name)): | |
423 template_file = 'impl_blink_%s.darttemplate' % interface_name | |
424 template = self._template_loader.TryLoad(template_file) | |
425 if not template: | |
426 template = \ | |
427 self._template_loader.Load('dart_blink_implementation.darttemplate') | |
428 return template | |
429 | |
356 def RootClassName(self): | 430 def RootClassName(self): |
357 return 'NativeFieldWrapperClass2' | 431 return 'NativeFieldWrapperClass2' |
358 | 432 |
359 def NativeSpec(self): | 433 def NativeSpec(self): |
360 return '' | 434 return '' |
361 | 435 |
362 def StartInterface(self, members_emitter): | 436 def _NativeInterfaceEmitter(self): |
437 basename = self._interface_type_info.implementation_name() | |
438 emitter = \ | |
439 self._native_library_emitter.FileEmitter(basename, | |
440 self._native_library_name) | |
441 return emitter.Emit(self._NativeImplementationTemplate(), | |
442 LIBRARYNAME='dart.dom.%s' % self._native_library_name) | |
443 | |
444 def StartInterface(self, members_emitter, toplevel_emitter): | |
363 # Create emitters for c++ implementation. | 445 # Create emitters for c++ implementation. |
364 if not IsPureInterface(self._interface.id) and not IsCustomType(self._interf ace.id): | 446 if not IsPureInterface(self._interface.id) and \ |
447 not IsCustomType(self._interface.id): | |
365 self._cpp_header_emitter = self._cpp_library_emitter.CreateHeaderEmitter( | 448 self._cpp_header_emitter = self._cpp_library_emitter.CreateHeaderEmitter( |
366 self._interface.id, | 449 self._interface.id, |
367 self._renamer.GetLibraryName(self._interface)) | 450 self._renamer.GetLibraryName(self._interface)) |
368 self._cpp_impl_emitter = self._cpp_library_emitter.CreateSourceEmitter(sel f._interface.id) | 451 self._cpp_impl_emitter = \ |
452 self._cpp_library_emitter.CreateSourceEmitter(self._interface.id) | |
369 else: | 453 else: |
370 self._cpp_header_emitter = emitter.Emitter() | 454 self._cpp_header_emitter = emitter.Emitter() |
371 self._cpp_impl_emitter = emitter.Emitter() | 455 self._cpp_impl_emitter = emitter.Emitter() |
372 | 456 |
373 self._interface_type_info = self._TypeInfo(self._interface.id) | 457 self._interface_type_info = self._TypeInfo(self._interface.id) |
374 self._members_emitter = members_emitter | 458 self._members_emitter = members_emitter |
459 if _single_blink: | |
460 self._native_interface_emitter = self._native_library_emitter | |
461 else: | |
462 self._native_interface_emitter = self._NativeInterfaceEmitter() | |
463 | |
375 self._cpp_declarations_emitter = emitter.Emitter() | 464 self._cpp_declarations_emitter = emitter.Emitter() |
376 | 465 |
377 self._cpp_impl_includes = set(['"' + partial + '.h"' | 466 self._cpp_impl_includes = \ |
378 for partial in _GetCPPPartialNames(self._inte rface)]) | 467 set(['"' + partial + '.h"' |
468 for partial in _GetCPPPartialNames(self._interface)]) | |
379 | 469 |
380 # This is a hack to work around a strange C++ compile error that we weren't | 470 # 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. | 471 # able to track down the true cause of. |
382 if self._interface.id == 'Timing': | 472 if self._interface.id == 'Timing': |
383 self._cpp_impl_includes.add('"core/animation/TimedItem.h"') | 473 self._cpp_impl_includes.add('"core/animation/TimedItem.h"') |
384 | 474 |
385 self._cpp_definitions_emitter = emitter.Emitter() | 475 self._cpp_definitions_emitter = emitter.Emitter() |
386 self._cpp_resolver_emitter = emitter.Emitter() | 476 self._cpp_resolver_emitter = emitter.Emitter() |
387 | 477 |
388 # We need to revisit our treatment of typed arrays, right now | 478 # We need to revisit our treatment of typed arrays, right now |
(...skipping 13 matching lines...) Expand all Loading... | |
402 '}\n', | 492 '}\n', |
403 INTERFACE_NAME=self._interface.id); | 493 INTERFACE_NAME=self._interface.id); |
404 | 494 |
405 def _EmitConstructorInfrastructure(self, | 495 def _EmitConstructorInfrastructure(self, |
406 constructor_info, constructor_callback_cpp_name, factory_method_name, | 496 constructor_info, constructor_callback_cpp_name, factory_method_name, |
407 argument_count=None): | 497 argument_count=None): |
408 constructor_callback_id = self._interface.id + '_' + constructor_callback_cp p_name | 498 constructor_callback_id = self._interface.id + '_' + constructor_callback_cp p_name |
409 if argument_count is None: | 499 if argument_count is None: |
410 argument_count = len(constructor_info.param_infos) | 500 argument_count = len(constructor_info.param_infos) |
411 | 501 |
412 self._members_emitter.Emit( | 502 typed_formals = constructor_info.ParametersAsArgumentList(argument_count) |
413 '\n @DocsEditable()\n' | 503 parameters = constructor_info.ParametersAsStringOfVariables(argument_count) |
414 ' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) ' | 504 interface_name = self._interface_type_info.interface_name() |
505 | |
506 if dart_use_blink: | |
507 # First we emit the toplevel function | |
508 dart_native_name = \ | |
509 DeriveNativeName(self._interface.id, constructor_callback_cpp_name, "") | |
510 self._native_interface_emitter.Emit( | |
511 '\n' | |
512 '$FACTORY_METHOD_NAME($PARAMETERS) native "$ID";\n', | |
513 FACTORY_METHOD_NAME=dart_native_name, | |
514 PARAMETERS=parameters, | |
515 ID=constructor_callback_id) | |
516 | |
517 # Then we emit the impedance matching wrapper to call out to the | |
518 # toplevel wrapper | |
519 self._members_emitter.Emit( | |
520 '\n @DocsEditable()\n' | |
521 ' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) => ' | |
522 '$TOPLEVEL_NAME($OUTPARAMETERS);\n', | |
523 INTERFACE_NAME=self._interface_type_info.interface_name(), | |
524 FACTORY_METHOD_NAME=factory_method_name, | |
525 PARAMETERS=typed_formals, | |
526 TOPLEVEL_NAME=DeriveQualifiedName(self._native_library_name, | |
527 dart_native_name), | |
528 OUTPARAMETERS=parameters) | |
529 else: | |
530 self._members_emitter.Emit( | |
531 '\n @DocsEditable()\n' | |
532 ' static $INTERFACE_NAME $FACTORY_METHOD_NAME($PARAMETERS) ' | |
415 'native "$ID";\n', | 533 'native "$ID";\n', |
416 INTERFACE_NAME=self._interface_type_info.interface_name(), | 534 INTERFACE_NAME=self._interface_type_info.interface_name(), |
417 FACTORY_METHOD_NAME=factory_method_name, | 535 FACTORY_METHOD_NAME=factory_method_name, |
418 # TODO: add types to parameters. | 536 PARAMETERS=typed_formals, |
419 PARAMETERS=constructor_info.ParametersAsArgumentList(argument_count), | 537 ID=constructor_callback_id) |
420 ID=constructor_callback_id) | |
421 | 538 |
422 self._cpp_resolver_emitter.Emit( | 539 self._cpp_resolver_emitter.Emit( |
423 ' if (name == "$ID")\n' | 540 ' if (name == "$ID")\n' |
424 ' return Dart$(WEBKIT_INTERFACE_NAME)Internal::$CPP_CALLBACK;\n', | 541 ' return Dart$(WEBKIT_INTERFACE_NAME)Internal::$CPP_CALLBACK;\n', |
425 ID=constructor_callback_id, | 542 ID=constructor_callback_id, |
426 WEBKIT_INTERFACE_NAME=self._interface.id, | 543 WEBKIT_INTERFACE_NAME=self._interface.id, |
427 CPP_CALLBACK=constructor_callback_cpp_name) | 544 CPP_CALLBACK=constructor_callback_cpp_name) |
428 | 545 |
429 def GenerateCustomFactory(self, constructor_info): | 546 def GenerateCustomFactory(self, constructor_info): |
430 if 'CustomConstructor' not in self._interface.ext_attrs: | 547 if 'CustomConstructor' not in self._interface.ext_attrs: |
431 return False | 548 return False |
432 | 549 |
433 annotations = self._metadata.GetFormattedMetadata(self._library_name, | 550 annotations = self._metadata.GetFormattedMetadata(self._library_name, |
434 self._interface, self._interface.id, ' ') | 551 self._interface, self._interface.id, ' ') |
435 | 552 |
436 self._members_emitter.Emit( | 553 self._members_emitter.Emit( |
437 '\n $(ANNOTATIONS)factory $CTOR($PARAMS) => _create($FACTORY_PARAMS);\n ', | 554 '\n $(ANNOTATIONS)factory $CTOR($PARAMS) => _create($FACTORY_PARAMS);\n ', |
438 ANNOTATIONS=annotations, | 555 ANNOTATIONS=annotations, |
439 CTOR=constructor_info._ConstructorFullName(self._DartType), | 556 CTOR=constructor_info._ConstructorFullName(self._DartType), |
440 PARAMS=constructor_info.ParametersDeclaration(self._DartType), | 557 PARAMS=constructor_info.ParametersAsDeclaration(self._DartType), |
441 FACTORY_PARAMS= \ | 558 FACTORY_PARAMS= \ |
442 constructor_info.ParametersAsArgumentList()) | 559 constructor_info.ParametersAsArgumentList()) |
443 | 560 |
444 constructor_callback_cpp_name = 'constructorCallback' | 561 constructor_callback_cpp_name = 'constructorCallback' |
445 self._EmitConstructorInfrastructure( | 562 self._EmitConstructorInfrastructure( |
446 constructor_info, constructor_callback_cpp_name, '_create') | 563 constructor_info, constructor_callback_cpp_name, '_create') |
447 | 564 |
448 self._cpp_declarations_emitter.Emit( | 565 self._cpp_declarations_emitter.Emit( |
449 '\n' | 566 '\n' |
450 'void $CPP_CALLBACK(Dart_NativeArguments);\n', | 567 'void $CPP_CALLBACK(Dart_NativeArguments);\n', |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
669 | 786 |
670 def _GenerateAutoSetupScope(self, idl_name, native_suffix): | 787 def _GenerateAutoSetupScope(self, idl_name, native_suffix): |
671 return (self._interface.id, idl_name, native_suffix) not in _cpp_no_auto_sco pe_list | 788 return (self._interface.id, idl_name, native_suffix) not in _cpp_no_auto_sco pe_list |
672 | 789 |
673 def _AddGetter(self, attr, html_name, read_only): | 790 def _AddGetter(self, attr, html_name, read_only): |
674 # Temporary hack to force dart:scalarlist clamped array for ImageData.data. | 791 # Temporary hack to force dart:scalarlist clamped array for ImageData.data. |
675 # TODO(antonm): solve in principled way. | 792 # TODO(antonm): solve in principled way. |
676 if self._interface.id == 'ImageData' and html_name == 'data': | 793 if self._interface.id == 'ImageData' and html_name == 'data': |
677 html_name = '_data' | 794 html_name = '_data' |
678 type_info = self._TypeInfo(attr.type.id) | 795 type_info = self._TypeInfo(attr.type.id) |
679 dart_declaration = '%s get %s' % ( | 796 return_type = self.SecureOutputType(attr.type.id, False, read_only) |
680 self.SecureOutputType(attr.type.id, False, read_only), html_name) | 797 parameters = [] |
798 dart_declaration = '%s get %s' % (return_type, html_name) | |
681 is_custom = ('Custom' in attr.ext_attrs and | 799 is_custom = ('Custom' in attr.ext_attrs and |
682 (attr.ext_attrs['Custom'] == None or | 800 (attr.ext_attrs['Custom'] == None or |
683 attr.ext_attrs['Custom'] == 'Getter')) | 801 attr.ext_attrs['Custom'] == 'Getter')) |
684 # This seems to have been replaced with Custom=Getter (see above), but | 802 # This seems to have been replaced with Custom=Getter (see above), but |
685 # check to be sure we don't see the old syntax | 803 # check to be sure we don't see the old syntax |
686 assert(not ('CustomGetter' in attr.ext_attrs)) | 804 assert(not ('CustomGetter' in attr.ext_attrs)) |
687 native_suffix = 'Getter' | 805 native_suffix = 'Getter' |
688 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) | 806 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) |
689 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, | 807 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, |
690 dart_declaration, native_suffix, is_custom, auto_scope_setup) | 808 dart_declaration, False, return_type, parameters, |
809 native_suffix, is_custom, auto_scope_setup) | |
691 if is_custom: | 810 if is_custom: |
692 return | 811 return |
693 | 812 |
694 if 'Reflect' in attr.ext_attrs: | 813 if 'Reflect' in attr.ext_attrs: |
695 webcore_function_name = self._TypeInfo(attr.type.id).webcore_getter_name() | 814 webcore_function_name = self._TypeInfo(attr.type.id).webcore_getter_name() |
696 if 'URL' in attr.ext_attrs: | 815 if 'URL' in attr.ext_attrs: |
697 if 'NonEmpty' in attr.ext_attrs: | 816 if 'NonEmpty' in attr.ext_attrs: |
698 webcore_function_name = 'getNonEmptyURLAttribute' | 817 webcore_function_name = 'getNonEmptyURLAttribute' |
699 else: | 818 else: |
700 webcore_function_name = 'getURLAttribute' | 819 webcore_function_name = 'getURLAttribute' |
(...skipping 18 matching lines...) Expand all Loading... | |
719 function_expression, | 838 function_expression, |
720 attr, | 839 attr, |
721 [], | 840 [], |
722 attr.type.id, | 841 attr.type.id, |
723 attr.type.nullable, | 842 attr.type.nullable, |
724 raises, | 843 raises, |
725 auto_scope_setup) | 844 auto_scope_setup) |
726 | 845 |
727 def _AddSetter(self, attr, html_name): | 846 def _AddSetter(self, attr, html_name): |
728 type_info = self._TypeInfo(attr.type.id) | 847 type_info = self._TypeInfo(attr.type.id) |
729 dart_declaration = 'void set %s(%s value)' % (html_name, self._DartType(attr .type.id)) | 848 return_type = 'void' |
849 parameters = ['value'] | |
850 ptype = self._DartType(attr.type.id) | |
851 dart_declaration = 'void set %s(%s value)' % (html_name, ptype) | |
730 is_custom = ('Custom' in attr.ext_attrs and | 852 is_custom = ('Custom' in attr.ext_attrs and |
731 (attr.ext_attrs['Custom'] == None or | 853 (attr.ext_attrs['Custom'] == None or |
732 attr.ext_attrs['Custom'] == 'Setter')) | 854 attr.ext_attrs['Custom'] == 'Setter')) |
733 # This seems to have been replaced with Custom=Setter (see above), but | 855 # This seems to have been replaced with Custom=Setter (see above), but |
734 # check to be sure we don't see the old syntax | 856 # check to be sure we don't see the old syntax |
735 assert(not ('CustomSetter' in attr.ext_attrs)) | 857 assert(not ('CustomSetter' in attr.ext_attrs)) |
736 assert(not ('V8CustomSetter' in attr.ext_attrs)) | 858 assert(not ('V8CustomSetter' in attr.ext_attrs)) |
737 native_suffix = 'Setter' | 859 native_suffix = 'Setter' |
738 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) | 860 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) |
739 cpp_callback_name = self._GenerateNativeBinding(attr.id, 2, | 861 cpp_callback_name = self._GenerateNativeBinding(attr.id, 2, |
740 dart_declaration, native_suffix, is_custom, auto_scope_setup) | 862 dart_declaration, False, return_type, parameters, |
863 native_suffix, is_custom, auto_scope_setup) | |
741 if is_custom: | 864 if is_custom: |
742 return | 865 return |
743 | 866 |
744 if 'Reflect' in attr.ext_attrs: | 867 if 'Reflect' in attr.ext_attrs: |
745 webcore_function_name = self._TypeInfo(attr.type.id).webcore_setter_name() | 868 webcore_function_name = self._TypeInfo(attr.type.id).webcore_setter_name() |
746 else: | 869 else: |
747 if 'ImplementedAs' in attr.ext_attrs: | 870 if 'ImplementedAs' in attr.ext_attrs: |
748 attr_name = attr.ext_attrs['ImplementedAs'] | 871 attr_name = attr.ext_attrs['ImplementedAs'] |
749 else: | 872 else: |
750 attr_name = attr.id | 873 attr_name = attr.id |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
786 # and | 909 # and |
787 # | 910 # |
788 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; } | 911 # class YImpl extends ListBase<T> { copies of transitive XImpl methods; } |
789 # | 912 # |
790 dart_element_type = self._DartType(element_type) | 913 dart_element_type = self._DartType(element_type) |
791 if self._HasNativeIndexGetter(): | 914 if self._HasNativeIndexGetter(): |
792 self._EmitNativeIndexGetter(dart_element_type) | 915 self._EmitNativeIndexGetter(dart_element_type) |
793 elif self._HasExplicitIndexedGetter(): | 916 elif self._HasExplicitIndexedGetter(): |
794 self._EmitExplicitIndexedGetter(dart_element_type) | 917 self._EmitExplicitIndexedGetter(dart_element_type) |
795 else: | 918 else: |
796 self._members_emitter.Emit( | 919 if dart_use_blink: |
797 '\n' | 920 dart_native_name = \ |
798 ' $TYPE operator[](int index) {\n' | 921 DeriveNativeName(self._interface.id, "NativeIndexed", "Getter") |
799 ' if (index < 0 || index >= length)\n' | 922 # First emit a toplevel function to do the native call |
800 ' throw new RangeError.range(index, 0, length);\n' | 923 # Calls to this are emitted elsewhere, |
801 ' return _nativeIndexedGetter(index);\n' | 924 self._native_interface_emitter.Emit( |
802 ' }\n' | 925 '\n' |
803 ' $TYPE _nativeIndexedGetter(int index) native "$(INTERFACE)_item_Cal lback";\n', | 926 '$(DART_NATIVE_NAME)(mthis, index) ' |
804 TYPE=self.SecureOutputType(element_type), | 927 'native "$(INTERFACE)_item_Callback";\n', |
805 INTERFACE=self._interface.id) | 928 DART_NATIVE_NAME = dart_native_name, |
929 INTERFACE=self._interface.id) | |
930 | |
931 # Emit the method which calls the toplevel function, along with | |
932 # the [] operator. | |
933 self._members_emitter.Emit( | |
934 '\n' | |
935 ' $TYPE operator[](int index) {\n' | |
936 ' if (index < 0 || index >= length)\n' | |
937 ' throw new RangeError.range(index, 0, length);\n' | |
938 ' return $(DART_NATIVE_NAME)(this, index);\n' | |
939 ' }\n\n' | |
940 ' $TYPE _nativeIndexedGetter(int index) =>' | |
941 ' $(DART_NATIVE_NAME)(this, index);\n', | |
942 DART_NATIVE_NAME=DeriveQualifiedName(self._native_library_name, | |
943 dart_native_name), | |
944 TYPE=self.SecureOutputType(element_type), | |
945 INTERFACE=self._interface.id) | |
946 else: | |
947 # Emit the method which calls the toplevel function, along with | |
948 # the [] operator. | |
949 self._members_emitter.Emit( | |
950 '\n' | |
951 ' $TYPE operator[](int index) {\n' | |
952 ' if (index < 0 || index >= length)\n' | |
953 ' throw new RangeError.range(index, 0, length);\n' | |
954 ' return _nativeIndexedGetter(index);\n' | |
955 ' }\n\n' | |
956 ' $TYPE _nativeIndexedGetter(int index) ' | |
957 ' native "$(INTERFACE)_item_Callback";\n', | |
958 TYPE=self.SecureOutputType(element_type), | |
959 INTERFACE=self._interface.id) | |
806 | 960 |
807 if self._HasNativeIndexSetter(): | 961 if self._HasNativeIndexSetter(): |
808 self._EmitNativeIndexSetter(dart_element_type) | 962 self._EmitNativeIndexSetter(dart_element_type) |
809 else: | 963 else: |
810 self._members_emitter.Emit( | 964 self._members_emitter.Emit( |
811 '\n' | 965 '\n' |
812 ' void operator[]=(int index, $TYPE value) {\n' | 966 ' void operator[]=(int index, $TYPE value) {\n' |
813 ' throw new UnsupportedError("Cannot assign element of immutable Li st.");\n' | 967 ' throw new UnsupportedError("Cannot assign element of immutable Li st.");\n' |
814 ' }\n', | 968 ' }\n', |
815 TYPE=dart_element_type) | 969 TYPE=dart_element_type) |
(...skipping 12 matching lines...) Expand all Loading... | |
828 | 982 |
829 if self._HasNativeIndexGetter(): | 983 if self._HasNativeIndexGetter(): |
830 self._EmitNativeIndexGetter(dart_element_type) | 984 self._EmitNativeIndexGetter(dart_element_type) |
831 if self._HasNativeIndexSetter(): | 985 if self._HasNativeIndexSetter(): |
832 self._EmitNativeIndexSetter(dart_element_type) | 986 self._EmitNativeIndexSetter(dart_element_type) |
833 | 987 |
834 def _HasNativeIndexGetter(self): | 988 def _HasNativeIndexGetter(self): |
835 return 'CustomIndexedGetter' in self._interface.ext_attrs | 989 return 'CustomIndexedGetter' in self._interface.ext_attrs |
836 | 990 |
837 def _EmitNativeIndexGetter(self, element_type): | 991 def _EmitNativeIndexGetter(self, element_type): |
838 dart_declaration = '%s operator[](int index)' % \ | 992 return_type = self.SecureOutputType(element_type, True) |
839 self.SecureOutputType(element_type, True) | 993 parameters = ['index'] |
840 self._GenerateNativeBinding('numericIndexGetter', 2, dart_declaration, | 994 dart_declaration = '%s operator[](int index)' % return_type |
841 'Callback', True, False) | 995 self._GenerateNativeBinding('numericIndexGetter', 2, |
996 dart_declaration, False, return_type, parameters, | |
997 'Callback', True, False) | |
842 | 998 |
843 def _HasExplicitIndexedGetter(self): | 999 def _HasExplicitIndexedGetter(self): |
844 return any(op.id == 'getItem' for op in self._interface.operations) | 1000 return any(op.id == 'getItem' for op in self._interface.operations) |
845 | 1001 |
846 def _EmitExplicitIndexedGetter(self, dart_element_type): | 1002 def _EmitExplicitIndexedGetter(self, dart_element_type): |
847 if any(op.id == 'getItem' for op in self._interface.operations): | 1003 if any(op.id == 'getItem' for op in self._interface.operations): |
848 indexed_getter = 'getItem' | 1004 indexed_getter = 'getItem' |
849 | 1005 |
850 self._members_emitter.Emit( | 1006 self._members_emitter.Emit( |
851 '\n' | 1007 '\n' |
852 ' $TYPE operator[](int index) {\n' | 1008 ' $TYPE operator[](int index) {\n' |
853 ' if (index < 0 || index >= length)\n' | 1009 ' if (index < 0 || index >= length)\n' |
854 ' throw new RangeError.range(index, 0, length);\n' | 1010 ' throw new RangeError.range(index, 0, length);\n' |
855 ' return $INDEXED_GETTER(index);\n' | 1011 ' return $INDEXED_GETTER(index);\n' |
856 ' }\n', | 1012 ' }\n', |
857 TYPE=dart_element_type, | 1013 TYPE=dart_element_type, |
858 INDEXED_GETTER=indexed_getter) | 1014 INDEXED_GETTER=indexed_getter) |
859 | 1015 |
860 def _HasNativeIndexSetter(self): | 1016 def _HasNativeIndexSetter(self): |
861 return 'CustomIndexedSetter' in self._interface.ext_attrs | 1017 return 'CustomIndexedSetter' in self._interface.ext_attrs |
862 | 1018 |
863 def _EmitNativeIndexSetter(self, element_type): | 1019 def _EmitNativeIndexSetter(self, element_type): |
864 dart_declaration = 'void operator[]=(int index, %s value)' % element_type | 1020 return_type = 'void' |
865 self._GenerateNativeBinding('numericIndexSetter', 3, dart_declaration, | 1021 formals = ', '.join(['int index', '%s value' % element_type]) |
866 'Callback', True, False) | 1022 parameters = ['index', 'value'] |
1023 dart_declaration = 'void operator[]=(%s)' % formals | |
1024 self._GenerateNativeBinding('numericIndexSetter', 3, | |
1025 dart_declaration, False, return_type, parameters, | |
1026 'Callback', True, False) | |
867 | 1027 |
868 def EmitOperation(self, info, html_name): | 1028 def EmitOperation(self, info, html_name): |
869 """ | 1029 """ |
870 Arguments: | 1030 Arguments: |
871 info: An OperationInfo object. | 1031 info: An OperationInfo object. |
872 """ | 1032 """ |
873 | 1033 return_type = self.SecureOutputType(info.type_name, False, True) |
1034 formals = info.ParametersAsDeclaration(self._DartType) | |
1035 parameters = info.ParametersAsListOfVariables() | |
874 dart_declaration = '%s%s %s(%s)' % ( | 1036 dart_declaration = '%s%s %s(%s)' % ( |
875 'static ' if info.IsStatic() else '', | 1037 'static ' if info.IsStatic() else '', |
876 self.SecureOutputType(info.type_name, False, True), | 1038 return_type, |
877 html_name, | 1039 html_name, |
878 info.ParametersDeclaration(self._DartType)) | 1040 formals) |
879 | 1041 |
880 operation = info.operations[0] | 1042 operation = info.operations[0] |
881 is_custom = 'Custom' in operation.ext_attrs | 1043 is_custom = 'Custom' in operation.ext_attrs |
882 has_optional_arguments = any(self._IsArgumentOptionalInWebCore(operation, ar gument) for argument in operation.arguments) | 1044 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) | 1045 needs_dispatcher = not is_custom and (len(info.operations) > 1 or has_option al_arguments) |
884 | 1046 |
885 if info.callback_args: | 1047 if info.callback_args: |
886 self._AddFutureifiedOperation(info, html_name) | 1048 self._AddFutureifiedOperation(info, html_name) |
887 elif not needs_dispatcher: | 1049 elif not needs_dispatcher: |
888 # Bind directly to native implementation | 1050 # Bind directly to native implementation |
889 argument_count = (0 if info.IsStatic() else 1) + len(info.param_infos) | 1051 argument_count = (0 if info.IsStatic() else 1) + len(info.param_infos) |
890 native_suffix = 'Callback' | 1052 native_suffix = 'Callback' |
891 auto_scope_setup = self._GenerateAutoSetupScope(info.name, native_suffix) | 1053 auto_scope_setup = self._GenerateAutoSetupScope(info.name, native_suffix) |
892 cpp_callback_name = self._GenerateNativeBinding( | 1054 cpp_callback_name = self._GenerateNativeBinding( |
893 info.name, argument_count, dart_declaration, native_suffix, is_custom, | 1055 info.name, argument_count, dart_declaration, |
894 auto_scope_setup) | 1056 info.IsStatic(), return_type, parameters, |
1057 native_suffix, is_custom, auto_scope_setup) | |
895 if not is_custom: | 1058 if not is_custom: |
896 self._GenerateOperationNativeCallback(operation, operation.arguments, cp p_callback_name, auto_scope_setup) | 1059 self._GenerateOperationNativeCallback(operation, operation.arguments, cp p_callback_name, auto_scope_setup) |
897 else: | 1060 else: |
898 self._GenerateDispatcher(info, info.operations, dart_declaration) | 1061 self._GenerateDispatcher(info, info.operations, dart_declaration) |
899 | 1062 |
900 def _GenerateDispatcher(self, info, operations, dart_declaration): | 1063 def _GenerateDispatcher(self, info, operations, dart_declaration): |
901 | 1064 |
902 def GenerateCall( | 1065 def GenerateCall( |
903 stmts_emitter, call_emitter, version, operation, argument_count): | 1066 stmts_emitter, call_emitter, version, operation, argument_count): |
904 overload_name = '_%s_%s' % (operation.id, version) | 1067 overload_name = '_%s_%s' % (operation.id, version) |
905 argument_list = ', '.join( | 1068 return_type = self.SecureOutputType(operation.type.id) |
906 [p.name for p in info.param_infos[:argument_count]]) | 1069 actuals = info.ParametersAsListOfVariables(argument_count) |
907 call_emitter.Emit('$NAME($ARGS)', NAME=overload_name, ARGS=argument_list) | 1070 actuals_s = ", ".join(actuals) |
908 | 1071 call_emitter.Emit('$NAME($ARGS)', NAME=overload_name, ARGS=actuals_s) |
909 dart_declaration = '%s%s %s(%s)' % ( | 1072 dart_declaration = '%s%s %s(%s)' % ( |
910 'static ' if operation.is_static else '', | 1073 'static ' if operation.is_static else '', |
911 self.SecureOutputType(operation.type.id), | 1074 return_type, |
912 overload_name, argument_list) | 1075 overload_name, actuals_s) |
913 is_custom = 'Custom' in operation.ext_attrs | 1076 is_custom = 'Custom' in operation.ext_attrs |
914 native_suffix = 'Callback' | 1077 native_suffix = 'Callback' |
915 auto_scope_setup = self._GenerateAutoSetupScope(overload_name, native_suff ix) | 1078 auto_scope_setup = \ |
1079 self._GenerateAutoSetupScope(overload_name, native_suffix) | |
916 cpp_callback_name = self._GenerateNativeBinding( | 1080 cpp_callback_name = self._GenerateNativeBinding( |
917 overload_name, (0 if operation.is_static else 1) + argument_count, | 1081 overload_name, (0 if operation.is_static else 1) + argument_count, |
918 dart_declaration, 'Callback', is_custom, auto_scope_setup, | 1082 dart_declaration, operation.is_static, return_type, actuals, |
919 emit_metadata=False) | 1083 'Callback', is_custom, auto_scope_setup, emit_metadata=False) |
920 if not is_custom: | 1084 if not is_custom: |
921 self._GenerateOperationNativeCallback(operation, operation.arguments[:ar gument_count], cpp_callback_name, auto_scope_setup) | 1085 self._GenerateOperationNativeCallback(operation, |
1086 operation.arguments[:argument_count], cpp_callback_name, | |
1087 auto_scope_setup) | |
922 | 1088 |
923 self._GenerateDispatcherBody( | 1089 self._GenerateDispatcherBody( |
924 info, | 1090 info, |
925 operations, | 1091 operations, |
926 dart_declaration, | 1092 dart_declaration, |
927 GenerateCall, | 1093 GenerateCall, |
928 self._IsArgumentOptionalInWebCore) | 1094 self._IsArgumentOptionalInWebCore) |
929 | 1095 |
930 def SecondaryContext(self, interface): | 1096 def SecondaryContext(self, interface): |
931 pass | 1097 pass |
(...skipping 26 matching lines...) Expand all Loading... | |
958 auto_scope_setup=True, | 1124 auto_scope_setup=True, |
959 generate_custom_element_scope_if_needed=False): | 1125 generate_custom_element_scope_if_needed=False): |
960 | 1126 |
961 ext_attrs = node.ext_attrs | 1127 ext_attrs = node.ext_attrs |
962 | 1128 |
963 if self._IsStatic(node.id): | 1129 if self._IsStatic(node.id): |
964 needs_receiver = True | 1130 needs_receiver = True |
965 | 1131 |
966 cpp_arguments = [] | 1132 cpp_arguments = [] |
967 runtime_check = None | 1133 runtime_check = None |
968 raises_exceptions = raises_dom_exception or arguments | 1134 raises_exceptions = raises_dom_exception or arguments or needs_receiver |
969 needs_custom_element_callbacks = False | 1135 needs_custom_element_callbacks = False |
970 | 1136 |
971 # TODO(antonm): unify with ScriptState below. | 1137 # TODO(antonm): unify with ScriptState below. |
972 requires_stack_info = (ext_attrs.get('CallWith') == 'ScriptArguments|ScriptS tate' or | 1138 requires_stack_info = (ext_attrs.get('CallWith') == 'ScriptArguments|ScriptS tate' or |
973 ext_attrs.get('ConstructorCallWith') == 'ScriptArgume nts|ScriptState' or | 1139 ext_attrs.get('ConstructorCallWith') == 'ScriptArgume nts|ScriptState' or |
974 ext_attrs.get('CallWith') == 'ScriptArguments&ScriptS tate' or | 1140 ext_attrs.get('CallWith') == 'ScriptArguments&ScriptS tate' or |
975 ext_attrs.get('ConstructorCallWith') == 'ScriptArgume nts&ScriptState') | 1141 ext_attrs.get('ConstructorCallWith') == 'ScriptArgume nts&ScriptState') |
976 if requires_stack_info: | 1142 if requires_stack_info: |
977 raises_exceptions = True | 1143 raises_exceptions = True |
978 cpp_arguments = ['&state', 'scriptArguments.release()'] | 1144 cpp_arguments = ['&state', 'scriptArguments.release()'] |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1108 | 1274 |
1109 body_emitter.Emit( | 1275 body_emitter.Emit( |
1110 ' DOMWindow* domWindow = DartUtilities::domWindowForCurrentIsol ate();\n' | 1276 ' DOMWindow* domWindow = DartUtilities::domWindowForCurrentIsol ate();\n' |
1111 ' if (!domWindow) {\n' | 1277 ' if (!domWindow) {\n' |
1112 ' exception = Dart_NewStringFromCString("Failed to fetch do mWindow");\n' | 1278 ' exception = Dart_NewStringFromCString("Failed to fetch do mWindow");\n' |
1113 ' goto fail;\n' | 1279 ' goto fail;\n' |
1114 ' }\n' | 1280 ' }\n' |
1115 ' Document& document = *domWindow->document();\n') | 1281 ' Document& document = *domWindow->document();\n') |
1116 | 1282 |
1117 if needs_receiver: | 1283 if needs_receiver: |
1118 body_emitter.Emit( | 1284 if dart_use_blink: |
1119 ' $WEBCORE_CLASS_NAME* receiver = DartDOMWrapper::receiver< $WE BCORE_CLASS_NAME >(args);\n', | 1285 body_emitter.Emit( |
1120 WEBCORE_CLASS_NAME=self._interface_type_info.native_type()) | 1286 ' $WEBCORE_CLASS_NAME* receiver = ' |
1287 'DartDOMWrapper::receiverChecked<Dart$INTERFACE>(args, exception);\n ' | |
1288 ' if (exception)\n' | |
1289 ' goto fail;\n', | |
1290 WEBCORE_CLASS_NAME=self._interface_type_info.native_type(), | |
1291 INTERFACE=self._interface.id) | |
1292 else: | |
1293 body_emitter.Emit( | |
1294 ' $WEBCORE_CLASS_NAME* receiver = ' | |
1295 'DartDOMWrapper::receiver< $WEBCORE_CLASS_NAME >(args);\n' | |
1296 ' if (exception)\n' | |
1297 ' goto fail;\n', | |
1298 WEBCORE_CLASS_NAME=self._interface_type_info.native_type()) | |
1121 | 1299 |
1122 if requires_stack_info: | 1300 if requires_stack_info: |
1123 self._cpp_impl_includes.add('"ScriptArguments.h"') | 1301 self._cpp_impl_includes.add('"ScriptArguments.h"') |
1124 body_emitter.Emit( | 1302 body_emitter.Emit( |
1125 '\n' | 1303 '\n' |
1126 ' ScriptState* currentState = DartUtilities::currentScriptState ();\n' | 1304 ' ScriptState* currentState = DartUtilities::currentScriptState ();\n' |
1127 ' if (!currentState) {\n' | 1305 ' if (!currentState) {\n' |
1128 ' exception = Dart_NewStringFromCString("Failed to retrieve a script state");\n' | 1306 ' exception = Dart_NewStringFromCString("Failed to retrieve a script state");\n' |
1129 ' goto fail;\n' | 1307 ' goto fail;\n' |
1130 ' }\n' | 1308 ' }\n' |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1299 value_expression, | 1477 value_expression, |
1300 auto_scope_setup, | 1478 auto_scope_setup, |
1301 self._interface.id, | 1479 self._interface.id, |
1302 ext_attrs) | 1480 ext_attrs) |
1303 set_return_value = '%s' % (return_to_dart_conversion) | 1481 set_return_value = '%s' % (return_to_dart_conversion) |
1304 invocation_emitter.Emit( | 1482 invocation_emitter.Emit( |
1305 ' $RETURN_VALUE;\n', | 1483 ' $RETURN_VALUE;\n', |
1306 RETURN_VALUE=set_return_value) | 1484 RETURN_VALUE=set_return_value) |
1307 | 1485 |
1308 def _GenerateNativeBinding(self, idl_name, argument_count, dart_declaration, | 1486 def _GenerateNativeBinding(self, idl_name, argument_count, dart_declaration, |
1309 native_suffix, is_custom, auto_scope_setup=True, emit_metadata=True): | 1487 static, return_type, parameters, native_suffix, is_custom, |
1310 | 1488 auto_scope_setup=True, emit_metadata=True): |
1311 metadata = [] | 1489 metadata = [] |
1312 if emit_metadata: | 1490 if emit_metadata: |
1313 metadata = self._metadata.GetFormattedMetadata( | 1491 metadata = self._metadata.GetFormattedMetadata( |
1314 self._renamer.GetLibraryName(self._interface), | 1492 self._renamer.GetLibraryName(self._interface), |
1315 self._interface, idl_name, ' ') | 1493 self._interface, idl_name, ' ') |
1494 dart_native_name = \ | |
1495 DeriveNativeName(self._interface.id, idl_name, native_suffix) | |
1496 native_binding = '%s_%s_%s' % (self._interface.id, idl_name, native_suffix) | |
1497 if dart_use_blink: | |
1498 if not static: | |
1499 formals = ", ".join(['mthis'] + parameters) | |
1500 actuals = ", ".join(['this'] + parameters) | |
1501 else: | |
1502 formals = ", ".join(parameters) | |
1503 actuals = ", ".join(parameters) | |
1316 | 1504 |
1317 native_binding = '%s_%s_%s' % (self._interface.id, idl_name, native_suffix) | 1505 self._native_interface_emitter.Emit( |
1318 self._members_emitter.Emit( | 1506 '\n' |
1319 '\n' | 1507 '$DART_NAME($FORMALS) native "$NATIVE_BINDING";\n', |
1320 ' $METADATA$DART_DECLARATION native "$NATIVE_BINDING";\n', | 1508 DART_NAME=dart_native_name, |
1321 DOMINTERFACE=self._interface.id, | 1509 FORMALS=formals, |
1322 METADATA=metadata, | 1510 NATIVE_BINDING=native_binding) |
1323 DART_DECLARATION=dart_declaration, | |
1324 NATIVE_BINDING=native_binding) | |
1325 | 1511 |
1512 # We then emit a class method which calls out to the mangled toplevel | |
1513 # function. Eventually this will be replaced with a call to an | |
1514 # interceptor | |
1515 self._members_emitter.Emit( | |
1516 '\n' | |
1517 ' $METADATA$DART_DECLARATION => $DART_NAME($ACTUALS);\n', | |
1518 METADATA=metadata, | |
1519 DART_DECLARATION=dart_declaration, | |
1520 DART_NAME=DeriveQualifiedName(self._native_library_name, | |
1521 dart_native_name), | |
1522 ACTUALS=actuals) | |
1523 else: | |
1524 self._members_emitter.Emit( | |
1525 '\n' | |
1526 ' $METADATA$DART_DECLARATION native "$NATIVE_BINDING";\n', | |
1527 METADATA=metadata, | |
1528 DART_DECLARATION=dart_declaration, | |
1529 NATIVE_BINDING=native_binding) | |
1326 cpp_callback_name = '%s%s' % (idl_name, native_suffix) | 1530 cpp_callback_name = '%s%s' % (idl_name, native_suffix) |
1327 | 1531 |
1328 self._cpp_resolver_emitter.Emit( | 1532 self._cpp_resolver_emitter.Emit( |
1329 ' if (argumentCount == $ARGC && name == "$NATIVE_BINDING") {\n' | 1533 ' if (argumentCount == $ARGC && name == "$NATIVE_BINDING") {\n' |
1330 ' *autoSetupScope = $AUTO_SCOPE_SETUP;\n' | 1534 ' *autoSetupScope = $AUTO_SCOPE_SETUP;\n' |
1331 ' return Dart$(INTERFACE_NAME)Internal::$CPP_CALLBACK_NAME;\n' | 1535 ' return Dart$(INTERFACE_NAME)Internal::$CPP_CALLBACK_NAME;\n' |
1332 ' }\n', | 1536 ' }\n', |
1333 ARGC=argument_count, | 1537 ARGC=argument_count, |
1334 NATIVE_BINDING=native_binding, | 1538 NATIVE_BINDING=native_binding, |
1335 INTERFACE_NAME=self._interface.id, | 1539 INTERFACE_NAME=self._interface.id, |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1584 e.Emit("};\n"); | 1788 e.Emit("};\n"); |
1585 e.Emit('\n'); | 1789 e.Emit('\n'); |
1586 e.Emit('} // namespace WebCore\n'); | 1790 e.Emit('} // namespace WebCore\n'); |
1587 | 1791 |
1588 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1792 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
1589 return ( | 1793 return ( |
1590 interface.id.endswith('Event') and | 1794 interface.id.endswith('Event') and |
1591 operation.id.startswith('init') and | 1795 operation.id.startswith('init') and |
1592 argument.ext_attrs.get('Default') == 'Undefined' and | 1796 argument.ext_attrs.get('Default') == 'Undefined' and |
1593 argument.type.id == 'DOMString') | 1797 argument.type.id == 'DOMString') |
OLD | NEW |