OLD | NEW |
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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 'Int32Array', | 63 'Int32Array', |
64 'Uint8Array', | 64 'Uint8Array', |
65 'Uint8ClampedArray', | 65 'Uint8ClampedArray', |
66 'Uint16Array', | 66 'Uint16Array', |
67 'Uint32Array', | 67 'Uint32Array', |
68 ]) | 68 ]) |
69 ARRAY_BUFFER_AND_VIEW_TYPES = TYPED_ARRAY_TYPES.union(frozenset([ | 69 ARRAY_BUFFER_AND_VIEW_TYPES = TYPED_ARRAY_TYPES.union(frozenset([ |
70 'ArrayBuffer', | 70 'ArrayBuffer', |
71 'ArrayBufferView', | 71 'ArrayBufferView', |
72 'DataView', | 72 'DataView', |
| 73 'SharedArrayBuffer', |
73 ])) | 74 ])) |
74 | 75 |
| 76 |
75 IdlType.is_array_buffer_or_view = property( | 77 IdlType.is_array_buffer_or_view = property( |
76 lambda self: self.base_type in ARRAY_BUFFER_AND_VIEW_TYPES) | 78 lambda self: self.base_type in ARRAY_BUFFER_AND_VIEW_TYPES) |
77 | 79 |
78 IdlType.is_typed_array = property( | 80 IdlType.is_typed_array = property( |
79 lambda self: self.base_type in TYPED_ARRAY_TYPES) | 81 lambda self: self.base_type in TYPED_ARRAY_TYPES) |
80 | 82 |
81 IdlType.is_wrapper_type = property( | 83 IdlType.is_wrapper_type = property( |
82 lambda self: (self.is_interface_type and | 84 lambda self: (self.is_interface_type and |
83 not self.is_callback_interface and | 85 not self.is_callback_interface and |
84 self.base_type not in NON_WRAPPER_TYPES)) | 86 self.base_type not in NON_WRAPPER_TYPES)) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 if base_idl_type in CPP_SPECIAL_CONVERSION_RULES: | 177 if base_idl_type in CPP_SPECIAL_CONVERSION_RULES: |
176 return CPP_SPECIAL_CONVERSION_RULES[base_idl_type] | 178 return CPP_SPECIAL_CONVERSION_RULES[base_idl_type] |
177 | 179 |
178 if base_idl_type in NON_WRAPPER_TYPES: | 180 if base_idl_type in NON_WRAPPER_TYPES: |
179 return ('PassRefPtr<%s>' if used_as_rvalue_type else 'RefPtr<%s>') % bas
e_idl_type | 181 return ('PassRefPtr<%s>' if used_as_rvalue_type else 'RefPtr<%s>') % bas
e_idl_type |
180 if idl_type.is_string_type: | 182 if idl_type.is_string_type: |
181 if not raw_type: | 183 if not raw_type: |
182 return 'String' | 184 return 'String' |
183 return 'V8StringResource<%s>' % string_mode() | 185 return 'V8StringResource<%s>' % string_mode() |
184 | 186 |
185 if idl_type.is_array_buffer_or_view and raw_type: | 187 if idl_type.base_type == 'ArrayBufferView' and 'FlexibleArrayBufferView' in
extended_attributes: |
186 return idl_type.implemented_as + '*' | 188 return 'FlexibleArrayBufferView' |
| 189 if idl_type.base_type in TYPED_ARRAY_TYPES and 'FlexibleArrayBufferView' in
extended_attributes: |
| 190 return 'Flexible' + idl_type.base_type + 'View' |
187 if idl_type.is_interface_type: | 191 if idl_type.is_interface_type: |
188 implemented_as_class = idl_type.implemented_as | 192 implemented_as_class = idl_type.implemented_as |
189 if raw_type or (used_as_rvalue_type and idl_type.is_garbage_collected): | 193 if raw_type or (used_as_rvalue_type and idl_type.is_garbage_collected): |
190 return implemented_as_class + '*' | 194 return implemented_as_class + '*' |
191 new_type = 'Member' if used_in_cpp_sequence else 'RawPtr' | 195 new_type = 'Member' if used_in_cpp_sequence else 'RawPtr' |
192 ptr_type = cpp_ptr_type(('PassRefPtr' if used_as_rvalue_type else 'RefPt
r'), new_type, idl_type.gc_type) | 196 ptr_type = cpp_ptr_type(('PassRefPtr' if used_as_rvalue_type else 'RefPt
r'), new_type, idl_type.gc_type) |
193 return cpp_template_type(ptr_type, implemented_as_class) | 197 return cpp_template_type(ptr_type, implemented_as_class) |
194 if idl_type.is_dictionary: | 198 if idl_type.is_dictionary: |
195 return base_idl_type | 199 return base_idl_type |
196 if idl_type.is_union_type: | 200 if idl_type.is_union_type: |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 ################################################################################ | 338 ################################################################################ |
335 # Includes | 339 # Includes |
336 ################################################################################ | 340 ################################################################################ |
337 | 341 |
338 def includes_for_cpp_class(class_name, relative_dir_posix): | 342 def includes_for_cpp_class(class_name, relative_dir_posix): |
339 return set([posixpath.join('bindings', relative_dir_posix, class_name + '.h'
)]) | 343 return set([posixpath.join('bindings', relative_dir_posix, class_name + '.h'
)]) |
340 | 344 |
341 | 345 |
342 INCLUDES_FOR_TYPE = { | 346 INCLUDES_FOR_TYPE = { |
343 'object': set(), | 347 'object': set(), |
| 348 'ArrayBufferView': set(['bindings/core/v8/V8ArrayBufferView.h', |
| 349 'core/dom/FlexibleArrayBufferView.h']), |
344 'Dictionary': set(['bindings/core/v8/Dictionary.h']), | 350 'Dictionary': set(['bindings/core/v8/Dictionary.h']), |
345 'EventHandler': set(['bindings/core/v8/V8AbstractEventListener.h', | 351 'EventHandler': set(['bindings/core/v8/V8AbstractEventListener.h', |
346 'bindings/core/v8/V8EventListenerList.h']), | 352 'bindings/core/v8/V8EventListenerList.h']), |
347 'EventListener': set(['bindings/core/v8/BindingSecurity.h', | 353 'EventListener': set(['bindings/core/v8/BindingSecurity.h', |
348 'bindings/core/v8/V8EventListenerList.h', | 354 'bindings/core/v8/V8EventListenerList.h', |
349 'core/frame/LocalDOMWindow.h']), | 355 'core/frame/LocalDOMWindow.h']), |
350 'HTMLCollection': set(['bindings/core/v8/V8HTMLCollection.h', | 356 'HTMLCollection': set(['bindings/core/v8/V8HTMLCollection.h', |
351 'core/dom/ClassCollection.h', | 357 'core/dom/ClassCollection.h', |
352 'core/dom/TagCollection.h', | 358 'core/dom/TagCollection.h', |
353 'core/html/HTMLCollection.h', | 359 'core/html/HTMLCollection.h', |
(...skipping 13 matching lines...) Expand all Loading... |
367 | 373 |
368 | 374 |
369 def includes_for_type(idl_type, extended_attributes=None): | 375 def includes_for_type(idl_type, extended_attributes=None): |
370 idl_type = idl_type.preprocessed_type | 376 idl_type = idl_type.preprocessed_type |
371 extended_attributes = extended_attributes or {} | 377 extended_attributes = extended_attributes or {} |
372 | 378 |
373 # Simple types | 379 # Simple types |
374 base_idl_type = idl_type.base_type | 380 base_idl_type = idl_type.base_type |
375 if base_idl_type in INCLUDES_FOR_TYPE: | 381 if base_idl_type in INCLUDES_FOR_TYPE: |
376 return INCLUDES_FOR_TYPE[base_idl_type] | 382 return INCLUDES_FOR_TYPE[base_idl_type] |
| 383 if idl_type.base_type in TYPED_ARRAY_TYPES: |
| 384 return INCLUDES_FOR_TYPE['ArrayBufferView'].union( |
| 385 set(['bindings/%s/v8/V8%s.h' % (component_dir[base_idl_type], base_i
dl_type)]) |
| 386 ) |
377 if idl_type.is_basic_type: | 387 if idl_type.is_basic_type: |
378 return set() | 388 return set() |
379 if base_idl_type.endswith('ConstructorConstructor'): | 389 if base_idl_type.endswith('ConstructorConstructor'): |
380 # FIXME: rename to NamedConstructor | 390 # FIXME: rename to NamedConstructor |
381 # FIXME: replace with a [NamedConstructorAttribute] extended attribute | 391 # FIXME: replace with a [NamedConstructorAttribute] extended attribute |
382 # Ending with 'ConstructorConstructor' indicates a named constructor, | 392 # Ending with 'ConstructorConstructor' indicates a named constructor, |
383 # and these do not have header files, as they are part of the generated | 393 # and these do not have header files, as they are part of the generated |
384 # bindings for the interface | 394 # bindings for the interface |
385 return set() | 395 return set() |
386 if base_idl_type.endswith('Constructor'): | 396 if base_idl_type.endswith('Constructor'): |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 'octet': 'toUInt8({isolate}, {arguments})', | 500 'octet': 'toUInt8({isolate}, {arguments})', |
491 'short': 'toInt16({isolate}, {arguments})', | 501 'short': 'toInt16({isolate}, {arguments})', |
492 'unsigned short': 'toUInt16({isolate}, {arguments})', | 502 'unsigned short': 'toUInt16({isolate}, {arguments})', |
493 'long': 'toInt32({isolate}, {arguments})', | 503 'long': 'toInt32({isolate}, {arguments})', |
494 'unsigned long': 'toUInt32({isolate}, {arguments})', | 504 'unsigned long': 'toUInt32({isolate}, {arguments})', |
495 'long long': 'toInt64({isolate}, {arguments})', | 505 'long long': 'toInt64({isolate}, {arguments})', |
496 'unsigned long long': 'toUInt64({isolate}, {arguments})', | 506 'unsigned long long': 'toUInt64({isolate}, {arguments})', |
497 # Interface types | 507 # Interface types |
498 'Dictionary': 'Dictionary({v8_value}, {isolate}, exceptionState)', | 508 'Dictionary': 'Dictionary({v8_value}, {isolate}, exceptionState)', |
499 'EventTarget': 'toEventTarget({isolate}, {v8_value})', | 509 'EventTarget': 'toEventTarget({isolate}, {v8_value})', |
| 510 'FlexibleArrayBufferView': 'toFlexibleArrayBufferView({isolate}, {v8_value},
{variable_name}, allocateFlexibleArrayBufferViewStorage({v8_value}))', |
500 'NodeFilter': 'toNodeFilter({v8_value}, info.Holder(), ScriptState::current(
{isolate}))', | 511 'NodeFilter': 'toNodeFilter({v8_value}, info.Holder(), ScriptState::current(
{isolate}))', |
501 'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value})
', | 512 'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value})
', |
502 'SerializedScriptValue': 'SerializedScriptValueFactory::instance().create({i
solate}, {v8_value}, 0, 0, exceptionState)', | 513 'SerializedScriptValue': 'SerializedScriptValueFactory::instance().create({i
solate}, {v8_value}, nullptr, nullptr, nullptr, exceptionState)', |
503 'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})', | 514 'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})', |
504 'Window': 'toDOMWindow({isolate}, {v8_value})', | 515 'Window': 'toDOMWindow({isolate}, {v8_value})', |
505 'XPathNSResolver': 'toXPathNSResolver(ScriptState::current({isolate}), {v8_v
alue})', | 516 'XPathNSResolver': 'toXPathNSResolver(ScriptState::current({isolate}), {v8_v
alue})', |
506 } | 517 } |
507 | 518 |
508 | 519 |
509 def v8_conversion_needs_exception_state(idl_type): | 520 def v8_conversion_needs_exception_state(idl_type): |
510 return (idl_type.is_numeric_type or | 521 return (idl_type.is_numeric_type or |
511 idl_type.is_enum or | 522 idl_type.is_enum or |
512 idl_type.is_dictionary or | 523 idl_type.is_dictionary or |
(...skipping 30 matching lines...) Expand all Loading... |
543 | 554 |
544 # Array or sequence types | 555 # Array or sequence types |
545 native_array_element_type = idl_type.native_array_element_type | 556 native_array_element_type = idl_type.native_array_element_type |
546 if native_array_element_type: | 557 if native_array_element_type: |
547 return v8_value_to_cpp_value_array_or_sequence(native_array_element_type
, v8_value, index, isolate) | 558 return v8_value_to_cpp_value_array_or_sequence(native_array_element_type
, v8_value, index, isolate) |
548 | 559 |
549 # Simple types | 560 # Simple types |
550 idl_type = idl_type.preprocessed_type | 561 idl_type = idl_type.preprocessed_type |
551 base_idl_type = idl_type.as_union_type.name if idl_type.is_union_type else i
dl_type.base_type | 562 base_idl_type = idl_type.as_union_type.name if idl_type.is_union_type else i
dl_type.base_type |
552 | 563 |
| 564 if 'FlexibleArrayBufferView' in extended_attributes: |
| 565 if base_idl_type not in TYPED_ARRAY_TYPES.union(set(['ArrayBufferView'])
): |
| 566 raise "Unrecognized base type for extended attribute 'FlexibleArrayB
ufferView': %s" % (idl_type.base_type) |
| 567 base_idl_type = 'FlexibleArrayBufferView' |
| 568 |
553 if idl_type.is_integer_type: | 569 if idl_type.is_integer_type: |
554 configuration = 'NormalConversion' | 570 configuration = 'NormalConversion' |
555 if 'EnforceRange' in extended_attributes: | 571 if 'EnforceRange' in extended_attributes: |
556 configuration = 'EnforceRange' | 572 configuration = 'EnforceRange' |
557 elif 'Clamp' in extended_attributes: | 573 elif 'Clamp' in extended_attributes: |
558 configuration = 'Clamp' | 574 configuration = 'Clamp' |
559 arguments = ', '.join([v8_value, configuration, 'exceptionState']) | 575 arguments = ', '.join([v8_value, configuration, 'exceptionState']) |
560 elif idl_type.v8_conversion_needs_exception_state: | 576 elif idl_type.v8_conversion_needs_exception_state: |
561 arguments = ', '.join([v8_value, 'exceptionState']) | 577 arguments = ', '.join([v8_value, 'exceptionState']) |
562 else: | 578 else: |
563 arguments = v8_value | 579 arguments = v8_value |
564 if base_idl_type in V8_VALUE_TO_CPP_VALUE: | 580 if base_idl_type in V8_VALUE_TO_CPP_VALUE: |
565 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type] | 581 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type] |
566 elif idl_type.is_array_buffer_or_view: | 582 elif idl_type.is_array_buffer_or_view: |
567 cpp_expression_format = ( | 583 cpp_expression_format = ( |
568 '{v8_value}->Is{idl_type}() ? ' | 584 '{v8_value}->Is{idl_type}() ? ' |
569 'V8{idl_type}::toImpl(v8::Local<v8::{idl_type}>::Cast({v8_value})) :
0') | 585 'V8{idl_type}::toImpl(v8::Local<v8::{idl_type}>::Cast({v8_value})) :
0') |
| 586 elif idl_type.is_union_type: |
| 587 nullable = 'UnionTypeConversionMode::Nullable' if idl_type.includes_null
able_type else 'UnionTypeConversionMode::NotNullable' |
| 588 cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, {va
riable_name}, %s, exceptionState)' % nullable |
570 elif idl_type.use_output_parameter_for_result: | 589 elif idl_type.use_output_parameter_for_result: |
571 if idl_type.includes_nullable_type: | |
572 base_idl_type = idl_type.cpp_type + 'OrNull' | |
573 cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, {va
riable_name}, exceptionState)' | 590 cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, {va
riable_name}, exceptionState)' |
574 else: | 591 else: |
575 cpp_expression_format = ( | 592 cpp_expression_format = ( |
576 'V8{idl_type}::toImplWithTypeCheck({isolate}, {v8_value})') | 593 'V8{idl_type}::toImplWithTypeCheck({isolate}, {v8_value})') |
577 | 594 |
578 return cpp_expression_format.format(arguments=arguments, idl_type=base_idl_t
ype, v8_value=v8_value, variable_name=variable_name, isolate=isolate) | 595 return cpp_expression_format.format(arguments=arguments, idl_type=base_idl_t
ype, v8_value=v8_value, variable_name=variable_name, isolate=isolate) |
579 | 596 |
580 | 597 |
581 def v8_value_to_cpp_value_array_or_sequence(native_array_element_type, v8_value,
index, isolate='info.GetIsolate()'): | 598 def v8_value_to_cpp_value_array_or_sequence(native_array_element_type, v8_value,
index, isolate='info.GetIsolate()'): |
582 # Index is None for setters, index (starting at 0) for method arguments, | 599 # Index is None for setters, index (starting at 0) for method arguments, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 # as the condition here would be wrong. | 656 # as the condition here would be wrong. |
640 if not idl_type.v8_conversion_needs_exception_state: | 657 if not idl_type.v8_conversion_needs_exception_state: |
641 if use_exception_state: | 658 if use_exception_state: |
642 check_expression = '!%s.prepare(exceptionState)' % variable_
name | 659 check_expression = '!%s.prepare(exceptionState)' % variable_
name |
643 else: | 660 else: |
644 check_expression = '!%s.prepare()' % variable_name | 661 check_expression = '!%s.prepare()' % variable_name |
645 elif not idl_type.v8_conversion_is_trivial: | 662 elif not idl_type.v8_conversion_is_trivial: |
646 return { | 663 return { |
647 'error_message': 'no V8 -> C++ conversion for IDL type: %s' % idl_ty
pe.name | 664 'error_message': 'no V8 -> C++ conversion for IDL type: %s' % idl_ty
pe.name |
648 } | 665 } |
| 666 elif 'FlexibleArrayBufferView' in extended_attributes: |
| 667 if idl_type.base_type not in TYPED_ARRAY_TYPES.union(set(['ArrayBufferVi
ew'])): |
| 668 raise "Unrecognized base type for extended attribute 'FlexibleArrayB
ufferView': %s" % (idl_type.base_type) |
| 669 set_expression = cpp_value |
649 else: | 670 else: |
650 assign_expression = cpp_value | 671 assign_expression = cpp_value |
651 | 672 |
652 # Types that don't need error handling, and simply assign a value to the | 673 # Types that don't need error handling, and simply assign a value to the |
653 # local variable. | 674 # local variable. |
654 | 675 |
655 return { | 676 return { |
656 'assign_expression': assign_expression, | 677 'assign_expression': assign_expression, |
657 'check_expression': check_expression, | 678 'check_expression': check_expression, |
658 'cpp_type': this_cpp_type, | 679 'cpp_type': this_cpp_type, |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
742 # Simple types | 763 # Simple types |
743 base_idl_type = idl_type.base_type | 764 base_idl_type = idl_type.base_type |
744 # Basic types, without additional includes | 765 # Basic types, without additional includes |
745 if base_idl_type in CPP_INT_TYPES: | 766 if base_idl_type in CPP_INT_TYPES: |
746 return 'int' | 767 return 'int' |
747 if base_idl_type in CPP_UNSIGNED_TYPES: | 768 if base_idl_type in CPP_UNSIGNED_TYPES: |
748 return 'unsigned' | 769 return 'unsigned' |
749 if idl_type.is_string_type: | 770 if idl_type.is_string_type: |
750 if idl_type.is_nullable: | 771 if idl_type.is_nullable: |
751 return 'StringOrNull' | 772 return 'StringOrNull' |
752 if 'TreatReturnedNullStringAs' not in extended_attributes: | 773 return base_idl_type |
753 return base_idl_type | |
754 treat_returned_null_string_as = extended_attributes['TreatReturnedNullSt
ringAs'] | |
755 if treat_returned_null_string_as == 'Null': | |
756 return 'StringOrNull' | |
757 if treat_returned_null_string_as == 'Undefined': | |
758 return 'StringOrUndefined' | |
759 raise 'Unrecognized TreatReturnedNullStringAs value: "%s"' % treat_retur
ned_null_string_as | |
760 if idl_type.is_basic_type or base_idl_type == 'ScriptValue': | 774 if idl_type.is_basic_type or base_idl_type == 'ScriptValue': |
761 return base_idl_type | 775 return base_idl_type |
762 # Generic dictionary type | 776 # Generic dictionary type |
763 if base_idl_type == 'Dictionary': | 777 if base_idl_type == 'Dictionary': |
764 return 'Dictionary' | 778 return 'Dictionary' |
765 | 779 |
766 # Data type with potential additional includes | 780 # Data type with potential additional includes |
767 if base_idl_type in V8_SET_RETURN_VALUE: # Special v8SetReturnValue treatme
nt | 781 if base_idl_type in V8_SET_RETURN_VALUE: # Special v8SetReturnValue treatme
nt |
768 return base_idl_type | 782 return base_idl_type |
769 | 783 |
770 # Pointer type | 784 # Pointer type |
771 return 'DOMWrapper' | 785 return 'DOMWrapper' |
772 | 786 |
773 IdlTypeBase.v8_conversion_type = v8_conversion_type | 787 IdlTypeBase.v8_conversion_type = v8_conversion_type |
774 | 788 |
775 | 789 |
776 V8_SET_RETURN_VALUE = { | 790 V8_SET_RETURN_VALUE = { |
777 'boolean': 'v8SetReturnValueBool(info, {cpp_value})', | 791 'boolean': 'v8SetReturnValueBool(info, {cpp_value})', |
778 'int': 'v8SetReturnValueInt(info, {cpp_value})', | 792 'int': 'v8SetReturnValueInt(info, {cpp_value})', |
779 'unsigned': 'v8SetReturnValueUnsigned(info, {cpp_value})', | 793 'unsigned': 'v8SetReturnValueUnsigned(info, {cpp_value})', |
780 'DOMString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', | 794 'DOMString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', |
781 'ByteString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())'
, | 795 'ByteString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())'
, |
782 'USVString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', | 796 'USVString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', |
783 # [TreatReturnedNullStringAs] | |
784 'StringOrNull': 'v8SetReturnValueStringOrNull(info, {cpp_value}, info.GetIso
late())', | 797 'StringOrNull': 'v8SetReturnValueStringOrNull(info, {cpp_value}, info.GetIso
late())', |
785 'StringOrUndefined': 'v8SetReturnValueStringOrUndefined(info, {cpp_value}, i
nfo.GetIsolate())', | |
786 'void': '', | 798 'void': '', |
787 # No special v8SetReturnValue* function (set value directly) | 799 # No special v8SetReturnValue* function (set value directly) |
788 'float': 'v8SetReturnValue(info, {cpp_value})', | 800 'float': 'v8SetReturnValue(info, {cpp_value})', |
789 'unrestricted float': 'v8SetReturnValue(info, {cpp_value})', | 801 'unrestricted float': 'v8SetReturnValue(info, {cpp_value})', |
790 'double': 'v8SetReturnValue(info, {cpp_value})', | 802 'double': 'v8SetReturnValue(info, {cpp_value})', |
791 'unrestricted double': 'v8SetReturnValue(info, {cpp_value})', | 803 'unrestricted double': 'v8SetReturnValue(info, {cpp_value})', |
792 # No special v8SetReturnValue* function, but instead convert value to V8 | 804 # No special v8SetReturnValue* function, but instead convert value to V8 |
793 # and then use general v8SetReturnValue. | 805 # and then use general v8SetReturnValue. |
794 'array': 'v8SetReturnValue(info, {cpp_value})', | 806 'array': 'v8SetReturnValue(info, {cpp_value})', |
795 'Date': 'v8SetReturnValue(info, {cpp_value})', | 807 'Date': 'v8SetReturnValue(info, {cpp_value})', |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 'ByteString': 'v8String({isolate}, {cpp_value})', | 874 'ByteString': 'v8String({isolate}, {cpp_value})', |
863 'USVString': 'v8String({isolate}, {cpp_value})', | 875 'USVString': 'v8String({isolate}, {cpp_value})', |
864 'boolean': 'v8Boolean({cpp_value}, {isolate})', | 876 'boolean': 'v8Boolean({cpp_value}, {isolate})', |
865 'int': 'v8::Integer::New({isolate}, {cpp_value})', | 877 'int': 'v8::Integer::New({isolate}, {cpp_value})', |
866 'unsigned': 'v8::Integer::NewFromUnsigned({isolate}, {cpp_value})', | 878 'unsigned': 'v8::Integer::NewFromUnsigned({isolate}, {cpp_value})', |
867 'float': 'v8::Number::New({isolate}, {cpp_value})', | 879 'float': 'v8::Number::New({isolate}, {cpp_value})', |
868 'unrestricted float': 'v8::Number::New({isolate}, {cpp_value})', | 880 'unrestricted float': 'v8::Number::New({isolate}, {cpp_value})', |
869 'double': 'v8::Number::New({isolate}, {cpp_value})', | 881 'double': 'v8::Number::New({isolate}, {cpp_value})', |
870 'unrestricted double': 'v8::Number::New({isolate}, {cpp_value})', | 882 'unrestricted double': 'v8::Number::New({isolate}, {cpp_value})', |
871 'void': 'v8Undefined()', | 883 'void': 'v8Undefined()', |
872 # [TreatReturnedNullStringAs] | |
873 'StringOrNull': '{cpp_value}.isNull() ? v8::Local<v8::Value>(v8::Null({isola
te})) : v8String({isolate}, {cpp_value})', | 884 'StringOrNull': '{cpp_value}.isNull() ? v8::Local<v8::Value>(v8::Null({isola
te})) : v8String({isolate}, {cpp_value})', |
874 'StringOrUndefined': '{cpp_value}.isNull() ? v8Undefined() : v8String({isola
te}, {cpp_value})', | |
875 # Special cases | 885 # Special cases |
876 'Dictionary': '{cpp_value}.v8Value()', | 886 'Dictionary': '{cpp_value}.v8Value()', |
877 'EventHandler': '{cpp_value} ? v8::Local<v8::Value>(V8AbstractEventListener:
:cast({cpp_value})->getListenerObject(impl->executionContext())) : v8::Local<v8:
:Value>(v8::Null({isolate}))', | 887 'EventHandler': '{cpp_value} ? v8::Local<v8::Value>(V8AbstractEventListener:
:cast({cpp_value})->getListenerObject(impl->executionContext())) : v8::Local<v8:
:Value>(v8::Null({isolate}))', |
878 'ScriptValue': '{cpp_value}.v8Value()', | 888 'ScriptValue': '{cpp_value}.v8Value()', |
879 'SerializedScriptValue': '{cpp_value} ? {cpp_value}->deserialize() : v8::Loc
al<v8::Value>(v8::Null({isolate}))', | 889 'SerializedScriptValue': '{cpp_value} ? {cpp_value}->deserialize() : v8::Loc
al<v8::Value>(v8::Null({isolate}))', |
880 # General | 890 # General |
881 'array': 'toV8({cpp_value}, {creation_context}, {isolate})', | 891 'array': 'toV8({cpp_value}, {creation_context}, {isolate})', |
882 'DOMWrapper': 'toV8({cpp_value}, {creation_context}, {isolate})', | 892 'DOMWrapper': 'toV8({cpp_value}, {creation_context}, {isolate})', |
883 # Passing nullable dictionaries isn't a pattern currently used | 893 # Passing nullable dictionaries isn't a pattern currently used |
884 # anywhere in the web platform, and more work would be needed in | 894 # anywhere in the web platform, and more work would be needed in |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
996 number_of_nullable_member_types_union) | 1006 number_of_nullable_member_types_union) |
997 | 1007 |
998 | 1008 |
999 def includes_nullable_type_union(idl_type): | 1009 def includes_nullable_type_union(idl_type): |
1000 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type | 1010 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type |
1001 return idl_type.number_of_nullable_member_types == 1 | 1011 return idl_type.number_of_nullable_member_types == 1 |
1002 | 1012 |
1003 IdlTypeBase.includes_nullable_type = False | 1013 IdlTypeBase.includes_nullable_type = False |
1004 IdlNullableType.includes_nullable_type = True | 1014 IdlNullableType.includes_nullable_type = True |
1005 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) | 1015 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) |
OLD | NEW |