Index: Source/bindings/scripts/v8_methods.py |
diff --git a/Source/bindings/scripts/v8_methods.py b/Source/bindings/scripts/v8_methods.py |
index 299f6ba4fb007550992743fd1485162e0fc87655..cdcb3f20988c294206d8d89e5684108a09693d0c 100644 |
--- a/Source/bindings/scripts/v8_methods.py |
+++ b/Source/bindings/scripts/v8_methods.py |
@@ -178,7 +178,7 @@ def method_context(interface, method, is_visible=True): |
'runtime_enabled_function': v8_utilities.runtime_enabled_function_name(method), # [RuntimeEnabled] |
'should_be_exposed_to_script': not (is_implemented_in_private_script and is_only_exposed_to_private_script), |
'signature': 'v8::Local<v8::Signature>()' if is_static or 'DoNotCheckSignature' in extended_attributes else 'defaultSignature', |
- 'union_arguments': idl_type.union_arguments, |
+ 'union_result_members': idl_type.union_result_members, |
'use_output_parameter_for_result': idl_type.is_dictionary, |
'use_local_result': use_local_result(method), |
'v8_set_return_value': v8_set_return_value(interface.name, method, this_cpp_value), |
@@ -296,11 +296,6 @@ def cpp_value(interface, method, number_of_arguments): |
cpp_arguments.append('*impl') |
cpp_arguments.extend(cpp_argument(argument) for argument in arguments) |
- this_union_arguments = method.idl_type and method.idl_type.union_arguments |
- if this_union_arguments: |
- cpp_arguments.extend([member_argument['cpp_value'] |
- for member_argument in this_union_arguments]) |
- |
if 'ImplementedInPrivateScript' in method.extended_attributes: |
if method.idl_type.name != 'void': |
cpp_arguments.append('&result') |
@@ -309,9 +304,10 @@ def cpp_value(interface, method, number_of_arguments): |
has_extended_attribute_value(interface, 'RaisesException', 'Constructor'))): |
cpp_arguments.append('exceptionState') |
- # If a method returns an IDL dictionary, the return value is passed |
- # as an argument to impl classes. |
- if method.idl_type and method.idl_type.is_dictionary: |
+ # If a method returns an IDL dictionary or union type, the return value is |
+ # passed as an argument to impl classes. |
+ idl_type = method.idl_type |
+ if idl_type and (idl_type.is_dictionary or idl_type.is_union_type): |
cpp_arguments.append('result') |
if method.name == 'Constructor': |
@@ -402,38 +398,24 @@ def property_attributes(method): |
return property_attributes_list |
-def union_member_argument_context(idl_type, index): |
- """Returns a context of union member for argument.""" |
- this_cpp_value = 'result%d' % index |
- this_cpp_type = idl_type.cpp_type |
- this_cpp_type_initializer = idl_type.cpp_type_initializer |
- cpp_return_value = this_cpp_value |
- |
- if not idl_type.cpp_type_has_null_value: |
- this_cpp_type = v8_types.cpp_template_type('Nullable', this_cpp_type) |
- this_cpp_type_initializer = '' |
- cpp_return_value = '%s.get()' % this_cpp_value |
- |
- if idl_type.is_string_type: |
- null_check_value = '!%s.isNull()' % this_cpp_value |
- else: |
- null_check_value = this_cpp_value |
- |
- return { |
- 'cpp_type': this_cpp_type, |
- 'cpp_type_initializer': this_cpp_type_initializer, |
- 'cpp_value': this_cpp_value, |
- 'null_check_value': null_check_value, |
- 'v8_set_return_value': idl_type.v8_set_return_value( |
- cpp_value=cpp_return_value, |
- release=idl_type.release), |
- } |
+def union_result_members_context(idl_type): |
+ """Returns a context of return value for methods/getters of which type |
Jens Widell
2014/10/28 11:31:38
I think "a context" here is expected to be a dict,
bashi
2014/10/29 01:34:32
Now we no longer need this method :)
|
+ is an union type. If a method/getter returns an union type, the impl class |
+ takes 'result' argument of which type is the corresponding container class. |
+ """ |
+ def union_result_member_context(idl_type): |
+ cpp_value = 'result.getAs%s()' % idl_type.name |
+ if idl_type.is_explicit_nullable: |
+ cpp_value = '%s.get()' % cpp_value |
Jens Widell
2014/10/28 11:31:37
Could be
cpp_value += '.get()'
too, which is e
|
+ return { |
+ 'null_check_value': 'result.is%s()' % idl_type.name, |
+ 'v8_set_return_value': idl_type.v8_set_return_value( |
+ cpp_value=cpp_value), |
+ } |
-def union_arguments(idl_type): |
- return [union_member_argument_context(member_idl_type, index) |
- for index, member_idl_type |
- in enumerate(idl_type.member_types)] |
+ return [union_result_member_context(member_idl_type) |
+ for member_idl_type in idl_type.member_types] |
def argument_default_cpp_value(argument): |
@@ -443,8 +425,8 @@ def argument_default_cpp_value(argument): |
return None |
return argument.idl_type.literal_cpp_value(argument.default_value) |
-IdlTypeBase.union_arguments = None |
-IdlUnionType.union_arguments = property(union_arguments) |
+IdlTypeBase.union_result_members = None |
+IdlUnionType.union_result_members = property(union_result_members_context) |
IdlArgument.default_cpp_value = property(argument_default_cpp_value) |