Chromium Code Reviews| Index: Source/bindings/scripts/v8_dictionary.py |
| diff --git a/Source/bindings/scripts/v8_dictionary.py b/Source/bindings/scripts/v8_dictionary.py |
| index c9fd904a9e40a735cd075a397bbefb316506c1ff..987c7d59c52265041e7f5c0efeb86afef3b7e5f3 100644 |
| --- a/Source/bindings/scripts/v8_dictionary.py |
| +++ b/Source/bindings/scripts/v8_dictionary.py |
| @@ -86,4 +86,85 @@ def member_context(member): |
| 'v8_type': v8_types.v8_type(idl_type.base_type), |
| } |
| -# FIXME: Implement context for impl class. |
| + |
| +# Context for implementation classes |
| + |
| +def dictionary_impl_context(dictionary, interfaces_info): |
| + includes.clear() |
| + header_includes = set(['platform/heap/Handle.h']) |
| + return { |
| + 'header_includes': header_includes, |
| + 'cpp_class': v8_utilities.cpp_name(dictionary), |
| + 'members': [member_impl_context(member, interfaces_info, |
| + header_includes) |
| + for member in dictionary.members], |
| + } |
| + |
| + |
| +def member_impl_context(member, interfaces_info, header_includes): |
| + idl_type = member.idl_type |
| + |
| + def should_use_nullable_container(): |
| + return idl_type.native_array_element_type or idl_type.is_primitive_type |
| + |
| + def collect_includes(idl_type): |
|
bashi
2014/07/25 10:05:40
Takes idl_type as argument as this function is rec
|
| + includes_for_type = set() |
| + if should_use_nullable_container(): |
| + includes_for_type.add('bindings/core/v8/Nullable.h') |
| + |
| + idl_type = idl_type.preprocessed_type |
| + native_array_element_type = idl_type.native_array_element_type |
| + if native_array_element_type: |
| + includes_for_type.update(collect_includes( |
| + native_array_element_type)) |
| + includes_for_type.add('wtf/Vector.h') |
| + |
| + if idl_type.is_string_type: |
| + includes_for_type.add('wtf/text/WTFString.h') |
| + if idl_type.name in interfaces_info: |
| + interface_info = interfaces_info[idl_type.name] |
| + includes_for_type.add(interface_info['include_path']) |
| + return includes_for_type |
| + |
| + def argument_cpp_type(): |
| + argument_cpp_type = idl_type.cpp_type_args(used_as_argument=True) |
| + if idl_type.native_array_element_type: |
| + return 'const %s&' % argument_cpp_type |
| + return argument_cpp_type |
| + |
| + def getter_cpp_type(): |
| + getter_cpp_type = idl_type.cpp_type_args(used_as_return_type=True) |
| + if (idl_type.native_array_element_type or idl_type.is_string_type): |
| + return 'const %s&' % getter_cpp_type |
| + return getter_cpp_type |
| + |
| + def getter_method_expression(): |
| + if should_use_nullable_container(): |
| + return 'm_%s.get()' % member.name |
| + return 'm_%s' % member.name |
| + |
| + def has_method_expression(): |
| + if should_use_nullable_container() or idl_type.is_string_type: |
| + return '!m_%s.isNull()' % member.name |
| + else: |
| + return 'm_%s' % member.name |
| + |
| + def member_cpp_type(): |
| + member_cpp_type = idl_type.cpp_type_args(used_as_member=True) |
| + if should_use_nullable_container(): |
| + return v8_types.cpp_template_type('Nullable', member_cpp_type) |
| + return member_cpp_type |
| + |
| + header_includes.update(collect_includes(idl_type)) |
| + return { |
| + 'argument_cpp_type': argument_cpp_type(), |
| + 'getter_cpp_type': getter_cpp_type(), |
| + 'getter_method_expression': getter_method_expression(), |
| + 'has_method_expression': has_method_expression(), |
| + 'has_name': has_name_for_dictionary_member(member), |
| + 'is_traceable': (idl_type.is_garbage_collected or |
| + idl_type.is_will_be_garbage_collected), |
| + 'member_cpp_type': member_cpp_type(), |
| + 'name': member.name, |
| + 'setter_name': setter_name_for_dictionary_member(member), |
| + } |