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

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

Issue 556893002: Move IdlType.may_raise_exception_on_conversion to v8_types.py (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | no next file » | 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 'EventTarget': 'V8DOMWrapper::isDOMWrapper({v8_value}) ? toWrapperTypeInfo(v 8::Handle<v8::Object>::Cast({v8_value}))->toEventTarget(v8::Handle<v8::Object>:: Cast({v8_value})) : 0', 466 'EventTarget': 'V8DOMWrapper::isDOMWrapper({v8_value}) ? toWrapperTypeInfo(v 8::Handle<v8::Object>::Cast({v8_value}))->toEventTarget(v8::Handle<v8::Object>:: Cast({v8_value})) : 0',
467 'NodeFilter': 'toNodeFilter({v8_value}, info.Holder(), ScriptState::current( {isolate}))', 467 'NodeFilter': 'toNodeFilter({v8_value}, info.Holder(), ScriptState::current( {isolate}))',
468 'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value}) ', 468 'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value}) ',
469 'SerializedScriptValue': 'SerializedScriptValue::create({v8_value}, {isolate })', 469 'SerializedScriptValue': 'SerializedScriptValue::create({v8_value}, {isolate })',
470 'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})', 470 'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})',
471 'Window': 'toDOMWindow({v8_value}, {isolate})', 471 'Window': 'toDOMWindow({v8_value}, {isolate})',
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):
477 return (idl_type.is_integer_type or
478 idl_type.name in ('ByteString', 'ScalarValueString'))
479
480 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep tion_state)
481
482
476 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat e): 483 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat e):
477 if idl_type.name == 'void': 484 if idl_type.name == 'void':
478 return '' 485 return ''
479 486
480 # Array or sequence types 487 # Array or sequence types
481 native_array_element_type = idl_type.native_array_element_type 488 native_array_element_type = idl_type.native_array_element_type
482 if native_array_element_type: 489 if native_array_element_type:
483 return v8_value_to_cpp_value_array_or_sequence(native_array_element_type , v8_value, index) 490 return v8_value_to_cpp_value_array_or_sequence(native_array_element_type , v8_value, index)
484 491
485 # Simple types 492 # Simple types
486 idl_type = idl_type.preprocessed_type 493 idl_type = idl_type.preprocessed_type
487 add_includes_for_type(idl_type) 494 add_includes_for_type(idl_type)
488 base_idl_type = idl_type.base_type 495 base_idl_type = idl_type.base_type
489 496
490 if 'EnforceRange' in extended_attributes: 497 if 'EnforceRange' in extended_attributes:
491 arguments = ', '.join([v8_value, 'EnforceRange', 'exceptionState']) 498 arguments = ', '.join([v8_value, 'EnforceRange', 'exceptionState'])
492 elif idl_type.may_raise_exception_on_conversion: 499 elif idl_type.v8_conversion_needs_exception_state:
493 arguments = ', '.join([v8_value, 'exceptionState']) 500 arguments = ', '.join([v8_value, 'exceptionState'])
494 else: 501 else:
495 arguments = v8_value 502 arguments = v8_value
496 503
497 if base_idl_type in V8_VALUE_TO_CPP_VALUE: 504 if base_idl_type in V8_VALUE_TO_CPP_VALUE:
498 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type] 505 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type]
499 elif idl_type.is_typed_array_element_type: 506 elif idl_type.is_typed_array_element_type:
500 cpp_expression_format = ( 507 cpp_expression_format = (
501 '{v8_value}->Is{idl_type}() ? ' 508 '{v8_value}->Is{idl_type}() ? '
502 'V8{idl_type}::toImpl(v8::Handle<v8::{idl_type}>::Cast({v8_value})) : 0') 509 'V8{idl_type}::toImpl(v8::Handle<v8::{idl_type}>::Cast({v8_value})) : 0')
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
537 if idl_type.is_union_type: 544 if idl_type.is_union_type:
538 return '' 545 return ''
539 546
540 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut es, raw_type=True) 547 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut es, raw_type=True)
541 548
542 idl_type = idl_type.preprocessed_type 549 idl_type = idl_type.preprocessed_type
543 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i ndex, isolate) 550 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, i ndex, isolate)
544 args = [variable_name, cpp_value] 551 args = [variable_name, cpp_value]
545 if idl_type.base_type == 'DOMString': 552 if idl_type.base_type == 'DOMString':
546 macro = 'TOSTRING_DEFAULT' if used_in_private_script else 'TOSTRING_VOID ' 553 macro = 'TOSTRING_DEFAULT' if used_in_private_script else 'TOSTRING_VOID '
547 elif idl_type.may_raise_exception_on_conversion: 554 elif idl_type.v8_conversion_needs_exception_state:
548 macro = 'TONATIVE_DEFAULT_EXCEPTIONSTATE' if used_in_private_script else 'TONATIVE_VOID_EXCEPTIONSTATE' 555 macro = 'TONATIVE_DEFAULT_EXCEPTIONSTATE' if used_in_private_script else 'TONATIVE_VOID_EXCEPTIONSTATE'
549 args.append('exceptionState') 556 args.append('exceptionState')
550 else: 557 else:
551 macro = 'TONATIVE_DEFAULT' if used_in_private_script else 'TONATIVE_VOID ' 558 macro = 'TONATIVE_DEFAULT' if used_in_private_script else 'TONATIVE_VOID '
552 559
553 if used_in_private_script: 560 if used_in_private_script:
554 args.append('false') 561 args.append('false')
555 562
556 # Macros come in several variants, to minimize expensive creation of 563 # Macros come in several variants, to minimize expensive creation of
557 # v8::TryCatch. 564 # v8::TryCatch.
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 819
813 820
814 def is_explicit_nullable(idl_type): 821 def is_explicit_nullable(idl_type):
815 # Nullable type that isn't implicit nullable (see above.) For such types, 822 # Nullable type that isn't implicit nullable (see above.) For such types,
816 # we use Nullable<T> or similar explicit ways to represent a null value. 823 # we use Nullable<T> or similar explicit ways to represent a null value.
817 return idl_type.is_nullable and not idl_type.is_implicit_nullable 824 return idl_type.is_nullable and not idl_type.is_implicit_nullable
818 825
819 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) 826 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable)
820 IdlUnionType.is_implicit_nullable = False 827 IdlUnionType.is_implicit_nullable = False
821 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) 828 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable)
OLDNEW
« no previous file with comments | « Source/bindings/scripts/v8_methods.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698