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 (attr.ext_attrs['Custom'] == None or |
vsm
2014/03/05 23:38:35
nit: 80 char limit per google style:
http://googl
Leaf
2014/03/06 00:00:13
Done.
| |
583 attr.ext_attrs['Custom'] == 'Get ter') | |
584 # This seems to have been replaced with Custom=Getter (see above), but check to be | |
585 # sure we don't see the old syntax | |
586 assert(not ('CustomGetter' in attr.ext_attrs)) | |
583 native_suffix = 'Getter' | 587 native_suffix = 'Getter' |
584 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) | 588 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) |
585 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, | 589 cpp_callback_name = self._GenerateNativeBinding(attr.id, 1, |
586 dart_declaration, native_suffix, is_custom, auto_scope_setup) | 590 dart_declaration, native_suffix, is_custom, auto_scope_setup) |
587 if is_custom: | 591 if is_custom: |
588 return | 592 return |
589 | 593 |
590 if 'Reflect' in attr.ext_attrs: | 594 if 'Reflect' in attr.ext_attrs: |
591 webcore_function_name = self._TypeInfo(attr.type.id).webcore_getter_name() | 595 webcore_function_name = self._TypeInfo(attr.type.id).webcore_getter_name() |
592 if 'URL' in attr.ext_attrs: | 596 if 'URL' in attr.ext_attrs: |
(...skipping 23 matching lines...) Expand all Loading... | |
616 attr, | 620 attr, |
617 [], | 621 [], |
618 attr.type.id, | 622 attr.type.id, |
619 attr.type.nullable, | 623 attr.type.nullable, |
620 raises, | 624 raises, |
621 auto_scope_setup) | 625 auto_scope_setup) |
622 | 626 |
623 def _AddSetter(self, attr, html_name): | 627 def _AddSetter(self, attr, html_name): |
624 type_info = self._TypeInfo(attr.type.id) | 628 type_info = self._TypeInfo(attr.type.id) |
625 dart_declaration = 'void set %s(%s value)' % (html_name, self._DartType(attr .type.id)) | 629 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) | 630 is_custom = 'Custom' in attr.ext_attrs and (attr.ext_attrs['Custom'] == None or |
vsm
2014/03/05 23:38:35
ditto
Leaf
2014/03/06 00:00:13
Done.
| |
631 attr.ext_attrs['Custom'] == 'Set ter') | |
632 # This seems to have been replaced with Custom=Setter (see above), but check to be | |
633 # sure we don't see the old syntax | |
634 assert(not ('CustomSetter' in attr.ext_attrs)) | |
635 assert(not ('V8CustomSetter' in attr.ext_attrs)) | |
627 native_suffix = 'Setter' | 636 native_suffix = 'Setter' |
628 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) | 637 auto_scope_setup = self._GenerateAutoSetupScope(attr.id, native_suffix) |
629 cpp_callback_name = self._GenerateNativeBinding(attr.id, 2, | 638 cpp_callback_name = self._GenerateNativeBinding(attr.id, 2, |
630 dart_declaration, native_suffix, is_custom, auto_scope_setup) | 639 dart_declaration, native_suffix, is_custom, auto_scope_setup) |
631 if is_custom: | 640 if is_custom: |
632 return | 641 return |
633 | 642 |
634 if 'Reflect' in attr.ext_attrs: | 643 if 'Reflect' in attr.ext_attrs: |
635 webcore_function_name = self._TypeInfo(attr.type.id).webcore_setter_name() | 644 webcore_function_name = self._TypeInfo(attr.type.id).webcore_setter_name() |
636 else: | 645 else: |
(...skipping 765 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1402 e.Emit("};\n"); | 1411 e.Emit("};\n"); |
1403 e.Emit('\n'); | 1412 e.Emit('\n'); |
1404 e.Emit('} // namespace WebCore\n'); | 1413 e.Emit('} // namespace WebCore\n'); |
1405 | 1414 |
1406 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1415 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
1407 return ( | 1416 return ( |
1408 interface.id.endswith('Event') and | 1417 interface.id.endswith('Event') and |
1409 operation.id.startswith('init') and | 1418 operation.id.startswith('init') and |
1410 argument.ext_attrs.get('Default') == 'Undefined' and | 1419 argument.ext_attrs.get('Default') == 'Undefined' and |
1411 argument.type.id == 'DOMString') | 1420 argument.type.id == 'DOMString') |
OLD | NEW |