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

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

Issue 567503002: Add toDouble() helper, and use toFloat()/toDouble() for conversions (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
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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 # V8 -> C++ 441 # V8 -> C++
442 ################################################################################ 442 ################################################################################
443 443
444 V8_VALUE_TO_CPP_VALUE = { 444 V8_VALUE_TO_CPP_VALUE = {
445 # Basic 445 # Basic
446 'Date': 'toCoreDate({v8_value})', 446 'Date': 'toCoreDate({v8_value})',
447 'DOMString': '{v8_value}', 447 'DOMString': '{v8_value}',
448 'ByteString': 'toByteString({arguments})', 448 'ByteString': 'toByteString({arguments})',
449 'ScalarValueString': 'toScalarValueString({arguments})', 449 'ScalarValueString': 'toScalarValueString({arguments})',
450 'boolean': '{v8_value}->BooleanValue()', 450 'boolean': '{v8_value}->BooleanValue()',
451 'float': 'static_cast<float>({v8_value}->NumberValue())', 451 'float': 'toFloat({arguments})',
452 'unrestricted float': 'static_cast<float>({v8_value}->NumberValue())', 452 'unrestricted float': 'toFloat({arguments})',
453 'double': 'static_cast<double>({v8_value}->NumberValue())', 453 'double': 'toDouble({arguments})',
454 'unrestricted double': 'static_cast<double>({v8_value}->NumberValue())', 454 'unrestricted double': 'toDouble({arguments})',
455 'byte': 'toInt8({arguments})', 455 'byte': 'toInt8({arguments})',
456 'octet': 'toUInt8({arguments})', 456 'octet': 'toUInt8({arguments})',
457 'short': 'toInt16({arguments})', 457 'short': 'toInt16({arguments})',
458 'unsigned short': 'toUInt16({arguments})', 458 'unsigned short': 'toUInt16({arguments})',
459 'long': 'toInt32({arguments})', 459 'long': 'toInt32({arguments})',
460 'unsigned long': 'toUInt32({arguments})', 460 'unsigned long': 'toUInt32({arguments})',
461 'long long': 'toInt64({arguments})', 461 'long long': 'toInt64({arguments})',
462 'unsigned long long': 'toUInt64({arguments})', 462 'unsigned long long': 'toUInt64({arguments})',
463 # Interface types 463 # Interface types
464 'CompareHow': 'static_cast<Range::CompareHow>({v8_value}->Int32Value())', 464 'CompareHow': 'static_cast<Range::CompareHow>({v8_value}->Int32Value())',
465 'Dictionary': 'Dictionary({v8_value}, {isolate})', 465 'Dictionary': 'Dictionary({v8_value}, {isolate})',
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): 476 def v8_conversion_needs_exception_state(idl_type):
477 return (idl_type.is_integer_type or 477 return (idl_type.is_numeric_type or
478 idl_type.is_dictionary or 478 idl_type.is_dictionary or
479 idl_type.name in ('ByteString', 'ScalarValueString')) 479 idl_type.name in ('ByteString', 'ScalarValueString'))
480 480
481 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep tion_state) 481 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep tion_state)
482 482
483 483
484 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat e): 484 def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, index, isolat e):
485 if idl_type.name == 'void': 485 if idl_type.name == 'void':
486 return '' 486 return ''
487 487
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 821
822 822
823 def is_explicit_nullable(idl_type): 823 def is_explicit_nullable(idl_type):
824 # Nullable type that isn't implicit nullable (see above.) For such types, 824 # Nullable type that isn't implicit nullable (see above.) For such types,
825 # we use Nullable<T> or similar explicit ways to represent a null value. 825 # we use Nullable<T> or similar explicit ways to represent a null value.
826 return idl_type.is_nullable and not idl_type.is_implicit_nullable 826 return idl_type.is_nullable and not idl_type.is_implicit_nullable
827 827
828 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) 828 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable)
829 IdlUnionType.is_implicit_nullable = False 829 IdlUnionType.is_implicit_nullable = False
830 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) 830 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698