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

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

Issue 555133003: Use ExceptionState to throw exceptions when converting arrays (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebased Created 6 years, 3 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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 'XPathNSResolver': 'toXPathNSResolver({v8_value}, {isolate})', 472 'XPathNSResolver': 'toXPathNSResolver({v8_value}, {isolate})',
473 } 473 }
474 474
475 475
476 def v8_conversion_needs_exception_state(idl_type): 476 def v8_conversion_needs_exception_state(idl_type):
477 return (idl_type.is_numeric_type or 477 return (idl_type.is_numeric_type or
478 idl_type.is_dictionary or 478 idl_type.is_dictionary or
479 idl_type.name in ('ByteString', 'ScalarValueString')) 479 idl_type.name in ('ByteString', 'ScalarValueString'))
480 480
481 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep tion_state) 481 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep tion_state)
482 IdlArrayOrSequenceType.v8_conversion_needs_exception_state = True
482 483
483 484
484 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat e): 485 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat e):
485 if idl_type.name == 'void': 486 if idl_type.name == 'void':
486 return '' 487 return ''
487 488
488 # Array or sequence types 489 # Array or sequence types
489 native_array_element_type = idl_type.native_array_element_type 490 native_array_element_type = idl_type.native_array_element_type
490 if native_array_element_type: 491 if native_array_element_type:
491 return v8_value_to_cpp_value_array_or_sequence(native_array_element_type , v8_value, index) 492 return v8_value_to_cpp_value_array_or_sequence(native_array_element_type , v8_value, index)
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 # Index is None for setters, index (starting at 0) for method arguments, 524 # Index is None for setters, index (starting at 0) for method arguments,
524 # and is used to provide a human-readable exception message 525 # and is used to provide a human-readable exception message
525 if index is None: 526 if index is None:
526 index = 0 # special case, meaning "setter" 527 index = 0 # special case, meaning "setter"
527 else: 528 else:
528 index += 1 # human-readable index 529 index += 1 # human-readable index
529 if (native_array_element_type.is_interface_type and 530 if (native_array_element_type.is_interface_type and
530 native_array_element_type.name != 'Dictionary'): 531 native_array_element_type.name != 'Dictionary'):
531 this_cpp_type = None 532 this_cpp_type = None
532 ref_ptr_type = cpp_ptr_type('RefPtr', 'Member', native_array_element_typ e.gc_type) 533 ref_ptr_type = cpp_ptr_type('RefPtr', 'Member', native_array_element_typ e.gc_type)
533 expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_ type}, V8{native_array_element_type}>({v8_value}, {index}, {isolate}))' 534 expression_format = '(to{ref_ptr_type}NativeArray<{native_array_element_ type}, V8{native_array_element_type}>({v8_value}, {index}, {isolate}, exceptionS tate))'
534 add_includes_for_type(native_array_element_type) 535 add_includes_for_type(native_array_element_type)
535 else: 536 else:
536 ref_ptr_type = None 537 ref_ptr_type = None
537 this_cpp_type = native_array_element_type.cpp_type 538 this_cpp_type = native_array_element_type.cpp_type
538 expression_format = 'toImplArray<{cpp_type}>({v8_value}, {index}, {isola te})' 539 expression_format = 'toImplArray<{cpp_type}>({v8_value}, {index}, {isola te}, exceptionState)'
539 expression = expression_format.format(native_array_element_type=native_array _element_type.name, cpp_type=this_cpp_type, index=index, ref_ptr_type=ref_ptr_ty pe, v8_value=v8_value, isolate=isolate) 540 expression = expression_format.format(native_array_element_type=native_array _element_type.name, cpp_type=this_cpp_type, index=index, ref_ptr_type=ref_ptr_ty pe, v8_value=v8_value, isolate=isolate)
540 return expression 541 return expression
541 542
542 543
543 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl e_name, index=None, declare_variable=True, isolate='info.GetIsolate()', used_in_ private_script=False, return_promise=False): 544 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl e_name, index=None, declare_variable=True, isolate='info.GetIsolate()', used_in_ private_script=False, return_promise=False):
544 """Returns an expression that converts a V8 value to a C++ value and stores it as a local value.""" 545 """Returns an expression that converts a V8 value to a C++ value and stores it as a local value."""
545 546
546 # FIXME: Support union type. 547 # FIXME: Support union type.
547 if idl_type.is_union_type: 548 if idl_type.is_union_type:
548 return '' 549 return ''
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 824
824 825
825 def is_explicit_nullable(idl_type): 826 def is_explicit_nullable(idl_type):
826 # Nullable type that isn't implicit nullable (see above.) For such types, 827 # Nullable type that isn't implicit nullable (see above.) For such types,
827 # we use Nullable<T> or similar explicit ways to represent a null value. 828 # we use Nullable<T> or similar explicit ways to represent a null value.
828 return idl_type.is_nullable and not idl_type.is_implicit_nullable 829 return idl_type.is_nullable and not idl_type.is_implicit_nullable
829 830
830 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) 831 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable)
831 IdlUnionType.is_implicit_nullable = False 832 IdlUnionType.is_implicit_nullable = False
832 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) 833 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698