| 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 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 for i, argument in enumerate(arguments): | 731 for i, argument in enumerate(arguments): |
| 732 type_info = self._TypeInfo(argument.type.id) | 732 type_info = self._TypeInfo(argument.type.id) |
| 733 argument_expression_template, type, cls, function = \ | 733 argument_expression_template, type, cls, function = \ |
| 734 type_info.to_native_info(argument, self._interface.id) | 734 type_info.to_native_info(argument, self._interface.id) |
| 735 | 735 |
| 736 def AllowsNull(): | 736 def AllowsNull(): |
| 737 assert argument.ext_attrs.get('TreatNullAs', 'NullString') == 'NullStrin
g' | 737 assert argument.ext_attrs.get('TreatNullAs', 'NullString') == 'NullStrin
g' |
| 738 if argument.ext_attrs.get('TreatNullAs') == 'NullString': | 738 if argument.ext_attrs.get('TreatNullAs') == 'NullString': |
| 739 return True | 739 return True |
| 740 | 740 |
| 741 if argument.type.nullable: |
| 742 return True |
| 743 |
| 741 if isinstance(argument, IDLArgument): | 744 if isinstance(argument, IDLArgument): |
| 742 if IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node
, argument): | 745 if IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node
, argument): |
| 743 return True | 746 return True |
| 744 if argument.ext_attrs.get('Default') == 'NullString': | 747 if argument.ext_attrs.get('Default') == 'NullString': |
| 745 return True | 748 return True |
| 746 if _IsOptionalStringArgumentInInitEventMethod(self._interface, node, a
rgument): | 749 if _IsOptionalStringArgumentInInitEventMethod(self._interface, node, a
rgument): |
| 747 return True | 750 return True |
| 748 | 751 |
| 749 return False | 752 return False |
| 750 | 753 |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' | 947 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' |
| 945 ' return func;\n', | 948 ' return func;\n', |
| 946 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) | 949 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) |
| 947 | 950 |
| 948 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 951 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 949 return ( | 952 return ( |
| 950 interface.id.endswith('Event') and | 953 interface.id.endswith('Event') and |
| 951 operation.id.startswith('init') and | 954 operation.id.startswith('init') and |
| 952 argument.ext_attrs.get('Default') == 'Undefined' and | 955 argument.ext_attrs.get('Default') == 'Undefined' and |
| 953 argument.type.id == 'DOMString') | 956 argument.type.id == 'DOMString') |
| OLD | NEW |