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

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

Issue 680193003: IDL: Generate union type containers (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 1 month 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
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 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 for constructor in constructors) 1037 for constructor in constructors)
1038 1038
1039 1039
1040 ################################################################################ 1040 ################################################################################
1041 # Special operations (methods) 1041 # Special operations (methods)
1042 # http://heycam.github.io/webidl/#idl-special-operations 1042 # http://heycam.github.io/webidl/#idl-special-operations
1043 ################################################################################ 1043 ################################################################################
1044 1044
1045 def property_getter(getter, cpp_arguments): 1045 def property_getter(getter, cpp_arguments):
1046 def is_null_expression(idl_type): 1046 def is_null_expression(idl_type):
1047 if idl_type.is_union_type: 1047 if v8_methods.use_output_parameter_for_result(idl_type):
1048 notnull = ' || '.join([ 1048 return 'result.isNull()'
1049 member_argument['null_check_value']
1050 for member_argument in idl_type.union_arguments])
1051 return '!(%s)' % notnull
1052 if idl_type.name == 'String': 1049 if idl_type.name == 'String':
1053 return 'result.isNull()' 1050 return 'result.isNull()'
1054 if idl_type.is_interface_type: 1051 if idl_type.is_interface_type:
1055 return '!result' 1052 return '!result'
1056 return '' 1053 return ''
1057 1054
1058 idl_type = getter.idl_type 1055 idl_type = getter.idl_type
1059 extended_attributes = getter.extended_attributes 1056 extended_attributes = getter.extended_attributes
1060 is_raises_exception = 'RaisesException' in extended_attributes 1057 is_raises_exception = 'RaisesException' in extended_attributes
1058 use_output_parameter_for_result = v8_methods.use_output_parameter_for_result (idl_type)
1061 1059
1062 # FIXME: make more generic, so can use v8_methods.cpp_value 1060 # FIXME: make more generic, so can use v8_methods.cpp_value
1063 cpp_method_name = 'impl->%s' % cpp_name(getter) 1061 cpp_method_name = 'impl->%s' % cpp_name(getter)
1064 1062
1065 if is_raises_exception: 1063 if is_raises_exception:
1066 cpp_arguments.append('exceptionState') 1064 cpp_arguments.append('exceptionState')
1067 union_arguments = idl_type.union_arguments 1065 if use_output_parameter_for_result:
1068 if union_arguments: 1066 cpp_arguments.append('result')
1069 cpp_arguments.extend([member_argument['cpp_value']
1070 for member_argument in union_arguments])
1071 1067
1072 cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) 1068 cpp_value = '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
1073 1069
1074 return { 1070 return {
1075 'cpp_type': idl_type.cpp_type, 1071 'cpp_type': idl_type.cpp_type,
1076 'cpp_value': cpp_value, 1072 'cpp_value': cpp_value,
1077 'is_custom': 1073 'is_custom':
1078 'Custom' in extended_attributes and 1074 'Custom' in extended_attributes and
1079 (not extended_attributes['Custom'] or 1075 (not extended_attributes['Custom'] or
1080 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')), 1076 has_extended_attribute_value(getter, 'Custom', 'PropertyGetter')),
1081 'is_custom_property_enumerator': has_extended_attribute_value( 1077 'is_custom_property_enumerator': has_extended_attribute_value(
1082 getter, 'Custom', 'PropertyEnumerator'), 1078 getter, 'Custom', 'PropertyEnumerator'),
1083 'is_custom_property_query': has_extended_attribute_value( 1079 'is_custom_property_query': has_extended_attribute_value(
1084 getter, 'Custom', 'PropertyQuery'), 1080 getter, 'Custom', 'PropertyQuery'),
1085 'is_enumerable': 'NotEnumerable' not in extended_attributes, 1081 'is_enumerable': 'NotEnumerable' not in extended_attributes,
1086 'is_null_expression': is_null_expression(idl_type), 1082 'is_null_expression': is_null_expression(idl_type),
1087 'is_raises_exception': is_raises_exception, 1083 'is_raises_exception': is_raises_exception,
1088 'name': cpp_name(getter), 1084 'name': cpp_name(getter),
1089 'union_arguments': union_arguments, 1085 'use_output_parameter_for_result': use_output_parameter_for_result,
1090 'v8_set_return_value': idl_type.v8_set_return_value('result', extended_a ttributes=extended_attributes, script_wrappable='impl', release=idl_type.release ), 1086 'v8_set_return_value': idl_type.v8_set_return_value('result', extended_a ttributes=extended_attributes, script_wrappable='impl', release=idl_type.release ),
1091 } 1087 }
1092 1088
1093 1089
1094 def property_setter(setter): 1090 def property_setter(setter):
1095 idl_type = setter.arguments[1].idl_type 1091 idl_type = setter.arguments[1].idl_type
1096 extended_attributes = setter.extended_attributes 1092 extended_attributes = setter.extended_attributes
1097 is_raises_exception = 'RaisesException' in extended_attributes 1093 is_raises_exception = 'RaisesException' in extended_attributes
1098 return { 1094 return {
1099 'has_type_checking_interface': 1095 'has_type_checking_interface':
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 deleter = next( 1218 deleter = next(
1223 method 1219 method
1224 for method in interface.operations 1220 for method in interface.operations
1225 if ('deleter' in method.specials and 1221 if ('deleter' in method.specials and
1226 len(method.arguments) == 1 and 1222 len(method.arguments) == 1 and
1227 str(method.arguments[0].idl_type) == 'DOMString')) 1223 str(method.arguments[0].idl_type) == 'DOMString'))
1228 except StopIteration: 1224 except StopIteration:
1229 return None 1225 return None
1230 1226
1231 return property_deleter(deleter) 1227 return property_deleter(deleter)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698