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

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

Issue 2725673002: WIP bindings: Expand usage of NativeValueTraits. (Closed)
Patch Set: Created 3 years, 9 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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 bool, True if idl_type's raw/primitive C++ type should be returned. 138 bool, True if idl_type's raw/primitive C++ type should be returned.
139 used_as_rvalue_type: 139 used_as_rvalue_type:
140 bool, True if the C++ type is used as an argument or the return 140 bool, True if the C++ type is used as an argument or the return
141 type of a method. 141 type of a method.
142 used_as_variadic_argument: 142 used_as_variadic_argument:
143 bool, True if the C++ type is used as a variadic argument of a metho d. 143 bool, True if the C++ type is used as a variadic argument of a metho d.
144 used_in_cpp_sequence: 144 used_in_cpp_sequence:
145 bool, True if the C++ type is used as an element of a container. 145 bool, True if the C++ type is used as an element of a container.
146 Containers can be an array, a sequence or a dictionary. 146 Containers can be an array, a sequence or a dictionary.
147 """ 147 """
148 def string_mode():
149 if idl_type.is_nullable:
150 return 'TreatNullAndUndefinedAsNullString'
151 if extended_attributes.get('TreatNullAs') == 'EmptyString':
152 return 'TreatNullAsEmptyString'
153 if extended_attributes.get('TreatNullAs') == 'NullString':
154 return 'TreatNullAsNullString'
155 return ''
156
157 extended_attributes = extended_attributes or {} 148 extended_attributes = extended_attributes or {}
158 idl_type = idl_type.preprocessed_type 149 idl_type = idl_type.preprocessed_type
159 150
160 # Array or sequence types 151 # Array or sequence types
161 if used_as_variadic_argument: 152 if used_as_variadic_argument:
162 native_array_element_type = idl_type 153 native_array_element_type = idl_type
163 else: 154 else:
164 native_array_element_type = idl_type.native_array_element_type 155 native_array_element_type = idl_type.native_array_element_type
165 if native_array_element_type: 156 if native_array_element_type:
166 vector_type = cpp_ptr_type('Vector', 'HeapVector', native_array_element_ type.is_gc_type) 157 vector_type = cpp_ptr_type('Vector', 'HeapVector', native_array_element_ type.is_gc_type)
(...skipping 12 matching lines...) Expand all
179 if base_idl_type in CPP_UNSIGNED_TYPES: 170 if base_idl_type in CPP_UNSIGNED_TYPES:
180 return 'unsigned' 171 return 'unsigned'
181 if base_idl_type in CPP_SPECIAL_CONVERSION_RULES: 172 if base_idl_type in CPP_SPECIAL_CONVERSION_RULES:
182 return CPP_SPECIAL_CONVERSION_RULES[base_idl_type] 173 return CPP_SPECIAL_CONVERSION_RULES[base_idl_type]
183 174
184 if base_idl_type == 'SerializedScriptValue': 175 if base_idl_type == 'SerializedScriptValue':
185 return ('PassRefPtr<%s>' if used_as_rvalue_type else 'RefPtr<%s>') % bas e_idl_type 176 return ('PassRefPtr<%s>' if used_as_rvalue_type else 'RefPtr<%s>') % bas e_idl_type
186 if idl_type.is_string_type: 177 if idl_type.is_string_type:
187 if not raw_type: 178 if not raw_type:
188 return 'String' 179 return 'String'
189 return 'V8StringResource<%s>' % string_mode() 180 return 'V8StringResource<>'
190 181
191 if base_idl_type == 'ArrayBufferView' and 'FlexibleArrayBufferView' in exten ded_attributes: 182 if base_idl_type == 'ArrayBufferView' and 'FlexibleArrayBufferView' in exten ded_attributes:
192 return 'FlexibleArrayBufferView' 183 return 'FlexibleArrayBufferView'
193 if base_idl_type in TYPED_ARRAY_TYPES and 'FlexibleArrayBufferView' in exten ded_attributes: 184 if base_idl_type in TYPED_ARRAY_TYPES and 'FlexibleArrayBufferView' in exten ded_attributes:
194 return 'Flexible' + base_idl_type + 'View' 185 return 'Flexible' + base_idl_type + 'View'
195 if idl_type.is_interface_type: 186 if idl_type.is_interface_type:
196 implemented_as_class = idl_type.implemented_as 187 implemented_as_class = idl_type.implemented_as
197 if raw_type or (used_as_rvalue_type and idl_type.is_garbage_collected) o r not used_in_cpp_sequence: 188 if raw_type or (used_as_rvalue_type and idl_type.is_garbage_collected) o r not used_in_cpp_sequence:
198 return implemented_as_class + '*' 189 return implemented_as_class + '*'
199 if not used_in_cpp_sequence: 190 if not used_in_cpp_sequence:
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 358
368 # Simple types 359 # Simple types
369 base_idl_type = idl_type.base_type 360 base_idl_type = idl_type.base_type
370 if base_idl_type in INCLUDES_FOR_TYPE: 361 if base_idl_type in INCLUDES_FOR_TYPE:
371 return INCLUDES_FOR_TYPE[base_idl_type] 362 return INCLUDES_FOR_TYPE[base_idl_type]
372 if base_idl_type in TYPED_ARRAY_TYPES: 363 if base_idl_type in TYPED_ARRAY_TYPES:
373 return INCLUDES_FOR_TYPE['ArrayBufferView'].union( 364 return INCLUDES_FOR_TYPE['ArrayBufferView'].union(
374 set(['bindings/%s/v8/V8%s.h' % (component_dir[base_idl_type], base_i dl_type)]) 365 set(['bindings/%s/v8/V8%s.h' % (component_dir[base_idl_type], base_i dl_type)])
375 ) 366 )
376 if idl_type.is_basic_type: 367 if idl_type.is_basic_type:
377 return set() 368 return set(['bindings/core/v8/IDLTypes.h'])
378 if base_idl_type.endswith('ConstructorConstructor'): 369 if base_idl_type.endswith('ConstructorConstructor'):
379 # FIXME: rename to NamedConstructor 370 # FIXME: rename to NamedConstructor
380 # FIXME: replace with a [NamedConstructorAttribute] extended attribute 371 # FIXME: replace with a [NamedConstructorAttribute] extended attribute
381 # Ending with 'ConstructorConstructor' indicates a named constructor, 372 # Ending with 'ConstructorConstructor' indicates a named constructor,
382 # and these do not have header files, as they are part of the generated 373 # and these do not have header files, as they are part of the generated
383 # bindings for the interface 374 # bindings for the interface
384 return set() 375 return set()
385 if base_idl_type.endswith('Constructor'): 376 if base_idl_type.endswith('Constructor'):
386 # FIXME: replace with a [ConstructorAttribute] extended attribute 377 # FIXME: replace with a [ConstructorAttribute] extended attribute
387 base_idl_type = idl_type.constructor_type_name 378 base_idl_type = idl_type.constructor_type_name
388 if idl_type.is_custom_callback_function: 379 if idl_type.is_custom_callback_function:
389 return set() 380 return set()
390 if idl_type.is_callback_function: 381 if idl_type.is_callback_function:
391 component = IdlType.callback_functions[base_idl_type]['component_dir'] 382 component = IdlType.callback_functions[base_idl_type]['component_dir']
392 return set(['bindings/%s/v8/%s.h' % (component, base_idl_type)]) 383 return set(['bindings/%s/v8/%s.h' % (component, base_idl_type)])
393 if base_idl_type not in component_dir: 384 if base_idl_type not in component_dir:
394 return set() 385 return set()
395 return set(['bindings/%s/v8/V8%s.h' % (component_dir[base_idl_type], 386 return set(['bindings/%s/v8/V8%s.h' % (component_dir[base_idl_type],
396 base_idl_type)]) 387 base_idl_type),
388 'bindings/core/v8/IDLTypes.h'])
397 389
398 IdlType.includes_for_type = includes_for_type 390 IdlType.includes_for_type = includes_for_type
399 391
400 392
401 def includes_for_union_type(idl_type, extended_attributes=None): 393 def includes_for_union_type(idl_type, extended_attributes=None):
402 return set.union(*[member_type.includes_for_type(extended_attributes) 394 return set.union(*[member_type.includes_for_type(extended_attributes)
403 for member_type in idl_type.member_types]) 395 for member_type in idl_type.member_types])
404 396
405 IdlUnionType.includes_for_type = includes_for_union_type 397 IdlUnionType.includes_for_type = includes_for_union_type
406 398
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 469
478 def set_component_dirs(new_component_dirs): 470 def set_component_dirs(new_component_dirs):
479 component_dir.update(new_component_dirs) 471 component_dir.update(new_component_dirs)
480 472
481 473
482 ################################################################################ 474 ################################################################################
483 # V8 -> C++ 475 # V8 -> C++
484 ################################################################################ 476 ################################################################################
485 477
486 V8_VALUE_TO_CPP_VALUE = { 478 V8_VALUE_TO_CPP_VALUE = {
487 # Basic
488 'Date': 'toCoreDate({isolate}, {v8_value}, exceptionState)',
489 'DOMString': '{v8_value}',
490 'ByteString': 'toByteString({isolate}, {arguments})',
491 'USVString': 'toUSVString({isolate}, {arguments})',
492 'boolean': 'toBoolean({isolate}, {arguments})',
493 'float': 'toRestrictedFloat({isolate}, {arguments})',
494 'unrestricted float': 'toFloat({isolate}, {arguments})',
495 'double': 'toRestrictedDouble({isolate}, {arguments})',
496 'unrestricted double': 'toDouble({isolate}, {arguments})',
497 'byte': 'toInt8({isolate}, {arguments})',
498 'octet': 'toUInt8({isolate}, {arguments})',
499 'short': 'toInt16({isolate}, {arguments})',
500 'unsigned short': 'toUInt16({isolate}, {arguments})',
501 'long': 'toInt32({isolate}, {arguments})',
502 'unsigned long': 'toUInt32({isolate}, {arguments})',
503 'long long': 'toInt64({isolate}, {arguments})',
504 'unsigned long long': 'toUInt64({isolate}, {arguments})',
505 # Interface types 479 # Interface types
506 'Dictionary': 'Dictionary({isolate}, {v8_value}, exceptionState)',
507 'FlexibleArrayBufferView': 'toFlexibleArrayBufferView({isolate}, {v8_value}, {variable_name}, allocateFlexibleArrayBufferViewStorage({v8_value}))', 480 'FlexibleArrayBufferView': 'toFlexibleArrayBufferView({isolate}, {v8_value}, {variable_name}, allocateFlexibleArrayBufferViewStorage({v8_value}))',
508 'NodeFilter': 'toNodeFilter({v8_value}, info.Holder(), ScriptState::current( {isolate}))', 481 'NodeFilter': 'toNodeFilter({v8_value}, info.Holder(), ScriptState::current( {isolate}))',
509 'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value}) ',
510 'SerializedScriptValue': 'SerializedScriptValue::serialize({isolate}, {v8_va lue}, nullptr, nullptr, exceptionState)',
511 'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})',
512 'Window': 'toDOMWindow({isolate}, {v8_value})',
513 'XPathNSResolver': 'toXPathNSResolver(ScriptState::current({isolate}), {v8_v alue})', 482 'XPathNSResolver': 'toXPathNSResolver(ScriptState::current({isolate}), {v8_v alue})',
514 } 483 }
515 484
516 485
517 def v8_conversion_needs_exception_state(idl_type): 486 def v8_conversion_needs_exception_state(idl_type):
518 return (idl_type.is_numeric_type or 487 return (idl_type.is_numeric_type or
519 idl_type.is_enum or 488 idl_type.is_enum or
520 idl_type.is_dictionary or 489 idl_type.is_dictionary or
490 idl_type.is_string_type or
521 idl_type.name in ('Boolean', 'ByteString', 'Date', 'Dictionary', 'US VString', 'SerializedScriptValue')) 491 idl_type.name in ('Boolean', 'ByteString', 'Date', 'Dictionary', 'US VString', 'SerializedScriptValue'))
522 492
523 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep tion_state) 493 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep tion_state)
524 IdlArrayOrSequenceType.v8_conversion_needs_exception_state = True 494 IdlArrayOrSequenceType.v8_conversion_needs_exception_state = True
525 IdlUnionType.v8_conversion_needs_exception_state = True 495 IdlUnionType.v8_conversion_needs_exception_state = True
526 496
527 497
528 TRIVIAL_CONVERSIONS = frozenset([ 498 TRIVIAL_CONVERSIONS = frozenset([
529 'any', 499 'any',
530 'boolean', 500 'boolean',
531 'Date', 501 'Date',
532 'Dictionary', 502 'Dictionary',
533 'NodeFilter', 503 'NodeFilter',
534 'XPathNSResolver', 504 'XPathNSResolver',
535 'Promise' 505 'Promise'
536 ]) 506 ])
537 507
538 508
539 def v8_conversion_is_trivial(idl_type): 509 def v8_conversion_is_trivial(idl_type):
540 # The conversion is a simple expression that returns the converted value and 510 # The conversion is a simple expression that returns the converted value and
541 # cannot raise an exception. 511 # cannot raise an exception.
542 return (idl_type.base_type in TRIVIAL_CONVERSIONS or 512 return (idl_type.base_type in TRIVIAL_CONVERSIONS or
543 idl_type.is_wrapper_type) 513 idl_type.is_wrapper_type)
544 514
545 IdlType.v8_conversion_is_trivial = property(v8_conversion_is_trivial) 515 IdlType.v8_conversion_is_trivial = property(v8_conversion_is_trivial)
546 516
547 517
518 def idl_type_name(idl_type):
519 idl_type = idl_type.preprocessed_type
520 if idl_type.native_array_element_type:
521 return 'idl::Sequence<%s>' % idl_type_name(idl_type.native_array_element _type)
522 elif idl_type.is_union_type:
523 return idl_type.as_union_type.name
524 elif idl_type.is_basic_type:
525 return 'idl::%s' % idl_type.name
526 elif idl_type.implemented_as is not None:
527 return idl_type.implemented_as
528 return idl_type.name
529
530
548 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, variable_name , index, isolate): 531 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, variable_name , index, isolate):
549 if idl_type.name == 'void': 532 if idl_type.name == 'void':
550 return '' 533 return ''
551 534
552 # Array or sequence types 535 def string_mode(idl_type):
553 native_array_element_type = idl_type.native_array_element_type 536 if idl_type.is_nullable:
554 if native_array_element_type: 537 return 'TreatNullAndUndefinedAsNullString'
555 return v8_value_to_cpp_value_array_or_sequence(native_array_element_type , v8_value, index, isolate) 538 if extended_attributes.get('TreatNullAs') == 'EmptyString':
539 return 'TreatNullAsEmptyString'
540 if extended_attributes.get('TreatNullAs') == 'NullString':
541 return 'TreatNullAsNullString'
542 return 'DefaultMode'
556 543
557 # Simple types 544 # Simple types
558 idl_type = idl_type.preprocessed_type 545 idl_type = idl_type.preprocessed_type
559 base_idl_type = idl_type.as_union_type.name if idl_type.is_union_type else i dl_type.base_type 546 if idl_type.is_union_type:
547 base_idl_type = idl_type.as_union_type.name
548 else:
549 base_idl_type = idl_type.base_type
560 550
561 if 'FlexibleArrayBufferView' in extended_attributes: 551 if 'FlexibleArrayBufferView' in extended_attributes:
562 if base_idl_type not in TYPED_ARRAY_TYPES.union(set(['ArrayBufferView']) ): 552 if base_idl_type not in TYPED_ARRAY_TYPES.union(set(['ArrayBufferView']) ):
563 raise "Unrecognized base type for extended attribute 'FlexibleArrayB ufferView': %s" % (idl_type.base_type) 553 raise "Unrecognized base type for extended attribute 'FlexibleArrayB ufferView': %s" % (idl_type.base_type)
564 base_idl_type = 'FlexibleArrayBufferView' 554 base_idl_type = 'FlexibleArrayBufferView'
565 555
566 if idl_type.is_integer_type: 556 if idl_type.is_integer_type:
567 configuration = 'NormalConversion' 557 configuration = 'NormalConversion'
568 if 'EnforceRange' in extended_attributes: 558 if 'EnforceRange' in extended_attributes:
569 configuration = 'EnforceRange' 559 configuration = 'EnforceRange'
570 elif 'Clamp' in extended_attributes: 560 elif 'Clamp' in extended_attributes:
571 configuration = 'Clamp' 561 configuration = 'Clamp'
572 arguments = ', '.join([v8_value, configuration, 'exceptionState']) 562 arguments = ', '.join([v8_value, 'exceptionState', configuration])
573 elif idl_type.v8_conversion_needs_exception_state: 563 elif idl_type.native_array_element_type:
564 # Index is None for setters, index (starting at 0) for method arguments,
565 # and is used to provide a human-readable exception message
566 if index is None:
567 index = 0 # special case, meaning "setter"
568 else:
569 index += 1 # human-readable index
570 arguments = ', '.join([v8_value, 'exceptionState', str(index)])
571 else:
574 arguments = ', '.join([v8_value, 'exceptionState']) 572 arguments = ', '.join([v8_value, 'exceptionState'])
575 else: 573
576 arguments = v8_value
577 if base_idl_type in V8_VALUE_TO_CPP_VALUE: 574 if base_idl_type in V8_VALUE_TO_CPP_VALUE:
578 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type] 575 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type]
579 elif idl_type.is_array_buffer_or_view: 576 else:
577 str_mode = string_mode(idl_type)
578
579 if idl_type.is_nullable:
580 idl_type = idl_type.inner_type
581 base_idl_type = idl_type_name(idl_type)
582
583 if base_idl_type == 'idl::String':
584 nvt_args = '<%s>' % str_mode
585 else:
586 nvt_args = ''
587
580 cpp_expression_format = ( 588 cpp_expression_format = (
581 '{v8_value}->Is{idl_type}() ? ' 589 'NativeValueTraits<{idl_type}>::nativeValue%s({isolate}, {arguments} )' % nvt_args)
582 'V8{idl_type}::toImpl(v8::Local<v8::{idl_type}>::Cast({v8_value})) : 0')
583 elif idl_type.is_union_type:
584 nullable = 'UnionTypeConversionMode::Nullable' if idl_type.includes_null able_type else 'UnionTypeConversionMode::NotNullable'
585 cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, {va riable_name}, %s, exceptionState)' % nullable
586 elif idl_type.use_output_parameter_for_result:
587 cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, {va riable_name}, exceptionState)'
588 elif idl_type.is_callback_function:
589 cpp_expression_format = (
590 '{idl_type}::create(ScriptState::current({isolate}), {v8_value})')
591 else:
592 cpp_expression_format = (
593 'V8{idl_type}::toImplWithTypeCheck({isolate}, {v8_value})')
594 590
595 return cpp_expression_format.format(arguments=arguments, idl_type=base_idl_t ype, v8_value=v8_value, variable_name=variable_name, isolate=isolate) 591 return cpp_expression_format.format(arguments=arguments, idl_type=base_idl_t ype, v8_value=v8_value, variable_name=variable_name, isolate=isolate)
596 592
597 593
598 def v8_value_to_cpp_value_array_or_sequence(native_array_element_type, v8_value, index, isolate='info.GetIsolate()'):
599 # Index is None for setters, index (starting at 0) for method arguments,
600 # and is used to provide a human-readable exception message
601 if index is None:
602 index = 0 # special case, meaning "setter"
603 else:
604 index += 1 # human-readable index
605 if (native_array_element_type.is_interface_type and
606 native_array_element_type.name != 'Dictionary'):
607 this_cpp_type = None
608 expression_format = 'toMemberNativeArray<{native_array_element_type}>({v 8_value}, {index}, {isolate}, exceptionState)'
609 else:
610 this_cpp_type = native_array_element_type.cpp_type
611 if native_array_element_type.is_dictionary or native_array_element_type. is_union_type:
612 vector_type = 'HeapVector'
613 else:
614 vector_type = 'Vector'
615 expression_format = 'toImplArray<%s<{cpp_type}>>({v8_value}, {index}, {i solate}, exceptionState)' % vector_type
616 expression = expression_format.format(native_array_element_type=native_array _element_type.name, cpp_type=this_cpp_type,
617 index=index, v8_value=v8_value, isolat e=isolate)
618 return expression
619
620
621 # FIXME: this function should be refactored, as this takes too many flags. 594 # FIXME: this function should be refactored, as this takes too many flags.
622 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl e_name, index=None, declare_variable=True, 595 def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl e_name, index=None, declare_variable=True,
623 isolate='info.GetIsolate()', bailout_return_valu e=None, use_exception_state=False): 596 isolate='info.GetIsolate()', bailout_return_valu e=None, use_exception_state=False):
624 """Returns an expression that converts a V8 value to a C++ value and stores it as a local value.""" 597 """Returns an expression that converts a V8 value to a C++ value and stores it as a local value."""
625 598
626 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut es, raw_type=True) 599 this_cpp_type = idl_type.cpp_type_args(extended_attributes=extended_attribut es, raw_type=True)
627 idl_type = idl_type.preprocessed_type 600 idl_type = idl_type.preprocessed_type
628 601
629 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, v ariable_name, index, isolate) 602 cpp_value = v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, v ariable_name, index, isolate)
630 603
631 # Optional expression that returns a value to be assigned to the local varia ble. 604 # Optional expression that returns a value to be assigned to the local varia ble.
632 assign_expression = None 605 assign_expression = None
633 # Optional void expression executed unconditionally. 606 # Optional void expression executed unconditionally.
634 set_expression = None 607 set_expression = None
635 # Optional expression that returns true if the conversion fails. 608 # Optional expression that returns true if the conversion fails.
636 check_expression = None 609 check_expression = None
637 # Optional expression used as the return value when returning. Only 610 # Optional expression used as the return value when returning. Only
638 # meaningful if 'check_expression' is not None. 611 # meaningful if 'check_expression' is not None.
639 return_expression = bailout_return_value 612 return_expression = bailout_return_value
640 613
641 if idl_type.is_string_type or idl_type.v8_conversion_needs_exception_state: 614 if idl_type.v8_conversion_needs_exception_state:
642 # Types for which conversion can fail and that need error handling. 615 # Types for which conversion can fail and that need error handling.
643
644 check_expression = 'exceptionState.hadException()' 616 check_expression = 'exceptionState.hadException()'
645 617 assign_expression = cpp_value
646 if idl_type.is_dictionary or idl_type.is_union_type:
647 set_expression = cpp_value
648 else:
649 assign_expression = cpp_value
650 # Note: 'not idl_type.v8_conversion_needs_exception_state' implies
651 # 'idl_type.is_string_type', but there are types for which both are
652 # true (ByteString and USVString), so using idl_type.is_string_type
653 # as the condition here would be wrong.
654 if not idl_type.v8_conversion_needs_exception_state:
655 if use_exception_state:
656 check_expression = '!%s.prepare(exceptionState)' % variable_ name
657 else:
658 check_expression = '!%s.prepare()' % variable_name
659 elif not idl_type.v8_conversion_is_trivial and not idl_type.is_callback_func tion: 618 elif not idl_type.v8_conversion_is_trivial and not idl_type.is_callback_func tion:
660 return { 619 return {
661 'error_message': 'no V8 -> C++ conversion for IDL type: %s' % idl_ty pe.name 620 'error_message': 'no V8 -> C++ conversion for IDL type: %s' % idl_ty pe.name
662 } 621 }
663 elif 'FlexibleArrayBufferView' in extended_attributes: 622 elif 'FlexibleArrayBufferView' in extended_attributes:
664 if idl_type.base_type not in TYPED_ARRAY_TYPES.union(set(['ArrayBufferVi ew'])): 623 if idl_type.base_type not in TYPED_ARRAY_TYPES.union(set(['ArrayBufferVi ew'])):
665 raise "Unrecognized base type for extended attribute 'FlexibleArrayB ufferView': %s" % (idl_type.base_type) 624 raise "Unrecognized base type for extended attribute 'FlexibleArrayB ufferView': %s" % (idl_type.base_type)
666 set_expression = cpp_value 625 set_expression = cpp_value
667 else: 626 else:
668 assign_expression = cpp_value 627 assign_expression = cpp_value
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
1028 number_of_nullable_member_types_union) 987 number_of_nullable_member_types_union)
1029 988
1030 989
1031 def includes_nullable_type_union(idl_type): 990 def includes_nullable_type_union(idl_type):
1032 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type 991 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type
1033 return idl_type.number_of_nullable_member_types == 1 992 return idl_type.number_of_nullable_member_types == 1
1034 993
1035 IdlTypeBase.includes_nullable_type = False 994 IdlTypeBase.includes_nullable_type = False
1036 IdlNullableType.includes_nullable_type = True 995 IdlNullableType.includes_nullable_type = True
1037 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) 996 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union)
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/v8_interface.py ('k') | third_party/WebKit/Source/bindings/scripts/v8_union.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698