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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
47 ################################################################################ | 47 ################################################################################ |
48 # V8-specific handling of IDL types | 48 # V8-specific handling of IDL types |
49 ################################################################################ | 49 ################################################################################ |
50 | 50 |
51 NON_WRAPPER_TYPES = frozenset([ | 51 NON_WRAPPER_TYPES = frozenset([ |
52 'Dictionary', | 52 'Dictionary', |
53 'EventHandler', | 53 'EventHandler', |
54 'EventListener', | 54 'EventListener', |
55 'NodeFilter', | 55 'NodeFilter', |
56 'SerializedScriptValue', | 56 'SerializedScriptValue', |
57 'SmallTypedArray', | |
57 ]) | 58 ]) |
58 TYPED_ARRAY_TYPES = frozenset([ | 59 TYPED_ARRAY_TYPES = frozenset([ |
59 'Float32Array', | 60 'Float32Array', |
60 'Float64Array', | 61 'Float64Array', |
61 'Int8Array', | 62 'Int8Array', |
62 'Int16Array', | 63 'Int16Array', |
63 'Int32Array', | 64 'Int32Array', |
64 'Uint8Array', | 65 'Uint8Array', |
65 'Uint8ClampedArray', | 66 'Uint8ClampedArray', |
66 'Uint16Array', | 67 'Uint16Array', |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 'unsigned long', | 105 'unsigned long', |
105 'unsigned short', | 106 'unsigned short', |
106 ]) | 107 ]) |
107 CPP_SPECIAL_CONVERSION_RULES = { | 108 CPP_SPECIAL_CONVERSION_RULES = { |
108 'Date': 'double', | 109 'Date': 'double', |
109 'Dictionary': 'Dictionary', | 110 'Dictionary': 'Dictionary', |
110 'EventHandler': 'EventListener*', | 111 'EventHandler': 'EventListener*', |
111 'NodeFilter': 'RefPtrWillBeRawPtr<NodeFilter>', | 112 'NodeFilter': 'RefPtrWillBeRawPtr<NodeFilter>', |
112 'Promise': 'ScriptPromise', | 113 'Promise': 'ScriptPromise', |
113 'ScriptValue': 'ScriptValue', | 114 'ScriptValue': 'ScriptValue', |
115 'SmallTypedArray': 'std::pair<void*, size_t>', | |
114 # FIXME: Eliminate custom bindings for XPathNSResolver http://crbug.com/345 529 | 116 # FIXME: Eliminate custom bindings for XPathNSResolver http://crbug.com/345 529 |
115 'XPathNSResolver': 'RefPtrWillBeRawPtr<XPathNSResolver>', | 117 'XPathNSResolver': 'RefPtrWillBeRawPtr<XPathNSResolver>', |
116 'boolean': 'bool', | 118 'boolean': 'bool', |
117 'unrestricted double': 'double', | 119 'unrestricted double': 'double', |
118 'unrestricted float': 'float', | 120 'unrestricted float': 'float', |
119 } | 121 } |
120 | 122 |
121 | 123 |
122 def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_rvalue_ type=False, used_as_variadic_argument=False, used_in_cpp_sequence=False): | 124 def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_rvalue_ type=False, used_as_variadic_argument=False, used_in_cpp_sequence=False): |
123 """Returns C++ type corresponding to IDL type. | 125 """Returns C++ type corresponding to IDL type. |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
485 'unsigned long': 'toUInt32({isolate}, {arguments})', | 487 'unsigned long': 'toUInt32({isolate}, {arguments})', |
486 'long long': 'toInt64({isolate}, {arguments})', | 488 'long long': 'toInt64({isolate}, {arguments})', |
487 'unsigned long long': 'toUInt64({isolate}, {arguments})', | 489 'unsigned long long': 'toUInt64({isolate}, {arguments})', |
488 # Interface types | 490 # Interface types |
489 'Dictionary': 'Dictionary({v8_value}, {isolate}, exceptionState)', | 491 'Dictionary': 'Dictionary({v8_value}, {isolate}, exceptionState)', |
490 'EventTarget': 'toEventTarget({isolate}, {v8_value})', | 492 'EventTarget': 'toEventTarget({isolate}, {v8_value})', |
491 'NodeFilter': 'toNodeFilter({v8_value}, info.Holder(), ScriptState::current( {isolate}))', | 493 'NodeFilter': 'toNodeFilter({v8_value}, info.Holder(), ScriptState::current( {isolate}))', |
492 'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value}) ', | 494 'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value}) ', |
493 'SerializedScriptValue': 'SerializedScriptValueFactory::instance().create({v 8_value}, 0, 0, exceptionState, {isolate})', | 495 'SerializedScriptValue': 'SerializedScriptValueFactory::instance().create({v 8_value}, 0, 0, exceptionState, {isolate})', |
494 'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})', | 496 'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})', |
497 'SmallTypedArray': '{v8_value}->IsArrayBufferView() ? {variable_name} = std: :make_pair(alloca(v8::ArrayBufferView::Cast(*{v8_value})->ByteLength()), v8::Arr ayBufferView::Cast(*{v8_value})->ByteLength()), v8::ArrayBufferView::Cast(*{v8_v alue})->CopyContents({variable_name}.first, {variable_name}.second), {variable_n ame} : std::make_pair(nullptr, 0)', | |
Ken Russell (switch to Gerrit)
2015/04/14 01:40:26
Is there any way to split this up into multiple ex
Jens Widell
2015/04/14 09:18:18
I think we should make a helper function out of it
| |
495 'Window': 'toDOMWindow({isolate}, {v8_value})', | 498 'Window': 'toDOMWindow({isolate}, {v8_value})', |
496 'XPathNSResolver': 'toXPathNSResolver({isolate}, {v8_value})', | 499 'XPathNSResolver': 'toXPathNSResolver({isolate}, {v8_value})', |
497 } | 500 } |
498 | 501 |
499 | 502 |
500 def v8_conversion_needs_exception_state(idl_type): | 503 def v8_conversion_needs_exception_state(idl_type): |
501 return (idl_type.is_numeric_type or | 504 return (idl_type.is_numeric_type or |
502 idl_type.is_enum or | 505 idl_type.is_enum or |
503 idl_type.is_dictionary or | 506 idl_type.is_dictionary or |
504 idl_type.name in ('ByteString', 'Dictionary', 'USVString', 'Serializ edScriptValue')) | 507 idl_type.name in ('ByteString', 'Dictionary', 'USVString', 'Serializ edScriptValue')) |
505 | 508 |
506 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep tion_state) | 509 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep tion_state) |
507 IdlArrayOrSequenceType.v8_conversion_needs_exception_state = True | 510 IdlArrayOrSequenceType.v8_conversion_needs_exception_state = True |
508 IdlUnionType.v8_conversion_needs_exception_state = True | 511 IdlUnionType.v8_conversion_needs_exception_state = True |
509 | 512 |
510 | 513 |
511 TRIVIAL_CONVERSIONS = frozenset([ | 514 TRIVIAL_CONVERSIONS = frozenset([ |
512 'any', | 515 'any', |
513 'boolean', | 516 'boolean', |
514 'Date', | 517 'Date', |
515 'Dictionary', | 518 'Dictionary', |
516 'NodeFilter', | 519 'NodeFilter', |
520 'SmallTypedArray', | |
517 'XPathNSResolver', | 521 'XPathNSResolver', |
518 'Promise' | 522 'Promise' |
519 ]) | 523 ]) |
520 | 524 |
521 | 525 |
522 def v8_conversion_is_trivial(idl_type): | 526 def v8_conversion_is_trivial(idl_type): |
523 # The conversion is a simple expression that returns the converted value and | 527 # The conversion is a simple expression that returns the converted value and |
524 # cannot raise an exception. | 528 # cannot raise an exception. |
525 return (idl_type.base_type in TRIVIAL_CONVERSIONS or | 529 return (idl_type.base_type in TRIVIAL_CONVERSIONS or |
526 idl_type.is_wrapper_type) | 530 idl_type.is_wrapper_type) |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
970 number_of_nullable_member_types_union) | 974 number_of_nullable_member_types_union) |
971 | 975 |
972 | 976 |
973 def includes_nullable_type_union(idl_type): | 977 def includes_nullable_type_union(idl_type): |
974 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type | 978 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type |
975 return idl_type.number_of_nullable_member_types == 1 | 979 return idl_type.number_of_nullable_member_types == 1 |
976 | 980 |
977 IdlTypeBase.includes_nullable_type = False | 981 IdlTypeBase.includes_nullable_type = False |
978 IdlNullableType.includes_nullable_type = True | 982 IdlNullableType.includes_nullable_type = True |
979 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) | 983 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) |
OLD | NEW |