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

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

Issue 229373006: Support optional, non-defaulted constructor arguments. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Formatting Created 6 years, 8 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/scripts/v8_interface.py ('k') | Source/bindings/scripts/v8_utilities.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 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 this_cpp_value = cpp_value(interface, method, index) 150 this_cpp_value = cpp_value(interface, method, index)
151 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type 151 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type
152 return { 152 return {
153 'cpp_type': idl_type.cpp_type_args(used_in_cpp_sequence=is_variadic_wrap per_type), 153 'cpp_type': idl_type.cpp_type_args(used_in_cpp_sequence=is_variadic_wrap per_type),
154 'cpp_value': this_cpp_value, 154 'cpp_value': this_cpp_value,
155 'enum_validation_expression': idl_type.enum_validation_expression, 155 'enum_validation_expression': idl_type.enum_validation_expression,
156 'has_default': 'Default' in extended_attributes, 156 'has_default': 'Default' in extended_attributes,
157 'has_event_listener_argument': any( 157 'has_event_listener_argument': any(
158 argument_so_far for argument_so_far in method.arguments[:index] 158 argument_so_far for argument_so_far in method.arguments[:index]
159 if argument_so_far.idl_type.name == 'EventListener'), 159 if argument_so_far.idl_type.name == 'EventListener'),
160 'idl_type_object': idl_type,
161 # Dictionary is special-cased, but arrays and sequences shouldn't be 160 # Dictionary is special-cased, but arrays and sequences shouldn't be
162 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type, 161 'idl_type': not idl_type.array_or_sequence_type and idl_type.base_type,
162 'idl_type_object': idl_type,
163 'index': index, 163 'index': index,
164 'is_clamp': 'Clamp' in extended_attributes, 164 'is_clamp': 'Clamp' in extended_attributes,
165 'is_callback_interface': idl_type.is_callback_interface, 165 'is_callback_interface': idl_type.is_callback_interface,
166 'is_nullable': idl_type.is_nullable, 166 'is_nullable': idl_type.is_nullable,
167 'is_optional': argument.is_optional, 167 'is_optional': argument.is_optional,
168 'is_strict_type_checking': 'StrictTypeChecking' in extended_attributes, 168 'is_strict_type_checking': 'StrictTypeChecking' in extended_attributes,
169 'is_variadic_wrapper_type': is_variadic_wrapper_type, 169 'is_variadic_wrapper_type': is_variadic_wrapper_type,
170 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.ga rbage_collection_type), 170 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.ga rbage_collection_type),
171 'is_wrapper_type': idl_type.is_wrapper_type, 171 'is_wrapper_type': idl_type.is_wrapper_type,
172 'name': argument.name, 172 'name': argument.name,
(...skipping 26 matching lines...) Expand all
199 # Truncate omitted optional arguments 199 # Truncate omitted optional arguments
200 arguments = method.arguments[:number_of_arguments] 200 arguments = method.arguments[:number_of_arguments]
201 cpp_arguments = v8_utilities.call_with_arguments(method) 201 cpp_arguments = v8_utilities.call_with_arguments(method)
202 # Members of IDL partial interface definitions are implemented in C++ as 202 # Members of IDL partial interface definitions are implemented in C++ as
203 # static member functions, which for instance members (non-static members) 203 # static member functions, which for instance members (non-static members)
204 # take *impl as their first argument 204 # take *impl as their first argument
205 if ('PartialInterfaceImplementedAs' in method.extended_attributes and 205 if ('PartialInterfaceImplementedAs' in method.extended_attributes and
206 not method.is_static): 206 not method.is_static):
207 cpp_arguments.append('*impl') 207 cpp_arguments.append('*impl')
208 cpp_arguments.extend(cpp_argument(argument) for argument in arguments) 208 cpp_arguments.extend(cpp_argument(argument) for argument in arguments)
209 this_union_arguments = method.idl_type.union_arguments 209 this_union_arguments = method.idl_type and method.idl_type.union_arguments
210 if this_union_arguments: 210 if this_union_arguments:
211 cpp_arguments.extend(this_union_arguments) 211 cpp_arguments.extend(this_union_arguments)
212 212
213 if 'RaisesException' in method.extended_attributes: 213 if 'RaisesException' in method.extended_attributes:
214 cpp_arguments.append('exceptionState') 214 cpp_arguments.append('exceptionState')
215 215
216 cpp_method_name = v8_utilities.scoped_name(interface, method, v8_utilities.c pp_name(method)) 216 if method.name == 'Constructor':
217 base_name = 'create'
218 elif method.name == 'NamedConstructor':
219 base_name = 'createForJSConstructor'
220 else:
221 base_name = v8_utilities.cpp_name(method)
222
223 cpp_method_name = v8_utilities.scoped_name(interface, method, base_name)
217 return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments)) 224 return '%s(%s)' % (cpp_method_name, ', '.join(cpp_arguments))
218 225
219 226
220 def v8_set_return_value(interface_name, method, cpp_value, for_main_world=False) : 227 def v8_set_return_value(interface_name, method, cpp_value, for_main_world=False) :
221 idl_type = method.idl_type 228 idl_type = method.idl_type
222 extended_attributes = method.extended_attributes 229 extended_attributes = method.extended_attributes
223 if idl_type.name == 'void': 230 if idl_type.name == 'void':
224 return None 231 return None
225 232
226 release = False 233 release = False
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 279
273 280
274 def union_arguments(idl_type): 281 def union_arguments(idl_type):
275 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value""" 282 """Return list of ['result0Enabled', 'result0', 'result1Enabled', ...] for u nion types, for use in setting return value"""
276 return [arg 283 return [arg
277 for i in range(len(idl_type.member_types)) 284 for i in range(len(idl_type.member_types))
278 for arg in ['result%sEnabled' % i, 'result%s' % i]] 285 for arg in ['result%sEnabled' % i, 'result%s' % i]]
279 286
280 IdlType.union_arguments = property(lambda self: None) 287 IdlType.union_arguments = property(lambda self: None)
281 IdlUnionType.union_arguments = property(union_arguments) 288 IdlUnionType.union_arguments = property(union_arguments)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/scripts/v8_utilities.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698