Index: Source/bindings/dart/scripts/dart_types.py |
diff --git a/Source/bindings/dart/scripts/dart_types.py b/Source/bindings/dart/scripts/dart_types.py |
index d7d94bceca3946677d8abca6b567f69d77fc6ab0..1ca39fb5ae9a44b5e34c20896ebf70bda7c50533 100644 |
--- a/Source/bindings/dart/scripts/dart_types.py |
+++ b/Source/bindings/dart/scripts/dart_types.py |
@@ -399,7 +399,7 @@ DART_TO_CPP_VALUE = { |
} |
-def dart_value_to_cpp_value(idl_type, extended_attributes, variable_name, |
+def dart_value_to_cpp_value(idl_type, interface_extended_attributes, extended_attributes, variable_name, |
null_check, index, auto_scope=True): |
# Composite types |
array_or_sequence_type = idl_type.array_or_sequence_type |
@@ -425,7 +425,8 @@ def dart_value_to_cpp_value(idl_type, extended_attributes, variable_name, |
# FIXME(vsm): When do we call the externalized version? E.g., see |
# bindings/dart/custom/DartWaveShaperNodeCustom.cpp - it calls |
# DartUtilities::dartToExternalizedArrayBufferView instead. |
- cpp_expression_format = ('DartUtilities::dartTo{idl_type}{null_check}(args, {index}, exception)') |
+ # V8 always converts null here |
+ cpp_expression_format = ('DartUtilities::dartTo{idl_type}WithNullCheck(args, {index}, exception)') |
elif idl_type.is_callback_interface: |
cpp_expression_format = ('Dart{idl_type}::create{null_check}(args, {index}, exception)') |
else: |
@@ -435,8 +436,7 @@ def dart_value_to_cpp_value(idl_type, extended_attributes, variable_name, |
# some cases that require calling context info. V8 handles all |
# of this differently, and we may wish to reconsider this approach |
null_check = 'WithNullCheck' \ |
- if null_check or allow_null(idl_type, extended_attributes) else '' |
- |
+ if null_check or allow_null(idl_type, interface_extended_attributes, extended_attributes) else '' |
return cpp_expression_format.format(null_check=null_check, |
arguments=arguments, |
index=index, |
@@ -469,14 +469,14 @@ def dart_value_to_cpp_value_array_or_sequence(array_or_sequence_type, variable_n |
return expression |
-def dart_value_to_local_cpp_value(idl_type, extended_attributes, variable_name, |
- null_check, index=None, auto_scope=True): |
+def dart_value_to_local_cpp_value(idl_type, interface_extended_attributes, extended_attributes, |
+ variable_name, null_check, index=None, auto_scope=True): |
"""Returns an expression that converts a Dart value to a C++ value as a local value.""" |
idl_type = idl_type.preprocessed_type |
cpp_value = dart_value_to_cpp_value( |
- idl_type, extended_attributes, variable_name, null_check, index, |
- auto_scope) |
+ idl_type, interface_extended_attributes, extended_attributes, |
+ variable_name, null_check, index, auto_scope) |
return cpp_value |
@@ -753,22 +753,43 @@ IdlType.name = property(dart_name) |
IdlUnionType.name = property(dart_name) |
+def typechecked_interface(extended_attributes): |
+ return ('TypeChecking' in extended_attributes and\ |
+ DartUtilities.extended_attribute_value_contains(extended_attributes['TypeChecking'], 'Interface')) |
+ |
+ |
+def typechecked_argument(idl_type, interface_extended_attributes, extended_attributes): |
+ return (idl_type.is_wrapper_type and |
+ (typechecked_interface(interface_extended_attributes) or |
+ (typechecked_interface(extended_attributes)))) |
+ |
+ |
# If True use the WithNullCheck version when converting. |
-def allow_null(idl_type, extended_attributes): |
+def allow_null(idl_type, interface_extended_attributes, extended_attributes): |
+ if idl_type.base_type in ('DOMString', 'ByteString', 'ScalarValueString'): |
+ # This logic is in cpp_types in v8_types.py, since they handle |
+ # this using the V8StringResource type. We handle it here |
+ if (extended_attributes.get('TreatNullAs') == 'NullString' or |
+ extended_attributes.get('TreatUndefinedAs') == 'NullString'): |
+ return True |
+ |
+ if extended_attributes.get('Default') == 'NullString': |
+ return True |
- # This logic is implemented in the methods.cpp template in V8 |
- if idl_type.is_nullable: |
- return True |
+ if extended_attributes.get('Default') == 'Undefined': |
+ return True |
- if extended_attributes.get('Default') == 'NullString': |
- return True |
+ if idl_type.is_nullable: |
+ return True |
+ |
+ return False |
+ else: |
+ # This logic is implemented in the methods.cpp template in V8 |
+ if (idl_type.is_nullable or |
+ (not typechecked_argument(idl_type, interface_extended_attributes, extended_attributes))): |
+ return True |
- if extended_attributes.get('Default') == 'Undefined': |
- return True |
+ if extended_attributes.get('Default') == 'Undefined': |
+ return True |
- # This logic is in cpp_types in v8_types.py, since they handle |
- # this using the V8StringResource type. We handle it here |
- if (extended_attributes.get('TreatNullAs') == 'NullString' or |
- extended_attributes.get('TreatUndefinedAs') == 'NullString'): |
- return True |
- return False |
+ return False |