| 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 |
| 11 from generator import * | 11 from generator import * |
| 12 from htmldartgenerator import * | 12 from htmldartgenerator import * |
| 13 from idlnode import IDLArgument | 13 from idlnode import IDLArgument, IDLAttribute |
| 14 from systemhtml import js_support_checks, GetCallbackInfo, HTML_LIBRARY_NAMES | 14 from systemhtml import js_support_checks, GetCallbackInfo, HTML_LIBRARY_NAMES |
| 15 | 15 |
| 16 _cpp_type_map = { | 16 _cpp_type_map = { |
| 17 ('DataTransferItem', 'webkitGetAsEntry'): 'DataTransferItemFileSystem', | 17 ('DataTransferItem', 'webkitGetAsEntry'): 'DataTransferItemFileSystem', |
| 18 ('DOMWindow', 'indexedDB'): 'DOMWindowIndexedDatabase', | 18 ('DOMWindow', 'indexedDB'): 'DOMWindowIndexedDatabase', |
| 19 ('DOMWindow', 'speechSynthesis'): 'DOMWindowSpeechSynthesis', | 19 ('DOMWindow', 'speechSynthesis'): 'DOMWindowSpeechSynthesis', |
| 20 ('DOMWindow', 'webkitNotifications'): 'DOMWindowNotifications', | 20 ('DOMWindow', 'webkitNotifications'): 'DOMWindowNotifications', |
| 21 ('DOMWindow', 'storage'): 'DOMWindowQuota', | 21 ('DOMWindow', 'storage'): 'DOMWindowQuota', |
| 22 ('DOMWindow', 'webkitStorageInfo'): 'DOMWindowQuota', | 22 ('DOMWindow', 'webkitStorageInfo'): 'DOMWindowQuota', |
| 23 ('DOMWindow', 'openDatabase'): 'DOMWindowWebDatabase', | 23 ('DOMWindow', 'openDatabase'): 'DOMWindowWebDatabase', |
| (...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 type_info.to_native_info(argument, self._interface.id) | 791 type_info.to_native_info(argument, self._interface.id) |
| 792 | 792 |
| 793 def AllowsNull(): | 793 def AllowsNull(): |
| 794 assert argument.ext_attrs.get('TreatNullAs', 'NullString') == 'NullStrin
g' | 794 assert argument.ext_attrs.get('TreatNullAs', 'NullString') == 'NullStrin
g' |
| 795 if argument.ext_attrs.get('TreatNullAs') == 'NullString': | 795 if argument.ext_attrs.get('TreatNullAs') == 'NullString': |
| 796 return True | 796 return True |
| 797 | 797 |
| 798 if argument.type.nullable: | 798 if argument.type.nullable: |
| 799 return True | 799 return True |
| 800 | 800 |
| 801 if isinstance(argument, IDLAttribute): |
| 802 return (argument.type.id == 'DOMString') and \ |
| 803 ('Reflect' in argument.ext_attrs) |
| 804 |
| 801 if isinstance(argument, IDLArgument): | 805 if isinstance(argument, IDLArgument): |
| 802 if IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node
, argument): | 806 if IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node
, argument): |
| 803 return True | 807 return True |
| 804 if argument.ext_attrs.get('Default') == 'NullString': | 808 if argument.ext_attrs.get('Default') == 'NullString': |
| 805 return True | 809 return True |
| 806 if _IsOptionalStringArgumentInInitEventMethod(self._interface, node, a
rgument): | 810 if _IsOptionalStringArgumentInInitEventMethod(self._interface, node, a
rgument): |
| 807 return True | 811 return True |
| 808 | 812 |
| 809 return False | 813 return False |
| 810 | 814 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' | 1025 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu
mentCount))\n' |
| 1022 ' return func;\n', | 1026 ' return func;\n', |
| 1023 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) | 1027 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) |
| 1024 | 1028 |
| 1025 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): | 1029 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): |
| 1026 return ( | 1030 return ( |
| 1027 interface.id.endswith('Event') and | 1031 interface.id.endswith('Event') and |
| 1028 operation.id.startswith('init') and | 1032 operation.id.startswith('init') and |
| 1029 argument.ext_attrs.get('Default') == 'Undefined' and | 1033 argument.ext_attrs.get('Default') == 'Undefined' and |
| 1030 argument.type.id == 'DOMString') | 1034 argument.type.id == 'DOMString') |
| OLD | NEW |