Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tools/dom/scripts/systemnative.py

Issue 14190019: Allow null assignments if there is a corresponding marker. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 ' return;\n', 725 ' return;\n',
726 INDEX=len(arguments) + 1) 726 INDEX=len(arguments) + 1)
727 727
728 # Emit arguments. 728 # Emit arguments.
729 start_index = 1 if needs_receiver else 0 729 start_index = 1 if needs_receiver else 0
730 for i, argument in enumerate(arguments): 730 for i, argument in enumerate(arguments):
731 type_info = self._TypeInfo(argument.type.id) 731 type_info = self._TypeInfo(argument.type.id)
732 argument_expression_template, type, cls, function = \ 732 argument_expression_template, type, cls, function = \
733 type_info.to_native_info(argument, self._interface.id) 733 type_info.to_native_info(argument, self._interface.id)
734 734
735 if (isinstance(argument, IDLArgument) and ( 735 def AllowsNull():
736 (IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node, argument)) or 736 assert argument.ext_attrs.get('TreatNullAs', 'NullString') == 'NullStrin g'
737 (argument.ext_attrs.get('Default') == 'NullString') or 737 if argument.ext_attrs.get('TreatNullAs') == 'NullString':
738 _IsOptionalStringArgumentInInitEventMethod(self._interface, node, arg ument))): 738 return True
739
740 if isinstance(argument, IDLArgument):
741 if IsOptional(argument) and not self._IsArgumentOptionalInWebCore(node , argument):
742 return True
743 if argument.ext_attrs.get('Default') == 'NullString':
744 return True
745 if _IsOptionalStringArgumentInInitEventMethod(self._interface, node, a rgument):
746 return True
747
748 return False
749
750 if AllowsNull():
739 function += 'WithNullCheck' 751 function += 'WithNullCheck'
740 752
741 argument_name = DartDomNameOfAttribute(argument) 753 argument_name = DartDomNameOfAttribute(argument)
742 if type_info.pass_native_by_ref(): 754 if type_info.pass_native_by_ref():
743 invocation_template =\ 755 invocation_template =\
744 ' $TYPE $ARGUMENT_NAME;\n'\ 756 ' $TYPE $ARGUMENT_NAME;\n'\
745 ' $CLS::$FUNCTION(Dart_GetNativeArgument(args, $INDEX), $ARGU MENT_NAME, exception);\n' 757 ' $CLS::$FUNCTION(Dart_GetNativeArgument(args, $INDEX), $ARGU MENT_NAME, exception);\n'
746 else: 758 else:
747 invocation_template =\ 759 invocation_template =\
748 ' $TYPE $ARGUMENT_NAME = $CLS::$FUNCTION(Dart_GetNativeArgume nt(args, $INDEX), exception);\n' 760 ' $TYPE $ARGUMENT_NAME = $CLS::$FUNCTION(Dart_GetNativeArgume nt(args, $INDEX), exception);\n'
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n' 942 ' if (Dart_NativeFunction func = $CLASS_NAME::resolver(name, argu mentCount))\n'
931 ' return func;\n', 943 ' return func;\n',
932 CLASS_NAME=os.path.splitext(os.path.basename(path))[0]) 944 CLASS_NAME=os.path.splitext(os.path.basename(path))[0])
933 945
934 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument): 946 def _IsOptionalStringArgumentInInitEventMethod(interface, operation, argument):
935 return ( 947 return (
936 interface.id.endswith('Event') and 948 interface.id.endswith('Event') and
937 operation.id.startswith('init') and 949 operation.id.startswith('init') and
938 argument.ext_attrs.get('Default') == 'Undefined' and 950 argument.ext_attrs.get('Default') == 'Undefined' and
939 argument.type.id == 'DOMString') 951 argument.type.id == 'DOMString')
OLDNEW
« tests/html/input_element_test.dart ('K') | « tests/html/input_element_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698