| Index: Source/bindings/scripts/v8_methods.py
|
| diff --git a/Source/bindings/scripts/v8_methods.py b/Source/bindings/scripts/v8_methods.py
|
| index 17a8c4ddf7467b42c8bdd0484c67391e07e58ca6..3372178c08ed9f093371d8234d4855e38883dc41 100644
|
| --- a/Source/bindings/scripts/v8_methods.py
|
| +++ b/Source/bindings/scripts/v8_methods.py
|
| @@ -209,18 +209,18 @@ def argument_context(interface, method, argument, index):
|
| not idl_type.is_basic_type):
|
| raise Exception('Private scripts supports only primitive types and DOM wrappers.')
|
|
|
| - default_cpp_value = argument.default_cpp_value
|
| + set_default_value = argument.set_default_value
|
| return {
|
| 'cpp_type': idl_type.cpp_type_args(extended_attributes=extended_attributes,
|
| raw_type=True,
|
| used_as_variadic_argument=argument.is_variadic),
|
| 'cpp_value': this_cpp_value,
|
| # FIXME: check that the default value's type is compatible with the argument's
|
| - 'default_value': default_cpp_value,
|
| + 'set_default_value': set_default_value,
|
| 'enum_validation_expression': idl_type.enum_validation_expression,
|
| 'handle': '%sHandle' % argument.name,
|
| # FIXME: remove once [Default] removed and just use argument.default_value
|
| - 'has_default': 'Default' in extended_attributes or default_cpp_value,
|
| + 'has_default': 'Default' in extended_attributes or set_default_value,
|
| 'has_type_checking_interface': type_checking_interface,
|
| 'has_type_checking_unrestricted':
|
| (has_extended_attribute_value(interface, 'TypeChecking', 'Unrestricted') or
|
| @@ -397,14 +397,42 @@ def property_attributes(method):
|
| return property_attributes_list
|
|
|
|
|
| -def argument_default_cpp_value(argument):
|
| - if argument.idl_type.is_dictionary:
|
| +def argument_set_default_value(argument):
|
| + idl_type = argument.idl_type
|
| + default_value = argument.default_value
|
| + if not default_value:
|
| return None
|
| - if not argument.default_value:
|
| + if idl_type.is_dictionary:
|
| + if not argument.default_value.is_null:
|
| + raise Exception('invalid default value for dictionary type')
|
| return None
|
| - return argument.idl_type.literal_cpp_value(argument.default_value)
|
| -
|
| -IdlArgument.default_cpp_value = property(argument_default_cpp_value)
|
| + if idl_type.is_union_type:
|
| + if argument.default_value.is_null:
|
| + if not idl_type.includes_nullable_type:
|
| + raise Exception('invalid default value for union type: null for %s'
|
| + % idl_type.name)
|
| + # Union container objects are "null" initially.
|
| + return '/* null default value */'
|
| + if isinstance(default_value.value, basestring):
|
| + member_type = idl_type.string_member_type
|
| + elif isinstance(default_value.value, (int, float)):
|
| + member_type = idl_type.numeric_member_type
|
| + elif isinstance(default_value.value, bool):
|
| + member_type = idl_type.boolean_member_type
|
| + else:
|
| + member_type = None
|
| + if member_type is None:
|
| + raise Exception('invalid default value for union type: %r for %s'
|
| + % (default_value.value, idl_type.name))
|
| + member_type_name = (member_type.inner_type.name
|
| + if member_type.is_nullable else
|
| + member_type.name)
|
| + return '%s.set%s(%s)' % (argument.name, member_type_name,
|
| + member_type.literal_cpp_value(default_value))
|
| + return '%s = %s' % (argument.name,
|
| + idl_type.literal_cpp_value(default_value))
|
| +
|
| +IdlArgument.set_default_value = property(argument_set_default_value)
|
|
|
|
|
| def method_returns_promise(method):
|
|
|