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 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1543 if argument.type.nullable: | 1543 if argument.type.nullable: |
1544 return True | 1544 return True |
1545 | 1545 |
1546 if isinstance(argument, IDLAttribute): | 1546 if isinstance(argument, IDLAttribute): |
1547 return (argument.type.id == 'DOMString') and \ | 1547 return (argument.type.id == 'DOMString') and \ |
1548 ('Reflect' in argument.ext_attrs) | 1548 ('Reflect' in argument.ext_attrs) |
1549 | 1549 |
1550 if isinstance(argument, IDLArgument): | 1550 if isinstance(argument, IDLArgument): |
1551 if IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node
, argument): | 1551 if IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node
, argument): |
1552 return True | 1552 return True |
1553 if argument.ext_attrs.get('Default') == 'NullString': | 1553 # argument default to null (e.g., DOMString arg = null). |
| 1554 if argument.default_value_is_null: |
1554 return True | 1555 return True |
1555 if _IsOptionalStringArgumentInInitEventMethod(self._interface, node, a
rgument): | 1556 if _IsOptionalStringArgumentInInitEventMethod(self._interface, node, a
rgument): |
1556 return True | 1557 return True |
1557 | 1558 |
1558 return False | 1559 return False |
1559 | 1560 |
1560 if AllowsNull(): | 1561 if AllowsNull(): |
1561 function += 'WithNullCheck' | 1562 function += 'WithNullCheck' |
1562 | 1563 |
1563 argument_name = DartDomNameOfAttribute(argument) | 1564 argument_name = DartDomNameOfAttribute(argument) |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1782 else: | 1783 else: |
1783 return '%s::%s' % (impl_type_name, function_name) | 1784 return '%s::%s' % (impl_type_name, function_name) |
1784 | 1785 |
1785 def _IsArgumentOptionalInWebCore(self, operation, argument): | 1786 def _IsArgumentOptionalInWebCore(self, operation, argument): |
1786 if not IsOptional(argument): | 1787 if not IsOptional(argument): |
1787 return False | 1788 return False |
1788 if 'Callback' in argument.ext_attrs: | 1789 if 'Callback' in argument.ext_attrs: |
1789 return False | 1790 return False |
1790 if operation.id in ['addEventListener', 'removeEventListener'] and argument.
id == 'useCapture': | 1791 if operation.id in ['addEventListener', 'removeEventListener'] and argument.
id == 'useCapture': |
1791 return False | 1792 return False |
1792 if 'ForceOptional' in argument.ext_attrs: | 1793 if 'DartForceOptional' in argument.ext_attrs: |
1793 return False | 1794 return False |
1794 if argument.type.id == 'Dictionary': | 1795 if argument.type.id == 'Dictionary': |
1795 return False | 1796 return False |
1796 return True | 1797 return True |
1797 | 1798 |
1798 def _GenerateCPPIncludes(self, includes): | 1799 def _GenerateCPPIncludes(self, includes): |
1799 return ''.join(['#include %s\n' % include for include in sorted(includes)]) | 1800 return ''.join(['#include %s\n' % include for include in sorted(includes)]) |
1800 | 1801 |
1801 def _ToWebKitName(self, name): | 1802 def _ToWebKitName(self, name): |
1802 name = name[0].lower() + name[1:] | 1803 name = name[0].lower() + name[1:] |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1990 e.Emit(' },\n') | 1991 e.Emit(' },\n') |
1991 | 1992 |
1992 e.Emit("};\n"); | 1993 e.Emit("};\n"); |
1993 e.Emit('\n'); | 1994 e.Emit('\n'); |
1994 e.Emit('} // namespace WebCore\n'); | 1995 e.Emit('} // namespace WebCore\n'); |
1995 | 1996 |
1996 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1997 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
1997 return ( | 1998 return ( |
1998 interface.id.endswith('Event') and | 1999 interface.id.endswith('Event') and |
1999 operation.id.startswith('init') and | 2000 operation.id.startswith('init') and |
2000 argument.ext_attrs.get('Default') == 'Undefined' and | 2001 argument.default_value == 'Undefined' and |
2001 argument.type.id == 'DOMString') | 2002 argument.type.id == 'DOMString') |
OLD | NEW |