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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 def set_component_dirs(new_component_dirs): | 461 def set_component_dirs(new_component_dirs): |
462 component_dir.update(new_component_dirs) | 462 component_dir.update(new_component_dirs) |
463 | 463 |
464 | 464 |
465 ################################################################################ | 465 ################################################################################ |
466 # V8 -> C++ | 466 # V8 -> C++ |
467 ################################################################################ | 467 ################################################################################ |
468 | 468 |
469 V8_VALUE_TO_CPP_VALUE = { | 469 V8_VALUE_TO_CPP_VALUE = { |
470 # Basic | 470 # Basic |
471 'Date': 'toCoreDate({v8_value})', | 471 'Date': 'toCoreDate({isolate}, {v8_value})', |
472 'DOMString': '{v8_value}', | 472 'DOMString': '{v8_value}', |
473 'ByteString': 'toByteString({arguments})', | 473 'ByteString': 'toByteString({isolate}, {arguments})', |
474 'USVString': 'toUSVString({arguments})', | 474 'USVString': 'toUSVString({isolate}, {arguments})', |
475 'boolean': '{v8_value}->BooleanValue()', | 475 'boolean': '{v8_value}->BooleanValue()', |
476 'float': 'toRestrictedFloat({arguments})', | 476 'float': 'toRestrictedFloat({isolate}, {arguments})', |
477 'unrestricted float': 'toFloat({arguments})', | 477 'unrestricted float': 'toFloat({isolate}, {arguments})', |
478 'double': 'toRestrictedDouble({arguments})', | 478 'double': 'toRestrictedDouble({isolate}, {arguments})', |
479 'unrestricted double': 'toDouble({arguments})', | 479 'unrestricted double': 'toDouble({isolate}, {arguments})', |
480 'byte': 'toInt8({arguments})', | 480 'byte': 'toInt8({isolate}, {arguments})', |
481 'octet': 'toUInt8({arguments})', | 481 'octet': 'toUInt8({isolate}, {arguments})', |
482 'short': 'toInt16({arguments})', | 482 'short': 'toInt16({isolate}, {arguments})', |
483 'unsigned short': 'toUInt16({arguments})', | 483 'unsigned short': 'toUInt16({isolate}, {arguments})', |
484 'long': 'toInt32({arguments})', | 484 'long': 'toInt32({isolate}, {arguments})', |
485 'unsigned long': 'toUInt32({arguments})', | 485 'unsigned long': 'toUInt32({isolate}, {arguments})', |
486 'long long': 'toInt64({arguments})', | 486 'long long': 'toInt64({isolate}, {arguments})', |
487 'unsigned long long': 'toUInt64({arguments})', | 487 'unsigned long long': 'toUInt64({isolate}, {arguments})', |
488 # Interface types | 488 # Interface types |
489 'Dictionary': 'Dictionary({v8_value}, {isolate}, exceptionState)', | 489 'Dictionary': 'Dictionary({v8_value}, {isolate}, exceptionState)', |
490 'EventTarget': 'toEventTarget({isolate}, {v8_value})', | 490 'EventTarget': 'toEventTarget({isolate}, {v8_value})', |
491 'NodeFilter': 'toNodeFilter({v8_value}, info.Holder(), ScriptState::current(
{isolate}))', | 491 'NodeFilter': 'toNodeFilter({v8_value}, info.Holder(), ScriptState::current(
{isolate}))', |
492 'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value})
', | 492 'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value})
', |
493 'SerializedScriptValue': 'SerializedScriptValueFactory::instance().create({v
8_value}, 0, 0, exceptionState, {isolate})', | 493 'SerializedScriptValue': 'SerializedScriptValueFactory::instance().create({v
8_value}, 0, 0, exceptionState, {isolate})', |
494 'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})', | 494 'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})', |
495 'Window': 'toDOMWindow({isolate}, {v8_value})', | 495 'Window': 'toDOMWindow({isolate}, {v8_value})', |
496 'XPathNSResolver': 'toXPathNSResolver({isolate}, {v8_value})', | 496 'XPathNSResolver': 'toXPathNSResolver({isolate}, {v8_value})', |
497 } | 497 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
542 base_idl_type = idl_type.as_union_type.name if idl_type.is_union_type else i
dl_type.base_type | 542 base_idl_type = idl_type.as_union_type.name if idl_type.is_union_type else i
dl_type.base_type |
543 | 543 |
544 if 'EnforceRange' in extended_attributes: | 544 if 'EnforceRange' in extended_attributes: |
545 arguments = ', '.join([v8_value, 'EnforceRange', 'exceptionState']) | 545 arguments = ', '.join([v8_value, 'EnforceRange', 'exceptionState']) |
546 elif 'Clamp' in extended_attributes: | 546 elif 'Clamp' in extended_attributes: |
547 arguments = ', '.join([v8_value, 'Clamp', 'exceptionState']) | 547 arguments = ', '.join([v8_value, 'Clamp', 'exceptionState']) |
548 elif idl_type.v8_conversion_needs_exception_state: | 548 elif idl_type.v8_conversion_needs_exception_state: |
549 arguments = ', '.join([v8_value, 'exceptionState']) | 549 arguments = ', '.join([v8_value, 'exceptionState']) |
550 else: | 550 else: |
551 arguments = v8_value | 551 arguments = v8_value |
552 | |
553 if base_idl_type in V8_VALUE_TO_CPP_VALUE: | 552 if base_idl_type in V8_VALUE_TO_CPP_VALUE: |
554 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type] | 553 cpp_expression_format = V8_VALUE_TO_CPP_VALUE[base_idl_type] |
555 elif idl_type.is_array_buffer_or_view: | 554 elif idl_type.is_array_buffer_or_view: |
556 cpp_expression_format = ( | 555 cpp_expression_format = ( |
557 '{v8_value}->Is{idl_type}() ? ' | 556 '{v8_value}->Is{idl_type}() ? ' |
558 'V8{idl_type}::toImpl(v8::Local<v8::{idl_type}>::Cast({v8_value})) :
0') | 557 'V8{idl_type}::toImpl(v8::Local<v8::{idl_type}>::Cast({v8_value})) :
0') |
559 elif idl_type.use_output_parameter_for_result: | 558 elif idl_type.use_output_parameter_for_result: |
560 if idl_type.includes_nullable_type: | 559 if idl_type.includes_nullable_type: |
561 base_idl_type = idl_type.cpp_type + 'OrNull' | 560 base_idl_type = idl_type.cpp_type + 'OrNull' |
562 cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, {va
riable_name}, exceptionState)' | 561 cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, {va
riable_name}, exceptionState)' |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
967 number_of_nullable_member_types_union) | 966 number_of_nullable_member_types_union) |
968 | 967 |
969 | 968 |
970 def includes_nullable_type_union(idl_type): | 969 def includes_nullable_type_union(idl_type): |
971 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type | 970 # http://heycam.github.io/webidl/#dfn-includes-a-nullable-type |
972 return idl_type.number_of_nullable_member_types == 1 | 971 return idl_type.number_of_nullable_member_types == 1 |
973 | 972 |
974 IdlTypeBase.includes_nullable_type = False | 973 IdlTypeBase.includes_nullable_type = False |
975 IdlNullableType.includes_nullable_type = True | 974 IdlNullableType.includes_nullable_type = True |
976 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) | 975 IdlUnionType.includes_nullable_type = property(includes_nullable_type_union) |
OLD | NEW |