| 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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 return (self._interface.id, idl_name, native_suffix) not in _cpp_no_auto_sco
pe_list | 572 return (self._interface.id, idl_name, native_suffix) not in _cpp_no_auto_sco
pe_list |
| 573 | 573 |
| 574 def _AddGetter(self, attr, html_name, read_only): | 574 def _AddGetter(self, attr, html_name, read_only): |
| 575 # Temporary hack to force dart:scalarlist clamped array for ImageData.data. | 575 # Temporary hack to force dart:scalarlist clamped array for ImageData.data. |
| 576 # TODO(antonm): solve in principled way. | 576 # TODO(antonm): solve in principled way. |
| 577 if self._interface.id == 'ImageData' and html_name == 'data': | 577 if self._interface.id == 'ImageData' and html_name == 'data': |
| 578 html_name = '_data' | 578 html_name = '_data' |
| 579 type_info = self._TypeInfo(attr.type.id) | 579 type_info = self._TypeInfo(attr.type.id) |
| 580 dart_declaration = '%s get %s' % ( | 580 dart_declaration = '%s get %s' % ( |
| 581 self.SecureOutputType(attr.type.id, False, read_only), html_name) | 581 self.SecureOutputType(attr.type.id, False, read_only), html_name) |
| 582 is_custom = 'Custom' in attr.ext_attrs or 'CustomGetter' in attr.ext_attrs | 582 is_custom = ('Custom' in attr.ext_attrs and |
| 583 (attr.ext_attrs['Custom'] == None or |
| 584 attr.ext_attrs['Custom'] == 'Getter')) |
| 585 # This seems to have been replaced with Custom=Getter (see above), but |
| 586 # check to be sure we don't see the old syntax |
| 587 assert(not ('CustomGetter' in attr.ext_attrs)) |
| 583 native_suffix = 'Getter' | 588 native_suffix = 'Getter' |
| 584 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) | 589 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) |
| 585 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, | 590 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, |
| 586 dart_declaration, native_suffix, is_custom, auto_scope_setup) | 591 dart_declaration, native_suffix, is_custom, auto_scope_setup) |
| 587 if is_custom: | 592 if is_custom: |
| 588 return | 593 return |
| 589 | 594 |
| 590 if 'Reflect' in attr.ext_attrs: | 595 if 'Reflect' in attr.ext_attrs: |
| 591 webcore_function_name = self._TypeInfo(attr.type.id).webcore_getter_name() | 596 webcore_function_name = self._TypeInfo(attr.type.id).webcore_getter_name() |
| 592 if 'URL' in attr.ext_attrs: | 597 if 'URL' in attr.ext_attrs: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 616 attr, | 621 attr, |
| 617 [], | 622 [], |
| 618 attr.type.id, | 623 attr.type.id, |
| 619 attr.type.nullable, | 624 attr.type.nullable, |
| 620 raises, | 625 raises, |
| 621 auto_scope_setup) | 626 auto_scope_setup) |
| 622 | 627 |
| 623 def _AddSetter(self, attr, html_name): | 628 def _AddSetter(self, attr, html_name): |
| 624 type_info = self._TypeInfo(attr.type.id) | 629 type_info = self._TypeInfo(attr.type.id) |
| 625 dart_declaration = 'void set %s(%s value)' % (html_name, self._DartType(attr
.type.id)) | 630 dart_declaration = 'void set %s(%s value)' % (html_name, self._DartType(attr
.type.id)) |
| 626 is_custom = set(['Custom', 'CustomSetter', 'V8CustomSetter']) & set(attr.ext
_attrs) | 631 is_custom = ('Custom' in attr.ext_attrs and |
| 632 (attr.ext_attrs['Custom'] == None or |
| 633 attr.ext_attrs['Custom'] == 'Setter')) |
| 634 # This seems to have been replaced with Custom=Setter (see above), but |
| 635 # check to be sure we don't see the old syntax |
| 636 assert(not ('CustomSetter' in attr.ext_attrs)) |
| 637 assert(not ('V8CustomSetter' in attr.ext_attrs)) |
| 627 native_suffix = 'Setter' | 638 native_suffix = 'Setter' |
| 628 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) | 639 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) |
| 629 cpp_callback_name = self._GenerateNativeBinding(attr.id, 2, | 640 cpp_callback_name = self._GenerateNativeBinding(attr.id, 2, |
| 630 dart_declaration, native_suffix, is_custom, auto_scope_setup) | 641 dart_declaration, native_suffix, is_custom, auto_scope_setup) |
| 631 if is_custom: | 642 if is_custom: |
| 632 return | 643 return |
| 633 | 644 |
| 634 if 'Reflect' in attr.ext_attrs: | 645 if 'Reflect' in attr.ext_attrs: |
| 635 webcore_function_name = self._TypeInfo(attr.type.id).webcore_setter_name() | 646 webcore_function_name = self._TypeInfo(attr.type.id).webcore_setter_name() |
| 636 else: | 647 else: |
| (...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1402 e.Emit("};\n"); | 1413 e.Emit("};\n"); |
| 1403 e.Emit('\n'); | 1414 e.Emit('\n'); |
| 1404 e.Emit('} // namespace WebCore\n'); | 1415 e.Emit('} // namespace WebCore\n'); |
| 1405 | 1416 |
| 1406 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1417 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 1407 return ( | 1418 return ( |
| 1408 interface.id.endswith('Event') and | 1419 interface.id.endswith('Event') and |
| 1409 operation.id.startswith('init') and | 1420 operation.id.startswith('init') and |
| 1410 argument.ext_attrs.get('Default') == 'Undefined' and | 1421 argument.ext_attrs.get('Default') == 'Undefined' and |
| 1411 argument.type.id == 'DOMString') | 1422 argument.type.id == 'DOMString') |
| OLD | NEW |