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

Side by Side Diff: Source/bindings/scripts/unstable/v8_types.py

Issue 121113004: Improve handling of failed integer type conversions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Update expected outputs Created 6 years, 11 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
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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 370
371 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index): 371 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index):
372 this_array_or_sequence_type = array_or_sequence_type(idl_type) 372 this_array_or_sequence_type = array_or_sequence_type(idl_type)
373 if this_array_or_sequence_type: 373 if this_array_or_sequence_type:
374 return v8_value_to_cpp_value_array_or_sequence(this_array_or_sequence_ty pe, v8_value, index) 374 return v8_value_to_cpp_value_array_or_sequence(this_array_or_sequence_ty pe, v8_value, index)
375 375
376 idl_type = preprocess_idl_type(idl_type) 376 idl_type = preprocess_idl_type(idl_type)
377 add_includes_for_type(idl_type) 377 add_includes_for_type(idl_type)
378 378
379 if 'EnforceRange' in extended_attributes: 379 if 'EnforceRange' in extended_attributes:
380 arguments = ', '.join([v8_value, 'EnforceRange', 'ok']) 380 arguments = ', '.join([v8_value, 'EnforceRange', 'exceptionState'])
381 else: # NormalConversion 381 else: # NormalConversion
382 arguments = v8_value 382 arguments = v8_value
383 383
384 if idl_type in V8_VALUE_TO_CPP_VALUE: 384 if idl_type in V8_VALUE_TO_CPP_VALUE:
385 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[idl_type] 385 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[idl_type]
386 elif is_typed_array_type(idl_type): 386 elif is_typed_array_type(idl_type):
387 cpp_expression_format = ( 387 cpp_expression_format = (
388 '{v8_value}->Is{idl_type}() ? ' 388 '{v8_value}->Is{idl_type}() ? '
389 'V8{idl_type}::toNative(v8::Handle<v8::{idl_type}>::Cast({v8_value}) ) : 0') 389 'V8{idl_type}::toNative(v8::Handle<v8::{idl_type}>::Cast({v8_value}) ) : 0')
390 else: 390 else:
(...skipping 24 matching lines...) Expand all
415 415
416 416
417 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl e_name, index=None): 417 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl e_name, index=None):
418 """Returns an expression that converts a V8 value to a C++ value and stores it as a local value.""" 418 """Returns an expression that converts a V8 value to a C++ value and stores it as a local value."""
419 this_cpp_type = cpp_type(idl_type, extended_attributes=extended_attributes, used_as_argument=True) 419 this_cpp_type = cpp_type(idl_type, extended_attributes=extended_attributes, used_as_argument=True)
420 420
421 idl_type = preprocess_idl_type(idl_type) 421 idl_type = preprocess_idl_type(idl_type)
422 if idl_type == 'DOMString': 422 if idl_type == 'DOMString':
423 format_string = 'V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID({cpp_type}, {varia ble_name}, {cpp_value})' 423 format_string = 'V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID({cpp_type}, {varia ble_name}, {cpp_value})'
424 elif 'EnforceRange' in extended_attributes: 424 elif 'EnforceRange' in extended_attributes:
425 format_string = 'V8TRYCATCH_WITH_TYPECHECK_VOID({cpp_type}, {variable_na me}, {cpp_value}, info.GetIsolate())' 425 format_string = 'V8TRYCATCH_EXCEPTION_VOID({cpp_type}, {variable_name}, {cpp_value}, exceptionState)'
426 else: 426 else:
427 format_string = 'V8TRYCATCH_VOID({cpp_type}, {variable_name}, {cpp_value })' 427 format_string = 'V8TRYCATCH_VOID({cpp_type}, {variable_name}, {cpp_value })'
428 428
429 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i ndex) 429 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i ndex)
430 return format_string.format(cpp_type=this_cpp_type, cpp_value=cpp_value, var iable_name=variable_name) 430 return format_string.format(cpp_type=this_cpp_type, cpp_value=cpp_value, var iable_name=variable_name)
431 431
432 432
433 ################################################################################ 433 ################################################################################
434 # C++ -> V8 434 # C++ -> V8
435 ################################################################################ 435 ################################################################################
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 575
576 576
577 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea tion_context='', extended_attributes=None): 577 def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', crea tion_context='', extended_attributes=None):
578 """Returns an expression that converts a C++ value to a V8 value.""" 578 """Returns an expression that converts a C++ value to a V8 value."""
579 # the isolate parameter is needed for callback interfaces 579 # the isolate parameter is needed for callback interfaces
580 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext ended_attributes) 580 idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, ext ended_attributes)
581 this_v8_conversion_type = v8_conversion_type(idl_type, extended_attributes) 581 this_v8_conversion_type = v8_conversion_type(idl_type, extended_attributes)
582 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type] 582 format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type]
583 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat ion_context=creation_context) 583 statement = format_string.format(cpp_value=cpp_value, isolate=isolate, creat ion_context=creation_context)
584 return statement 584 return statement
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698