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

Side by Side Diff: Source/bindings/scripts/v8_interface.py

Issue 466323002: IDL: Use Nullable for union type return value (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « Source/bindings/core/v8/Nullable.h ('k') | Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (C) 2013 Google Inc. All rights reserved. 1 # Copyright (C) 2013 Google Inc. All rights reserved.
2 # coding=utf-8 2 # coding=utf-8
3 # 3 #
4 # Redistribution and use in source and binary forms, with or without 4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are 5 # modification, are permitted provided that the following conditions are
6 # met: 6 # met:
7 # 7 #
8 # * Redistributions of source code must retain the above copyright 8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer. 9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above 10 # * Redistributions in binary form must reproduce the above
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 927
928 928
929 ################################################################################ 929 ################################################################################
930 # Special operations (methods) 930 # Special operations (methods)
931 # http://heycam.github.io/webidl/#idl-special-operations 931 # http://heycam.github.io/webidl/#idl-special-operations
932 ################################################################################ 932 ################################################################################
933 933
934 def property_getter(getter, cpp_arguments): 934 def property_getter(getter, cpp_arguments):
935 def is_null_expression(idl_type): 935 def is_null_expression(idl_type):
936 if idl_type.is_union_type: 936 if idl_type.is_union_type:
937 return ' && '.join('!result%sEnabled' % i 937 notnull = ' || '.join([
938 for i, _ in enumerate(idl_type.member_types)) 938 member_argument['null_check_value']
939 for member_argument in idl_type.union_arguments])
940 return '!(%s)' % notnull
939 if idl_type.name == 'String': 941 if idl_type.name == 'String':
940 return 'result.isNull()' 942 return 'result.isNull()'
941 if idl_type.is_interface_type: 943 if idl_type.is_interface_type:
942 return '!result' 944 return '!result'
943 return '' 945 return ''
944 946
945 idl_type = getter.idl_type 947 idl_type = getter.idl_type
946 extended_attributes = getter.extended_attributes 948 extended_attributes = getter.extended_attributes
947 is_raises_exception = 'RaisesException' in extended_attributes 949 is_raises_exception = 'RaisesException' in extended_attributes
948 950
949 # FIXME: make more generic, so can use v8_methods.cpp_value 951 # FIXME: make more generic, so can use v8_methods.cpp_value
950 cpp_method_name = 'impl->%s' % cpp_name(getter) 952 cpp_method_name = 'impl->%s' % cpp_name(getter)
951 953
952 if is_raises_exception: 954 if is_raises_exception:
953 cpp_arguments.append('exceptionState') 955 cpp_arguments.append('exceptionState')
954 union_arguments = idl_type.union_arguments 956 union_arguments = idl_type.union_arguments
955 if union_arguments: 957 if union_arguments:
956 cpp_arguments.extend(union_arguments) 958 cpp_arguments.extend([member_argument['cpp_value']
959 for member_argument in union_arguments])
957 960
958 cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) 961 cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
959 962
960 return { 963 return {
961 'cpp_type': idl_type.cpp_type, 964 'cpp_type': idl_type.cpp_type,
962 'cpp_value': cpp_value, 965 'cpp_value': cpp_value,
963 'is_custom': 966 'is_custom':
964 'Custom' in extended_attributes and 967 'Custom' in extended_attributes and
965 (not extended_attributes['Custom'] or 968 (not extended_attributes['Custom'] or
966 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')), 969 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')),
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 deleter = next( 1111 deleter = next(
1109 method 1112 method
1110 for method in interface.operations 1113 for method in interface.operations
1111 if ('deleter' in method.specials and 1114 if ('deleter' in method.specials and
1112 len(method.arguments) == 1 and 1115 len(method.arguments) == 1 and
1113 str(method.arguments[0].idl_type) == 'DOMString')) 1116 str(method.arguments[0].idl_type) == 'DOMString'))
1114 except StopIteration: 1117 except StopIteration:
1115 return None 1118 return None
1116 1119
1117 return property_deleter(deleter) 1120 return property_deleter(deleter)
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/Nullable.h ('k') | Source/bindings/scripts/v8_methods.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698