| Index: Source/bindings/scripts/v8_types.py
|
| diff --git a/Source/bindings/scripts/v8_types.py b/Source/bindings/scripts/v8_types.py
|
| index 0a070f8074c00ca2bed6b7a4c1d70b52bf6b4bee..ea639007ff3047bcfe3dc273fb0808a76aacbb57 100644
|
| --- a/Source/bindings/scripts/v8_types.py
|
| +++ b/Source/bindings/scripts/v8_types.py
|
| @@ -120,7 +120,8 @@ CPP_SPECIAL_CONVERSION_RULES = {
|
| }
|
|
|
|
|
| -def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_argument=False, used_as_variadic_argument=False, used_in_cpp_sequence=False):
|
| +# FIXME: too many flags.
|
| +def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_argument=False, used_as_variadic_argument=False, used_as_member=False, used_as_return_type=False):
|
| """Returns C++ type corresponding to IDL type.
|
|
|
| |idl_type| argument is of type IdlType, while return value is a string
|
| @@ -134,8 +135,11 @@ def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_argumen
|
| bool, True if the C++ type is used as an argument of a method.
|
| used_as_variadic_argument:
|
| bool, True if the C++ type is used as a variadic argument of a method.
|
| - used_in_cpp_sequence:
|
| - bool, True if the C++ type is used as an element of an array or sequence.
|
| + used_as_member:
|
| + bool, True if the C++ type is used as a member of a container.
|
| + Containers can be an array, a sequence or a dictionary.
|
| + used_as_return_type:
|
| + bool, True if the C++ type is used as a return type of a method.
|
| """
|
| def string_mode():
|
| if extended_attributes.get('TreatNullAs') == 'EmptyString':
|
| @@ -156,7 +160,10 @@ def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_argumen
|
| native_array_element_type = idl_type.native_array_element_type
|
| if native_array_element_type:
|
| vector_type = cpp_ptr_type('Vector', 'HeapVector', native_array_element_type.gc_type)
|
| - return cpp_template_type(vector_type, native_array_element_type.cpp_type_args(used_in_cpp_sequence=True))
|
| + vector_template_type = cpp_template_type(vector_type, native_array_element_type.cpp_type_args(used_as_member=True))
|
| + if used_as_return_type:
|
| + return 'const %s&' % vector_template_type
|
| + return vector_template_type
|
|
|
| # Simple types
|
| base_idl_type = idl_type.base_type
|
| @@ -171,7 +178,7 @@ def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_argumen
|
| return CPP_SPECIAL_CONVERSION_RULES[base_idl_type]
|
|
|
| if base_idl_type in NON_WRAPPER_TYPES:
|
| - return ('PassRefPtr<%s>' if used_as_argument else 'RefPtr<%s>') % base_idl_type
|
| + return ('PassRefPtr<%s>' if used_as_argument or used_as_return_type else 'RefPtr<%s>') % base_idl_type
|
| if idl_type.is_string_type:
|
| if not raw_type:
|
| return 'String'
|
| @@ -183,8 +190,8 @@ def cpp_type(idl_type, extended_attributes=None, raw_type=False, used_as_argumen
|
| implemented_as_class = idl_type.implemented_as
|
| if raw_type:
|
| return implemented_as_class + '*'
|
| - new_type = 'Member' if used_in_cpp_sequence else 'RawPtr'
|
| - ptr_type = cpp_ptr_type(('PassRefPtr' if used_as_argument else 'RefPtr'), new_type, idl_type.gc_type)
|
| + new_type = 'Member' if used_as_member else 'RawPtr'
|
| + ptr_type = cpp_ptr_type(('PassRefPtr' if used_as_argument or used_as_return_type else 'RefPtr'), new_type, idl_type.gc_type)
|
| return cpp_template_type(ptr_type, implemented_as_class)
|
| # Default, assume native type is a pointer with same type name as idl type
|
| return base_idl_type + '*'
|
| @@ -723,6 +730,8 @@ CPP_VALUE_TO_V8_VALUE = {
|
| def cpp_value_to_v8_value(idl_type, cpp_value, isolate='info.GetIsolate()', creation_context='info.Holder()', extended_attributes=None):
|
| """Returns an expression that converts a C++ value to a V8 value."""
|
| # the isolate parameter is needed for callback interfaces
|
| + if cpp_value == 'nullptr':
|
| + return 'v8::Null(%s)' % isolate
|
| idl_type, cpp_value = preprocess_idl_type_and_value(idl_type, cpp_value, extended_attributes)
|
| this_v8_conversion_type = idl_type.v8_conversion_type(extended_attributes)
|
| format_string = CPP_VALUE_TO_V8_VALUE[this_v8_conversion_type]
|
|
|