Index: bindings/scripts/v8_types.py |
diff --git a/bindings/scripts/v8_types.py b/bindings/scripts/v8_types.py |
index f5c92bcfc28ebc2c4a955765cc627b3c43accbd1..04739d2e46ae0fb02a255a9e12b9a11cd68c2554 100644 |
--- a/bindings/scripts/v8_types.py |
+++ b/bindings/scripts/v8_types.py |
@@ -70,8 +70,10 @@ ARRAY_BUFFER_AND_VIEW_TYPES = TYPED_ARRAY_TYPES.union(frozenset([ |
'ArrayBuffer', |
'ArrayBufferView', |
'DataView', |
+ 'SharedArrayBuffer', |
])) |
+ |
IdlType.is_array_buffer_or_view = property( |
lambda self: self.base_type in ARRAY_BUFFER_AND_VIEW_TYPES) |
@@ -182,8 +184,10 @@ def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_rvalue_ |
return 'String' |
return 'V8StringResource<%s>' % string_mode() |
- if idl_type.is_array_buffer_or_view and raw_type: |
- return idl_type.implemented_as + '*' |
+ if idl_type.base_type == 'ArrayBufferView' and 'FlexibleArrayBufferView' in extended_attributes: |
+ return 'FlexibleArrayBufferView' |
+ if idl_type.base_type in TYPED_ARRAY_TYPES and 'FlexibleArrayBufferView' in extended_attributes: |
+ return 'Flexible' + idl_type.base_type + 'View' |
if idl_type.is_interface_type: |
implemented_as_class = idl_type.implemented_as |
if raw_type or (used_as_rvalue_type and idl_type.is_garbage_collected): |
@@ -341,6 +345,8 @@ def includes_for_cpp_class(class_name, relative_dir_posix): |
INCLUDES_FOR_TYPE = { |
'object': set(), |
+ 'ArrayBufferView': set(['bindings/core/v8/V8ArrayBufferView.h', |
+ 'core/dom/FlexibleArrayBufferView.h']), |
'Dictionary': set(['bindings/core/v8/Dictionary.h']), |
'EventHandler': set(['bindings/core/v8/V8AbstractEventListener.h', |
'bindings/core/v8/V8EventListenerList.h']), |
@@ -374,6 +380,10 @@ def includes_for_type(idl_type, extended_attributes=None): |
base_idl_type = idl_type.base_type |
if base_idl_type in INCLUDES_FOR_TYPE: |
return INCLUDES_FOR_TYPE[base_idl_type] |
+ if idl_type.base_type in TYPED_ARRAY_TYPES: |
+ return INCLUDES_FOR_TYPE['ArrayBufferView'].union( |
+ set(['bindings/%s/v8/V8%s.h' % (component_dir[base_idl_type], base_idl_type)]) |
+ ) |
if idl_type.is_basic_type: |
return set() |
if base_idl_type.endswith('ConstructorConstructor'): |
@@ -497,9 +507,10 @@ V8_VALUE_TO_CPP_VALUE = { |
# Interface types |
'Dictionary': 'Dictionary({v8_value}, {isolate}, exceptionState)', |
'EventTarget': 'toEventTarget({isolate}, {v8_value})', |
+ 'FlexibleArrayBufferView': 'toFlexibleArrayBufferView({isolate}, {v8_value}, {variable_name}, allocateFlexibleArrayBufferViewStorage({v8_value}))', |
'NodeFilter': 'toNodeFilter({v8_value}, info.Holder(), ScriptState::current({isolate}))', |
'Promise': 'ScriptPromise::cast(ScriptState::current({isolate}), {v8_value})', |
- 'SerializedScriptValue': 'SerializedScriptValueFactory::instance().create({isolate}, {v8_value}, 0, 0, exceptionState)', |
+ 'SerializedScriptValue': 'SerializedScriptValueFactory::instance().create({isolate}, {v8_value}, nullptr, nullptr, nullptr, exceptionState)', |
'ScriptValue': 'ScriptValue(ScriptState::current({isolate}), {v8_value})', |
'Window': 'toDOMWindow({isolate}, {v8_value})', |
'XPathNSResolver': 'toXPathNSResolver(ScriptState::current({isolate}), {v8_value})', |
@@ -550,6 +561,11 @@ def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, variable_name |
idl_type = idl_type.preprocessed_type |
base_idl_type = idl_type.as_union_type.name if idl_type.is_union_type else idl_type.base_type |
+ if 'FlexibleArrayBufferView' in extended_attributes: |
+ if base_idl_type not in TYPED_ARRAY_TYPES.union(set(['ArrayBufferView'])): |
+ raise "Unrecognized base type for extended attribute 'FlexibleArrayBufferView': %s" % (idl_type.base_type) |
+ base_idl_type = 'FlexibleArrayBufferView' |
+ |
if idl_type.is_integer_type: |
configuration = 'NormalConversion' |
if 'EnforceRange' in extended_attributes: |
@@ -567,9 +583,10 @@ def v8_value_to_cpp_value(idl_type, extended_attributes, v8_value, variable_name |
cpp_expression_format = ( |
'{v8_value}->Is{idl_type}() ? ' |
'V8{idl_type}::toImpl(v8::Local<v8::{idl_type}>::Cast({v8_value})) : 0') |
+ elif idl_type.is_union_type: |
+ nullable = 'UnionTypeConversionMode::Nullable' if idl_type.includes_nullable_type else 'UnionTypeConversionMode::NotNullable' |
+ cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, {variable_name}, %s, exceptionState)' % nullable |
elif idl_type.use_output_parameter_for_result: |
- if idl_type.includes_nullable_type: |
- base_idl_type = idl_type.cpp_type + 'OrNull' |
cpp_expression_format = 'V8{idl_type}::toImpl({isolate}, {v8_value}, {variable_name}, exceptionState)' |
else: |
cpp_expression_format = ( |
@@ -646,6 +663,10 @@ def v8_value_to_local_cpp_value(idl_type, extended_attributes, v8_value, variabl |
return { |
'error_message': 'no V8 -> C++ conversion for IDL type: %s' % idl_type.name |
} |
+ elif 'FlexibleArrayBufferView' in extended_attributes: |
+ if idl_type.base_type not in TYPED_ARRAY_TYPES.union(set(['ArrayBufferView'])): |
+ raise "Unrecognized base type for extended attribute 'FlexibleArrayBufferView': %s" % (idl_type.base_type) |
+ set_expression = cpp_value |
else: |
assign_expression = cpp_value |
@@ -749,14 +770,7 @@ def v8_conversion_type(idl_type, extended_attributes): |
if idl_type.is_string_type: |
if idl_type.is_nullable: |
return 'StringOrNull' |
- if 'TreatReturnedNullStringAs' not in extended_attributes: |
- return base_idl_type |
- treat_returned_null_string_as = extended_attributes['TreatReturnedNullStringAs'] |
- if treat_returned_null_string_as == 'Null': |
- return 'StringOrNull' |
- if treat_returned_null_string_as == 'Undefined': |
- return 'StringOrUndefined' |
- raise 'Unrecognized TreatReturnedNullStringAs value: "%s"' % treat_returned_null_string_as |
+ return base_idl_type |
if idl_type.is_basic_type or base_idl_type == 'ScriptValue': |
return base_idl_type |
# Generic dictionary type |
@@ -780,9 +794,7 @@ V8_SET_RETURN_VALUE = { |
'DOMString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', |
'ByteString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', |
'USVString': 'v8SetReturnValueString(info, {cpp_value}, info.GetIsolate())', |
- # [TreatReturnedNullStringAs] |
'StringOrNull': 'v8SetReturnValueStringOrNull(info, {cpp_value}, info.GetIsolate())', |
- 'StringOrUndefined': 'v8SetReturnValueStringOrUndefined(info, {cpp_value}, info.GetIsolate())', |
'void': '', |
# No special v8SetReturnValue* function (set value directly) |
'float': 'v8SetReturnValue(info, {cpp_value})', |
@@ -869,9 +881,7 @@ CPP_VALUE_TO_V8_VALUE = { |
'double': 'v8::Number::New({isolate}, {cpp_value})', |
'unrestricted double': 'v8::Number::New({isolate}, {cpp_value})', |
'void': 'v8Undefined()', |
- # [TreatReturnedNullStringAs] |
'StringOrNull': '{cpp_value}.isNull() ? v8::Local<v8::Value>(v8::Null({isolate})) : v8String({isolate}, {cpp_value})', |
- 'StringOrUndefined': '{cpp_value}.isNull() ? v8Undefined() : v8String({isolate}, {cpp_value})', |
# Special cases |
'Dictionary': '{cpp_value}.v8Value()', |
'EventHandler': '{cpp_value} ? v8::Local<v8::Value>(V8AbstractEventListener::cast({cpp_value})->getListenerObject(impl->executionContext())) : v8::Local<v8::Value>(v8::Null({isolate}))', |