| 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 433 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  444  |  444  | 
|  445 ################################################################################ |  445 ################################################################################ | 
|  446 # V8 -> C++ |  446 # V8 -> C++ | 
|  447 ################################################################################ |  447 ################################################################################ | 
|  448  |  448  | 
|  449 V8_VALUE_TO_CPP_VALUE = { |  449 V8_VALUE_TO_CPP_VALUE = { | 
|  450     # Basic |  450     # Basic | 
|  451     'Date': 'toCoreDate({v8_value})', |  451     'Date': 'toCoreDate({v8_value})', | 
|  452     'DOMString': '{v8_value}', |  452     'DOMString': '{v8_value}', | 
|  453     'ByteString': 'toByteString({arguments})', |  453     'ByteString': 'toByteString({arguments})', | 
|  454     'ScalarValueString': 'toScalarValueString({arguments})', |  454     'USVString': 'toUSVString({arguments})', | 
|  455     'boolean': '{v8_value}->BooleanValue()', |  455     'boolean': '{v8_value}->BooleanValue()', | 
|  456     'float': 'toFloat({arguments})', |  456     'float': 'toFloat({arguments})', | 
|  457     'unrestricted float': 'toFloat({arguments})', |  457     'unrestricted float': 'toFloat({arguments})', | 
|  458     'double': 'toDouble({arguments})', |  458     'double': 'toDouble({arguments})', | 
|  459     'unrestricted double': 'toDouble({arguments})', |  459     'unrestricted double': 'toDouble({arguments})', | 
|  460     'byte': 'toInt8({arguments})', |  460     'byte': 'toInt8({arguments})', | 
|  461     'octet': 'toUInt8({arguments})', |  461     'octet': 'toUInt8({arguments})', | 
|  462     'short': 'toInt16({arguments})', |  462     'short': 'toInt16({arguments})', | 
|  463     'unsigned short': 'toUInt16({arguments})', |  463     'unsigned short': 'toUInt16({arguments})', | 
|  464     'long': 'toInt32({arguments})', |  464     'long': 'toInt32({arguments})', | 
|  465     'unsigned long': 'toUInt32({arguments})', |  465     'unsigned long': 'toUInt32({arguments})', | 
|  466     'long long': 'toInt64({arguments})', |  466     'long long': 'toInt64({arguments})', | 
|  467     'unsigned long long': 'toUInt64({arguments})', |  467     'unsigned long long': 'toUInt64({arguments})', | 
|  468     # Interface types |  468     # Interface types | 
|  469     'Dictionary': 'Dictionary({v8_value}, {isolate})', |  469     'Dictionary': 'Dictionary({v8_value}, {isolate})', | 
|  470     'EventTarget': 'V8DOMWrapper::isDOMWrapper({v8_value}) ? toWrapperTypeInfo(v
     8::Handle<v8::Object>::Cast({v8_value}))->toEventTarget(v8::Handle<v8::Object>::
     Cast({v8_value})) : 0', |  470     'EventTarget': 'V8DOMWrapper::isDOMWrapper({v8_value}) ? toWrapperTypeInfo(v
     8::Handle<v8::Object>::Cast({v8_value}))->toEventTarget(v8::Handle<v8::Object>::
     Cast({v8_value})) : 0', | 
|  471     'NodeFilter': 'toNodeFilter({v8_value}, info.Holder(), ScriptState::current(
     {isolate}))', |  471     'NodeFilter': 'toNodeFilter({v8_value}, info.Holder(), ScriptState::current(
     {isolate}))', | 
|  472     'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value})
     ', |  472     'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value})
     ', | 
|  473     'SerializedScriptValue': 'SerializedScriptValue::create({v8_value}, 0, 0, ex
     ceptionState, {isolate})', |  473     'SerializedScriptValue': 'SerializedScriptValue::create({v8_value}, 0, 0, ex
     ceptionState, {isolate})', | 
|  474     'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})', |  474     'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})', | 
|  475     'Window': 'toDOMWindow({v8_value}, {isolate})', |  475     'Window': 'toDOMWindow({v8_value}, {isolate})', | 
|  476     'XPathNSResolver': 'toXPathNSResolver({v8_value}, {isolate})', |  476     'XPathNSResolver': 'toXPathNSResolver({v8_value}, {isolate})', | 
|  477 } |  477 } | 
|  478  |  478  | 
|  479  |  479  | 
|  480 def v8_conversion_needs_exception_state(idl_type): |  480 def v8_conversion_needs_exception_state(idl_type): | 
|  481     return (idl_type.is_numeric_type or |  481     return (idl_type.is_numeric_type or | 
|  482             idl_type.is_dictionary or |  482             idl_type.is_dictionary or | 
|  483             idl_type.name in ('ByteString', 'ScalarValueString', 'SerializedScri
     ptValue')) |  483             idl_type.name in ('ByteString', 'USVString', 'SerializedScriptValue'
     )) | 
|  484  |  484  | 
|  485 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep
     tion_state) |  485 IdlType.v8_conversion_needs_exception_state = property(v8_conversion_needs_excep
     tion_state) | 
|  486 IdlArrayOrSequenceType.v8_conversion_needs_exception_state = True |  486 IdlArrayOrSequenceType.v8_conversion_needs_exception_state = True | 
|  487  |  487  | 
|  488  |  488  | 
|  489 TRIVIAL_CONVERSIONS = frozenset([ |  489 TRIVIAL_CONVERSIONS = frozenset([ | 
|  490     'any', |  490     'any', | 
|  491     'boolean', |  491     'boolean', | 
|  492     'Date', |  492     'Date', | 
|  493     'Dictionary', |  493     'Dictionary', | 
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  729  |  729  | 
|  730 IdlTypeBase.v8_conversion_type = v8_conversion_type |  730 IdlTypeBase.v8_conversion_type = v8_conversion_type | 
|  731  |  731  | 
|  732  |  732  | 
|  733 V8_SET_RETURN_VALUE = { |  733 V8_SET_RETURN_VALUE = { | 
|  734     'boolean': 'v8SetReturnValueBool(info, {cpp_value})', |  734     'boolean': 'v8SetReturnValueBool(info, {cpp_value})', | 
|  735     'int': 'v8SetReturnValueInt(info, {cpp_value})', |  735     'int': 'v8SetReturnValueInt(info, {cpp_value})', | 
|  736     'unsigned': 'v8SetReturnValueUnsigned(info, {cpp_value})', |  736     'unsigned': 'v8SetReturnValueUnsigned(info, {cpp_value})', | 
|  737     'DOMString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', |  737     'DOMString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', | 
|  738     'ByteString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())'
     , |  738     'ByteString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())'
     , | 
|  739     'ScalarValueString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsol
     ate())', |  739     'USVString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', | 
|  740     # [TreatReturnedNullStringAs] |  740     # [TreatReturnedNullStringAs] | 
|  741     'StringOrNull': 'v8SetReturnValueStringOrNull(info, {cpp_value}, info.GetIso
     late())', |  741     'StringOrNull': 'v8SetReturnValueStringOrNull(info, {cpp_value}, info.GetIso
     late())', | 
|  742     'StringOrUndefined': 'v8SetReturnValueStringOrUndefined(info, {cpp_value}, i
     nfo.GetIsolate())', |  742     'StringOrUndefined': 'v8SetReturnValueStringOrUndefined(info, {cpp_value}, i
     nfo.GetIsolate())', | 
|  743     'void': '', |  743     'void': '', | 
|  744     # No special v8SetReturnValue* function (set value directly) |  744     # No special v8SetReturnValue* function (set value directly) | 
|  745     'float': 'v8SetReturnValue(info, {cpp_value})', |  745     'float': 'v8SetReturnValue(info, {cpp_value})', | 
|  746     'unrestricted float': 'v8SetReturnValue(info, {cpp_value})', |  746     'unrestricted float': 'v8SetReturnValue(info, {cpp_value})', | 
|  747     'double': 'v8SetReturnValue(info, {cpp_value})', |  747     'double': 'v8SetReturnValue(info, {cpp_value})', | 
|  748     'unrestricted double': 'v8SetReturnValue(info, {cpp_value})', |  748     'unrestricted double': 'v8SetReturnValue(info, {cpp_value})', | 
|  749     # No special v8SetReturnValue* function, but instead convert value to V8 |  749     # No special v8SetReturnValue* function, but instead convert value to V8 | 
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  802 IdlUnionType.release = property( |  802 IdlUnionType.release = property( | 
|  803     lambda self: [member_type.is_interface_type |  803     lambda self: [member_type.is_interface_type | 
|  804                   for member_type in self.member_types]) |  804                   for member_type in self.member_types]) | 
|  805  |  805  | 
|  806  |  806  | 
|  807 CPP_VALUE_TO_V8_VALUE = { |  807 CPP_VALUE_TO_V8_VALUE = { | 
|  808     # Built-in types |  808     # Built-in types | 
|  809     'Date': 'v8DateOrNaN({cpp_value}, {isolate})', |  809     'Date': 'v8DateOrNaN({cpp_value}, {isolate})', | 
|  810     'DOMString': 'v8String({isolate}, {cpp_value})', |  810     'DOMString': 'v8String({isolate}, {cpp_value})', | 
|  811     'ByteString': 'v8String({isolate}, {cpp_value})', |  811     'ByteString': 'v8String({isolate}, {cpp_value})', | 
|  812     'ScalarValueString': 'v8String({isolate}, {cpp_value})', |  812     'USVString': 'v8String({isolate}, {cpp_value})', | 
|  813     'boolean': 'v8Boolean({cpp_value}, {isolate})', |  813     'boolean': 'v8Boolean({cpp_value}, {isolate})', | 
|  814     'int': 'v8::Integer::New({isolate}, {cpp_value})', |  814     'int': 'v8::Integer::New({isolate}, {cpp_value})', | 
|  815     'unsigned': 'v8::Integer::NewFromUnsigned({isolate}, {cpp_value})', |  815     'unsigned': 'v8::Integer::NewFromUnsigned({isolate}, {cpp_value})', | 
|  816     'float': 'v8::Number::New({isolate}, {cpp_value})', |  816     'float': 'v8::Number::New({isolate}, {cpp_value})', | 
|  817     'unrestricted float': 'v8::Number::New({isolate}, {cpp_value})', |  817     'unrestricted float': 'v8::Number::New({isolate}, {cpp_value})', | 
|  818     'double': 'v8::Number::New({isolate}, {cpp_value})', |  818     'double': 'v8::Number::New({isolate}, {cpp_value})', | 
|  819     'unrestricted double': 'v8::Number::New({isolate}, {cpp_value})', |  819     'unrestricted double': 'v8::Number::New({isolate}, {cpp_value})', | 
|  820     'void': 'v8Undefined()', |  820     'void': 'v8Undefined()', | 
|  821     # [TreatReturnedNullStringAs] |  821     # [TreatReturnedNullStringAs] | 
|  822     'StringOrNull': '{cpp_value}.isNull() ? v8::Handle<v8::Value>(v8::Null({isol
     ate})) : v8String({isolate}, {cpp_value})', |  822     'StringOrNull': '{cpp_value}.isNull() ? v8::Handle<v8::Value>(v8::Null({isol
     ate})) : v8String({isolate}, {cpp_value})', | 
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  879  |  879  | 
|  880  |  880  | 
|  881 def is_explicit_nullable(idl_type): |  881 def is_explicit_nullable(idl_type): | 
|  882     # Nullable type that isn't implicit nullable (see above.) For such types, |  882     # Nullable type that isn't implicit nullable (see above.) For such types, | 
|  883     # we use Nullable<T> or similar explicit ways to represent a null value. |  883     # we use Nullable<T> or similar explicit ways to represent a null value. | 
|  884     return idl_type.is_nullable and not idl_type.is_implicit_nullable |  884     return idl_type.is_nullable and not idl_type.is_implicit_nullable | 
|  885  |  885  | 
|  886 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) |  886 IdlTypeBase.is_implicit_nullable = property(is_implicit_nullable) | 
|  887 IdlUnionType.is_implicit_nullable = False |  887 IdlUnionType.is_implicit_nullable = False | 
|  888 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) |  888 IdlTypeBase.is_explicit_nullable = property(is_explicit_nullable) | 
| OLD | NEW |