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

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

Issue 608853008: Canvas2D Performance: fix the bottleneck of hasInstance in JS binding -- TypeChecking Interface (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | Source/bindings/scripts/v8_types.py » ('j') | Source/bindings/scripts/v8_types.py » ('J')
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 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), 184 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True),
185 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings], 185 'world_suffixes': ['', 'ForMainWorld'] if 'PerWorldBindings' in extended _attributes else [''], # [PerWorldBindings],
186 } 186 }
187 187
188 188
189 def argument_context(interface, method, argument, index): 189 def argument_context(interface, method, argument, index):
190 extended_attributes = argument.extended_attributes 190 extended_attributes = argument.extended_attributes
191 idl_type = argument.idl_type 191 idl_type = argument.idl_type
192 this_cpp_value = cpp_value(interface, method, index) 192 this_cpp_value = cpp_value(interface, method, index)
193 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type 193 is_variadic_wrapper_type = argument.is_variadic and idl_type.is_wrapper_type
194 type_checking_interface = (has_extended_attribute_value(interface, 'TypeChec king', 'Interface') or has_extended_attribute_value(method, 'TypeChecking', 'Int erface')) and idl_type.is_wrapper_type
Jens Widell 2014/10/02 12:18:14 Please wrap the line (like it used to be wrapped w
194 195
195 if ('ImplementedInPrivateScript' in extended_attributes and 196 if ('ImplementedInPrivateScript' in extended_attributes and
196 not idl_type.is_wrapper_type and 197 not idl_type.is_wrapper_type and
197 not idl_type.is_basic_type): 198 not idl_type.is_basic_type):
198 raise Exception('Private scripts supports only primitive types and DOM w rappers.') 199 raise Exception('Private scripts supports only primitive types and DOM w rappers.')
199 200
200 default_cpp_value = argument.default_cpp_value 201 default_cpp_value = argument.default_cpp_value
201 return { 202 return {
202 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es, 203 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attribut es,
203 raw_type=True, 204 raw_type=True,
204 used_as_variadic_argument=argument.is _variadic), 205 used_as_variadic_argument=argument.is _variadic),
205 'cpp_value': this_cpp_value, 206 'cpp_value': this_cpp_value,
206 # FIXME: check that the default value's type is compatible with the argu ment's 207 # FIXME: check that the default value's type is compatible with the argu ment's
207 'default_value': default_cpp_value, 208 'default_value': default_cpp_value,
208 'enum_validation_expression': idl_type.enum_validation_expression, 209 'enum_validation_expression': idl_type.enum_validation_expression,
209 'handle': '%sHandle' % argument.name, 210 'handle': '%sHandle' % argument.name,
210 # FIXME: remove once [Default] removed and just use argument.default_val ue 211 # FIXME: remove once [Default] removed and just use argument.default_val ue
211 'has_default': 'Default' in extended_attributes or default_cpp_value, 212 'has_default': 'Default' in extended_attributes or default_cpp_value,
212 'has_type_checking_interface': 213 'has_type_checking_interface': type_checking_interface,
haraken 2014/10/02 11:52:56 Can we rename this to needs_type_check ?
213 (has_extended_attribute_value(interface, 'TypeChecking', 'Interface' ) or
214 has_extended_attribute_value(method, 'TypeChecking', 'Interface')) and
215 idl_type.is_wrapper_type,
216 'has_type_checking_unrestricted': 214 'has_type_checking_unrestricted':
217 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or 215 (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestrict ed') or
218 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and 216 has_extended_attribute_value(method, 'TypeChecking', 'Unrestricted' )) and
219 idl_type.name in ('Float', 'Double'), 217 idl_type.name in ('Float', 'Double'),
220 # Dictionary is special-cased, but arrays and sequences shouldn't be 218 # Dictionary is special-cased, but arrays and sequences shouldn't be
221 'idl_type': idl_type.base_type, 219 'idl_type': idl_type.base_type,
222 'idl_type_object': idl_type, 220 'idl_type_object': idl_type,
223 'index': index, 221 'index': index,
224 'is_callback_interface': idl_type.is_callback_interface, 222 'is_callback_interface': idl_type.is_callback_interface,
225 # FIXME: Remove generic 'Dictionary' special-casing 223 # FIXME: Remove generic 'Dictionary' special-casing
226 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictio nary', 224 'is_dictionary': idl_type.is_dictionary or idl_type.base_type == 'Dictio nary',
227 'is_nullable': idl_type.is_nullable, 225 'is_nullable': idl_type.is_nullable,
228 'is_optional': argument.is_optional, 226 'is_optional': argument.is_optional,
229 'is_variadic_wrapper_type': is_variadic_wrapper_type, 227 'is_variadic_wrapper_type': is_variadic_wrapper_type,
230 'is_wrapper_type': idl_type.is_wrapper_type, 228 'is_wrapper_type': idl_type.is_wrapper_type,
231 'name': argument.name, 229 'name': argument.name,
232 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value( 230 'private_script_cpp_value_to_v8_value': idl_type.cpp_value_to_v8_value(
233 argument.name, isolate='scriptState->isolate()', 231 argument.name, isolate='scriptState->isolate()',
234 creation_context='scriptState->context()->Global()'), 232 creation_context='scriptState->context()->Global()'),
235 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value), 233 'v8_set_return_value': v8_set_return_value(interface.name, method, this_ cpp_value),
236 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True), 234 'v8_set_return_value_for_main_world': v8_set_return_value(interface.name , method, this_cpp_value, for_main_world=True),
237 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex, return_promise=method.returns_promise), 235 'v8_value_to_local_cpp_value': v8_value_to_local_cpp_value(argument, ind ex, type_checking_interface, return_promise=method.returns_promise),
238 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc _type), 236 'vector_type': v8_types.cpp_ptr_type('Vector', 'HeapVector', idl_type.gc _type),
239 } 237 }
240 238
241 239
242 def argument_declarations_for_private_script(interface, method): 240 def argument_declarations_for_private_script(interface, method):
243 argument_declarations = ['LocalFrame* frame'] 241 argument_declarations = ['LocalFrame* frame']
244 argument_declarations.append('%s* holderImpl' % interface.name) 242 argument_declarations.append('%s* holderImpl' % interface.name)
245 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args( 243 argument_declarations.extend(['%s %s' % (argument.idl_type.cpp_type_args(
246 used_as_rvalue_type=True), argument.name) for argument in method.argumen ts]) 244 used_as_rvalue_type=True), argument.name) for argument in method.argumen ts])
247 if method.idl_type.name != 'void': 245 if method.idl_type.name != 'void':
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 353
356 if return_promise: 354 if return_promise:
357 suffix += '_PROMISE' 355 suffix += '_PROMISE'
358 macro_args.extend(['info', 'ScriptState::current(info.GetIsolate())']) 356 macro_args.extend(['info', 'ScriptState::current(info.GetIsolate())'])
359 357
360 suffix += '_INTERNAL' 358 suffix += '_INTERNAL'
361 359
362 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args)) 360 return '%s%s(%s)' % (macro, suffix, ', '.join(macro_args))
363 361
364 362
365 def v8_value_to_local_cpp_value(argument, index, return_promise=False): 363 def v8_value_to_local_cpp_value(argument, index, type_checked, return_promise=Fa lse):
366 extended_attributes = argument.extended_attributes 364 extended_attributes = argument.extended_attributes
367 idl_type = argument.idl_type 365 idl_type = argument.idl_type
368 name = argument.name 366 name = argument.name
369 if argument.is_variadic: 367 if argument.is_variadic:
370 return v8_value_to_local_cpp_variadic_value(argument, index, return_prom ise) 368 return v8_value_to_local_cpp_variadic_value(argument, index, return_prom ise)
371 return idl_type.v8_value_to_local_cpp_value(extended_attributes, 'info[%s]' % index, 369 return idl_type.v8_value_to_local_cpp_value(extended_attributes, 'info[%s]' % index,
372 name, index=index, declare_varia ble=False, return_promise=return_promise) 370 name, type_checked, index=index, declare_variable=False, return_promise=return_promise)
Jens Widell 2014/10/02 12:18:14 Please pass the new argument as a keyword argument
373 371
374 372
375 ################################################################################ 373 ################################################################################
376 # Auxiliary functions 374 # Auxiliary functions
377 ################################################################################ 375 ################################################################################
378 376
379 # [NotEnumerable] 377 # [NotEnumerable]
380 def property_attributes(method): 378 def property_attributes(method):
381 extended_attributes = method.extended_attributes 379 extended_attributes = method.extended_attributes
382 property_attributes_list = [] 380 property_attributes_list = []
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 439
442 IdlOperation.returns_promise = property(method_returns_promise) 440 IdlOperation.returns_promise = property(method_returns_promise)
443 441
444 442
445 def argument_conversion_needs_exception_state(method, argument): 443 def argument_conversion_needs_exception_state(method, argument):
446 idl_type = argument.idl_type 444 idl_type = argument.idl_type
447 return (idl_type.v8_conversion_needs_exception_state or 445 return (idl_type.v8_conversion_needs_exception_state or
448 argument.is_variadic or 446 argument.is_variadic or
449 (method.returns_promise and (idl_type.is_string_type or 447 (method.returns_promise and (idl_type.is_string_type or
450 idl_type.is_enum))) 448 idl_type.is_enum)))
OLDNEW
« no previous file with comments | « no previous file | Source/bindings/scripts/v8_types.py » ('j') | Source/bindings/scripts/v8_types.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698